mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
remove largeEps in adjoint unit test and use a more accurate test_isApproxWithRef test.
This commit is contained in:
@@ -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>()) );
|
||||
|
||||
Reference in New Issue
Block a user