bug #1005: fix regression regarding sparse coeff-wise binary operator that did not trigger a static assertion for mismatched storage
This commit is contained in:
		
							parent
							
								
									0a9b5d1396
								
							
						
					
					
						commit
						a7ae628c9f
					
				| @ -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") | ||||
|  | ||||
							
								
								
									
										16
									
								
								failtest/sparse_storage_mismatch.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								failtest/sparse_storage_mismatch.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -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; | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Gael Guennebaud
						Gael Guennebaud