20 template <
typename PlainObjectType_,
int Options_,
typename Str
ideType_>
21 struct traits<
Ref<PlainObjectType_, Options_, StrideType_> >
22 :
public traits<Map<PlainObjectType_, Options_, StrideType_> > {
33 template <
typename Derived>
36 IsVectorAtCompileTime = PlainObjectType::IsVectorAtCompileTime || Derived::IsVectorAtCompileTime,
40 InnerStrideMatch =
int(InnerStrideAtCompileTime) ==
int(
Dynamic) ||
41 int(InnerStrideAtCompileTime) ==
int(Derived::InnerStrideAtCompileTime) ||
42 (
int(InnerStrideAtCompileTime) == 0 &&
int(Derived::InnerStrideAtCompileTime) == 1),
43 OuterStrideMatch = IsVectorAtCompileTime ||
int(OuterStrideAtCompileTime) ==
int(
Dynamic) ||
44 int(OuterStrideAtCompileTime) ==
int(Derived::OuterStrideAtCompileTime),
52 (DerivedAlignment >=
int(Alignment)),
55 MatchAtCompileTime = HasDirectAccess && StorageOrderMatch && InnerStrideMatch && OuterStrideMatch &&
56 AlignmentMatch && ScalarTypeMatch
58 typedef std::conditional_t<MatchAtCompileTime, internal::true_type, internal::false_type>
type;
62 template <
typename Derived>
67 template <
typename Derived>
77 return StrideType::InnerStrideAtCompileTime != 0 ?
m_stride.
inner() : 1;
81 return StrideType::OuterStrideAtCompileTime != 0 ?
m_stride.
outer()
82 : IsVectorAtCompileTime ? this->
size()
88 : Base(0, RowsAtCompileTime ==
Dynamic ? 0 : RowsAtCompileTime,
89 ColsAtCompileTime ==
Dynamic ? 0 : ColsAtCompileTime),
104 bool isVectorAtCompileTime,
bool isRowMajor) {
105 return outer == 0 ? isVectorAtCompileTime ? inner *
rows *
cols : isRowMajor ? inner *
cols : inner *
rows : outer;
110 template <
typename Expression>
116 || (PlainObjectType::IsVectorAtCompileTime &&
119 int(PlainObjectType::RowsAtCompileTime) ==
int(Expression::ColsAtCompileTime)) &&
122 int(PlainObjectType::ColsAtCompileTime) ==
int(Expression::RowsAtCompileTime)))),
123 YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES)
128 if (PlainObjectType::RowsAtCompileTime == 1) {
132 }
else if (PlainObjectType::ColsAtCompileTime == 1) {
142 const bool transpose = PlainObjectType::IsVectorAtCompileTime && (
rows != expr.rows());
144 const bool row_major = ((PlainObjectType::Flags)&
RowMajorBit) != 0;
145 const bool expr_row_major = (Expression::Flags &
RowMajorBit) != 0;
146 const bool storage_differs = (row_major != expr_row_major);
148 const bool swap_stride = (
transpose != storage_differs);
152 const Index expr_outer_actual =
resolveOuterStride(expr_inner_actual, expr.outerStride(), expr.rows(), expr.cols(),
153 Expression::IsVectorAtCompileTime != 0, expr_row_major);
157 const bool row_vector = (
rows == 1);
158 const bool col_vector = (
cols == 1);
159 const Index inner_stride =
160 ((!row_major && row_vector) || (row_major && col_vector))
161 ? (StrideType::InnerStrideAtCompileTime > 0 ?
Index(StrideType::InnerStrideAtCompileTime) : 1)
162 : swap_stride ? expr_outer_actual
167 const Index outer_stride =
168 ((!row_major && col_vector) || (row_major && row_vector))
169 ? (StrideType::OuterStrideAtCompileTime > 0 ?
Index(StrideType::OuterStrideAtCompileTime)
171 : swap_stride ? expr_inner_actual
175 const bool inner_valid = (StrideType::InnerStrideAtCompileTime ==
Dynamic) ||
181 const bool outer_valid =
182 (StrideType::OuterStrideAtCompileTime ==
Dynamic) ||
184 PlainObjectType::IsVectorAtCompileTime != 0, row_major) == outer_stride);
189 internal::construct_at<Base>(
this, expr.data(),
rows,
cols);
191 (StrideType::InnerStrideAtCompileTime == 0) ? 0 : inner_stride);
263 template <
typename PlainObjectType,
int Options,
typename Str
ideType>
264 class Ref :
public RefBase<Ref<PlainObjectType, Options, StrideType> > {
267 template <
typename Derived>
270 std::enable_if_t<
bool(Traits::template match<Derived>::MatchAtCompileTime), Derived>* = 0);
276 #ifndef EIGEN_PARSED_BY_DOXYGEN
277 template <
typename Derived>
280 std::enable_if_t<
bool(Traits::template match<Derived>::MatchAtCompileTime), Derived>* = 0) {
281 EIGEN_STATIC_ASSERT(
bool(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);
287 template <
typename Derived>
290 std::enable_if_t<
bool(Traits::template match<Derived>::MatchAtCompileTime), Derived>* = 0)
293 template <
typename Derived>
298 EIGEN_STATIC_ASSERT(
bool(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);
299 EIGEN_STATIC_ASSERT(!Derived::IsPlainObjectBase, THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);
310 template <
typename TPlainObjectType,
int Options,
typename Str
ideType>
312 :
public RefBase<Ref<const TPlainObjectType, Options, StrideType> > {
315 static constexpr
bool may_map_m_object_successfully =
316 (
static_cast<int>(StrideType::InnerStrideAtCompileTime) == 0 ||
317 static_cast<int>(StrideType::InnerStrideAtCompileTime) == 1 ||
318 static_cast<int>(StrideType::InnerStrideAtCompileTime) ==
Dynamic) &&
319 (TPlainObjectType::IsVectorAtCompileTime ||
static_cast<int>(StrideType::OuterStrideAtCompileTime) == 0 ||
320 static_cast<int>(StrideType::OuterStrideAtCompileTime) ==
Dynamic ||
321 static_cast<int>(StrideType::OuterStrideAtCompileTime) ==
322 static_cast<int>(TPlainObjectType::InnerSizeAtCompileTime) ||
323 static_cast<int>(TPlainObjectType::InnerSizeAtCompileTime) ==
Dynamic);
329 template <
typename Derived>
331 std::enable_if_t<
bool(Traits::template match<Derived>::ScalarTypeMatch), Derived>* = 0) {
337 STORAGE_LAYOUT_DOES_NOT_MATCH);
346 if (other.data() == other.m_object.data()) {
347 m_object = std::move(other.m_object);
353 template <
typename OtherRef>
356 STORAGE_LAYOUT_DOES_NOT_MATCH);
361 template <
typename Expression>
369 template <
typename Expression>
#define EIGEN_CONSTEXPR
Definition: Macros.h:758
#define EIGEN_UNUSED_VARIABLE(var)
Definition: Macros.h:966
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
Definition: Macros.h:922
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1171
#define eigen_assert(x)
Definition: Macros.h:910
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
Macro to manually inherit assignment operators. This is necessary, because the implicitly defined ass...
Definition: Macros.h:1126
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
#define EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0, TYPE1)
Definition: StaticAssert.h:66
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:44
Definition: ForwardDeclarations.h:150
Definition: PlainObjectBase.h:121
internal::traits< Derived >::PlainObjectType PlainObjectType
Definition: Ref.h:69
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index innerStride() const
Definition: Ref.h:76
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index outerStride() const
Definition: Ref.h:80
static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index resolveInnerStride(Index inner)
Definition: Ref.h:100
static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index resolveOuterStride(Index inner, Index outer, Index rows, Index cols, bool isVectorAtCompileTime, bool isRowMajor)
Definition: Ref.h:103
EIGEN_DEVICE_FUNC bool construct(Expression &expr)
Definition: Ref.h:111
EIGEN_DEVICE_FUNC RefBase()
Definition: Ref.h:87
internal::traits< Derived >::StrideType StrideType
Definition: Ref.h:70
Stride< StrideType::OuterStrideAtCompileTime, StrideType::InnerStrideAtCompileTime > StrideBase
Definition: Ref.h:97
StrideBase m_stride
Definition: Ref.h:195
MapBase< Derived > Base
Definition: Ref.h:73
EIGEN_DEVICE_FUNC Ref(const DenseBase< Derived > &expr, std::enable_if_t< bool(Traits::template match< Derived >::ScalarTypeMatch), Derived > *=0)
Definition: Ref.h:330
internal::traits< Ref > Traits
Definition: Ref.h:313
EIGEN_DEVICE_FUNC Ref(const RefBase< OtherRef > &other)
Definition: Ref.h:354
TPlainObjectType m_object
Definition: Ref.h:378
RefBase< Ref > Base
Definition: Ref.h:326
EIGEN_DEVICE_FUNC void construct(const Expression &expr, internal::false_type)
Definition: Ref.h:370
EIGEN_DEVICE_FUNC void construct(const Expression &expr, internal::true_type)
Definition: Ref.h:362
EIGEN_DEVICE_FUNC Ref(Ref &&other)
Definition: Ref.h:345
EIGEN_DEVICE_FUNC Ref(const Ref &other)
Definition: Ref.h:341
A matrix or vector expression mapping an existing expression.
Definition: Ref.h:264
EIGEN_DEVICE_FUNC Ref(PlainObjectBase< Derived > &expr, std::enable_if_t< bool(Traits::template match< Derived >::MatchAtCompileTime), Derived > *=0)
Definition: Ref.h:278
internal::traits< Ref > Traits
Definition: Ref.h:266
RefBase< Ref > Base
Definition: Ref.h:273
EIGEN_DEVICE_FUNC Ref(const DenseBase< Derived > &expr, std::enable_if_t< bool(Traits::template match< Derived >::MatchAtCompileTime), Derived > *=0)
Definition: Ref.h:288
EIGEN_DEVICE_FUNC Ref(const PlainObjectBase< Derived > &expr, std::enable_if_t< bool(Traits::template match< Derived >::MatchAtCompileTime), Derived > *=0)
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index outer() const
Definition: Stride.h:81
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index inner() const
Definition: Stride.h:83
@ Unaligned
Definition: Constants.h:235
const unsigned int RowMajorBit
Definition: Constants.h:70
bool match(const T &xpr, std::string ref, std::string str_xpr="")
Definition: indexed_view.cpp:29
EIGEN_DEVICE_FUNC T * construct_at(T *p, Args &&... args)
Definition: Memory.h:1321
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)
Definition: AssignEvaluator.h:812
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
squared absolute value
Definition: GlobalFunctions.h:87
const unsigned int NestByRefBit
Definition: Constants.h:173
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
const int Dynamic
Definition: Constants.h:25
Extend namespace for flags.
Definition: fsi_chan_precond_driver.cc:56
void transpose()
Definition: skew_symmetric_matrix3.cpp:135
type
Definition: compute_granudrum_aor.py:141
Definition: Eigen_Colamd.h:49
Template functor for scalar/packet assignment.
Definition: AssignmentFunctors.h:25
Definition: CoreEvaluators.h:104
Definition: ForwardDeclarations.h:31
Definition: XprHelper.h:819
std::conditional_t< MatchAtCompileTime, internal::true_type, internal::false_type > type
Definition: Ref.h:58
StrideType_ StrideType
Definition: Ref.h:24
PlainObjectType_ PlainObjectType
Definition: Ref.h:23
Definition: ForwardDeclarations.h:21