matrix.h

来自「用c++的一个矩阵类」· C头文件 代码 · 共 54 行

H
54
字号
#ifndef _MATRIX_H_
#define _MATRIX_H_
#include "math.h"
#include "stdlib.h"

#include "stdio.h"
#include "memory.h"
#include "assert.h"
//#include "windows.h"


class CMatrix
{
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& m);
 ~CMatrix();
public:
    bool Init(int nRows, int nCols);  //初始化矩阵
    bool MakeUnitMatrix(int nSize);	  //单位矩阵
  
 void SetData(double value[]);		
 bool SetElement(int nRow, int nCol, double value);	//为矩阵中的元素设置数值
 double GetElement(int nRow, int nCol)const;	//获得矩阵中的一个元素
 int GetNumColumns()const; 
 int GetNumRows()const; 
 double* GetData()const; 
 CMatrix& operator=(const CMatrix& m);
 bool operator==(const CMatrix& m)const; 
 bool operator!=(const CMatrix& m)const; 
 CMatrix operator+(const CMatrix& m)const; 
 CMatrix operator-(const CMatrix& m)const; 
 CMatrix operator*(double value)const; 
 CMatrix operator*(const CMatrix& m)const; 
 CMatrix Transpose()const; 
 CMatrix DinV();
 //CMatrix equation(CMatrix &m,CMatrix &m1);  //一个求解方程的函数
 

 double Det();
 int Rank();
 void Print();



private:
 int m_nNumColumns, m_nNumRows;
 double *m_pData;
};
#endif

⌨️ 快捷键说明

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