diff options
author | Gael Guennebaud <g.gael@free.fr> | 2015-06-08 10:14:08 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2015-06-08 10:14:08 +0200 |
commit | a7ae628c9f8a83973e899866ecd344bbfde6e844 (patch) | |
tree | da400d0bb3ff1fd3853b783a90a41ad121486eb2 | |
parent | 0a9b5d13965aa2294ed657ffef327287df99cfd3 (diff) |
bug #1005: fix regression regarding sparse coeff-wise binary operator that did not trigger a static assertion for mismatched storage
-rw-r--r-- | Eigen/src/SparseCore/SparseCwiseBinaryOp.h | 18 | ||||
-rw-r--r-- | failtest/CMakeLists.txt | 2 | ||||
-rw-r--r-- | failtest/sparse_storage_mismatch.cpp | 16 |
3 files changed, 36 insertions, 0 deletions
diff --git a/Eigen/src/SparseCore/SparseCwiseBinaryOp.h b/Eigen/src/SparseCore/SparseCwiseBinaryOp.h index f53427abf..096af7fb0 100644 --- a/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +++ b/Eigen/src/SparseCore/SparseCwiseBinaryOp.h @@ -29,6 +29,24 @@ namespace Eigen { // 4 - dense op dense product dense // generic dense +template<typename BinaryOp, typename Lhs, typename Rhs> +class CwiseBinaryOpImpl<BinaryOp, Lhs, Rhs, Sparse> + : public SparseMatrixBase<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > +{ + public: + typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> Derived; + EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) + CwiseBinaryOpImpl() + { + typedef typename internal::traits<Lhs>::StorageKind LhsStorageKind; + typedef typename internal::traits<Rhs>::StorageKind RhsStorageKind; + EIGEN_STATIC_ASSERT(( + (!internal::is_same<LhsStorageKind,RhsStorageKind>::value) + || ((Lhs::Flags&RowMajorBit) == (Rhs::Flags&RowMajorBit))), + THE_STORAGE_ORDER_OF_BOTH_SIDES_MUST_MATCH); + } +}; + namespace internal { template<typename BinaryOp, typename Lhs, typename Rhs, typename Derived, diff --git a/failtest/CMakeLists.txt b/failtest/CMakeLists.txt index d3e82ecd9..8df0a7631 100644 --- a/failtest/CMakeLists.txt +++ b/failtest/CMakeLists.txt @@ -47,6 +47,8 @@ ei_add_failtest("sparse_ref_3") ei_add_failtest("sparse_ref_4") ei_add_failtest("sparse_ref_5") +ei_add_failtest("sparse_storage_mismatch") + ei_add_failtest("partialpivlu_int") ei_add_failtest("fullpivlu_int") ei_add_failtest("llt_int") diff --git a/failtest/sparse_storage_mismatch.cpp b/failtest/sparse_storage_mismatch.cpp new file mode 100644 index 000000000..51840d416 --- /dev/null +++ b/failtest/sparse_storage_mismatch.cpp @@ -0,0 +1,16 @@ +#include "../Eigen/Sparse" +using namespace Eigen; + +typedef SparseMatrix<double,ColMajor> Mat1; +#ifdef EIGEN_SHOULD_FAIL_TO_BUILD +typedef SparseMatrix<double,RowMajor> Mat2; +#else +typedef SparseMatrix<double,ColMajor> Mat2; +#endif + +int main() +{ + Mat1 a(10,10); + Mat2 b(10,10); + a += b; +} |