diff options
author | Gael Guennebaud <g.gael@free.fr> | 2016-10-26 22:50:41 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2016-10-26 22:50:41 +0200 |
commit | 3ecb343dc3f0be6c60654cec581d0f3145553238 (patch) | |
tree | ad1f322152f69276dcd0a4e370c7e5901c9d3068 /test/product_extra.cpp | |
parent | 97feea9d39ccaf298082cd537e85c311bf354010 (diff) |
Fix regression in X = (X*X.transpose())/s with X rectangular by deferring resizing of the destination after the creation of the evaluator of the source expression.
Diffstat (limited to 'test/product_extra.cpp')
-rw-r--r-- | test/product_extra.cpp | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/test/product_extra.cpp b/test/product_extra.cpp index e4990ac8c..03d5c3657 100644 --- a/test/product_extra.cpp +++ b/test/product_extra.cpp @@ -256,7 +256,49 @@ Index compute_block_size() return ret; } - +template<typename> +void aliasing_with_resize() +{ + Index m = internal::random<Index>(10,50); + Index n = internal::random<Index>(10,50); + MatrixXd A, B, C(m,n), D(m,m); + VectorXd a, b, c(n); + C.setRandom(); + D.setRandom(); + c.setRandom(); + double s = internal::random<double>(1,10); + + A = C; + B = A * A.transpose(); + A = A * A.transpose(); + VERIFY_IS_APPROX(A,B); + + A = C; + B = (A * A.transpose())/s; + A = (A * A.transpose())/s; + VERIFY_IS_APPROX(A,B); + + A = C; + B = (A * A.transpose()) + D; + A = (A * A.transpose()) + D; + VERIFY_IS_APPROX(A,B); + + A = C; + B = D + (A * A.transpose()); + A = D + (A * A.transpose()); + VERIFY_IS_APPROX(A,B); + + A = C; + B = s * (A * A.transpose()); + A = s * (A * A.transpose()); + VERIFY_IS_APPROX(A,B); + + A = C; + a = c; + b = (A * a)/s; + a = (A * a)/s; + VERIFY_IS_APPROX(a,b); +} template<int> void bug_1308() @@ -318,5 +360,6 @@ void test_product_extra() CALL_SUBTEST_7( compute_block_size<float>() ); CALL_SUBTEST_7( compute_block_size<double>() ); CALL_SUBTEST_7( compute_block_size<std::complex<double> >() ); + CALL_SUBTEST_8( aliasing_with_resize<void>() ); } |