matrix.h

来自「这是一个可进行矩阵维数变换的程序」· C头文件 代码 · 共 44 行

H
44
字号
//矩阵类声明:
//
//矩阵类的目的是为减化程序设计中文本数据的输入和输出,增加二维
//数组对一维指针、和二维指针的支持,并提供基本的矩阵运算功能。
//王仁铭    98.10月
class ifstream;
class ofstream;
class CMatrix  
{
public:
	int m_nCol;
	int m_nRow;
	double** m_pData;

	CMatrix();//未定大小
	CMatrix(int,int);//指定大小
	CMatrix(int,int,double*);//根据一维指针生成CMatrix对象
	CMatrix(CMatrix & m);//拷贝
	virtual ~CMatrix();


	CMatrix& operator=(CMatrix&);

	CMatrix operator+(CMatrix&);		//矩阵相加
	void operator+=(CMatrix&);		//矩阵相加

	CMatrix operator-(CMatrix&);		//矩阵相减
	void operator-=(CMatrix&);		//矩阵相减

	CMatrix operator*(CMatrix&);		//矩阵相乘
	CMatrix operator*(double);		//矩阵乘数

	CMatrix operator!();			//求逆矩阵
	CMatrix operator/(CMatrix&);		//乘逆矩阵

	operator double**();			//强制转换成二维指针
	operator double*();				//强制转换成一维指针
	double*  operator[](int);		//用二维指针存取数据
	
	friend ifstream& operator>>(ifstream&,CMatrix&) ;
	friend ofstream& operator<<(ofstream&,CMatrix&) ;

};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?