diff options
author | Yi Kong <yikong@google.com> | 2022-02-25 15:53:09 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-02-25 15:53:09 +0000 |
commit | 10f298fc4175c1b8537c674f654a070c871960e5 (patch) | |
tree | fb979fb4cf4f8052c8cc66b1ec9516d91fcd859b /test/linearstructure.cpp | |
parent | 892aea0d75825c43d5b630e2060622cbba23694c (diff) | |
parent | 79df15ea886a5fc1b85de433f9b3518c68934bae (diff) | |
download | eigen-10f298fc4175c1b8537c674f654a070c871960e5.tar.gz |
Merge changes Iee153445,Iee274471 am: 79df15ea88android-games-sdk-games-performance-tuner-releaseandroid-games-sdk-games-memory-advice-releaseandroid-games-sdk-games-frame-pacing-releaseandroid-games-sdk-games-controller-releaseandroid-games-sdk-game-text-input-releaseandroid-games-sdk-game-activity-release
Original change: https://android-review.googlesource.com/c/platform/external/eigen/+/1999079
Change-Id: I0c5108390c595f0d39af8797875f2b88accb7b56
Diffstat (limited to 'test/linearstructure.cpp')
-rw-r--r-- | test/linearstructure.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/test/linearstructure.cpp b/test/linearstructure.cpp index 17474af10..46ee5162b 100644 --- a/test/linearstructure.cpp +++ b/test/linearstructure.cpp @@ -19,7 +19,6 @@ template<typename MatrixType> void linearStructure(const MatrixType& m) /* this test covers the following files: CwiseUnaryOp.h, CwiseBinaryOp.h, SelfCwiseBinaryOp.h */ - typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; @@ -111,7 +110,20 @@ template<typename MatrixType> void real_complex(DenseIndex rows = MatrixType::Ro VERIFY(g_called && "matrix<complex> - real not properly optimized"); } -void test_linearstructure() +template<int> +void linearstructure_overflow() +{ + // make sure that /=scalar and /scalar do not overflow + // rational: 1.0/4.94e-320 overflow, but m/4.94e-320 should not + Matrix4d m2, m3; + m3 = m2 = Matrix4d::Random()*1e-20; + m2 = m2 / 4.9e-320; + VERIFY_IS_APPROX(m2.cwiseQuotient(m2), Matrix4d::Ones()); + m3 /= 4.9e-320; + VERIFY_IS_APPROX(m3.cwiseQuotient(m3), Matrix4d::Ones()); +} + +EIGEN_DECLARE_TEST(linearstructure) { g_called = true; VERIFY(g_called); // avoid `unneeded-internal-declaration` warning. @@ -131,19 +143,5 @@ void test_linearstructure() CALL_SUBTEST_11( real_complex<MatrixXcf>(10,10) ); CALL_SUBTEST_11( real_complex<ArrayXXcf>(10,10) ); } - -#ifdef EIGEN_TEST_PART_4 - { - // make sure that /=scalar and /scalar do not overflow - // rational: 1.0/4.94e-320 overflow, but m/4.94e-320 should not - Matrix4d m2, m3; - m3 = m2 = Matrix4d::Random()*1e-20; - m2 = m2 / 4.9e-320; - VERIFY_IS_APPROX(m2.cwiseQuotient(m2), Matrix4d::Ones()); - m3 /= 4.9e-320; - VERIFY_IS_APPROX(m3.cwiseQuotient(m3), Matrix4d::Ones()); - - - } -#endif + CALL_SUBTEST_4( linearstructure_overflow<0>() ); } |