📄 matrix.h
字号:
// Matrix.h: interface for the CMatrix class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MATRIX_H__CDA96547_19FC_4FAA_B386_154270DB33A9__INCLUDED_)
#define AFX_MATRIX_H__CDA96547_19FC_4FAA_B386_154270DB33A9__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
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 FromString(CString s,const CString&sDelim="",bool bLineBreak=TRUE);
//将矩阵转换为字符串
CString ToString(const CString& sDelim="",bool bLineBreak=TRUE)const;
getMatrix(int nRow,int nCol,double head[]);
//将矩阵指定行转换为字符串
CString RowToString(int nRow,const CString&sDelim=" ")const;
//将矩阵指定列转换为字符串
CString ColToString(int nCol,const CString& sDelim=" ")const;
//
//元素与值操作
//
//设置制定元素的值
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;
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;
//复矩阵乘法
// bool CMul(const CMatrix& AR,const CMatrix& AI,const CMatrix& BR,const CMatrix& BI,CMatrix& CR,CMatrix& CI)const;
//矩阵转置
CMatrix Transpose() const;
//
//算法
//
//实矩阵求逆的全选主高斯-约当法
bool InvertGaussJordan();
/* //复矩阵求逆的全选主高斯-约当法
bool InvertGaussJodan(CMatrix& mtxImag);
//对称正定矩阵求逆
bool InvertSsgj();
//托伯利兹矩阵求逆的特兰持方法
bool InvertTrench();
//求行列式值的全选主高斯消去法
double DetGauss();
//对称正定矩阵的乔里斯基分解与行列式的求解
bool DetCholesky(double* dblDet);
//矩阵的三角分解
bool SplitLU(CMatrix& mtxL,CMatrix& mtxU);
//一般实矩阵的QR分解
bool SplitQR(CMatrix& mtxQ);
//一般实矩阵的奇异值分解
bool SolitUV(CMatrix& mtxU,CMatrix& mtxV,double eps=0.000001);
//求广义逆的奇异值分解法
bool GInvertUV(CMatrix& mtxAP,CMatrix& mtxU,CMatrix& mtxV,double eps=0.000001);
//约化对称矩阵为对称三角阵的毫斯荷尔德变换法
bool MakeSymTri(CMatrix&mtxQ,CMatrix&mtxT,double dblB[],double dblC[]);
//实对称三角阵的全部特征值与特征向量计算
bool SymTriEigenV(double dblB[],double dblC[],CMatrix&mtxQ,int nMaxIt=60,double eps=0.000001);
//约化一般实矩阵为赫申伯格矩阵的初等相似变换法
void MakeHberg();
//求赫申伯格矩阵全部特征值的QR方法
bool HBergEigenv(double dblU[],double dblV[],int nMaxIt=60,double eps=0.000001);
//求实对称矩阵与特征向量的雅可比法
bool JecobiEigenv(double dblEigenValue[],CMatrix& mtxEigenVector,int nMaxIT=60,double eps=0.000001);
//求实对称矩阵特征值与特征向量的雅可比过关法
bool JecobiEigenv2(double dblEigenValue[],CMatrix& mtxEigenVector,double eps=0.000001);
*/
//
//保护性数据成员
//
public:
int m_nNumColumns;
int m_nNumRows;
double *m_pData;
//
//内部函数
//
private:
void ppp(double a[],double e[],double s[],double v[],int m,int n);
void sss(double fg[2],double cs[2]);
};
#endif // !defined(AFX_MATRIX_H__CDA96547_19FC_4FAA_B386_154270DB33A9__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -