这个样子行不行?
/**//***
*
*
* purpose:Defines functions for matrix
*
***/
#pragma once
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "MatrixException.h"
using namespace std;
class Matrix
{
public:
// Constructors
explicit Matrix();
explicit Matrix(int size);
Matrix(int row,int col);
Matrix(const Matrix& m);
// Destructor
~Matrix();
// Assignment operators
Matrix& operator= (const Matrix& m);
// Value extraction method
int GetRow() const;
int GetCol() const;
// Subscript operator
double operator()(int i,int j)const; //subscript operator to get individual elements
double& operator()(int i,int j); //subscript operator to set individual elements
// Unary operators
Matrix operator+() const; //unary negation operator
Matrix operator-() const; //unary negation operator
//Binary operators
Matrix operator+(const Matrix& m) const;
Matrix operator-(const Matrix& m) const;
Matrix operator*(const Matrix& m) const;
// Matrix operator*(double d)const;
Matrix operator/(const Matrix& m) const;
Matrix operator/(double d) const;
Matrix operator^(int pow) const;
bool operator== (const Matrix& m) const; //logical equal-to operator
bool operator!= (const Matrix& m) const; //logical not-equal-to operator
friend Matrix operator* (double d,const Matrix& m);
friend Matrix operator/ (double d,const Matrix& m);
// Combined assignment - calculation operators
Matrix& operator +=(const Matrix& m) const;
Matrix& operator -=(const Matrix& m) const;
Matrix& operator *=(const Matrix& m) const;
Matrix& operator *=(double d) const;
Matrix& operator /=(const Matrix& m) const;
Matrix& operator /=(double d) const;
Matrix& operator ^=(int pow) const;
// Miscellaneous -methods
void SetZero() ; //zero matrix:零阵
void SetUnit() ; //unit matrix:单位阵
void SetSize(int size) ; //rsizing matrix
void SetSize(int row,int col) ; //resizing matrix
// Utility methods
Matrix Solve(const Matrix& m)const; //
Matrix Adjoin() const; //adjoin matrix:伴随矩阵
double Determinant() const; //determinant:行列式
double Norm() const; //norm:模
Matrix Inverse() const; //inverse:逆阵
Matrix Transpose() const; //transpose:转置
double Cofactor() const; //confactor
double Condition() const; //the condition number of a matrix
int Pivot(int row) const; // partial pivoting
//primary change
Matrix& Exchange(int i,int j);// 初等变换 对调两行:ri<-->rj
Matrix& Multiple(int index,double k); //初等变换 第index 行乘以k
Matrix& MultipleAdd(int index,int src,double k); //初等变换 第src行乘以k加到第index行
// Type of matrices
bool IsSquare() const; //determine if the matrix is square:方阵
bool IsSingular() const; //determine if the matrix is singular奇异阵
bool IsDiagonal() const; //determine if the matrix is diagonal对角阵
bool IsScalar() const; //determine if the matrix is scalar数量阵
bool IsUnit() const; //determine if the matrix is unit单位阵
bool IsZero() const; //determine if the matrix is zero零矩阵
bool IsSymmetric() const; //determine if the matrix is symmetric对称阵
bool IsSkewSymmetric() const; //determine if the matrix is skew-symmetric斜对称阵
bool IsUpperTriangular() const; //determine if the matrix is upper-triangular上三角阵
bool IsLowerTriangular() const; //determine if the matrix is lower-triangular下三角阵
// output stream function
friend ostream& operator<<(ostream& os,const Matrix& m);
// input stream function
friend istream& operator>>(istream& is,Matrix& m);
//conert to string
string ToString() const;
protected:
//delete the matrix
void Create(int row,int col);
void Clear();
private:
const static double epsilon;
double** m_data;
size_t m_row;
size_t m_col;
};