Add explicit regression test for bug #1622

This commit is contained in:
Gael Guennebaud 2018-11-16 11:24:51 +01:00
parent 670d56441c
commit 43c987b1c1
2 changed files with 14 additions and 0 deletions

View File

@ -503,6 +503,7 @@ EIGEN_DECLARE_TEST(evaluators)
VERIFY_IS_EQUAL( get_cost(a.lazyProduct(a+b)), 15); VERIFY_IS_EQUAL( get_cost(a.lazyProduct(a+b)), 15);
} }
// regression test for PR 544 and bug 1622 (introduced in #71609c4)
{ {
// test restricted_packet_assignment with an unaligned destination // test restricted_packet_assignment with an unaligned destination
const size_t M = 2; const size_t M = 2;

View File

@ -8,6 +8,7 @@
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include "product.h" #include "product.h"
#include <Eigen/LU>
template<typename T> template<typename T>
void test_aliasing() void test_aliasing()
@ -87,6 +88,16 @@ void product_large_regressions()
} }
} }
template<int>
void bug_1622() {
typedef Matrix<double, 2, -1, 0, 2, -1> Mat2X;
Mat2X x(2,2); x.setRandom();
MatrixXd y(2,2); y.setRandom();
const Mat2X K1 = x * y.inverse();
const Matrix2d K2 = x * y.inverse();
VERIFY_IS_APPROX(K1,K2);
}
EIGEN_DECLARE_TEST(product_large) EIGEN_DECLARE_TEST(product_large)
{ {
for(int i = 0; i < g_repeat; i++) { for(int i = 0; i < g_repeat; i++) {
@ -99,6 +110,8 @@ EIGEN_DECLARE_TEST(product_large)
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_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>() ); CALL_SUBTEST_1( test_aliasing<float>() );
CALL_SUBTEST_6( bug_1622<1>() );
} }
CALL_SUBTEST_6( product_large_regressions<0>() ); CALL_SUBTEST_6( product_large_regressions<0>() );