⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrix.h

📁 模式识别的作业代码
💻 H
字号:
// Matrix.h: interface for the CMatrix class.
//
//////////////////////////////////////////////////////////////////////
#ifndef MATRIX_CALC_BASIC
#define MATRIX_CALC_BASIC

class CMatrix  
{
public:
	CMatrix();                                  //缺省构造函数
	virtual ~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);              //拷贝构造函数

public:    
	BOOL Init(int nRows,int nCols);             //初始化矩阵
	BOOL MakeUnitMatrix(int nSize);             //将方阵初始化为单位矩阵

	
	//设置元素的值
	BOOL    SetElement(int nRows,int nCols,double value);
	double  GetElement(int nRows,int nCols) const;//获取指定元素的值
	void    SetData(double value[]);              //设置矩阵的值

	int     GetNumColumns() const;                //获取矩阵的列数
	int     GetNumRow() const;                    //获取矩阵的行数
	int		GetSize() const;					  //获取矩阵大小

	//获取矩阵的指定行矩阵
	int     GetRowVector(int nRow,double* pVector=NULL) const;
    //获取矩阵的指定列矩阵
	int     GetColVector(int nCol,double* pVector=NULL) 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;
	double operator[](int index) const;

	//矩阵转置
	CMatrix Transpose() const;

	//=======算法==============================
	BOOL InvertGaussJordan();
	CMatrix inv() const;
	// 求实对称矩阵特征值与特征向量的雅可比过关法
	BOOL JacobiEigenv2(double dblEigenValue[], CMatrix& mtxEigenVector, double eps = 0.000001);
	// 判断实对称矩阵满秩与否
	BOOL SymFullRankOrNot();

public:
	void static WGAU(int IP,CMatrix &A);
public:
	int     m_nNumColumns;     //矩阵列数
	int     m_nNumRows;        //矩阵行数
	double* m_pData;           //数据缓冲区

public:
	void multipVec(double* dMultipVec,double* dFinalVec);
	CMatrix mean(int dim=1) const; //求矩阵的均值
	CMatrix std(int dim=1) const; //求矩阵的方差
};

#endif

⌨️ 快捷键说明

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