17 template<
typename _PlainObjectType,
int _Options,
typename _Str
ideType>
18 struct traits<
Ref<_PlainObjectType, _Options, _StrideType> >
19 :
public traits<Map<_PlainObjectType, _Options, _StrideType> >
29 template<
typename Derived>
struct match {
32 StorageOrderMatch = PlainObjectType::IsVectorAtCompileTime || Derived::IsVectorAtCompileTime || ((PlainObjectType::Flags&
RowMajorBit)==(Derived::Flags&
RowMajorBit)),
33 InnerStrideMatch =
int(StrideType::InnerStrideAtCompileTime)==int(
Dynamic)
34 || int(StrideType::InnerStrideAtCompileTime)==int(Derived::InnerStrideAtCompileTime)
35 || (int(StrideType::InnerStrideAtCompileTime)==0 && int(Derived::InnerStrideAtCompileTime)==1),
36 OuterStrideMatch = Derived::IsVectorAtCompileTime
37 ||
int(StrideType::OuterStrideAtCompileTime)==int(
Dynamic) || int(StrideType::OuterStrideAtCompileTime)==int(Derived::OuterStrideAtCompileTime),
46 MatchAtCompileTime = HasDirectAccess && StorageOrderMatch && InnerStrideMatch && OuterStrideMatch && AlignmentMatch && ScalarTypeMatch
53 template<
typename Derived>
69 EIGEN_DEVICE_FUNC inline
Index innerStride()
const 71 return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1;
76 return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer()
77 : IsVectorAtCompileTime ? this->
size()
78 : int(Flags)&RowMajorBit ? this->cols()
83 : Base(0,RowsAtCompileTime==
Dynamic?0:RowsAtCompileTime,ColsAtCompileTime==
Dynamic?0:ColsAtCompileTime),
85 m_stride(StrideType::OuterStrideAtCompileTime==
Dynamic?0:StrideType::OuterStrideAtCompileTime,
86 StrideType::InnerStrideAtCompileTime==
Dynamic?0:StrideType::InnerStrideAtCompileTime)
95 template<
typename Expression>
98 if(PlainObjectType::RowsAtCompileTime==1)
101 ::new (static_cast<Base*>(
this)) Base(expr.data(), 1, expr.size());
103 else if(PlainObjectType::ColsAtCompileTime==1)
106 ::new (static_cast<Base*>(
this)) Base(expr.data(), expr.size(), 1);
109 ::new (static_cast<Base*>(
this)) Base(expr.data(), expr.rows(), expr.cols());
111 if(Expression::IsVectorAtCompileTime && (!PlainObjectType::IsVectorAtCompileTime) && ((Expression::Flags&
RowMajorBit)!=(PlainObjectType::Flags&RowMajorBit)))
112 ::new (&m_stride) StrideBase(expr.innerStride(), StrideType::InnerStrideAtCompileTime==0?0:1);
114 ::new (&m_stride) StrideBase(StrideType::OuterStrideAtCompileTime==0?0:expr.outerStride(),
115 StrideType::InnerStrideAtCompileTime==0?0:expr.innerStride());
190 template<
typename PlainObjectType,
int Options,
typename Str
ideType>
class Ref 191 :
public RefBase<Ref<PlainObjectType, Options, StrideType> >
195 template<
typename Derived>
197 typename internal::enable_if<
bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>::type* = 0);
204 #ifndef EIGEN_PARSED_BY_DOXYGEN 205 template<
typename Derived>
207 typename internal::enable_if<
bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>::type* = 0)
209 EIGEN_STATIC_ASSERT(
bool(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);
210 Base::construct(expr.derived());
212 template<
typename Derived>
214 typename internal::enable_if<
bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>::type* = 0)
217 template<
typename Derived>
222 EIGEN_STATIC_ASSERT(
bool(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);
223 EIGEN_STATIC_ASSERT(!Derived::IsPlainObjectBase,THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);
224 Base::construct(expr.const_cast_derived());
232 template<
typename TPlainObjectType,
int Options,
typename Str
ideType>
class Ref<const TPlainObjectType, Options, StrideType>
233 :
public RefBase<Ref<const TPlainObjectType, Options, StrideType> >
241 template<typename Derived>
243 typename
internal::enable_if<
bool(Traits::template match<Derived>::ScalarTypeMatch),Derived>::type* = 0)
248 construct(expr.derived(),
typename Traits::template match<Derived>::type());
251 EIGEN_DEVICE_FUNC
inline Ref(
const Ref& other) : Base(other) {
255 template<
typename OtherRef>
257 construct(other.derived(),
typename Traits::template match<OtherRef>::type());
262 template<
typename Expression>
265 Base::construct(expr);
268 template<
typename Expression>
272 Base::construct(m_object);
281 #endif // EIGEN_REF_H EIGEN_DEVICE_FUNC Index outerStride() const
EIGEN_DEVICE_FUNC Ref(const DenseBase< Derived > &expr, typename internal::enable_if< bool(Traits::template match< Derived >::MatchAtCompileTime), Derived >::type *=0)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)
Stride< StrideType::OuterStrideAtCompileTime, StrideType::InnerStrideAtCompileTime > StrideBase
EIGEN_DEVICE_FUNC RefBase()
internal::traits< Ref > Traits
internal::traits< Ref > Traits
internal::traits< Derived >::PlainObjectType PlainObjectType
static constexpr size_t size(Tuple< Args... > &)
Provides access to the number of elements in a tuple as a compile-time constant expression.
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
EIGEN_DEVICE_FUNC Ref(const RefBase< OtherRef > &other)
const unsigned int RowMajorBit
Base class for all dense matrices, vectors, and arrays.
EIGEN_DEVICE_FUNC void construct(Expression &expr)
internal::conditional< MatchAtCompileTime, internal::true_type, internal::false_type >::type type
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
EIGEN_DEVICE_FUNC Ref(const Ref &other)
TPlainObjectType m_object
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
A matrix or vector expression mapping an existing expression.
const unsigned int NestByRefBit
EIGEN_DEVICE_FUNC Ref(PlainObjectBase< Derived > &expr, typename internal::enable_if< bool(Traits::template match< Derived >::MatchAtCompileTime), Derived >::type *=0)
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
EIGEN_DEVICE_FUNC void construct(const Expression &expr, internal::true_type)
_PlainObjectType PlainObjectType
EIGEN_DEVICE_FUNC void construct(const Expression &expr, internal::false_type)
internal::traits< Derived >::StrideType StrideType