📄 matrix.h
字号:
#ifndef MATRIX_H_
#define MATRIX_H_
const int rowdefault = 5;
const int coldefault = 5;
class CMatrix
{
public:
CMatrix(unsigned int irow = rowdefault ,unsigned int icol = coldefault);
CMatrix(const CMatrix&);
~CMatrix()
{
for(int i=0;i<row;i++)
delete [] matrix[i];
delete[] matrix;
}
unsigned int GetRow()const //获得行数
{
return row;
}
unsigned int GetCol()const //获得列数
{
return col;
}
CMatrix& operator=(const CMatrix&); //附值
CMatrix& operator+(const CMatrix&); //操作符+重载
CMatrix& operator*(const CMatrix&); //操作符*重载
CMatrix& operator-(const CMatrix&); //操作符-重载
bool operator==(const CMatrix&);
CMatrix& rowsort(int therow, bool direct); //任意行排序
CMatrix& colsort(int thecol, bool direct1); //任意行排序
CMatrix& inverse(); //求逆
CMatrix& onesmat(int size = rowdefault); //单位矩阵
CMatrix& randmat(int irrow,int ircol); // 随机矩阵
CMatrix& randmat(int size1); // 随机矩阵重载
CMatrix& zeros(); // 零矩阵
CMatrix& turnmat();//转置
void display() const; //显示矩阵元素
void initMatrix(); //矩阵数出始化
private:
unsigned int row,col; //row代表行, col代表列
double** matrix;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -