mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-03-07 18:27:40 +08:00
Enable construction of Ref<VectorType> from a runtime vector.
This commit is contained in:
parent
9ba81cf0ff
commit
b0d406d91c
@ -28,12 +28,13 @@ struct traits<Ref<_PlainObjectType, _Options, _StrideType> >
|
||||
|
||||
template<typename Derived> struct match {
|
||||
enum {
|
||||
IsVectorAtCompileTime = PlainObjectType::IsVectorAtCompileTime || Derived::IsVectorAtCompileTime,
|
||||
HasDirectAccess = internal::has_direct_access<Derived>::ret,
|
||||
StorageOrderMatch = PlainObjectType::IsVectorAtCompileTime || Derived::IsVectorAtCompileTime || ((PlainObjectType::Flags&RowMajorBit)==(Derived::Flags&RowMajorBit)),
|
||||
StorageOrderMatch = IsVectorAtCompileTime || ((PlainObjectType::Flags&RowMajorBit)==(Derived::Flags&RowMajorBit)),
|
||||
InnerStrideMatch = int(StrideType::InnerStrideAtCompileTime)==int(Dynamic)
|
||||
|| int(StrideType::InnerStrideAtCompileTime)==int(Derived::InnerStrideAtCompileTime)
|
||||
|| (int(StrideType::InnerStrideAtCompileTime)==0 && int(Derived::InnerStrideAtCompileTime)==1),
|
||||
OuterStrideMatch = Derived::IsVectorAtCompileTime
|
||||
OuterStrideMatch = IsVectorAtCompileTime
|
||||
|| int(StrideType::OuterStrideAtCompileTime)==int(Dynamic) || int(StrideType::OuterStrideAtCompileTime)==int(Derived::OuterStrideAtCompileTime),
|
||||
// NOTE, this indirection of evaluator<Derived>::Alignment is needed
|
||||
// to workaround a very strange bug in MSVC related to the instantiation
|
||||
|
12
test/ref.cpp
12
test/ref.cpp
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user