Skip to content
Snippets Groups Projects
Commit a7ae628c authored by Gael Guennebaud's avatar Gael Guennebaud
Browse files

bug #1005: fix regression regarding sparse coeff-wise binary operator that did...

bug #1005: fix regression regarding sparse coeff-wise binary operator that did not trigger a static assertion for mismatched storage
parent 0a9b5d13
No related branches found
No related tags found
No related merge requests found
......@@ -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,
......
......@@ -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")
......
#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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment