Home > Back-end >  C a great god, please help to implement the following four functions, I wrote a beginning, don'
C a great god, please help to implement the following four functions, I wrote a beginning, don'

Time:12-20

Best, you can comment on, or you can't read

Here is my code
/*
Implementation of matrix inverse solving
Realize the determinant of a matrix computation
Implement AK=b solving operation
1 o matrix rank of
*/
#include
#include
#include
#include
using namespace std;
Class Matrix {//two-dimensional Matrix class
Private:
A double * *;
Int row;
Int col;
Void initMatrix ();//assign matrix space
Public:
M Matrix (int, int n);//the constructor
M Matrix (int, int n, double * a);//the constructor
~ Matrix ();//destructors
Matrix & amp; Operator=(const Matrix & amp;);
Void the show ();//output matrix
};
//allocate space
Void Matrix: : initMatrix () {
A=new double * (row),
for(int i=0; iA [I]=new double (col);
}
}
//the constructor
Matrix: : Matrix (int m, int n) {
The row=m;
Col=n;
InitMatrix ();
for(int i=0; ifor(int j=0; JA [I] [j]=0;
}
}
//the constructor
Matrix: : Matrix (int m, int n, double * a) {
The row=m;
Col=n;
InitMatrix ();
for(int i=0; ifor(int j=0; JA [I] [j]=* (A + I + j * col);
}
}
Void Matrix: : show () {
Cout<& lt;" \ n matrix for: \ n ";
for(int i=0; ifor(int j=0; JCoutCout<& lt;" \ n ";
}
}
//destructors
Matrix: : ~ Matrix () {
for(int i=0; iThe delete [] A [I];
}
The delete [] A;
}

//implementation matrix copy
Matrix & amp; Matrix: : operator=(const Matrix & amp; M) {
If (this==& amp; M) {
Return * this;
}
If (row!=m.r ow | | col! M.c ol)={
for(int i=0; iThe delete [] A [I];
}
The delete [] A;
The row=m.r ow.
Col=m.c ol;
InitMatrix ();
}
for (int i=0; ifor (int j=0; JA [I] [j]=m. [I] [j];
}
}
Return * this;
}
  • Related