From 7995cec90c63380ba05b297d1e196affc371cac9 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Sun, 31 Jul 2016 15:20:22 +0200 Subject: Fix vectorization logic for coeff-based product for some corner cases. --- test/product_small.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test/product_small.cpp') diff --git a/test/product_small.cpp b/test/product_small.cpp index c35db6f65..3e8dab01e 100644 --- a/test/product_small.cpp +++ b/test/product_small.cpp @@ -177,6 +177,38 @@ void test_lazy_l3() CALL_SUBTEST(( test_lazy_all_layout(4,cols,depth) )); } +template +void test_linear_but_not_vectorizable() +{ + // Check tricky cases for which the result of the product is a vector and thus must exhibit the LinearBit flag, + // but is not vectorizable along the linear dimension. + Index n = N==Dynamic ? internal::random(1,32) : N; + Index m = M==Dynamic ? internal::random(1,32) : M; + Index k = K==Dynamic ? internal::random(1,32) : K; + + { + Matrix A; A.setRandom(n,m+1); + Matrix B; B.setRandom(m*2,k); + Matrix C; + Matrix R; + + C.noalias() = A.template topLeftCorner<1,M>() * (B.template topRows()+B.template bottomRows()); + R.noalias() = A.template topLeftCorner<1,M>() * (B.template topRows()+B.template bottomRows()).eval(); + VERIFY_IS_APPROX(C,R); + } + + { + Matrix A; A.setRandom(m+1,n); + Matrix B; B.setRandom(k,m*2); + Matrix C; + Matrix R; + + C.noalias() = (B.template leftCols()+B.template rightCols()) * A.template topLeftCorner(); + R.noalias() = (B.template leftCols()+B.template rightCols()).eval() * A.template topLeftCorner(); + VERIFY_IS_APPROX(C,R); + } +} + void test_product_small() { for(int i = 0; i < g_repeat; i++) { @@ -202,6 +234,10 @@ void test_product_small() CALL_SUBTEST_41( test_lazy_l1 >() ); CALL_SUBTEST_42( test_lazy_l2 >() ); CALL_SUBTEST_43( test_lazy_l3 >() ); + + CALL_SUBTEST_7(( test_linear_but_not_vectorizable() )); + CALL_SUBTEST_7(( test_linear_but_not_vectorizable() )); + CALL_SUBTEST_7(( test_linear_but_not_vectorizable() )); } #ifdef EIGEN_TEST_PART_6 -- cgit v1.2.3