📄 cmatrix.h
字号:
// Matrix.h: interface for the CMatrix class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(__MATRIX_H__)
#define __MATRIX_H__
#include <math.h>
#include <selfdefine.h>
class CMatrix
{
public:
CMatrix();
CMatrix(const CMatrix& OriginalMatrix);
CMatrix(const f8* pData,i4 nRowNumber,i4 nColumnNumber);
virtual ~CMatrix();
//operation
public:
i4 InitMatrix(const f8* pData,i4 nRowNumber,i4 nColumnNumber);
i4 InitZeroMatrix(i4 nRowNumber,i4 nColumnNumber);
i4 GetInverseMatrix(CMatrix& maInverse)const;
CMatrix GetInverseMatrix()const;
i4 Inverse();
i4 GetTransposedMatrix(CMatrix& maTransposed)const;
CMatrix GetTransposedMatrix()const;
i4 GetSubMatrix(i4 nSubRowNumber,i4 nSubColumnNumber,CMatrix& maSubMatrix)const;
CMatrix GetSubMatrix(i4 nSubRowNumber,i4 nSubColumnNumber)const;
CMatrix GetSubMatrix(const i4 nBeginRowNo,const i4 nEndRowNo,const i4 nBeginColumnNo,const i4 nEndColumnNo)const;
i4 AppendRBSubMatrix(const CMatrix maSubMatrix, CMatrix& maSuperMaxtrix)const;
// CMatrix AppendRBSubMatrix(const CMatrix maSubMatrix) const;
i4 AppendRSubMatrix(const CMatrix maSubMatrix, CMatrix& maSuperMaxtrix)const;
// CMatrix AppendRSubMatrix(const CMatrix maSubMatrix) const;
i4 AppendBSubMatrix(const CMatrix maSubMatrix, CMatrix& maSuperMaxtrix)const;
// CMatrix AppendBSubMatrix(const CMatrix maSubMatrix) const;
i4 GetMember(i4 nRowNo,i4 nColumnNo, f8& f8Member)const;
f8 GetMember(i4 nRowNo,i4 nColumnNo)const;
i4 ChangeMember(i4 nRowNo,i4 nColumnNo, f8 f8Member)const;
i4 AppendNewRow(f8* pData,i4 nDataNumber);
i4 AppendNewColumn(f8* pData,i4 nDataNumber);
i4 AppendMatrixInRow(const CMatrix& SecMatrix);
i4 AppendMatrixInColumn(const CMatrix& SecMatrix);
i4 GetOneRow(i4 nRowNo, f8* pData)const;
i4 GetOneRow(i4 nRowNo, CMatrix& maRowMAtrix)const;
// i4 GetOneColumn(i4 nColumnNo, f8* pData)const;
// i4 GetOneColumn(i4 nColumnNo, CMatrix& maColumnMAtrix)const;
i4 DeleteOneRow(i4 nRowNo);
// i4 DeleteOneRow(i4 nRowNo, CMatrix& maRowMAtrix);
i4 DeleteOneColumn(i4 nColumnNo);
// i4 DeleteOneColumn(i4 nColumnNo, CMatrix& maColumnMatrix);
i4 CombineRow(i4 nRowNo, i4 nComMode);
// i4 CombineColumn(i4 nColumnNo, i4 nComMode);
i4 Dump();//将矩阵清零,并不是将矩阵元素设零
i4 SetZero();//将矩阵元素设零
i4 SetMinus();//将矩阵元素设负
i4 Multiply(f8 f8MulNum);//将矩阵元素乘以倍数
i4 SetIdentity(i4 nRowNumber);//将矩阵设成单位阵
i4 SetCorrelativity(i4 nRowNumber);//将矩阵设成简单相关阵
virtual i4 PrintFile(FILE& fp); //在fp按行列输出矩阵元素
CMatrix& operator= (const CMatrix & SecMatrix);
CMatrix operator+ (const CMatrix & SecMatrix)const;
CMatrix operator- (const CMatrix & SecMatrix)const;
CMatrix operator- ();
CMatrix operator* (const CMatrix & SecMatrix)const;
CMatrix operator* (const f8 dMultiNum) const;
CMatrix operator/ (const f8 dDevideNum) const;
CMatrix operator/ (const CMatrix & SecMatrix)const;// A/B:表示A乘以B的逆阵
CMatrix operator% (const CMatrix & SecMatrix)const;// A%B:表示A的逆阵乘以B
// f8 operator[](const i4 row,const i4 colum)const;
//Attribute interface
public:
i4 GetData(f8 * pDestiData)const;
i4 GetData(i4 ,f8 * pDestiData)const;
f8* GetDataAddress()const;
i4 GetRowNumber()const {return m_nRowNumber;};
i4 GetColumnNumber()const {return m_nColumnNumber;};
f8 GetTrace();
f8 GetValue();
f8 GetNorm();
//protected operation
private:
void Initate();
i4 InitEmptyMatrix(i4 nRowNumber,i4 nColumnNumber);
i4 CalcuTrace();
i4 CalcuValue();
i4 CalcuNorm();
void Transpose(const f8 *m1,f8 *m2,i4 m,i4 n)const;
void Mult(const f8 *m1,const f8 *m2, f8 *result,i4 i_1,i4 j_12,i4 j_2)const;
i4 InversMatrix(f8 *m1,i4 n)const;
//Attribute
protected:
f8* m_pData;
i4 m_nRowNumber,m_nColumnNumber;
f8 m_dTrace; //迹
f8 m_dValue; //行列式
f8 m_dNorm; //范数
BOOL m_bTraceIsGot; //判断迹是否计算的标志量
BOOL m_bValueIsGot; //判断行列式是否计算的标志量
BOOL m_bNormIsGot; //判断范数是否计算的标志量
private://取消的操作
CMatrix operator+= (CMatrix & SecMatrix){};
CMatrix operator-= (CMatrix & SecMatrix){};
i4 operator== (CMatrix & SecMatrix){};
i4 operator!= (CMatrix & SecMatrix){};
};
#endif // !defined(__MATRIX_H__)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -