diff options
author | Gael Guennebaud <g.gael@free.fr> | 2016-08-23 16:52:22 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2016-08-23 16:52:22 +0200 |
commit | 504a4404f11270df5cc372ff3465b07018a1d40b (patch) | |
tree | 3fd1f859f9769627f980a887525b4579b2e621a9 /test | |
parent | e47a8928ecfcb4abe05ac95872afedf496cb3928 (diff) |
Optimize expression matching "d?=a-b*c" as "d?=a; d?=b*c;"
Diffstat (limited to 'test')
-rw-r--r-- | test/product.h | 8 | ||||
-rw-r--r-- | test/product_notemporary.cpp | 3 |
2 files changed, 11 insertions, 0 deletions
diff --git a/test/product.h b/test/product.h index 27976a4ae..cabfc0b03 100644 --- a/test/product.h +++ b/test/product.h @@ -119,6 +119,14 @@ template<typename MatrixType> void product(const MatrixType& m) res.noalias() -= square + m1 * m2.transpose(); VERIFY_IS_APPROX(res, square + m1 * m2.transpose()); + // test d ?= a-b*c rules + res.noalias() = square - m1 * m2.transpose(); + VERIFY_IS_APPROX(res, square - m1 * m2.transpose()); + res.noalias() += square - m1 * m2.transpose(); + VERIFY_IS_APPROX(res, 2*(square - m1 * m2.transpose())); + res.noalias() -= square - m1 * m2.transpose(); + VERIFY_IS_APPROX(res, square - m1 * m2.transpose()); + tm1 = m1; VERIFY_IS_APPROX(tm1.transpose() * v1, m1.transpose() * v1); diff --git a/test/product_notemporary.cpp b/test/product_notemporary.cpp index 5a3f3a01a..2bb19a681 100644 --- a/test/product_notemporary.cpp +++ b/test/product_notemporary.cpp @@ -56,6 +56,9 @@ template<typename MatrixType> void product_notemporary(const MatrixType& m) VERIFY_EVALUATION_COUNT( m3.noalias() = m3 + m1 * m2.transpose(), 0); VERIFY_EVALUATION_COUNT( m3.noalias() += m3 + m1 * m2.transpose(), 0); VERIFY_EVALUATION_COUNT( m3.noalias() -= m3 + m1 * m2.transpose(), 0); + VERIFY_EVALUATION_COUNT( m3.noalias() = m3 - m1 * m2.transpose(), 0); + VERIFY_EVALUATION_COUNT( m3.noalias() += m3 - m1 * m2.transpose(), 0); + VERIFY_EVALUATION_COUNT( m3.noalias() -= m3 - m1 * m2.transpose(), 0); VERIFY_EVALUATION_COUNT( m3.noalias() = s1 * m1 * s2 * m2.adjoint(), 0); VERIFY_EVALUATION_COUNT( m3.noalias() = s1 * m1 * s2 * (m1*s3+m2*s2).adjoint(), 1); |