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

📄 matrix.h

📁 一个最小二乘法的拟合数据的小程序
💻 H
字号:
// Matrix.h: interface for the CMatrix class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_MATRIX_H__5FC9A140_85EC_4C91_90D0_363D5E1A0E29__INCLUDED_)
#define AFX_MATRIX_H__5FC9A140_85EC_4C91_90D0_363D5E1A0E29__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CMatrix : public CObject  
{
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[]);//设定矩阵的值
    double * GetData()const;//获取矩阵的值
	int GetNumColums()const;//获取矩阵的列数
	int GetNumRows()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*(const CMatrix& other)const;
	CMatrix operator*(double value)const;


	//转置
	CMatrix Transpose()const;

	//实矩阵求逆——全选主元高斯-约旦法
	BOOL InvertGaussJordan();

	//方阵行列式的值
	double DetGauss();

	//求秩	
	int RankGauss();

protected:
	int m_nNumColumns;//列数
	int m_nNumRows;//行数
	double* m_pData;//矩阵数据缓冲区


};

#endif // !defined(AFX_MATRIX_H__5FC9A140_85EC_4C91_90D0_363D5E1A0E29__INCLUDED_)

⌨️ 快捷键说明

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