aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/adjoint.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2011-02-18 17:39:04 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2011-02-18 17:39:04 +0100
commit86ca05b324f3f27249eb74b5ec839e2c331c8bbb (patch)
tree6bc852a2e421e7a6cd0037f1a5b57c5321775687 /test/adjoint.cpp
parent8f8c67b8bd2915d1927c848e557e5076a00e25f9 (diff)
remove largeEps in adjoint unit test and use a more accurate test_isApproxWithRef test.
Diffstat (limited to 'test/adjoint.cpp')
-rw-r--r--test/adjoint.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/test/adjoint.cpp b/test/adjoint.cpp
index bed409191..bc0bad4d0 100644
--- a/test/adjoint.cpp
+++ b/test/adjoint.cpp
@@ -40,10 +40,6 @@ template<typename MatrixType> void adjoint(const MatrixType& m)
Index rows = m.rows();
Index cols = m.cols();
- RealScalar largerEps = test_precision<RealScalar>();
- if (internal::is_same<RealScalar,float>::value)
- largerEps = RealScalar(1e-3f);
-
MatrixType m1 = MatrixType::Random(rows, cols),
m2 = MatrixType::Random(rows, cols),
m3(rows, cols),
@@ -68,8 +64,10 @@ template<typename MatrixType> void adjoint(const MatrixType& m)
// check basic properties of dot, norm, norm2
typedef typename NumTraits<Scalar>::Real RealScalar;
- VERIFY(internal::isApprox((s1 * v1 + s2 * v2).dot(v3), internal::conj(s1) * v1.dot(v3) + internal::conj(s2) * v2.dot(v3), largerEps));
- VERIFY(internal::isApprox(v3.dot(s1 * v1 + s2 * v2), s1*v3.dot(v1)+s2*v3.dot(v2), largerEps));
+
+ RealScalar ref = NumTraits<Scalar>::IsInteger ? 0 : std::max((s1 * v1 + s2 * v2).norm(),v3.norm());
+ VERIFY(test_isApproxWithRef((s1 * v1 + s2 * v2).dot(v3), internal::conj(s1) * v1.dot(v3) + internal::conj(s2) * v2.dot(v3), ref));
+ VERIFY(test_isApproxWithRef(v3.dot(s1 * v1 + s2 * v2), s1*v3.dot(v1)+s2*v3.dot(v2), ref));
VERIFY_IS_APPROX(internal::conj(v1.dot(v2)), v2.dot(v1));
VERIFY_IS_APPROX(internal::real(v1.dot(v1)), v1.squaredNorm());
if(!NumTraits<Scalar>::IsInteger)
@@ -77,7 +75,9 @@ template<typename MatrixType> void adjoint(const MatrixType& m)
VERIFY_IS_MUCH_SMALLER_THAN(internal::abs(vzero.dot(v1)), static_cast<RealScalar>(1));
// check compatibility of dot and adjoint
- VERIFY(internal::isApprox(v1.dot(square * v2), (square.adjoint() * v1).dot(v2), largerEps));
+
+ ref = NumTraits<Scalar>::IsInteger ? 0 : std::max(std::max(v1.norm(),v2.norm()),std::max((square * v2).norm(),(square.adjoint() * v1).norm()));
+ VERIFY(test_isApproxWithRef(v1.dot(square * v2), (square.adjoint() * v1).dot(v2), ref));
// like in testBasicStuff, test operator() to check const-qualification
Index r = internal::random<Index>(0, rows-1),
@@ -119,9 +119,9 @@ void test_adjoint()
CALL_SUBTEST_1( adjoint(Matrix<float, 1, 1>()) );
CALL_SUBTEST_2( adjoint(Matrix3d()) );
CALL_SUBTEST_3( adjoint(Matrix4f()) );
- CALL_SUBTEST_4( adjoint(MatrixXcf(4, 4)) );
- CALL_SUBTEST_5( adjoint(MatrixXi(8, 12)) );
- CALL_SUBTEST_6( adjoint(MatrixXf(21, 21)) );
+ CALL_SUBTEST_4( adjoint(MatrixXcf(internal::random<int>(1,50), internal::random<int>(1,50))) );
+ CALL_SUBTEST_5( adjoint(MatrixXi(internal::random<int>(1,50), internal::random<int>(1,50))) );
+ CALL_SUBTEST_6( adjoint(MatrixXf(internal::random<int>(1,50), internal::random<int>(1,50))) );
}
// test a large matrix only once
CALL_SUBTEST_7( adjoint(Matrix<float, 100, 100>()) );