mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-13 01:43:13 +08:00
bug #1311: fix alignment logic in some cases of (scalar*small).lazyProduct(small)
This commit is contained in:
parent
6565f8d60f
commit
779774f98c
@ -503,8 +503,8 @@ struct product_evaluator<Product<Lhs, Rhs, LazyProduct>, ProductTag, DenseShape,
|
|||||||
LhsOuterStrideBytes = int(LhsNestedCleaned::OuterStrideAtCompileTime) * int(sizeof(typename LhsNestedCleaned::Scalar)),
|
LhsOuterStrideBytes = int(LhsNestedCleaned::OuterStrideAtCompileTime) * int(sizeof(typename LhsNestedCleaned::Scalar)),
|
||||||
RhsOuterStrideBytes = int(RhsNestedCleaned::OuterStrideAtCompileTime) * int(sizeof(typename RhsNestedCleaned::Scalar)),
|
RhsOuterStrideBytes = int(RhsNestedCleaned::OuterStrideAtCompileTime) * int(sizeof(typename RhsNestedCleaned::Scalar)),
|
||||||
|
|
||||||
Alignment = bool(CanVectorizeLhs) ? (LhsOuterStrideBytes<0 || (int(LhsOuterStrideBytes) % EIGEN_PLAIN_ENUM_MAX(1,LhsAlignment))!=0 ? 0 : LhsAlignment)
|
Alignment = bool(CanVectorizeLhs) ? (LhsOuterStrideBytes<=0 || (int(LhsOuterStrideBytes) % EIGEN_PLAIN_ENUM_MAX(1,LhsAlignment))!=0 ? 0 : LhsAlignment)
|
||||||
: bool(CanVectorizeRhs) ? (RhsOuterStrideBytes<0 || (int(RhsOuterStrideBytes) % EIGEN_PLAIN_ENUM_MAX(1,RhsAlignment))!=0 ? 0 : RhsAlignment)
|
: bool(CanVectorizeRhs) ? (RhsOuterStrideBytes<=0 || (int(RhsOuterStrideBytes) % EIGEN_PLAIN_ENUM_MAX(1,RhsAlignment))!=0 ? 0 : RhsAlignment)
|
||||||
: 0,
|
: 0,
|
||||||
|
|
||||||
/* CanVectorizeInner deserves special explanation. It does not affect the product flags. It is not used outside
|
/* CanVectorizeInner deserves special explanation. It does not affect the product flags. It is not used outside
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <Eigen/LU>
|
#include <Eigen/LU>
|
||||||
|
|
||||||
// regression test for bug 447
|
// regression test for bug 447
|
||||||
|
template<int>
|
||||||
void product1x1()
|
void product1x1()
|
||||||
{
|
{
|
||||||
Matrix<float,1,3> matAstatic;
|
Matrix<float,1,3> matAstatic;
|
||||||
@ -209,6 +210,24 @@ void test_linear_but_not_vectorizable()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<int Rows>
|
||||||
|
void bug_1311()
|
||||||
|
{
|
||||||
|
Matrix< double, Rows, 2 > A; A.setRandom();
|
||||||
|
Vector2d b = Vector2d::Random() ;
|
||||||
|
Matrix<double,Rows,1> res;
|
||||||
|
res.noalias() = 1. * (A * b);
|
||||||
|
VERIFY_IS_APPROX(res, A*b);
|
||||||
|
res.noalias() = 1.*A * b;
|
||||||
|
VERIFY_IS_APPROX(res, A*b);
|
||||||
|
res.noalias() = (1.*A).lazyProduct(b);
|
||||||
|
VERIFY_IS_APPROX(res, A*b);
|
||||||
|
res.noalias() = (1.*A).lazyProduct(1.*b);
|
||||||
|
VERIFY_IS_APPROX(res, A*b);
|
||||||
|
res.noalias() = (A).lazyProduct(1.*b);
|
||||||
|
VERIFY_IS_APPROX(res, A*b);
|
||||||
|
}
|
||||||
|
|
||||||
void test_product_small()
|
void test_product_small()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < g_repeat; i++) {
|
for(int i = 0; i < g_repeat; i++) {
|
||||||
@ -218,7 +237,7 @@ void test_product_small()
|
|||||||
CALL_SUBTEST_3( product(Matrix3d()) );
|
CALL_SUBTEST_3( product(Matrix3d()) );
|
||||||
CALL_SUBTEST_4( product(Matrix4d()) );
|
CALL_SUBTEST_4( product(Matrix4d()) );
|
||||||
CALL_SUBTEST_5( product(Matrix4f()) );
|
CALL_SUBTEST_5( product(Matrix4f()) );
|
||||||
CALL_SUBTEST_6( product1x1() );
|
CALL_SUBTEST_6( product1x1<0>() );
|
||||||
|
|
||||||
CALL_SUBTEST_11( test_lazy_l1<float>() );
|
CALL_SUBTEST_11( test_lazy_l1<float>() );
|
||||||
CALL_SUBTEST_12( test_lazy_l2<float>() );
|
CALL_SUBTEST_12( test_lazy_l2<float>() );
|
||||||
@ -239,6 +258,9 @@ void test_product_small()
|
|||||||
CALL_SUBTEST_7(( test_linear_but_not_vectorizable<float,2,1,Dynamic>() ));
|
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,3,1,Dynamic>() ));
|
||||||
CALL_SUBTEST_7(( test_linear_but_not_vectorizable<float,2,1,16>() ));
|
CALL_SUBTEST_7(( test_linear_but_not_vectorizable<float,2,1,16>() ));
|
||||||
|
|
||||||
|
CALL_SUBTEST_6( bug_1311<3>() );
|
||||||
|
CALL_SUBTEST_6( bug_1311<5>() );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EIGEN_TEST_PART_6
|
#ifdef EIGEN_TEST_PART_6
|
||||||
|
Loading…
x
Reference in New Issue
Block a user