www.gusucode.com > 几种基本的C++矩阵运算代码演示-源码程序 > 几种基本的C++矩阵运算代码演示-源码程序/code/test.cpp

    #include <iostream.h>
#include "MatrixOperation.h"
//Download by http://www.NewXing.com
void main()
{
	int k;
	double c[16];

	//相加
/*	double a[12] = {1,1,1,1,1,1,1,1,1,1,1,1};
	double b[12] = {2,2,2,2,2,2,2,2,2,2,2,2};

	MatrixAdd(a,b,b,12);
	for (k=0;k<12;k++)
	{
		cout<<b[k]<<endl;
	}
*/
/*
	//转置
	double d[16] = {1,1,1,1,0,1,1,1,0,0,1,1,0,0,0,1};
	MatrixTranspose(d,c,4,4);
	for (k=0;k<16;k++)
	{
		cout<<c[k]<<endl;
	}
	cout<<endl<<endl;
*/
/*	//复制
	MatrixCopy(d,c,16);
	for (k=0;k<16;k++)
	{
		cout<<c[k]<<endl;
	}
	cout<<endl;
*/
	//相乘
	double e[6] = {1,2,3,4,5,6};
	double f[9] = {7,8,9,1,2,3,4,5,6};
	double g[6];
//	MatrixMultiply(e,f,g,2,3,3);
	Multiply(e,f,g,2,3,3);
	for (k=0;k<6;k++)
	{
		cout<<g[k]<<endl;
	}

}