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

📄 matrix.h

📁 原创C++的matrix类,有许多运算符重载,很简单,但是好用,好看
💻 H
字号:
// Matrix.h: interface for the CMatrix class.
//
//////////////////////////////////////////////////////////////////////
#include <iostream>
using namespace std;

#if !defined(AFX_MATRIX_H__3D76145F_E96A_466E_8E88_3EFBA2D184E5__INCLUDED_)
#define AFX_MATRIX_H__3D76145F_E96A_466E_8E88_3EFBA2D184E5__INCLUDED_

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

class CMatrix  
{	
	friend CMatrix linequ2(const CMatrix & A, const CMatrix & B);
	friend CMatrix symmeig(const CMatrix &H, CMatrix &E);
	friend void ql(CMatrix &z, CMatrix &d, CMatrix &e);
	friend void householder(CMatrix &m, CMatrix &d, CMatrix &e);
	friend CMatrix linequ(const CMatrix & A, const CMatrix & B);
	friend double trace(const CMatrix &m);
	friend CMatrix identity(int n);
	friend CMatrix step(const CMatrix &m);
	friend CMatrix rand(int nr, int nc);
	friend double determinant(const CMatrix &m);

	friend CMatrix operator *(double x, const CMatrix &m);	
	friend istream & operator >>(istream & input, CMatrix &m);
	friend ostream & operator <<(ostream & output, CMatrix &m);

public:

	CMatrix operator |(const CMatrix &m);
	bool operator ==(const CMatrix &m);
	CMatrix operator /=(double x);
	CMatrix operator *=(double x);
	CMatrix operator *=(const CMatrix &m);
	CMatrix operator -=(const CMatrix &m);
	CMatrix operator +=(const CMatrix &m);
	CMatrix operator !();
	CMatrix operator ~();
	CMatrix operator -();
	CMatrix operator /(double x);
	CMatrix operator *(double x);
	CMatrix operator -(const CMatrix &m);
	CMatrix operator +(const CMatrix &m);
	CMatrix operator *(const CMatrix &m);

	inline int getnr() const { return m_nr;}
	inline int getnc() const { return m_nc;}
	inline double* operator [](const int i) { return m_data[i];}
	inline const double* operator [](const int i) const  { return m_data[i];}
	CMatrix operator =(const CMatrix &m);

	CMatrix(const CMatrix &m);
	CMatrix(double** data, int nr, int nc);
	CMatrix(int nr, int nc);
	CMatrix();
	virtual ~CMatrix();

private:
	void clear();
	void create(int nr, int nc);
	double** m_data;
	int m_nc;
	int m_nr;
};

#endif // !defined(AFX_MATRIX_H__3D76145F_E96A_466E_8E88_3EFBA2D184E5__INCLUDED_)

⌨️ 快捷键说明

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