diff options
author | Gael Guennebaud <g.gael@free.fr> | 2015-10-09 15:28:09 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2015-10-09 15:28:09 +0200 |
commit | 6536b4bad71de912f240c6fffa6fd29e5b7b4bbc (patch) | |
tree | 45a897b1c521b7882f415782a8389db9ddc76d53 /test | |
parent | a4cc4c1e5e0ca1ee46818cda81793e4b5e586221 (diff) |
Implement temporary-free path for "D.nolias() ?= C + A*B". (I thought it was already implemented)
Diffstat (limited to 'test')
-rw-r--r-- | test/nesting_ops.cpp | 21 | ||||
-rw-r--r-- | test/product.h | 9 | ||||
-rw-r--r-- | test/product_notemporary.cpp | 4 | ||||
-rw-r--r-- | test/redux.cpp | 1 |
4 files changed, 16 insertions, 19 deletions
diff --git a/test/nesting_ops.cpp b/test/nesting_ops.cpp index 1e96075f8..76a63400c 100644 --- a/test/nesting_ops.cpp +++ b/test/nesting_ops.cpp @@ -54,25 +54,8 @@ template <typename MatrixType> void run_nesting_ops_2(const MatrixType& _m) if((MatrixType::SizeAtCompileTime==Dynamic)) { - - VERIFY_EVALUATION_COUNT( use_n_times<10>(m1), 0 ); - if(!NumTraits<Scalar>::IsComplex) - { - VERIFY_EVALUATION_COUNT( use_n_times<3>(2*m1), 0 ); - VERIFY_EVALUATION_COUNT( use_n_times<4>(2*m1), 1 ); - } - else - { - VERIFY_EVALUATION_COUNT( use_n_times<1>(2*m1), 0 ); - VERIFY_EVALUATION_COUNT( use_n_times<2>(2*m1), 1 ); - } - VERIFY_EVALUATION_COUNT( use_n_times<2>(m1+m1), 0 ); - VERIFY_EVALUATION_COUNT( use_n_times<3>(m1+m1), 1 ); - VERIFY_EVALUATION_COUNT( use_n_times<1>(m1*m1.transpose()), 1 ); - VERIFY_EVALUATION_COUNT( use_n_times<2>(m1*m1.transpose()), 1 ); - - VERIFY_EVALUATION_COUNT( use_n_times<1>(m1 + m1*m1), 2 ); // FIXME should already be 1 thanks the already existing rule - VERIFY_EVALUATION_COUNT( use_n_times<10>(m1 + m1*m1), 2 ); + VERIFY_EVALUATION_COUNT( use_n_times<1>(m1 + m1*m1), 1 ); + VERIFY_EVALUATION_COUNT( use_n_times<10>(m1 + m1*m1), 1 ); VERIFY_EVALUATION_COUNT( use_n_times<1>(m1.template triangularView<Lower>().solve(m1.col(0))), 1 ); VERIFY_EVALUATION_COUNT( use_n_times<10>(m1.template triangularView<Lower>().solve(m1.col(0))), 1 ); diff --git a/test/product.h b/test/product.h index 672d0cee9..9dfff9303 100644 --- a/test/product.h +++ b/test/product.h @@ -111,6 +111,15 @@ template<typename MatrixType> void product(const MatrixType& m) vcres.noalias() -= m1.transpose() * v1; VERIFY_IS_APPROX(vcres, vc2 - m1.transpose() * v1); + // 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); VERIFY_IS_APPROX(v1.transpose() * tm1, v1.transpose() * m1); diff --git a/test/product_notemporary.cpp b/test/product_notemporary.cpp index 16f6266f7..ff93cb881 100644 --- a/test/product_notemporary.cpp +++ b/test/product_notemporary.cpp @@ -47,6 +47,10 @@ template<typename MatrixType> void product_notemporary(const MatrixType& m) VERIFY_EVALUATION_COUNT( m3.noalias() = s1 * (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); VERIFY_EVALUATION_COUNT( m3.noalias() = (s1 * m1).adjoint() * s2 * m2, 0); diff --git a/test/redux.cpp b/test/redux.cpp index f3e7cc2a7..9b0767c73 100644 --- a/test/redux.cpp +++ b/test/redux.cpp @@ -2,6 +2,7 @@ // for linear algebra. // // Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com> +// Copyright (C) 2015 Gael Guennebaud <gael.guennebaud@inria.fr> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed |