12#ifndef EIGEN_XPRHELPER_H
13#define EIGEN_XPRHELPER_H
16#include "../InternalHeaderCheck.h"
23template <
typename IndexType>
24EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::make_unsigned_t<IndexType> returnUnsignedIndexValue(
const IndexType& idx) {
25 EIGEN_STATIC_ASSERT((NumTraits<IndexType>::IsInteger), THIS FUNCTION IS FOR INTEGER TYPES)
26 eigen_internal_assert(idx >= 0 &&
"Index value is negative and target type is unsigned");
27 using UnsignedType = std::make_unsigned_t<IndexType>;
28 return static_cast<UnsignedType
>(idx);
31template <typename IndexDest, typename IndexSrc, bool IndexDestIsInteger = NumTraits<IndexDest>::IsInteger,
32 bool IndexDestIsSigned = NumTraits<IndexDest>::IsSigned,
33 bool IndexSrcIsInteger = NumTraits<IndexSrc>::IsInteger,
34 bool IndexSrcIsSigned = NumTraits<IndexSrc>::IsSigned>
35struct convert_index_impl {
36 static inline EIGEN_DEVICE_FUNC IndexDest run(
const IndexSrc& idx) {
37 eigen_internal_assert(idx <= NumTraits<IndexDest>::highest() &&
"Index value is too big for target type");
38 return static_cast<IndexDest
>(idx);
41template <
typename IndexDest,
typename IndexSrc>
42struct convert_index_impl<IndexDest, IndexSrc, true, true, true, false> {
45 static inline EIGEN_DEVICE_FUNC IndexDest run(
const IndexSrc& idx) {
46 eigen_internal_assert(idx <= returnUnsignedIndexValue(NumTraits<IndexDest>::highest()) &&
47 "Index value is too big for target type");
48 return static_cast<IndexDest
>(idx);
51template <
typename IndexDest,
typename IndexSrc>
52struct convert_index_impl<IndexDest, IndexSrc, true, false, true, true> {
55 static inline EIGEN_DEVICE_FUNC IndexDest run(
const IndexSrc& idx) {
56 eigen_internal_assert(returnUnsignedIndexValue(idx) <= NumTraits<IndexDest>::highest() &&
57 "Index value is too big for target type");
58 return static_cast<IndexDest
>(idx);
62template <
typename IndexDest,
typename IndexSrc>
63EIGEN_DEVICE_FUNC
inline IndexDest convert_index(
const IndexSrc& idx) {
64 return convert_index_impl<IndexDest, IndexSrc>::run(idx);
68template <
typename RowIndices,
typename ColIndices>
69struct valid_indexed_view_overload : bool_constant<!(internal::is_valid_index_type<RowIndices>::value &&
70 internal::is_valid_index_type<ColIndices>::value)> {};
86template <
typename ExprScalar,
typename T,
bool IsSupported>
87struct promote_scalar_arg;
89template <
typename S,
typename T>
90struct promote_scalar_arg<S, T, true> {
95template <
typename ExprScalar,
typename T,
typename PromotedType,
96 bool ConvertibleToLiteral = std::is_convertible<T, PromotedType>::value,
97 bool IsSafe = NumTraits<T>::IsInteger || !NumTraits<PromotedType>::IsInteger>
98struct promote_scalar_arg_unsupported;
101template <
typename S,
typename T>
102struct promote_scalar_arg<S, T, false> : promote_scalar_arg_unsupported<S, T, typename NumTraits<S>::Literal> {};
105template <
typename S,
typename T,
typename PromotedType>
106struct promote_scalar_arg_unsupported<S, T, PromotedType, true, true> {
107 using type = PromotedType;
112template <
typename ExprScalar,
typename T,
typename PromotedType>
113struct promote_scalar_arg_unsupported<ExprScalar, T, PromotedType, false, true>
114 : promote_scalar_arg_unsupported<ExprScalar, T, ExprScalar> {};
117template <
typename S,
typename T,
typename PromotedType,
bool ConvertibleToLiteral>
118struct promote_scalar_arg_unsupported<S, T, PromotedType, ConvertibleToLiteral, false> {};
121template <
typename S,
typename T>
122struct promote_scalar_arg_unsupported<S, T, S, false, true> {};
125class no_assignment_operator {
126 no_assignment_operator& operator=(
const no_assignment_operator&) =
delete;
129 EIGEN_DEFAULT_COPY_CONSTRUCTOR(no_assignment_operator)
130 EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(no_assignment_operator)
134template <
typename I1,
typename I2>
135struct promote_index_type {
136 using type = std::conditional_t<(
sizeof(I1) <
sizeof(I2)), I2, I1>;
143template <
typename T,
int Value>
144class variable_if_dynamic {
146 EIGEN_DEVICE_FUNC
constexpr EIGEN_STRONG_INLINE
explicit variable_if_dynamic(T v)
noexcept {
147 EIGEN_ONLY_USED_FOR_DEBUG(v);
148 eigen_plain_assert(v == T(Value));
150 EIGEN_DEVICE_FUNC
static constexpr T value() {
return T(Value); }
151 EIGEN_DEVICE_FUNC
constexpr operator T()
const {
return T(Value); }
152 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void setValue(T v)
const {
153 EIGEN_ONLY_USED_FOR_DEBUG(v);
154 eigen_assert(v == T(Value));
159class variable_if_dynamic<T, Dynamic> {
163 EIGEN_DEVICE_FUNC
constexpr EIGEN_STRONG_INLINE
explicit variable_if_dynamic(T value = 0) noexcept : m_value(value) {}
164 EIGEN_DEVICE_FUNC
constexpr EIGEN_STRONG_INLINE T value()
const {
return m_value; }
165 EIGEN_DEVICE_FUNC
constexpr EIGEN_STRONG_INLINE
operator T()
const {
return m_value; }
166 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void setValue(T value) { m_value = value; }
171template <
typename T,
int Value>
172class variable_if_dynamicindex {
174 EIGEN_DEVICE_FUNC
constexpr EIGEN_STRONG_INLINE
explicit variable_if_dynamicindex(T v) {
175 EIGEN_ONLY_USED_FOR_DEBUG(v);
176 eigen_assert(v == T(Value));
178 EIGEN_DEVICE_FUNC
static constexpr T value() {
return T(Value); }
179 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void setValue(T) {}
183class variable_if_dynamicindex<T, DynamicIndex> {
185 EIGEN_DEVICE_FUNC variable_if_dynamicindex() { eigen_assert(
false); }
188 EIGEN_DEVICE_FUNC
constexpr EIGEN_STRONG_INLINE
explicit variable_if_dynamicindex(T value) : m_value(value) {}
189 EIGEN_DEVICE_FUNC
constexpr T EIGEN_STRONG_INLINE value()
const {
return m_value; }
190 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void setValue(T value) { m_value = value; }
194struct functor_traits {
195 enum { Cost = 10, PacketAccess =
false, IsRepeatable =
false };
203template <
typename Func>
204struct functor_is_commutative : std::false_type {};
207template <
typename Xpr>
208struct nested_functor_cost {
209 static constexpr Index Cost =
static_cast<Index
>(functor_traits<Xpr>::Cost);
212template <
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
213struct nested_functor_cost<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols>> {
214 static constexpr Index Cost = 1;
217template <
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
218struct nested_functor_cost<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols>> {
219 static constexpr Index Cost = 1;
223template <
typename PlainObjectType,
int MapOptions,
typename Str
ideType>
224struct nested_functor_cost<Map<PlainObjectType, MapOptions, StrideType>> : nested_functor_cost<PlainObjectType> {};
226template <
typename Func,
typename Xpr>
227struct nested_functor_cost<CwiseUnaryOp<Func, Xpr>> {
228 using XprCleaned = remove_all_t<Xpr>;
229 using FuncCleaned = remove_all_t<Func>;
230 static constexpr Index Cost = nested_functor_cost<FuncCleaned>::Cost + nested_functor_cost<XprCleaned>::Cost;
233template <
typename Func,
typename Xpr>
234struct nested_functor_cost<CwiseNullaryOp<Func, Xpr>> {
235 using XprCleaned = remove_all_t<Xpr>;
236 using FuncCleaned = remove_all_t<Func>;
237 static constexpr Index Cost = nested_functor_cost<FuncCleaned>::Cost + nested_functor_cost<XprCleaned>::Cost;
240template <
typename Func,
typename LhsXpr,
typename RhsXpr>
241struct nested_functor_cost<CwiseBinaryOp<Func, LhsXpr, RhsXpr>> {
242 using LhsXprCleaned = remove_all_t<LhsXpr>;
243 using RhsXprCleaned = remove_all_t<RhsXpr>;
244 using FuncCleaned = remove_all_t<Func>;
245 static constexpr Index Cost = nested_functor_cost<FuncCleaned>::Cost + nested_functor_cost<LhsXprCleaned>::Cost +
246 nested_functor_cost<RhsXprCleaned>::Cost;
249template <
typename Func,
typename LhsXpr,
typename M
idXpr,
typename RhsXpr>
250struct nested_functor_cost<CwiseTernaryOp<Func, LhsXpr, MidXpr, RhsXpr>> {
251 using LhsXprCleaned = remove_all_t<LhsXpr>;
252 using MidXprCleaned = remove_all_t<MidXpr>;
253 using RhsXprCleaned = remove_all_t<RhsXpr>;
254 using FuncCleaned = remove_all_t<Func>;
255 static constexpr Index Cost = nested_functor_cost<FuncCleaned>::Cost + nested_functor_cost<LhsXprCleaned>::Cost +
256 nested_functor_cost<MidXprCleaned>::Cost + nested_functor_cost<RhsXprCleaned>::Cost;
259template <
typename Xpr>
261 static constexpr Index Cost = plain_enum_max(nested_functor_cost<Xpr>::Cost, 1);
268struct unpacket_traits;
270template <
int Size,
typename PacketType,
271 bool Stop = Size == Dynamic || (Size % unpacket_traits<PacketType>::size) == 0 ||
272 std::is_same<PacketType,
typename unpacket_traits<PacketType>::half>::value>
273struct find_best_packet_helper;
275template <
int Size,
typename PacketType>
276struct find_best_packet_helper<Size, PacketType, true> {
277 using type = PacketType;
280template <
int Size,
typename PacketType>
281struct find_best_packet_helper<Size, PacketType, false> {
282 using type =
typename find_best_packet_helper<Size, typename unpacket_traits<PacketType>::half>::type;
285template <
typename T,
int Size>
286struct find_best_packet {
287 using type =
typename find_best_packet_helper<Size, typename packet_traits<T>::type>::type;
292template <
int Size,
typename PacketType,
293 bool Stop = Size == Dynamic || Size >= unpacket_traits<PacketType>::size ||
294 std::is_same<PacketType, typename unpacket_traits<PacketType>::half>::value>
295struct find_largest_packet_helper;
297template <
int Size,
typename PacketType>
298struct find_largest_packet_helper<Size, PacketType, true> {
299 using type = PacketType;
302template <
int Size,
typename PacketType>
303struct find_largest_packet_helper<Size, PacketType, false> {
304 using type =
typename find_largest_packet_helper<Size, typename unpacket_traits<PacketType>::half>::type;
307template <
typename T,
int Size>
308struct find_largest_packet {
309 using type =
typename find_largest_packet_helper<Size, typename packet_traits<T>::type>::type;
327template <
typename T,
int Size>
328struct find_assign_linear_packet {
330 using best_type =
typename find_best_packet<T, Size>::type;
331 using largest_type =
typename find_largest_packet<T, Size>::type;
335 template <
typename P>
336 static constexpr int ops() {
337 constexpr int sz = unpacket_traits<P>::size;
338 return Size == Dynamic ? 0 : Size / sz + Size % sz;
342 using type = std::conditional_t<(ops<largest_type>() < ops<best_type>()), largest_type, best_type>;
345template <
int Size,
typename PacketType,
346 bool Stop = (Size == unpacket_traits<PacketType>::size) ||
347 std::is_same<PacketType,
typename unpacket_traits<PacketType>::half>::value>
348struct find_packet_by_size_helper;
349template <
int Size,
typename PacketType>
350struct find_packet_by_size_helper<Size, PacketType, true> {
351 using type = PacketType;
353template <
int Size,
typename PacketType>
354struct find_packet_by_size_helper<Size, PacketType, false> {
355 using type =
typename find_packet_by_size_helper<Size, typename unpacket_traits<PacketType>::half>::type;
358template <
typename T,
int Size>
359struct find_packet_by_size {
360 using type =
typename find_packet_by_size_helper<Size, typename packet_traits<T>::type>::type;
361 static constexpr bool value = (Size == unpacket_traits<type>::size);
364struct find_packet_by_size<T, 1> {
365 using type =
typename unpacket_traits<T>::type;
366 static constexpr bool value = (unpacket_traits<type>::size == 1);
369#if EIGEN_MAX_STATIC_ALIGN_BYTES > 0
370constexpr int compute_default_alignment_helper(
int ArrayBytes,
int AlignmentBytes) {
371 if ((ArrayBytes % AlignmentBytes) == 0) {
372 return AlignmentBytes;
373 }
else if (EIGEN_MIN_ALIGN_BYTES < AlignmentBytes) {
374 return compute_default_alignment_helper(ArrayBytes, AlignmentBytes / 2);
382constexpr int compute_default_alignment_helper(
int ArrayBytes,
int AlignmentBytes) {
383 EIGEN_UNUSED_VARIABLE(ArrayBytes);
384 EIGEN_UNUSED_VARIABLE(AlignmentBytes);
389template <
typename T,
int Size>
390struct compute_default_alignment
391 : std::integral_constant<int, compute_default_alignment_helper(Size * sizeof(T), EIGEN_MAX_STATIC_ALIGN_BYTES)> {};
394struct compute_default_alignment<T, Dynamic> : std::integral_constant<int, EIGEN_MAX_ALIGN_BYTES> {};
396template <
typename Scalar_,
int Rows_,
int Cols_,
398 : (Cols_ == 1 && Rows_ != 1) ?
ColMajor
399 : EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION),
400 int MaxRows_ = Rows_,
int MaxCols_ = Cols_>
401struct make_proper_matrix_type {
403 static constexpr bool IsColVector = Cols_ == 1 && Rows_ != 1;
404 static constexpr bool IsRowVector = Rows_ == 1 && Cols_ != 1;
405 static constexpr int Options = IsColVector ? (Options_ |
ColMajor) & ~
RowMajor
410 using type = Matrix<Scalar_, Rows_, Cols_, Options, MaxRows_, MaxCols_>;
413constexpr unsigned compute_matrix_flags(
int Options) {
424constexpr int size_at_compile_time(
int rows,
int cols) {
425 if (rows == 0 || cols == 0)
return 0;
426 if (rows == Dynamic || cols == Dynamic)
return Dynamic;
427 if (rows > (std::numeric_limits<int>::max)() / cols)
return Dynamic;
431template <
typename XprType>
432struct size_of_xpr_at_compile_time
433 : std::integral_constant<int, size_at_compile_time(traits<XprType>::RowsAtCompileTime,
434 traits<XprType>::ColsAtCompileTime)> {};
440template <typename T, typename StorageKind = typename traits<T>::StorageKind>
441struct plain_matrix_type;
448struct plain_object_options {
449 static constexpr int value = int(traits<T>::Options);
451template <
typename PlainObjectType,
int Options,
typename Str
ideType>
452struct plain_object_options<Ref<PlainObjectType, Options, StrideType>> : plain_object_options<PlainObjectType> {};
456struct is_ref : std::false_type {};
457template <
typename PlainObjectType,
int Options,
typename Str
ideType>
458struct is_ref<Ref<PlainObjectType, Options, StrideType>> : std::true_type {};
460template <
typename T,
typename BaseClassType,
int Flags>
461struct plain_matrix_type_dense;
463struct plain_matrix_type<T, Dense> {
464 using type =
typename plain_matrix_type_dense<T, typename traits<T>::XprKind, traits<T>::Flags>::type;
467struct plain_matrix_type<T, DiagonalShape> {
468 using type =
typename T::PlainObject;
472struct plain_matrix_type<T, SkewSymmetricShape> {
473 using type =
typename T::PlainObject;
476template <
typename T,
int Flags>
477struct plain_matrix_type_dense<T, MatrixXpr, Flags> {
478 using type = Matrix<typename traits<T>::Scalar, traits<T>::RowsAtCompileTime, traits<T>::ColsAtCompileTime,
480 traits<T>::MaxColsAtCompileTime>;
483template <
typename T,
int Flags>
484struct plain_matrix_type_dense<T, ArrayXpr, Flags> {
485 using type = Array<typename traits<T>::Scalar, traits<T>::RowsAtCompileTime, traits<T>::ColsAtCompileTime,
487 traits<T>::MaxColsAtCompileTime>;
494template <typename T, typename StorageKind = typename traits<T>::StorageKind>
498struct eval<T, Dense> {
499 using type =
typename plain_matrix_type<T>::type;
503struct eval<T, DiagonalShape> {
504 using type =
typename plain_matrix_type<T>::type;
508struct eval<T, SkewSymmetricShape> {
509 using type =
typename plain_matrix_type<T>::type;
513template <
typename Scalar_,
int Rows_,
int Cols_,
int Options_,
int MaxRows_,
int MaxCols_>
514struct eval<Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>, Dense> {
515 using type =
const Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>&;
518template <
typename Scalar_,
int Rows_,
int Cols_,
int Options_,
int MaxRows_,
int MaxCols_>
519struct eval<Array<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>, Dense> {
520 using type =
const Array<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>&;
524template <typename T, typename StorageKind = typename traits<T>::StorageKind>
525struct plain_object_eval;
528struct plain_object_eval<T, Dense> {
529 using type =
typename plain_matrix_type_dense<T, typename traits<T>::XprKind, evaluator<T>::Flags>::type;
535struct plain_matrix_type_column_major {
536 static constexpr int Rows = traits<T>::RowsAtCompileTime;
537 static constexpr int Cols = traits<T>::ColsAtCompileTime;
538 static constexpr int MaxRows = traits<T>::MaxRowsAtCompileTime;
539 static constexpr int MaxCols = traits<T>::MaxColsAtCompileTime;
540 using type = Matrix<typename traits<T>::Scalar, Rows, Cols, (MaxRows == 1 && MaxCols != 1) ?
RowMajor :
ColMajor,
547struct plain_matrix_type_row_major {
548 static constexpr int Rows = traits<T>::RowsAtCompileTime;
549 static constexpr int Cols = traits<T>::ColsAtCompileTime;
550 static constexpr int MaxRows = traits<T>::MaxRowsAtCompileTime;
551 static constexpr int MaxCols = traits<T>::MaxColsAtCompileTime;
552 using type = Matrix<typename traits<T>::Scalar, Rows, Cols, (MaxCols == 1 && MaxRows != 1) ?
ColMajor :
RowMajor,
561 using type = std::conditional_t<bool(traits<T>::Flags& NestByRefBit), T
const&,
const T>;
563 using non_const_type = std::conditional_t<bool(traits<T>::Flags& NestByRefBit), T&, T>;
580template <typename T, int n, typename PlainObject = typename plain_object_eval<T>::type>
583 ScalarReadCost = NumTraits<typename traits<T>::Scalar>::ReadCost,
585 evaluator<T>::CoeffReadCost,
591 NAsInteger = n == Dynamic ? HugeCost : n,
592 CostEval = (NAsInteger + 1) * ScalarReadCost + CoeffReadCost,
593 CostNoEval =
int(NAsInteger) * int(CoeffReadCost),
594 Evaluate = (int(evaluator<T>::Flags) &
EvalBeforeNestingBit) || (
int(CostEval) <
int(CostNoEval))
597 using type = std::conditional_t<Evaluate, PlainObject, typename ref_selector<T>::type>;
600template <typename Derived, typename XprKind = typename traits<Derived>::XprKind>
601struct dense_xpr_base {
606template <
typename Derived>
607struct dense_xpr_base<Derived, MatrixXpr> {
608 using type = MatrixBase<Derived>;
611template <
typename Derived>
612struct dense_xpr_base<Derived, ArrayXpr> {
613 using type = ArrayBase<Derived>;
616template <typename Derived, typename XprKind = typename traits<Derived>::XprKind,
617 typename StorageKind =
typename traits<Derived>::StorageKind>
618struct generic_xpr_base;
620template <
typename Derived,
typename XprKind>
621struct generic_xpr_base<Derived, XprKind, Dense> {
622 using type =
typename dense_xpr_base<Derived, XprKind>::type;
625template <
typename XprType,
typename CastType>
626struct cast_return_type {
627 using CurrentScalarType =
typename XprType::Scalar;
628 using CastType_ = remove_all_t<CastType>;
629 using NewScalarType =
typename CastType_::Scalar;
630 using type = std::conditional_t<std::is_same<CurrentScalarType, NewScalarType>::value,
const XprType&, CastType>;
633template <
typename A,
typename B>
634struct promote_storage_type;
637struct promote_storage_type<A, A> {
641struct promote_storage_type<A, const A> {
645struct promote_storage_type<const A, A> {
662template <
typename A,
typename B,
typename Functor>
663struct cwise_promote_storage_type;
665template <
typename A,
typename Functor>
666struct cwise_promote_storage_type<A, A, Functor> {
669template <
typename Functor>
670struct cwise_promote_storage_type<Dense, Dense, Functor> {
673template <
typename A,
typename Functor>
674struct cwise_promote_storage_type<A, Dense, Functor> {
677template <
typename B,
typename Functor>
678struct cwise_promote_storage_type<Dense, B, Functor> {
681template <
typename Functor>
682struct cwise_promote_storage_type<Sparse, Dense, Functor> {
685template <
typename Functor>
686struct cwise_promote_storage_type<Dense, Sparse, Functor> {
690template <
typename LhsKind,
typename RhsKind,
int LhsOrder,
int RhsOrder>
691struct cwise_promote_storage_order : std::integral_constant<int, LhsOrder> {};
693template <
typename LhsKind,
int LhsOrder,
int RhsOrder>
694struct cwise_promote_storage_order<LhsKind, Sparse, LhsOrder, RhsOrder> : std::integral_constant<int, RhsOrder> {};
695template <
typename RhsKind,
int LhsOrder,
int RhsOrder>
696struct cwise_promote_storage_order<Sparse, RhsKind, LhsOrder, RhsOrder> : std::integral_constant<int, LhsOrder> {};
698struct cwise_promote_storage_order<Sparse, Sparse, Order, Order> : std::integral_constant<int, Order> {};
714template <
typename A,
typename B,
int ProductTag>
715struct product_promote_storage_type;
717template <
typename A,
int ProductTag>
718struct product_promote_storage_type<A, A, ProductTag> {
721template <
int ProductTag>
722struct product_promote_storage_type<Dense, Dense, ProductTag> {
725template <
typename A,
int ProductTag>
726struct product_promote_storage_type<A, Dense, ProductTag> {
729template <
typename B,
int ProductTag>
730struct product_promote_storage_type<Dense, B, ProductTag> {
734template <
typename A,
int ProductTag>
735struct product_promote_storage_type<A, DiagonalShape, ProductTag> {
738template <
typename B,
int ProductTag>
739struct product_promote_storage_type<DiagonalShape, B, ProductTag> {
742template <
int ProductTag>
743struct product_promote_storage_type<Dense, DiagonalShape, ProductTag> {
746template <
int ProductTag>
747struct product_promote_storage_type<DiagonalShape, Dense, ProductTag> {
751template <
typename A,
int ProductTag>
752struct product_promote_storage_type<A, SkewSymmetricShape, ProductTag> {
755template <
typename B,
int ProductTag>
756struct product_promote_storage_type<SkewSymmetricShape, B, ProductTag> {
759template <
int ProductTag>
760struct product_promote_storage_type<Dense, SkewSymmetricShape, ProductTag> {
763template <
int ProductTag>
764struct product_promote_storage_type<SkewSymmetricShape, Dense, ProductTag> {
767template <
int ProductTag>
768struct product_promote_storage_type<SkewSymmetricShape, SkewSymmetricShape, ProductTag> {
773template <
int ProductTag>
774struct product_promote_storage_type<SkewSymmetricShape, DiagonalShape, ProductTag> {
777template <
int ProductTag>
778struct product_promote_storage_type<DiagonalShape, SkewSymmetricShape, ProductTag> {
782template <
typename A,
int ProductTag>
783struct product_promote_storage_type<A, PermutationStorage, ProductTag> {
786template <
typename B,
int ProductTag>
787struct product_promote_storage_type<PermutationStorage, B, ProductTag> {
790template <
int ProductTag>
791struct product_promote_storage_type<Dense, PermutationStorage, ProductTag> {
794template <
int ProductTag>
795struct product_promote_storage_type<PermutationStorage, Dense, ProductTag> {
802template <
typename ExpressionType,
typename Scalar =
typename ExpressionType::Scalar>
803struct plain_row_type {
804 using MatrixRowType =
805 Matrix<Scalar, 1, ExpressionType::ColsAtCompileTime, int(ExpressionType::PlainObject::Options) | int(
RowMajor), 1,
806 ExpressionType::MaxColsAtCompileTime>;
808 Array<Scalar, 1, ExpressionType::ColsAtCompileTime, int(ExpressionType::PlainObject::Options) | int(
RowMajor), 1,
809 ExpressionType::MaxColsAtCompileTime>;
811 using type = std::conditional_t<std::is_same<typename traits<ExpressionType>::XprKind, MatrixXpr>::value,
812 MatrixRowType, ArrayRowType>;
815template <
typename ExpressionType,
typename Scalar =
typename ExpressionType::Scalar>
816struct plain_col_type {
817 using MatrixColType =
818 Matrix<Scalar, ExpressionType::RowsAtCompileTime, 1, ExpressionType::PlainObject::Options & ~RowMajor,
819 ExpressionType::MaxRowsAtCompileTime, 1>;
820 using ArrayColType = Array<Scalar, ExpressionType::RowsAtCompileTime, 1,
821 ExpressionType::PlainObject::Options & ~RowMajor, ExpressionType::MaxRowsAtCompileTime, 1>;
823 using type = std::conditional_t<std::is_same<typename traits<ExpressionType>::XprKind, MatrixXpr>::value,
824 MatrixColType, ArrayColType>;
827template <
typename ExpressionType,
typename Scalar =
typename ExpressionType::Scalar>
828struct plain_diag_type {
829 static constexpr int diag_size =
830 internal::min_size_prefer_dynamic(ExpressionType::RowsAtCompileTime, ExpressionType::ColsAtCompileTime);
831 static constexpr int max_diag_size =
832 min_size_prefer_fixed(ExpressionType::MaxRowsAtCompileTime, ExpressionType::MaxColsAtCompileTime);
833 using MatrixDiagType =
834 Matrix<Scalar, diag_size, 1, ExpressionType::PlainObject::Options & ~RowMajor, max_diag_size, 1>;
835 using ArrayDiagType = Array<Scalar, diag_size, 1, ExpressionType::PlainObject::Options & ~RowMajor, max_diag_size, 1>;
837 using type = std::conditional_t<std::is_same<typename traits<ExpressionType>::XprKind, MatrixXpr>::value,
838 MatrixDiagType, ArrayDiagType>;
841template <
typename Expr,
typename Scalar =
typename Expr::Scalar>
842struct plain_constant_type {
845 using array_type = Array<Scalar, traits<Expr>::RowsAtCompileTime, traits<Expr>::ColsAtCompileTime, Options,
846 traits<Expr>::MaxRowsAtCompileTime, traits<Expr>::MaxColsAtCompileTime>;
848 using matrix_type = Matrix<Scalar, traits<Expr>::RowsAtCompileTime, traits<Expr>::ColsAtCompileTime, Options,
849 traits<Expr>::MaxRowsAtCompileTime, traits<Expr>::MaxColsAtCompileTime>;
851 using type = CwiseNullaryOp<scalar_constant_op<Scalar>,
852 const std::conditional_t<std::is_same<typename traits<Expr>::XprKind, MatrixXpr>::value,
853 matrix_type, array_type>>;
856template <
typename ExpressionType>
857struct is_lvalue : bool_constant<(!bool(std::is_const<ExpressionType>::value)) &&
858 bool((traits<ExpressionType>::Flags & LvalueBit))> {};
861struct is_diagonal : std::false_type {};
864struct is_diagonal<DiagonalBase<T>> : std::true_type {};
867struct is_diagonal<DiagonalWrapper<T>> : std::true_type {};
869template <
typename T,
int S>
870struct is_diagonal<DiagonalMatrix<T, S>> : std::true_type {};
873struct is_identity : std::false_type {};
876struct is_identity<CwiseNullaryOp<internal::scalar_identity_op<typename T::Scalar>, T>> : std::true_type {};
878template <
typename S1,
typename S2>
881struct glue_shapes<DenseShape, TriangularShape> {
882 using type = TriangularShape;
885template <
typename T1,
typename T2>
886struct possibly_same_dense : bool_constant<has_direct_access<T1>::value && has_direct_access<T2>::value &&
887 std::is_same<typename T1::Scalar, typename T2::Scalar>::value> {};
889template <typename T1, typename T2, std::enable_if_t<possibly_same_dense<T1, T2>::value,
int> = 0>
890EIGEN_DEVICE_FUNC
bool is_same_dense(
const T1& mat1,
const T2& mat2) {
891 return (mat1.data() == mat2.data()) && (mat1.innerStride() == mat2.innerStride()) &&
892 (mat1.outerStride() == mat2.outerStride());
895template <typename T1, typename T2, std::enable_if_t<!possibly_same_dense<T1, T2>::value,
int> = 0>
896EIGEN_DEVICE_FUNC
bool is_same_dense(
const T1&,
const T2&) {
902template <
typename T,
bool Vectorized = false,
typename EnableIf =
void>
903struct scalar_div_cost : std::integral_constant<int, 8 * NumTraits<T>::MulCost> {};
905template <
typename T,
bool Vectorized>
906struct scalar_div_cost<T, Vectorized, std::enable_if_t<NumTraits<T>::IsComplex>>
907 : std::integral_constant<int, 2 * scalar_div_cost<typename NumTraits<T>::Real>::value +
908 6 * NumTraits<typename NumTraits<T>::Real>::MulCost +
909 3 * NumTraits<typename NumTraits<T>::Real>::AddCost> {};
911template <
bool Vectorized>
912struct scalar_div_cost<signed long, Vectorized, std::conditional_t<sizeof(long) == 8, void, std::false_type>>
913 : std::integral_constant<int, 24> {};
914template <
bool Vectorized>
915struct scalar_div_cost<unsigned long, Vectorized, std::conditional_t<sizeof(long) == 8, void, std::false_type>>
916 : std::integral_constant<int, 21> {};
918#ifdef EIGEN_DEBUG_ASSIGN
919std::string demangle_traversal(
int t) {
920 if (t == DefaultTraversal)
return "DefaultTraversal";
921 if (t == LinearTraversal)
return "LinearTraversal";
922 if (t == InnerVectorizedTraversal)
return "InnerVectorizedTraversal";
923 if (t == LinearVectorizedTraversal)
return "LinearVectorizedTraversal";
924 if (t == SliceVectorizedTraversal)
return "SliceVectorizedTraversal";
927std::string demangle_unrolling(
int t) {
928 if (t == NoUnrolling)
return "NoUnrolling";
929 if (t == InnerUnrolling)
return "InnerUnrolling";
930 if (t == CompleteUnrolling)
return "CompleteUnrolling";
933std::string demangle_flags(
int f) {
940 if (f & NestByRefBit) res +=
" | NestByRef";
947template <
typename XprType>
948struct is_block_xpr : std::false_type {};
950template <
typename XprType,
int BlockRows,
int BlockCols,
bool InnerPanel>
951struct is_block_xpr<Block<XprType, BlockRows, BlockCols, InnerPanel>> : std::true_type {};
953template <
typename XprType,
int BlockRows,
int BlockCols,
bool InnerPanel>
954struct is_block_xpr<const Block<XprType, BlockRows, BlockCols, InnerPanel>> : std::true_type {};
957template <
typename XprType>
958struct block_xpr_helper {
959 using BaseType = XprType;
963 static constexpr bool is_inner_panel(
bool inner_panel) {
return inner_panel; }
966 template <typename T = XprType, typename EnableIf = std::enable_if_t<!std::is_const<T>::value>>
967 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE BaseType& base(XprType& xpr) {
970 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
const BaseType& base(
const XprType& xpr) {
return xpr; }
971 static constexpr EIGEN_ALWAYS_INLINE Index row(
const XprType& , Index r) {
return r; }
972 static constexpr EIGEN_ALWAYS_INLINE Index col(
const XprType& , Index c) {
return c; }
975template <
typename XprType,
int BlockRows,
int BlockCols,
bool InnerPanel>
976struct block_xpr_helper<Block<XprType, BlockRows, BlockCols, InnerPanel>> {
977 using BlockXprType = Block<XprType, BlockRows, BlockCols, InnerPanel>;
979 using NestedXprHelper = block_xpr_helper<XprType>;
980 using BaseType =
typename NestedXprHelper::BaseType;
984 static constexpr bool is_inner_panel(
bool inner_panel) {
985 return NestedXprHelper::is_inner_panel(InnerPanel && inner_panel);
989 template <typename T = XprType, typename EnableIf = std::enable_if_t<!std::is_const<T>::value>>
990 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE BaseType& base(BlockXprType& xpr) {
991 return NestedXprHelper::base(xpr.nestedExpression());
993 static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
const BaseType& base(
const BlockXprType& xpr) {
994 return NestedXprHelper::base(xpr.nestedExpression());
996 static constexpr EIGEN_ALWAYS_INLINE Index row(
const BlockXprType& xpr, Index r) {
997 return xpr.startRow() + NestedXprHelper::row(xpr.nestedExpression(), r);
999 static constexpr EIGEN_ALWAYS_INLINE Index col(
const BlockXprType& xpr, Index c) {
1000 return xpr.startCol() + NestedXprHelper::col(xpr.nestedExpression(), c);
1004template <
typename XprType,
int BlockRows,
int BlockCols,
bool InnerPanel>
1005struct block_xpr_helper<const Block<XprType, BlockRows, BlockCols, InnerPanel>>
1006 : block_xpr_helper<Block<XprType, BlockRows, BlockCols, InnerPanel>> {};
1008template <
typename XprType>
1009struct is_matrix_base_xpr : std::is_base_of<MatrixBase<remove_all_t<XprType>>, remove_all_t<XprType>> {};
1011template <
typename XprType>
1012struct is_permutation_base_xpr : std::is_base_of<PermutationBase<remove_all_t<XprType>>, remove_all_t<XprType>> {};
1056template <
typename ScalarA,
typename ScalarB,
typename BinaryOp =
internal::scalar_product_op<ScalarA, ScalarB>>
1058#ifndef EIGEN_PARSED_BY_DOXYGEN
1060 : internal::scalar_product_traits<ScalarA, ScalarB>
1065template <
typename T,
typename BinaryOp>
1067 using ReturnType = T;
1070template <
typename T,
typename BinaryOp>
1071struct ScalarBinaryOpTraits<T, typename NumTraits<std::enable_if_t<NumTraits<T>::IsComplex, T>>::Real, BinaryOp> {
1072 using ReturnType = T;
1074template <
typename T,
typename BinaryOp>
1076 using ReturnType = T;
1080template <
typename T,
typename BinaryOp>
1082 using ReturnType = T;
1086template <
typename T,
typename BinaryOp>
1088 using ReturnType = T;
1092template <
typename BinaryOp>
1094 using ReturnType = void;
1101#define EIGEN_CHECK_BINARY_COMPATIBILITY(BINOP, LHS, RHS) \
1102 EIGEN_STATIC_ASSERT( \
1103 (Eigen::internal::has_ReturnType<ScalarBinaryOpTraits<LHS, RHS, BINOP>>::value), \
1104 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
@ ColMajor
Definition Constants.h:319
@ RowMajor
Definition Constants.h:321
@ AutoAlign
Definition Constants.h:323
constexpr unsigned int NoPreferredStorageOrderBit
Definition Constants.h:183
constexpr unsigned int PacketAccessBit
Definition Constants.h:98
constexpr unsigned int DirectAccessBit
Definition Constants.h:160
constexpr unsigned int EvalBeforeNestingBit
Definition Constants.h:75
constexpr unsigned int LinearAccessBit
Definition Constants.h:134
constexpr unsigned int LvalueBit
Definition Constants.h:149
constexpr unsigned int RowMajorBit
Definition Constants.h:71
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition NumTraits.h:233
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition XprHelper.h:1062