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

📄 matrix.h

📁 模式识别HK分类算法 vc下dos程序
💻 H
字号:
// Matrix.h: interface for the CMatrix class.

//////////////////////////////////
//自己编写的CMatrix类,用于矩阵运算
//////////////////////////////////

class CMatrix : public CObject  
{
	DECLARE_SERIAL(CMatrix)//声明串行化宏

public:
	CMatrix(const CMatrix &m);//深度拷贝函数
	CMatrix(unsigned int row=1,unsigned int col=1,double x=0);//构造函数
	virtual ~CMatrix();//析构函数

public:
	////////////////////////////////
	//矩阵运算操作符重载
	/////////////////////////////////
	
    double & operator () (unsigned int row,unsigned int col);//(,)操作符重载
	CMatrix  operator + ();//正号操作符重载
	CMatrix  operator - ();//负号操作符重载
	CMatrix& operator = (const CMatrix &m);//等号操作符重载
	CMatrix& operator += (const CMatrix &m);//+=操作符重载
	CMatrix& operator -= (const CMatrix &m);//-=操作符重载
	CMatrix& operator *= (const CMatrix &m);//*=操作符重载
	CMatrix& operator *= (const double &c);///*=操作符重载
	CMatrix& operator /= (const double &c);///=操作符重载
	CMatrix& operator ^= (const unsigned int & pow);//^=操作符重载
	//判断操作符重载
	bool operator==(const CMatrix &m);//相等
	bool operator!=(const CMatrix &m);//不等
	bool operator<=(const CMatrix &m);//小于等于
	bool operator>=(const CMatrix &m);//大于等于
	bool operator<(const CMatrix &m);//小于
	bool operator>(const CMatrix &m);//大于
	//基本运算操作符重载
	CMatrix operator + (const CMatrix &m);//加法操作符重载
	CMatrix operator - (const CMatrix &m);//减法操作符重载
	CMatrix operator * (const CMatrix &m);//矩阵乘法操作符重载
	CMatrix operator * (const double &no);//矩阵数乘操作符重载
	friend CMatrix operator * (const double  &no,CMatrix &m)
	                  {return (m*no);}//矩阵数乘操作符重载
	CMatrix operator / (CMatrix &m)//矩阵除法操作符重载
	                  {return (*this* !m);}
	CMatrix operator / (const double  &no)
	                   {return (*this*(1/no));}//矩阵数除操作符重载
	friend CMatrix operator / (const double  &no,CMatrix &m)
	                   {return (!m*no);}//矩阵数除操作符重载
	CMatrix operator ~ ();//转置操作符重载
	CMatrix operator ! ();//求逆操作符重载
	CMatrix operator ^ (const unsigned int &pow);//幂操作符重载
public:
	//其他函数
	void Null(const unsigned int &row,const unsigned int &col);
	void Null();//矩阵置空
	void Unit(const unsigned int &row);
	void Unit();//矩阵变为单位阵

	double Det();//求行列式
	double Max();//求最大值
	double Min();//求最小值
	friend CMatrix Abs(const CMatrix &m);//求绝对值
	
	void SetSize(unsigned int row,unsigned int col);//改变矩阵大小

	virtual void OnDraw(CDC * pDC,CPoint Pos=CPoint(0,0));//windows下显示函数
	void Display();//dos下显示

	virtual void Serialize(CArchive &ar);//串行化函数




private:
	double * * Val;//矩阵指针
	unsigned int ColSize;//列
	unsigned int RowSize;//行
	unsigned int Col;//列数
	unsigned int Row;//行数
	int pivot(unsigned int row);//对角化
	void realloc(unsigned int row,unsigned int col);//重新分配内存

};

⌨️ 快捷键说明

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