17 template<
typename _PlainObjectType,
int _Options,
typename _Str
ideType>
18 struct traits<
Ref<_PlainObjectType, _Options, _StrideType> >
19 :
public traits<Map<_PlainObjectType, _Options, _StrideType> >
21 typedef _PlainObjectType PlainObjectType;
22 typedef _StrideType StrideType;
29 template<
typename Derived>
struct match {
31 IsVectorAtCompileTime = PlainObjectType::IsVectorAtCompileTime || Derived::IsVectorAtCompileTime,
33 StorageOrderMatch = IsVectorAtCompileTime || ((PlainObjectType::Flags&
RowMajorBit)==(Derived::Flags&
RowMajorBit)),
34 InnerStrideMatch =
int(StrideType::InnerStrideAtCompileTime)==int(
Dynamic)
35 || int(StrideType::InnerStrideAtCompileTime)==int(Derived::InnerStrideAtCompileTime)
36 || (int(StrideType::InnerStrideAtCompileTime)==0 && int(Derived::InnerStrideAtCompileTime)==1),
37 OuterStrideMatch = IsVectorAtCompileTime
38 ||
int(StrideType::OuterStrideAtCompileTime)==int(
Dynamic) || int(StrideType::OuterStrideAtCompileTime)==int(Derived::OuterStrideAtCompileTime),
47 MatchAtCompileTime = HasDirectAccess && StorageOrderMatch && InnerStrideMatch && OuterStrideMatch && AlignmentMatch && ScalarTypeMatch
54 template<
typename Derived>
68 EIGEN_DENSE_PUBLIC_INTERFACE(
RefBase)
70 EIGEN_DEVICE_FUNC
inline Index innerStride()
const
72 return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.
inner() : 1;
75 EIGEN_DEVICE_FUNC
inline Index outerStride()
const
77 return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.
outer()
78 : IsVectorAtCompileTime ? this->size()
84 :
Base(0,RowsAtCompileTime==
Dynamic?0:RowsAtCompileTime,ColsAtCompileTime==
Dynamic?0:ColsAtCompileTime),
86 m_stride(StrideType::OuterStrideAtCompileTime==
Dynamic?0:StrideType::OuterStrideAtCompileTime,
87 StrideType::InnerStrideAtCompileTime==
Dynamic?0:StrideType::InnerStrideAtCompileTime)
90 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(
RefBase)
96 template<
typename Expression>
97 EIGEN_DEVICE_FUNC
void construct(Expression& expr)
99 EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(PlainObjectType,Expression);
101 if(PlainObjectType::RowsAtCompileTime==1)
103 eigen_assert(expr.rows()==1 || expr.cols()==1);
104 ::new (
static_cast<Base*
>(
this))
Base(expr.data(), 1, expr.size());
106 else if(PlainObjectType::ColsAtCompileTime==1)
108 eigen_assert(expr.rows()==1 || expr.cols()==1);
109 ::new (
static_cast<Base*
>(
this))
Base(expr.data(), expr.size(), 1);
112 ::new (
static_cast<Base*
>(
this))
Base(expr.data(), expr.rows(), expr.cols());
114 if(Expression::IsVectorAtCompileTime && (!PlainObjectType::IsVectorAtCompileTime) && ((Expression::Flags&
RowMajorBit)!=(PlainObjectType::Flags&
RowMajorBit)))
115 ::new (&m_stride)
StrideBase(expr.innerStride(), StrideType::InnerStrideAtCompileTime==0?0:1);
117 ::new (&m_stride)
StrideBase(StrideType::OuterStrideAtCompileTime==0?0:expr.outerStride(),
118 StrideType::InnerStrideAtCompileTime==0?0:expr.innerStride());
195 template<
typename PlainObjectType,
int Options,
typename Str
ideType>
class Ref
196 :
public RefBase<Ref<PlainObjectType, Options, StrideType> >
200 template<
typename Derived>
202 typename internal::enable_if<
bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>::type* = 0);
206 EIGEN_DENSE_PUBLIC_INTERFACE(
Ref)
209 #ifndef EIGEN_PARSED_BY_DOXYGEN
210 template<
typename Derived>
212 typename internal::enable_if<
bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>::type* = 0)
214 EIGEN_STATIC_ASSERT(
bool(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);
215 Base::construct(expr.derived());
217 template<
typename Derived>
219 typename internal::enable_if<
bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>::type* = 0)
222 template<
typename Derived>
227 EIGEN_STATIC_ASSERT(
bool(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);
228 EIGEN_STATIC_ASSERT(!Derived::IsPlainObjectBase,THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);
229 Base::construct(expr.const_cast_derived());
232 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(
Ref)
237 template<
typename TPlainObjectType,
int Options,
typename Str
ideType>
class Ref<const TPlainObjectType, Options, StrideType>
238 :
public RefBase<Ref<const TPlainObjectType, Options, StrideType> >
244 EIGEN_DENSE_PUBLIC_INTERFACE(
Ref)
246 template<
typename Derived>
248 typename internal::enable_if<
bool(Traits::template match<Derived>::ScalarTypeMatch),Derived>::type* = 0)
253 construct(expr.derived(),
typename Traits::template match<Derived>::type());
256 EIGEN_DEVICE_FUNC
inline Ref(
const Ref& other) :
Base(other) {
260 template<
typename OtherRef>
262 construct(other.derived(),
typename Traits::template match<OtherRef>::type());
267 template<
typename Expression>
270 Base::construct(expr);
273 template<
typename Expression>
277 Base::construct(m_object);
281 TPlainObjectType m_object;
286 #endif // EIGEN_REF_H