jmatrix.h

来自「矩阵运算库」· C头文件 代码 · 共 110 行

H
110
字号
// JMatrix.h: interface for the JMatrix class.
//
//	Lu Ying Jie
//	DV Lab
//
//	date notes:
//		1th edition : 2001.5
//		2th edition : 2002.7
//		3th edition : 2003.1
//
//
//////////////////////////////////////////////////////////////////////


#if !defined(AFX_JMATRIX_H__C19BCFE3_D35E_4B5D_87E3_5CE922C1E0EA__INCLUDED_)
#define AFX_JMATRIX_H__C19BCFE3_D35E_4B5D_87E3_5CE922C1E0EA__INCLUDED_




class JMatrix
{
private:

	unsigned int	row, col ;											//  number of rows and columns

	double			* data ;											//  pointer to the matrix's data


public:

	JMatrix( unsigned int ROW=1, unsigned int COL=1 ) ;

	JMatrix( const JMatrix & A ) ;

	~JMatrix() ;


public:

	unsigned int	DimRow( ) const ;									//  query

	unsigned int	DimCol( ) const ;									//  query


public:

	double			operator () ( unsigned int ROW, unsigned int COL ) const ;
																		//  read only		T[ROW][COL]

	double *		operator [] ( unsigned int ROW ) ;					//  read & write	T[ROW]


	const JMatrix	operator +  ( double v ) const ;					//	T + v

	const JMatrix	operator -  ( double v ) const ;					//	T - v

	const JMatrix	operator *  ( double v ) const ;					//	T * v

	const JMatrix	operator +  ( const JMatrix & A ) const ;			//  T + A

	const JMatrix	operator -  ( const JMatrix & A ) const ;			//  T - A

	const JMatrix	operator *  ( const JMatrix & A ) const ;			//  T * A


	JMatrix &		operator =  ( const JMatrix & A ) ;					//  T = A


	JMatrix &		operator += ( double v ) ;							//  T = T + v

	JMatrix &		operator -= ( double v ) ;							//  T = T - v

	JMatrix &		operator *= ( double v ) ;							//  T = T * v

	JMatrix &		operator += ( const JMatrix & A ) ;					//  T = T + A

	JMatrix &		operator -= ( const JMatrix & A ) ;					//  T = T - A


public:

	JMatrix &		Transpose() ;

	JMatrix &		Inverse( double tol=0 ) ;

	JMatrix &		Zero() ;


	JMatrix &		EqAdd( const JMatrix & A, const JMatrix & B ) ;		//  T = A + B

	JMatrix &		EqSub( const JMatrix & A, const JMatrix & B ) ;		//  T = A - B

	JMatrix &		EqMul( const JMatrix & A, const JMatrix & B ) ;		//  T = A * B


	double			NormF() const ;

	double			Norm1() const ;

	double			NormInf() const ;


	int				LinSol( JMatrix & B, double tol=0 ) ;				//  solve linear equation:	A * X = B

};


#endif // !defined(AFX_JMATRIX_H__C19BCFE3_D35E_4B5D_87E3_5CE922C1E0EA__INCLUDED_)

⌨️ 快捷键说明

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