19 template<
typename PlainObjectType_,
int Options_,
typename Str
ideType_>
20 struct traits<Ref<PlainObjectType_, Options_, StrideType_> >
21 :
public traits<Map<PlainObjectType_, Options_, StrideType_> >
23 typedef PlainObjectType_ PlainObjectType;
24 typedef StrideType_ StrideType;
27 Flags = traits<Map<PlainObjectType_, Options_, StrideType_> >::Flags |
NestByRefBit,
28 Alignment = traits<Map<PlainObjectType_, Options_, StrideType_> >::Alignment
31 template<
typename Derived>
struct match {
33 IsVectorAtCompileTime = PlainObjectType::IsVectorAtCompileTime || Derived::IsVectorAtCompileTime,
34 HasDirectAccess = internal::has_direct_access<Derived>::ret,
35 StorageOrderMatch = IsVectorAtCompileTime || ((PlainObjectType::Flags&
RowMajorBit)==(Derived::Flags&
RowMajorBit)),
36 InnerStrideMatch =
int(StrideType::InnerStrideAtCompileTime)==int(
Dynamic)
37 || int(StrideType::InnerStrideAtCompileTime)==int(Derived::InnerStrideAtCompileTime)
38 || (int(StrideType::InnerStrideAtCompileTime)==0 && int(Derived::InnerStrideAtCompileTime)==1),
39 OuterStrideMatch = IsVectorAtCompileTime
40 ||
int(StrideType::OuterStrideAtCompileTime)==int(
Dynamic) || int(StrideType::OuterStrideAtCompileTime)==int(Derived::OuterStrideAtCompileTime),
46 DerivedAlignment = int(evaluator<Derived>::Alignment),
47 AlignmentMatch = (int(traits<PlainObjectType>::Alignment)==int(
Unaligned)) || (DerivedAlignment >=
int(Alignment)),
48 ScalarTypeMatch = internal::is_same<typename PlainObjectType::Scalar, typename Derived::Scalar>::value,
49 MatchAtCompileTime = HasDirectAccess && StorageOrderMatch && InnerStrideMatch && OuterStrideMatch && AlignmentMatch && ScalarTypeMatch
51 typedef std::conditional_t<MatchAtCompileTime,internal::true_type,internal::false_type> type;
56 template<
typename Derived>
57 struct traits<RefBase<Derived> > :
public traits<Derived> {};
65 typedef typename internal::traits<Derived>::StrideType
StrideType;
74 return StrideType::InnerStrideAtCompileTime != 0 ?
m_stride.
inner() : 1;
79 return StrideType::OuterStrideAtCompileTime != 0 ?
m_stride.
outer()
80 : IsVectorAtCompileTime ? this->
size()
86 : Base(0,RowsAtCompileTime==
Dynamic?0:RowsAtCompileTime,ColsAtCompileTime==
Dynamic?0:ColsAtCompileTime),
100 return inner == 0 ? 1 : inner;
105 return outer == 0 ? isVectorAtCompileTime ? inner *
rows *
cols : isRowMajor ? inner *
cols : inner *
rows : outer;
110 template<
typename Expression>
118 || ( PlainObjectType::IsVectorAtCompileTime
121 ||
int(PlainObjectType::RowsAtCompileTime)==
int(Expression::ColsAtCompileTime))
124 ||
int(PlainObjectType::ColsAtCompileTime)==
int(Expression::RowsAtCompileTime)))),
125 YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES
131 if(PlainObjectType::RowsAtCompileTime==1)
137 else if(PlainObjectType::ColsAtCompileTime==1)
145 (PlainObjectType::RowsAtCompileTime ==
Dynamic) || (PlainObjectType::RowsAtCompileTime ==
rows));
147 (PlainObjectType::ColsAtCompileTime ==
Dynamic) || (PlainObjectType::ColsAtCompileTime ==
cols));
151 const bool transpose = PlainObjectType::IsVectorAtCompileTime && (
rows != expr.rows());
153 const bool row_major = ((PlainObjectType::Flags)&
RowMajorBit) != 0;
154 const bool expr_row_major = (Expression::Flags&
RowMajorBit) != 0;
155 const bool storage_differs = (row_major != expr_row_major);
157 const bool swap_stride = (transpose != storage_differs);
165 Expression::IsVectorAtCompileTime != 0,
170 const bool row_vector = (
rows == 1);
171 const bool col_vector = (
cols == 1);
172 const Index inner_stride =
173 ( (!row_major && row_vector) || (row_major && col_vector) ) ?
174 ( StrideType::InnerStrideAtCompileTime > 0 ?
Index(StrideType::InnerStrideAtCompileTime) : 1)
175 : swap_stride ? expr_outer_actual : expr_inner_actual;
179 const Index outer_stride =
180 ( (!row_major && col_vector) || (row_major && row_vector) ) ?
181 ( StrideType::OuterStrideAtCompileTime > 0 ?
Index(StrideType::OuterStrideAtCompileTime) :
rows *
cols * inner_stride)
182 : swap_stride ? expr_inner_actual : expr_outer_actual;
185 const bool inner_valid = (StrideType::InnerStrideAtCompileTime ==
Dynamic)
191 const bool outer_valid = (StrideType::OuterStrideAtCompileTime ==
Dynamic)
194 Index(StrideType::OuterStrideAtCompileTime),
195 rows,
cols, PlainObjectType::IsVectorAtCompileTime != 0,
202 internal::construct_at<Base>(
this, expr.data(),
rows,
cols);
204 (StrideType::OuterStrideAtCompileTime == 0) ? 0 : outer_stride,
205 (StrideType::InnerStrideAtCompileTime == 0) ? 0 : inner_stride );
283 template<
typename PlainObjectType,
int Options,
typename Str
ideType>
class Ref
284 :
public RefBase<Ref<PlainObjectType, Options, StrideType> >
288 template<
typename Derived>
290 std::enable_if_t<
bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>* = 0);
297 #ifndef EIGEN_PARSED_BY_DOXYGEN
298 template<
typename Derived>
300 std::enable_if_t<
bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>* = 0)
302 EIGEN_STATIC_ASSERT(
bool(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);
308 template<
typename Derived>
310 std::enable_if_t<
bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>* = 0)
313 template<
typename Derived>
317 EIGEN_STATIC_ASSERT(
bool(internal::is_lvalue<Derived>::value), THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);
318 EIGEN_STATIC_ASSERT(
bool(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);
319 EIGEN_STATIC_ASSERT(!Derived::IsPlainObjectBase,THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);
331 template<
typename TPlainObjectType,
int Options,
typename Str
ideType>
class Ref<const TPlainObjectType, Options,
StrideType>
332 :
public RefBase<Ref<const TPlainObjectType, Options, StrideType> >
336 static constexpr
bool may_map_m_object_successfully =
337 (
static_cast<int>(StrideType::InnerStrideAtCompileTime) == 0 ||
338 static_cast<int>(StrideType::InnerStrideAtCompileTime) == 1 ||
339 static_cast<int>(StrideType::InnerStrideAtCompileTime) ==
Dynamic) &&
340 (TPlainObjectType::IsVectorAtCompileTime ||
341 static_cast<int>(StrideType::OuterStrideAtCompileTime) == 0 ||
342 static_cast<int>(StrideType::OuterStrideAtCompileTime) ==
Dynamic ||
343 static_cast<int>(StrideType::OuterStrideAtCompileTime) ==
static_cast<int>(TPlainObjectType::InnerSizeAtCompileTime) ||
344 static_cast<int>(TPlainObjectType::InnerSizeAtCompileTime) ==
Dynamic);
350 template<
typename Derived>
352 std::enable_if_t<
bool(Traits::template match<Derived>::ScalarTypeMatch),Derived>* = 0)
357 EIGEN_STATIC_ASSERT(Traits::template match<Derived>::type::value || may_map_m_object_successfully,
358 STORAGE_LAYOUT_DOES_NOT_MATCH);
359 construct(expr.
derived(),
typename Traits::template match<Derived>::type());
367 if (other.data() == other.m_object.data()) {
368 m_object = std::move(other.m_object);
375 template<
typename OtherRef>
377 EIGEN_STATIC_ASSERT(Traits::template match<OtherRef>::type::value || may_map_m_object_successfully,
378 STORAGE_LAYOUT_DOES_NOT_MATCH);
379 construct(other.derived(),
typename Traits::template match<OtherRef>::type());
384 template<
typename Expression>
393 template<
typename Expression>
#define EIGEN_UNUSED_VARIABLE(var)
#define EIGEN_DEVICE_FUNC
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
#define EIGEN_STATIC_ASSERT(X, MSG)
#define EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0, TYPE1)
Base class for all dense matrices, vectors, and arrays.
Dense storage base class for matrices and arrays.
internal::traits< Derived >::PlainObjectType PlainObjectType
static EIGEN_CONSTEXPR Index resolveInnerStride(Index inner)
EIGEN_CONSTEXPR Index innerStride() const
static EIGEN_CONSTEXPR Index resolveOuterStride(Index inner, Index outer, Index rows, Index cols, bool isVectorAtCompileTime, bool isRowMajor)
Stride< StrideType::OuterStrideAtCompileTime, StrideType::InnerStrideAtCompileTime > StrideBase
EIGEN_CONSTEXPR Index outerStride() const
internal::traits< Derived >::StrideType StrideType
bool construct(Expression &expr)
internal::traits< Ref > Traits
void construct(const Expression &expr, internal::false_type)
TPlainObjectType m_object
Ref(const RefBase< OtherRef > &other)
void construct(const Expression &expr, internal::true_type)
Ref(const DenseBase< Derived > &expr, std::enable_if_t< bool(Traits::template match< Derived >::ScalarTypeMatch), Derived > *=0)
A matrix or vector expression mapping an existing expression.
Ref(DenseBase< Derived > &expr)
internal::traits< Ref > Traits
Ref(const PlainObjectBase< Derived > &expr, std::enable_if_t< bool(Traits::template match< Derived >::MatchAtCompileTime), Derived > *=0)
EIGEN_CONSTEXPR Index inner() const
EIGEN_CONSTEXPR Index outer() const
const unsigned int RowMajorBit
EIGEN_CONSTEXPR void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)
T * construct_at(T *p, Args &&... args)
const unsigned int NestByRefBit
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Derived & const_cast_derived() const