diff --git a/cpp/Matrix.cpp b/cpp/Matrix.cpp index acb681751..f88ad8029 100644 --- a/cpp/Matrix.cpp +++ b/cpp/Matrix.cpp @@ -84,7 +84,7 @@ Matrix diag(const Vector& v) { } /* ************************************************************************* */ -/** Check if two matrizes are the same */ +/** Check if two matrices are the same */ /* ************************************************************************* */ bool equal_with_abs_tol(const Matrix& A, const Matrix& B, double tol) { @@ -94,9 +94,12 @@ bool equal_with_abs_tol(const Matrix& A, const Matrix& B, double tol) { if(m1!=m2 || n1!=n2) return false; for(size_t i=0; i tol) - return false; + for(size_t j=0; j tol) + return false; + } return true; } diff --git a/cpp/testMatrix.cpp b/cpp/testMatrix.cpp index 0874a76d4..eb8dc84c7 100644 --- a/cpp/testMatrix.cpp +++ b/cpp/testMatrix.cpp @@ -172,6 +172,23 @@ TEST( matrix, equal ) CHECK(A!=A3); } +/* ************************************************************************* */ +TEST( matrix, equal_nan ) +{ + Matrix A(4,4); + A(0,0) = -1; A(0,1) = 1; A(0,2)= 2; A(0,3)= 3; + A(1,0) = 1; A(1,1) =-3; A(1,2)= 1; A(1,3)= 3; + A(2,0) = 1; A(2,1) = 2; A(2,2)=-1; A(2,3)= 4; + A(3,0) = 2; A(3,1) = 1; A(3,2)= 2; A(3,3)=-2; + + Matrix A2(A); + + Matrix A3(A); + A3(3,3)=0.0/0.0; + + CHECK(A!=A3); +} + /* ************************************************************************* */ TEST( matrix, addition ) { diff --git a/cpp/testVector.cpp b/cpp/testVector.cpp index 74400172d..0226e38a7 100644 --- a/cpp/testVector.cpp +++ b/cpp/testVector.cpp @@ -209,8 +209,6 @@ TEST( TestVector, equals ) Vector v1 = Vector_(1, 0.0/0.0); //testing nan Vector v2 = Vector_(1, 1.0); double tol = 1.; - print(v1, "v1"); - print(v2, "v2"); CHECK(!equal_with_abs_tol(v1, v2, tol)); }