class Matrix { frien..." />
电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

C++矩阵类

C++矩阵类_第1页
1/28
C++矩阵类_第2页
2/28
C++矩阵类_第3页
3/28
//构造矩阵类MATRIX_H #ifndef MATRIX_H #define MATRIX_H #include "Complex.h" #include class Matrix { friend ostream &operator<<(ostream &,const Matrix &); friend istream &operator>>(istream &,Matrix &);//输入矩阵元素时,列之间请以“,”隔开,行之间请以“;”隔开 friend Matrix diag(Matrix &);//提取方阵对角元素 friend Matrix con(Matrix &);//求共轭矩阵 public: Matrix(int r=0,int c=0); Matrix(const Matrix &M); ~ Matrix(); int getRow() const; int getCol() const; int getsize() const; Complex &operator()(int i,int j);//引用 const Matrix &operator=(const Matrix &);//赋值 Matrix operator==(const Matrix &) const;//判断相等,输出相同大小的矩阵 比较的两个矩阵应该行列相等 Matrix operator!=(const Matrix &) const;//判断不等,输出相同大小的矩阵 比较的两个矩阵应该行列相等 Matrix operator~ ();//矩阵转置 Matrix operator+(Matrix &);//矩阵元素相加 Matrix operator-(Matrix &);//矩阵元素相减 Matrix operator*(Matrix &);//矩阵元素相乘 Matrix operator/(Matrix &);//矩阵元素相除 Matrix operator&(Matrix &);//矩阵乘法 static int getMatrixCount(); private: Complex *ptr; int Row; int Col; int size; static int MatrixCount; }; #endif //MATRIX_CPP #include #include #include #include #include "Matrix.h" #include "Complex.h" Matrix::Matrix(int r,int c) { ++MatrixCount; Row=r; Col=c; size=Row*Col; ptr=new Complex[size]; assert(ptr!=0); cout<<"调用默认构造 构造矩阵个数: "<

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

确认删除?
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群