Fix matrix operator bug on - and /.2

This commit is contained in:
Krad
2023-04-21 15:32:09 +08:00
parent b323ef5c0f
commit df36096f72
3 changed files with 10 additions and 10 deletions

View File

@@ -350,7 +350,7 @@ namespace Aurora {
Matrix Matrix::operator+(Matrix &&aMatrix) const {
return operatorMxM_RR(&vdAddI,&vzAddI,*this,std::forward<Matrix&&>(aMatrix));
}
Matrix operator+(Matrix &&aMatrix, const Matrix &aOther) {
Matrix operator+(Matrix &&aMatrix, Matrix &aOther) {
return operatorMxM_RR(&vdAddI,&vzAddI,aOther,std::forward<Matrix&&>(aMatrix),true);
}
@@ -367,7 +367,7 @@ namespace Aurora {
Matrix Matrix::operator-(Matrix &&aMatrix) const {
return operatorMxM_RR(&vdSubI,&vzSubI,*this,std::forward<Matrix&&>(aMatrix));
}
Matrix operator-(Matrix &&aMatrix, const Matrix &aOther) {
Matrix operator-(Matrix &&aMatrix, Matrix &aOther) {
return operatorMxM_RR(&vdSubI,&vzSubI,aOther,std::forward<Matrix&&>(aMatrix),true);
}
@@ -384,7 +384,7 @@ namespace Aurora {
Matrix Matrix::operator*(Matrix &&aMatrix) const {
return operatorMxM_RR(&vdMulI,&vzMulI,*this,std::forward<Matrix&&>(aMatrix));
}
Matrix operator*(Matrix &&aMatrix, const Matrix &aOther) {
Matrix operator*(Matrix &&aMatrix, Matrix &aOther) {
return operatorMxM_RR(&vdMulI,&vzMulI,aOther,std::forward<Matrix&&>(aMatrix),true);
}
@@ -401,7 +401,7 @@ namespace Aurora {
Matrix Matrix::operator/(Matrix &&aMatrix) const {
return operatorMxM_RR(&vdDivI,&vzDivI,*this,std::forward<Matrix&&>(aMatrix));
}
Matrix operator/(Matrix &&aMatrix, const Matrix &aOther) {
Matrix operator/(Matrix &&aMatrix, Matrix &aOther) {
return operatorMxM_RR(&vdDivI,&vzDivI,aOther,std::forward<Matrix&&>(aMatrix),true);
}

View File

@@ -111,7 +111,7 @@ namespace Aurora {
friend Matrix& operator+(Matrix &&matrix,double aScalar);
Matrix operator+(const Matrix &matrix) const;
Matrix operator+(Matrix &&matrix) const;
friend Matrix operator+(Matrix &&aMatrix,const Matrix &aOther);
friend Matrix operator+(Matrix &&aMatrix,Matrix &aOther);
// sub
Matrix operator-(double aScalar) const;
@@ -120,7 +120,7 @@ namespace Aurora {
friend Matrix& operator-(Matrix &&matrix,double aScalar);
Matrix operator-(const Matrix &matrix) const;
Matrix operator-(Matrix &&matrix) const;
friend Matrix operator-(Matrix &&aMatrix,const Matrix &aOther);
friend Matrix operator-(Matrix &&aMatrix,Matrix &aOther);
// mul
Matrix operator*(double aScalar) const;
@@ -129,7 +129,7 @@ namespace Aurora {
friend Matrix& operator*(Matrix &&matrix,double aScalar);
Matrix operator*(const Matrix &matrix) const;
Matrix operator*(Matrix &&matrix) const;
friend Matrix operator*(Matrix &&aMatrix,const Matrix &aOther);
friend Matrix operator*(Matrix &&aMatrix,Matrix &aOther);
// div
Matrix operator/(double aScalar) const;
@@ -138,7 +138,7 @@ namespace Aurora {
friend Matrix& operator/(Matrix &&matrix,double aScalar);
Matrix operator/(const Matrix &matrix) const;
Matrix operator/(Matrix &&matrix) const;
friend Matrix operator/(Matrix &&aMatrix,const Matrix &aOther);
friend Matrix operator/(Matrix &&aMatrix, Matrix &aOther);
// pow
Matrix operator^(int times) const;

View File

@@ -188,8 +188,8 @@ TEST_F(FunctionTester, matrixOpertaor) {
EXPECT_EQ(C.getData()[2],2);
C = A*B/2.0;
EXPECT_EQ(C.getData()[2],2);
C = A*B*B/2.0;
EXPECT_EQ(C.getData()[2],4);
C = (A*8.0/B) * (B+1.0)-2.0+8;
EXPECT_EQ(C.getData()[2],30);
}
}