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

📄 matrix.h

📁 矩阵类 可实现转置
💻 H
字号:
#if !defined(AFX_MATRIX_H__3E289FE1_35F9_439B_B0FD_0553A00287F2__INCLUDED_)
#define AFX_MATRIX_H__3E289FE1_35F9_439B_B0FD_0553A00287F2__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "iostream.h"
// Matrix.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CMatrix document
class  CMatrix : public CDocument
{
protected:
          // protected constructor used by dynamic creation
	DECLARE_DYNCREATE(CMatrix)

// Attributes
private:
 double * p;
 //矩阵宽度
 long width;
 //矩阵高度
 long height;

// Operations
public:
 long getHeight();
 long getWidth();
 CMatrix T();//转置
 double order();//求秩
 bool isPtv();//是否正定
 CMatrix rever();//求逆阵
 double Arg();//求行列式的值
 bool isVector();//如果是false,那就是一个数

 CMatrix GetTrian();//获得上三角形阵,用选行主元消去法
 CMatrix GetTopTrian();//获得上三角形阵,用顺序削去法
 CMatrix GetBotTrian();//获得下三角形阵,用顺序削去法(未讨论0的情况)
 long findMainElem(long height,long width);//选主元,返回值为主元所在行
 void exchangeRow(long i,long j);//用于交换第i行和第j行

 CMatrix addMatrix(CMatrix &,bool);//实现增广矩阵,bool为1则为(A,b)形式,为0为列向量
 CMatrix subCMatrix(long offset);
 void Test();//测试函数
    /***********重载部分-Overloaded Part*****************/
 CMatrix operator+(CMatrix &);
 CMatrix operator-(CMatrix &);
 CMatrix operator-();//负号重载
 CMatrix operator*(CMatrix &);
 friend CMatrix operator*(double alpha,CMatrix &);//实数与矩阵相乘
 CMatrix operator*(double alpha);//矩阵与实数相乘
 CMatrix operator/(CMatrix &);//实际是实数相除或矩阵和实数相除
 CMatrix operator/(double sub);
 CMatrix operator+=(CMatrix &);
 CMatrix operator-=(CMatrix &);
 CMatrix operator*=(double alpha);//矩阵与实数相乘
 friend CMatrix  sqrt(CMatrix m);//开方
 friend double abs(CMatrix &);//取绝对值
 CMatrix &operator=(CMatrix &);
 double * operator[](long heightPos);//用于实现用[][]操作矩阵元素
 friend ostream & operator<<(ostream &,CMatrix &);
 CMatrix(void);//default constructor
 CMatrix(long n);//单位矩阵
 CMatrix(double * arrAddress,long arrWidth);//构造一维矩阵
 CMatrix(double * arrAddress,long arrHeight,long arrWidth);
 CMatrix(const CMatrix &);//copy constructor
 ~CMatrix(void);//default destructor
 /***********重载部分-Overloaded Part*****************/
// Overrides
	// CMatrixWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMatrix)
	public:
	virtual void Serialize(CArchive& ar);   // overridden for document i/o
	protected:
	virtual BOOL OnNewDocument();
	//}}AFX_VIRTUAL

// Implementation

#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

	// Generated message map functions
protected:
	//{{AFX_MSG(CMatrix)
		// NOTE - the CMatrixWizard will add and remove member functions here.
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MATRIX_H__3E289FE1_35F9_439B_B0FD_0553A00287F2__INCLUDED_)

⌨️ 快捷键说明

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