matrix.h

来自「DFP变尺度法」· C头文件 代码 · 共 34 行

H
34
字号
//matrix.h      //矩阵类及其运算
#if !defined(_MATRIX_H)
#define _MATRIX_H
#include <iostream.h>

class CMatrix
{
	public:
		CMatrix(){}
		void set(int row,int col);                     //设置矩钲的行列数
		CMatrix(int row,int col);                      //构造
		~CMatrix() {delete[] elem;}                    //析构
		double& operator()(int x, int y) ;
		double  operator()(int x, int y) const ;       //const?
		int getrow(){return row;}
		int getcol(){return col;}
		double getmod();                               //求向量的模
		double getval(){}               
		CMatrix invert();                              //求矩阵的转置
		double mult(const CMatrix& b);                 

		friend CMatrix operator+(const CMatrix& a, const CMatrix& b);
		friend CMatrix operator-(const CMatrix& a, const CMatrix& b);
	    friend CMatrix operator*(double a, const CMatrix& b);
        friend CMatrix operator*(const CMatrix& a, const CMatrix& b);
		friend CMatrix operator/(const CMatrix& b,double a);
		friend ostream& operator<<(ostream& out,const CMatrix& a);
		CMatrix& operator =(const CMatrix& m);          //赋值
		CMatrix(const CMatrix& m);                      //初始化拷贝
	private:
		int row,col;
		double *elem;
};
#endif      

⌨️ 快捷键说明

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