📄 cmatrix.h
字号:
/* CMatrix类声明*/
#ifndef MATRIX
#define MATRIX
#include "Head.h"
class CMatrix
{
// 接口函数
public:
// 缺省构造函数
CMatrix();
// 指定行列构造函数
CMatrix( int nRow, int nCol);
// 指定数据构造函数
CMatrix( int nRow, int nCol, double value[]);
// 指定方阵和个数构造对角方阵
CMatrix( CMatrix t, int Num);
// 方阵构造函数
CMatrix(int nSize);
// 指定数据方阵构造函数
CMatrix(int nSize, double value[]);
// 拷贝构造函数
CMatrix(const CMatrix& other);
// 析构函数
virtual ~CMatrix();
// 成员函数
// 初始化矩阵
bool Init(int nRow, int nCol);
// 设置矩阵的值
void SetData(double value[]);
// 设置指定元素的值
bool SetElement(int nRow, int nCol, double value);
// 获取指定元素的值
double GetElement(int nRow, int nCol) const;
// 获取矩阵的列数
int GetNumCol(void) const;
// 获取矩阵的行数
int GetNumRow(void) const;
// 获取矩阵的值
double* GetData(void) const;
// 获取矩阵的指定行向量
int GetRowVector(int nRow, double* &pVector) const;
// 获取矩阵的指定列向量
int GetColVector( int nCol, double* &pVector) const;
// 对调第x,y行
void SwapRow( int x, int y);
// 运算符重载
CMatrix& operator=( const CMatrix& other);
CMatrix operator+( const CMatrix& other) const;
CMatrix operator-( const CMatrix& other) const;
CMatrix operator*( const CMatrix& other) const;
CMatrix operator*( double value) const;
// 矩阵转置
CMatrix Transpose(void) const;
// 矩阵类的转换
// 检查是否为对称矩阵
bool Is(void);
// 将CMatrix类转换为CDMatrix类
CDMatrix Change(void);
// 用CDMatrix构造函数
CMatrix( CDMatrix dmatrix);
// 用CEMatrix构造函数
CMatrix( CEMatrix ematrix);
// 添加子块矩阵并和原子块相加
void AddPartK(
int nRowStart,
int nColStart,
CMatrix PartK );
// 获得矩阵中的子块
CMatrix GetPartK(
int nRowStart,
int nRowNum,
int nColStart,
int nColNum );
// 将矩阵转化为字符串
CString ToString( const CString& sDelim =" ",
BOOL bLineBreak = TRUE ) const;
// 从文件中读取一个矩阵
bool Read( ifstream& readfile );
// 写入一个矩阵到文件中
bool Write( ofstream& writefile);
// 保护性数据成员
protected:
// 矩阵列数
int m_nNumCol;
// 矩阵行数
int m_nNumRow;
// 矩阵数据
double* p_Data;
// 内部函数
private:
//
};
#endif // CMATRIX
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -