Enable construction of Ref<VectorType> from a runtime vector.

This commit is contained in:
Gael Guennebaud
2019-03-03 15:25:25 +01:00
parent 9ba81cf0ff
commit b0d406d91c
2 changed files with 11 additions and 6 deletions

View File

@@ -102,10 +102,14 @@ template<typename VectorType> void ref_vector(const VectorType& m)
Index i = internal::random<Index>(0,size-1);
Index bsize = internal::random<Index>(1,size-i);
RefMat rm0 = v1;
VERIFY_IS_EQUAL(rm0, v1);
RefDynMat rv1 = v1;
VERIFY_IS_EQUAL(rv1, v1);
{ RefMat rm0 = v1; VERIFY_IS_EQUAL(rm0, v1); }
{ RefMat rm0 = v1.block(0,0,size,1); VERIFY_IS_EQUAL(rm0, v1); }
{ RefDynMat rv1 = v1; VERIFY_IS_EQUAL(rv1, v1); }
{ RefDynMat rv1 = v1.block(0,0,size,1); VERIFY_IS_EQUAL(rv1, v1); }
{ VERIFY_RAISES_ASSERT( RefMat rm0 = v1.block(0, 0, size, 0); EIGEN_UNUSED_VARIABLE(rm0); ); }
if(VectorType::SizeAtCompileTime!=1)
{ VERIFY_RAISES_ASSERT( RefDynMat rv1 = v1.block(0, 0, size, 0); EIGEN_UNUSED_VARIABLE(rv1); ); }
RefDynMat rv2 = v1.segment(i,bsize);
VERIFY_IS_EQUAL(rv2, v1.segment(i,bsize));
rv2.setOnes();