Я определил 2 функции в моем классе Matrix
следующим образом (в Matrix.hpp)
static Matrix MCopy( Matrix &a );
static Matrix MatInvert( Matrix &x )
static double MatDet( Matrix &x ); // Matdef function
В моем файле Matrix.Cpp я определил эти функции следующим образом:
Matrix Matrix::MatCopy( Matrix &a )
{
Matrix P( a.getRow() , a.getCol() , Empty );
int j=0;
while( j != P.getRow() ){
int i=0;
while( i != P.getCol() ){
P(j,i)=a(j,i);
++i;
}
++j;
}
return P;
}
Matrix Matrix::MatInvert( Matrix &x )
{
Matrix aa = Matrix::MatCopy(x); // i got error message here
int n = aa.getCol();
Matrix ab(n,1,Empty);
Matrix ac(n,n,Empty);
Matrix ad(n,1,Empty);
if(MatLu(aa,ad)==-1){
assert( "singular Matrix" );
exit(1);
}
int i=0;
while( i != n ){
ab.fill(Zero);
ab (i,0)=1.0;
MatRuecksub(aa, ab,ac,ad,i);
++i;
}
return ac;
}
хорошо, это моя функция MatDef
double Matrix::MatDet( Matrix &x )
{
double result;
double vorz[2] = {1.0, -1.0};
int n = x.getRow();
Matrix a = Matrix::MatCopy(x);
Matrix p( n, 1, Empty);
int i = MatLu(a, p);
if(i==-1){
result = 0.0;
}
else {
result = 1.0;
int j=0;
while(j != n){
result *= a( static_cast<int>(p(j,0)) ,j);
++j;
}
result *= vorz[i%2];
}
return result;
}
, но когда я компилирую это, я получаю сообщение об ошибке, сообщающее, что:
line 306:no matching function for call to ‘Matrix::Matrix[Matrix]’:
note: candidates are: Matrix::Matrix[Matrix&]
note:in static member function ‘static double Matrix ::MatDet[Matrix&]’:
Я не могу понять, в чем проблемаЭто потому, что я новичок в программировании на C ++, поэтому, пожалуйста, помогите мне исправить эту ошибку.
Где я использовал
Matrix aa = Matrix::MatCopy(x);
Он показывает то же сообщение об ошибке, что и строка 306, но с другими примечаниями, поэтомуЯ думаю MatDef
не проблема.Пожалуйста, дайте ваши комментарии, чтобы решить эту проблему.Спасибо!