aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/product_small.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2016-07-31 15:20:22 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2016-07-31 15:20:22 +0200
commit7995cec90c63380ba05b297d1e196affc371cac9 (patch)
tree6484f8671a84cc9ca9db590591b33e0eac15b0d9 /test/product_small.cpp
parent02fe89f5ef060d2348dc67e5a2d3c5b47890e071 (diff)
Fix vectorization logic for coeff-based product for some corner cases.
Diffstat (limited to 'test/product_small.cpp')
-rw-r--r--test/product_small.cpp36
1 files changed, 36 insertions, 0 deletions
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<T,4,-1,-1>(4,cols,depth) ));
}
+template<typename T,int N,int M,int K>
+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<Index>(1,32) : N;
+ Index m = M==Dynamic ? internal::random<Index>(1,32) : M;
+ Index k = K==Dynamic ? internal::random<Index>(1,32) : K;
+
+ {
+ Matrix<T,N,M+1> A; A.setRandom(n,m+1);
+ Matrix<T,M*2,K> B; B.setRandom(m*2,k);
+ Matrix<T,1,K> C;
+ Matrix<T,1,K> R;
+
+ C.noalias() = A.template topLeftCorner<1,M>() * (B.template topRows<M>()+B.template bottomRows<M>());
+ R.noalias() = A.template topLeftCorner<1,M>() * (B.template topRows<M>()+B.template bottomRows<M>()).eval();
+ VERIFY_IS_APPROX(C,R);
+ }
+
+ {
+ Matrix<T,M+1,N,RowMajor> A; A.setRandom(m+1,n);
+ Matrix<T,K,M*2,RowMajor> B; B.setRandom(k,m*2);
+ Matrix<T,K,1> C;
+ Matrix<T,K,1> R;
+
+ C.noalias() = (B.template leftCols<M>()+B.template rightCols<M>()) * A.template topLeftCorner<M,1>();
+ R.noalias() = (B.template leftCols<M>()+B.template rightCols<M>()).eval() * A.template topLeftCorner<M,1>();
+ 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<std::complex<double> >() );
CALL_SUBTEST_42( test_lazy_l2<std::complex<double> >() );
CALL_SUBTEST_43( test_lazy_l3<std::complex<double> >() );
+
+ CALL_SUBTEST_7(( test_linear_but_not_vectorizable<float,2,1,Dynamic>() ));
+ CALL_SUBTEST_7(( test_linear_but_not_vectorizable<float,3,1,Dynamic>() ));
+ CALL_SUBTEST_7(( test_linear_but_not_vectorizable<float,2,1,16>() ));
}
#ifdef EIGEN_TEST_PART_6