diff options
author | Gael Guennebaud <g.gael@free.fr> | 2016-01-09 08:30:38 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2016-01-09 08:30:38 +0100 |
commit | 8b9dc9f0dfb44c2c4ad6d02fb88ecce0986cd154 (patch) | |
tree | b821895e79c11c8be9d2f8c4af77046eba6f7811 /test/product_large.cpp | |
parent | f9d71a172992cfda5e2733f9f4a6e12a14b9ed73 (diff) |
bug #1144: fix regression in x=y+A*x (aliasing), and move evaluator_traits::AssumeAliasing to evaluator_assume_aliasing.
Diffstat (limited to 'test/product_large.cpp')
-rw-r--r-- | test/product_large.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/product_large.cpp b/test/product_large.cpp index 7207973c2..98f84c53b 100644 --- a/test/product_large.cpp +++ b/test/product_large.cpp @@ -9,6 +9,27 @@ #include "product.h" +template<typename T> +void test_aliasing() +{ + int rows = internal::random<int>(1,12); + int cols = internal::random<int>(1,12); + typedef Matrix<T,Dynamic,Dynamic> MatrixType; + typedef Matrix<T,Dynamic,1> VectorType; + VectorType x(cols); x.setRandom(); + VectorType z(x); + VectorType y(rows); y.setZero(); + MatrixType A(rows,cols); A.setRandom(); + // CwiseBinaryOp + VERIFY_IS_APPROX(x = y + A*x, A*z); // OK because "y + A*x" is marked as "assume-aliasing" + x = z; + // CwiseUnaryOp + VERIFY_IS_APPROX(x = T(1.)*(A*x), A*z); // OK because 1*(A*x) is replaced by (1*A*x) which is a Product<> expression + x = z; + // VERIFY_IS_APPROX(x = y-A*x, -A*z); // Not OK in 3.3 because x is resized before A*x gets evaluated + x = z; +} + void test_product_large() { for(int i = 0; i < g_repeat; i++) { @@ -17,6 +38,8 @@ void test_product_large() CALL_SUBTEST_3( product(MatrixXi(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) ); CALL_SUBTEST_4( product(MatrixXcf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2), internal::random<int>(1,EIGEN_TEST_MAX_SIZE/2))) ); CALL_SUBTEST_5( product(Matrix<float,Dynamic,Dynamic,RowMajor>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) ); + + CALL_SUBTEST_1( test_aliasing<float>() ); } #if defined EIGEN_TEST_PART_6 |