📄 matrix.h
字号:
//matrix.h
#ifndef MATRIX_H
#define MATRIX_H
//CMatrix
class AFX_EXT_CLASS CMatrix
{
//公共成员接口
public:
//构造和析构
CMatrix(); //缺省
CMatrix(int nRows,int nCols); //指定行列
CMatrix(int nRows,int nCols,double value[]); //指定行列数据
CMatrix(int nSize); //方阵
CMatrix(int nSize,double value[]); //方阵
CMatrix(const CMatrix& other); //拷贝
virtual ~CMatrix();
BOOL Init(int nRows,int nCols);
BOOL MakeUnitMatrix(int nSize);
//设置知道元素的值
BOOL SetElement(int nRow,int nCol,double value);
double GetElement(int nRow,int nCol) const;
void SetData(double value[]);
int GetNumColumns() const;
int GetNumRows() const;
int GetRowVector(int nRow,double* pVector) const;
int GetColVector(int nCol,double* pVector) const;
double* GetData() const;
//数学操作
CMatrix& operator=(const CMatrix& other);
BOOL operator==(const CMatrix& other) const;
BOOL operator!=(const CMatrix& other) const;
CMatrix operator+(const CMatrix& other) const;
CMatrix operator-(const CMatrix& other) const;
CMatrix operator*(double value) const; //数乘
CMatrix operator*(const CMatrix& other) const; //矩阵相乘
CMatrix Transpose() const; //矩阵转置
//保护数据成员
protected:
int m_nNumRows; //行数
int m_nNumColumns; //列数
double* m_pData; //数据缓冲区
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -