Format EIGEN_STATIC_ASSERT() as a statement macro

This commit is contained in:
Tyler Veness 2024-05-20 23:02:42 +00:00 committed by Rasmus Munk Larsen
parent f78dfe36b0
commit d165c7377f
15 changed files with 114 additions and 110 deletions

View File

@ -2,6 +2,8 @@
Language: Cpp Language: Cpp
BasedOnStyle: Google BasedOnStyle: Google
ColumnLimit: 120 ColumnLimit: 120
StatementMacros:
- EIGEN_STATIC_ASSERT
SortIncludes: false SortIncludes: false
AttributeMacros: AttributeMacros:
- EIGEN_STRONG_INLINE - EIGEN_STRONG_INLINE

View File

@ -167,7 +167,7 @@ class plainobjectbase_evaluator_data<Scalar, Dynamic> {
}; };
template <typename Derived> template <typename Derived>
struct evaluator<PlainObjectBase<Derived> > : evaluator_base<Derived> { struct evaluator<PlainObjectBase<Derived>> : evaluator_base<Derived> {
typedef PlainObjectBase<Derived> PlainObjectType; typedef PlainObjectBase<Derived> PlainObjectType;
typedef typename PlainObjectType::Scalar Scalar; typedef typename PlainObjectType::Scalar Scalar;
typedef typename PlainObjectType::CoeffReturnType CoeffReturnType; typedef typename PlainObjectType::CoeffReturnType CoeffReturnType;
@ -247,31 +247,29 @@ struct evaluator<PlainObjectBase<Derived> > : evaluator_base<Derived> {
}; };
template <typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols> template <typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>
struct evaluator<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > struct evaluator<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>
: evaluator<PlainObjectBase<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > > { : evaluator<PlainObjectBase<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>> {
typedef Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> XprType; typedef Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> XprType;
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE evaluator() {} EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE evaluator() {}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& m) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& m) : evaluator<PlainObjectBase<XprType>>(m) {}
: evaluator<PlainObjectBase<XprType> >(m) {}
}; };
template <typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols> template <typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>
struct evaluator<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > struct evaluator<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>
: evaluator<PlainObjectBase<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > > { : evaluator<PlainObjectBase<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>> {
typedef Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> XprType; typedef Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> XprType;
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE evaluator() {} EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE evaluator() {}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& m) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& m) : evaluator<PlainObjectBase<XprType>>(m) {}
: evaluator<PlainObjectBase<XprType> >(m) {}
}; };
// -------------------- Transpose -------------------- // -------------------- Transpose --------------------
template <typename ArgType> template <typename ArgType>
struct unary_evaluator<Transpose<ArgType>, IndexBased> : evaluator_base<Transpose<ArgType> > { struct unary_evaluator<Transpose<ArgType>, IndexBased> : evaluator_base<Transpose<ArgType>> {
typedef Transpose<ArgType> XprType; typedef Transpose<ArgType> XprType;
enum { enum {
@ -460,8 +458,8 @@ struct nullary_wrapper<Scalar,NullaryOp,true,true,true>
#endif // MSVC workaround #endif // MSVC workaround
template <typename NullaryOp, typename PlainObjectType> template <typename NullaryOp, typename PlainObjectType>
struct evaluator<CwiseNullaryOp<NullaryOp, PlainObjectType> > struct evaluator<CwiseNullaryOp<NullaryOp, PlainObjectType>>
: evaluator_base<CwiseNullaryOp<NullaryOp, PlainObjectType> > { : evaluator_base<CwiseNullaryOp<NullaryOp, PlainObjectType>> {
typedef CwiseNullaryOp<NullaryOp, PlainObjectType> XprType; typedef CwiseNullaryOp<NullaryOp, PlainObjectType> XprType;
typedef internal::remove_all_t<PlainObjectType> PlainObjectTypeCleaned; typedef internal::remove_all_t<PlainObjectType> PlainObjectTypeCleaned;
@ -509,7 +507,7 @@ struct evaluator<CwiseNullaryOp<NullaryOp, PlainObjectType> >
// -------------------- CwiseUnaryOp -------------------- // -------------------- CwiseUnaryOp --------------------
template <typename UnaryOp, typename ArgType> template <typename UnaryOp, typename ArgType>
struct unary_evaluator<CwiseUnaryOp<UnaryOp, ArgType>, IndexBased> : evaluator_base<CwiseUnaryOp<UnaryOp, ArgType> > { struct unary_evaluator<CwiseUnaryOp<UnaryOp, ArgType>, IndexBased> : evaluator_base<CwiseUnaryOp<UnaryOp, ArgType>> {
typedef CwiseUnaryOp<UnaryOp, ArgType> XprType; typedef CwiseUnaryOp<UnaryOp, ArgType> XprType;
enum { enum {
@ -762,17 +760,17 @@ struct unary_evaluator<CwiseUnaryOp<core_cast_op<SrcType, DstType>, ArgType>, In
// this is a ternary expression // this is a ternary expression
template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3> template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3>
struct evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> > struct evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>>
: public ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> > { : public ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> {
typedef CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> XprType; typedef CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> XprType;
typedef ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> > Base; typedef ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> Base;
EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : Base(xpr) {} EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : Base(xpr) {}
}; };
template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3> template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3>
struct ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>, IndexBased, IndexBased> struct ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>, IndexBased, IndexBased>
: evaluator_base<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> > { : evaluator_base<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> {
typedef CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> XprType; typedef CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> XprType;
enum { enum {
@ -865,16 +863,16 @@ struct evaluator<CwiseTernaryOp<scalar_boolean_select_op<Scalar, Scalar, bool>,
// this is a binary expression // this is a binary expression
template <typename BinaryOp, typename Lhs, typename Rhs> template <typename BinaryOp, typename Lhs, typename Rhs>
struct evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > : public binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > { struct evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> : public binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> {
typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType; typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;
typedef binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > Base; typedef binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> Base;
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& xpr) : Base(xpr) {} EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& xpr) : Base(xpr) {}
}; };
template <typename BinaryOp, typename Lhs, typename Rhs> template <typename BinaryOp, typename Lhs, typename Rhs>
struct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IndexBased, IndexBased> struct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IndexBased, IndexBased>
: evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > { : evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> {
typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType; typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;
enum { enum {
@ -939,7 +937,7 @@ struct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IndexBased, IndexBase
template <typename UnaryOp, typename ArgType, typename StrideType> template <typename UnaryOp, typename ArgType, typename StrideType>
struct unary_evaluator<CwiseUnaryView<UnaryOp, ArgType, StrideType>, IndexBased> struct unary_evaluator<CwiseUnaryView<UnaryOp, ArgType, StrideType>, IndexBased>
: evaluator_base<CwiseUnaryView<UnaryOp, ArgType, StrideType> > { : evaluator_base<CwiseUnaryView<UnaryOp, ArgType, StrideType>> {
typedef CwiseUnaryView<UnaryOp, ArgType, StrideType> XprType; typedef CwiseUnaryView<UnaryOp, ArgType, StrideType> XprType;
enum { enum {
@ -1067,7 +1065,7 @@ struct mapbase_evaluator : evaluator_base<Derived> {
}; };
template <typename PlainObjectType, int MapOptions, typename StrideType> template <typename PlainObjectType, int MapOptions, typename StrideType>
struct evaluator<Map<PlainObjectType, MapOptions, StrideType> > struct evaluator<Map<PlainObjectType, MapOptions, StrideType>>
: public mapbase_evaluator<Map<PlainObjectType, MapOptions, StrideType>, PlainObjectType> { : public mapbase_evaluator<Map<PlainObjectType, MapOptions, StrideType>, PlainObjectType> {
typedef Map<PlainObjectType, MapOptions, StrideType> XprType; typedef Map<PlainObjectType, MapOptions, StrideType> XprType;
typedef typename XprType::Scalar Scalar; typedef typename XprType::Scalar Scalar;
@ -1100,13 +1098,13 @@ struct evaluator<Map<PlainObjectType, MapOptions, StrideType> >
// -------------------- Ref -------------------- // -------------------- Ref --------------------
template <typename PlainObjectType, int RefOptions, typename StrideType> template <typename PlainObjectType, int RefOptions, typename StrideType>
struct evaluator<Ref<PlainObjectType, RefOptions, StrideType> > struct evaluator<Ref<PlainObjectType, RefOptions, StrideType>>
: public mapbase_evaluator<Ref<PlainObjectType, RefOptions, StrideType>, PlainObjectType> { : public mapbase_evaluator<Ref<PlainObjectType, RefOptions, StrideType>, PlainObjectType> {
typedef Ref<PlainObjectType, RefOptions, StrideType> XprType; typedef Ref<PlainObjectType, RefOptions, StrideType> XprType;
enum { enum {
Flags = evaluator<Map<PlainObjectType, RefOptions, StrideType> >::Flags, Flags = evaluator<Map<PlainObjectType, RefOptions, StrideType>>::Flags,
Alignment = evaluator<Map<PlainObjectType, RefOptions, StrideType> >::Alignment Alignment = evaluator<Map<PlainObjectType, RefOptions, StrideType>>::Alignment
}; };
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& ref) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& ref)
@ -1120,7 +1118,7 @@ template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel,
struct block_evaluator; struct block_evaluator;
template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel> template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
struct evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel> > struct evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>>
: block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel> { : block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel> {
typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType; typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
typedef typename XprType::Scalar Scalar; typedef typename XprType::Scalar Scalar;
@ -1171,7 +1169,7 @@ struct evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel> >
// no direct-access => dispatch to a unary evaluator // no direct-access => dispatch to a unary evaluator
template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel> template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
struct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, /*HasDirectAccess*/ false> struct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, /*HasDirectAccess*/ false>
: unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel> > { : unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>> {
typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType; typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit block_evaluator(const XprType& block) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit block_evaluator(const XprType& block)
@ -1180,7 +1178,7 @@ struct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, /*HasDirectAcc
template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel> template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBased> struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBased>
: evaluator_base<Block<ArgType, BlockRows, BlockCols, InnerPanel> > { : evaluator_base<Block<ArgType, BlockRows, BlockCols, InnerPanel>> {
typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType; typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& block) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& block)
@ -1293,8 +1291,8 @@ struct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, /* HasDirectAc
// TODO enable vectorization for Select // TODO enable vectorization for Select
template <typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType> template <typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>
struct evaluator<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> > struct evaluator<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType>>
: evaluator_base<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> > { : evaluator_base<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType>> {
typedef Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> XprType; typedef Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> XprType;
enum { enum {
CoeffReadCost = evaluator<ConditionMatrixType>::CoeffReadCost + CoeffReadCost = evaluator<ConditionMatrixType>::CoeffReadCost +
@ -1335,8 +1333,8 @@ struct evaluator<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
// -------------------- Replicate -------------------- // -------------------- Replicate --------------------
template <typename ArgType, int RowFactor, int ColFactor> template <typename ArgType, int RowFactor, int ColFactor>
struct unary_evaluator<Replicate<ArgType, RowFactor, ColFactor> > struct unary_evaluator<Replicate<ArgType, RowFactor, ColFactor>>
: evaluator_base<Replicate<ArgType, RowFactor, ColFactor> > { : evaluator_base<Replicate<ArgType, RowFactor, ColFactor>> {
typedef Replicate<ArgType, RowFactor, ColFactor> XprType; typedef Replicate<ArgType, RowFactor, ColFactor> XprType;
typedef typename XprType::CoeffReturnType CoeffReturnType; typedef typename XprType::CoeffReturnType CoeffReturnType;
enum { Factor = (RowFactor == Dynamic || ColFactor == Dynamic) ? Dynamic : RowFactor * ColFactor }; enum { Factor = (RowFactor == Dynamic || ColFactor == Dynamic) ? Dynamic : RowFactor * ColFactor };
@ -1461,19 +1459,19 @@ struct evaluator_wrapper_base : evaluator_base<XprType> {
}; };
template <typename TArgType> template <typename TArgType>
struct unary_evaluator<MatrixWrapper<TArgType> > : evaluator_wrapper_base<MatrixWrapper<TArgType> > { struct unary_evaluator<MatrixWrapper<TArgType>> : evaluator_wrapper_base<MatrixWrapper<TArgType>> {
typedef MatrixWrapper<TArgType> XprType; typedef MatrixWrapper<TArgType> XprType;
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& wrapper) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& wrapper)
: evaluator_wrapper_base<MatrixWrapper<TArgType> >(wrapper.nestedExpression()) {} : evaluator_wrapper_base<MatrixWrapper<TArgType>>(wrapper.nestedExpression()) {}
}; };
template <typename TArgType> template <typename TArgType>
struct unary_evaluator<ArrayWrapper<TArgType> > : evaluator_wrapper_base<ArrayWrapper<TArgType> > { struct unary_evaluator<ArrayWrapper<TArgType>> : evaluator_wrapper_base<ArrayWrapper<TArgType>> {
typedef ArrayWrapper<TArgType> XprType; typedef ArrayWrapper<TArgType> XprType;
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& wrapper) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& wrapper)
: evaluator_wrapper_base<ArrayWrapper<TArgType> >(wrapper.nestedExpression()) {} : evaluator_wrapper_base<ArrayWrapper<TArgType>>(wrapper.nestedExpression()) {}
}; };
// -------------------- Reverse -------------------- // -------------------- Reverse --------------------
@ -1483,7 +1481,7 @@ template <typename PacketType, bool ReversePacket>
struct reverse_packet_cond; struct reverse_packet_cond;
template <typename ArgType, int Direction> template <typename ArgType, int Direction>
struct unary_evaluator<Reverse<ArgType, Direction> > : evaluator_base<Reverse<ArgType, Direction> > { struct unary_evaluator<Reverse<ArgType, Direction>> : evaluator_base<Reverse<ArgType, Direction>> {
typedef Reverse<ArgType, Direction> XprType; typedef Reverse<ArgType, Direction> XprType;
typedef typename XprType::Scalar Scalar; typedef typename XprType::Scalar Scalar;
typedef typename XprType::CoeffReturnType CoeffReturnType; typedef typename XprType::CoeffReturnType CoeffReturnType;
@ -1584,7 +1582,7 @@ struct unary_evaluator<Reverse<ArgType, Direction> > : evaluator_base<Reverse<Ar
// -------------------- Diagonal -------------------- // -------------------- Diagonal --------------------
template <typename ArgType, int DiagIndex> template <typename ArgType, int DiagIndex>
struct evaluator<Diagonal<ArgType, DiagIndex> > : evaluator_base<Diagonal<ArgType, DiagIndex> > { struct evaluator<Diagonal<ArgType, DiagIndex>> : evaluator_base<Diagonal<ArgType, DiagIndex>> {
typedef Diagonal<ArgType, DiagIndex> XprType; typedef Diagonal<ArgType, DiagIndex> XprType;
enum { enum {
@ -1643,10 +1641,10 @@ template <typename ArgType>
class EvalToTemp; class EvalToTemp;
template <typename ArgType> template <typename ArgType>
struct traits<EvalToTemp<ArgType> > : public traits<ArgType> {}; struct traits<EvalToTemp<ArgType>> : public traits<ArgType> {};
template <typename ArgType> template <typename ArgType>
class EvalToTemp : public dense_xpr_base<EvalToTemp<ArgType> >::type { class EvalToTemp : public dense_xpr_base<EvalToTemp<ArgType>>::type {
public: public:
typedef typename dense_xpr_base<EvalToTemp>::type Base; typedef typename dense_xpr_base<EvalToTemp>::type Base;
EIGEN_GENERIC_PUBLIC_INTERFACE(EvalToTemp) EIGEN_GENERIC_PUBLIC_INTERFACE(EvalToTemp)
@ -1664,7 +1662,7 @@ class EvalToTemp : public dense_xpr_base<EvalToTemp<ArgType> >::type {
}; };
template <typename ArgType> template <typename ArgType>
struct evaluator<EvalToTemp<ArgType> > : public evaluator<typename ArgType::PlainObject> { struct evaluator<EvalToTemp<ArgType>> : public evaluator<typename ArgType::PlainObject> {
typedef EvalToTemp<ArgType> XprType; typedef EvalToTemp<ArgType> XprType;
typedef typename ArgType::PlainObject PlainObject; typedef typename ArgType::PlainObject PlainObject;
typedef evaluator<PlainObject> Base; typedef evaluator<PlainObject> Base;

View File

@ -243,17 +243,15 @@ struct gemv_static_vector_if<Scalar, Size, Dynamic, true> {
template <typename Scalar, int Size, int MaxSize> template <typename Scalar, int Size, int MaxSize>
struct gemv_static_vector_if<Scalar, Size, MaxSize, true> { struct gemv_static_vector_if<Scalar, Size, MaxSize, true> {
#if EIGEN_MAX_STATIC_ALIGN_BYTES != 0 #if EIGEN_MAX_STATIC_ALIGN_BYTES != 0
internal::plain_array<Scalar, internal::min_size_prefer_fixed(Size, MaxSize), 0, AlignedMax> internal::plain_array<Scalar, internal::min_size_prefer_fixed(Size, MaxSize), 0, AlignedMax> m_data;
m_data;
EIGEN_STRONG_INLINE Scalar* data() { return m_data.array; } EIGEN_STRONG_INLINE Scalar* data() { return m_data.array; }
#else #else
// Some architectures cannot align on the stack, // Some architectures cannot align on the stack,
// => let's manually enforce alignment by allocating more data and return the address of the first aligned element. // => let's manually enforce alignment by allocating more data and return the address of the first aligned element.
internal::plain_array< internal::plain_array<Scalar, internal::min_size_prefer_fixed(Size, MaxSize) + EIGEN_MAX_ALIGN_BYTES, 0> m_data;
Scalar, internal::min_size_prefer_fixed(Size, MaxSize) + EIGEN_MAX_ALIGN_BYTES, 0>
m_data;
EIGEN_STRONG_INLINE Scalar* data() { EIGEN_STRONG_INLINE Scalar* data() {
return reinterpret_cast<Scalar*>((std::uintptr_t(m_data.array) & ~(std::size_t(EIGEN_MAX_ALIGN_BYTES - 1))) + EIGEN_MAX_ALIGN_BYTES); return reinterpret_cast<Scalar*>((std::uintptr_t(m_data.array) & ~(std::size_t(EIGEN_MAX_ALIGN_BYTES - 1))) +
EIGEN_MAX_ALIGN_BYTES);
} }
#endif #endif
}; };

View File

@ -80,15 +80,12 @@ class Replicate : public internal::dense_xpr_base<Replicate<MatrixType, RowFacto
template <typename OriginalMatrixType> template <typename OriginalMatrixType>
EIGEN_DEVICE_FUNC inline Replicate(const OriginalMatrixType& matrix, Index rowFactor, Index colFactor) EIGEN_DEVICE_FUNC inline Replicate(const OriginalMatrixType& matrix, Index rowFactor, Index colFactor)
: m_matrix(matrix), : m_matrix(matrix), m_rowFactor(rowFactor), m_colFactor(colFactor) {
m_rowFactor(rowFactor), EIGEN_STATIC_ASSERT((internal::is_same<std::remove_const_t<MatrixType>, OriginalMatrixType>::value),
m_colFactor(colFactor){ THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)
EIGEN_STATIC_ASSERT((internal::is_same<std::remove_const_t<MatrixType>, OriginalMatrixType>::value),
THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)}
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index rows() const {
return m_matrix.rows() * m_rowFactor.value();
} }
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index rows() const { return m_matrix.rows() * m_rowFactor.value(); }
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index cols() const { return m_matrix.cols() * m_colFactor.value(); } EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index cols() const { return m_matrix.cols() * m_colFactor.value(); }
EIGEN_DEVICE_FUNC const MatrixTypeNested_& nestedExpression() const { return m_matrix; } EIGEN_DEVICE_FUNC const MatrixTypeNested_& nestedExpression() const { return m_matrix; }

View File

@ -57,7 +57,7 @@ EIGEN_STRONG_INLINE void trsmKernelL<Scalar, Index, Mode, Conjugate, TriStorageO
Index rs = size - k - 1; // remaining size Index rs = size - k - 1; // remaining size
Index s = TriStorageOrder == RowMajor ? (IsLower ? 0 : i + 1) : IsLower ? i + 1 : i - rs; Index s = TriStorageOrder == RowMajor ? (IsLower ? 0 : i + 1) : IsLower ? i + 1 : i - rs;
Scalar a = (Mode & UnitDiag) ? Scalar(1) : Scalar(Scalar(1)/conj(tri(i,i))); Scalar a = (Mode & UnitDiag) ? Scalar(1) : Scalar(Scalar(1) / conj(tri(i, i)));
for (Index j = 0; j < otherSize; ++j) { for (Index j = 0; j < otherSize; ++j) {
if (TriStorageOrder == RowMajor) { if (TriStorageOrder == RowMajor) {
Scalar b(0); Scalar b(0);

View File

@ -96,17 +96,17 @@ class BaseExpr {
return AddExpr<Derived, ValueExpr<>>(derived(), -a); return AddExpr<Derived, ValueExpr<>>(derived(), -a);
} }
constexpr ProductExpr<Derived, ValueExpr<>> operator*(Index a) const { constexpr ProductExpr<Derived, ValueExpr<>> operator*(Index a) const {
return ProductExpr<Derived, ValueExpr<> >(derived(), a); return ProductExpr<Derived, ValueExpr<>>(derived(), a);
} }
constexpr QuotientExpr<Derived, ValueExpr<>> operator/(Index a) const { constexpr QuotientExpr<Derived, ValueExpr<>> operator/(Index a) const {
return QuotientExpr<Derived, ValueExpr<> >(derived(), a); return QuotientExpr<Derived, ValueExpr<>>(derived(), a);
} }
friend constexpr AddExpr<Derived, ValueExpr<>> operator+(Index a, const BaseExpr& b) { friend constexpr AddExpr<Derived, ValueExpr<>> operator+(Index a, const BaseExpr& b) {
return AddExpr<Derived, ValueExpr<> >(b.derived(), a); return AddExpr<Derived, ValueExpr<>>(b.derived(), a);
} }
friend constexpr AddExpr<NegateExpr<Derived>, ValueExpr<>> operator-(Index a, const BaseExpr& b) { friend constexpr AddExpr<NegateExpr<Derived>, ValueExpr<>> operator-(Index a, const BaseExpr& b) {
return AddExpr<NegateExpr<Derived>, ValueExpr<> >(-b.derived(), a); return AddExpr<NegateExpr<Derived>, ValueExpr<>>(-b.derived(), a);
} }
friend constexpr ProductExpr<ValueExpr<>, Derived> operator*(Index a, const BaseExpr& b) { friend constexpr ProductExpr<ValueExpr<>, Derived> operator*(Index a, const BaseExpr& b) {
return ProductExpr<ValueExpr<>, Derived>(a, b.derived()); return ProductExpr<ValueExpr<>, Derived>(a, b.derived());
@ -117,41 +117,41 @@ class BaseExpr {
template <int N> template <int N>
constexpr AddExpr<Derived, ValueExpr<internal::FixedInt<N>>> operator+(internal::FixedInt<N>) const { constexpr AddExpr<Derived, ValueExpr<internal::FixedInt<N>>> operator+(internal::FixedInt<N>) const {
return AddExpr<Derived, ValueExpr<internal::FixedInt<N> > >(derived(), ValueExpr<internal::FixedInt<N> >()); return AddExpr<Derived, ValueExpr<internal::FixedInt<N>>>(derived(), ValueExpr<internal::FixedInt<N>>());
} }
template <int N> template <int N>
constexpr AddExpr<Derived, ValueExpr<internal::FixedInt<-N>>> operator-(internal::FixedInt<N>) const { constexpr AddExpr<Derived, ValueExpr<internal::FixedInt<-N>>> operator-(internal::FixedInt<N>) const {
return AddExpr<Derived, ValueExpr<internal::FixedInt<-N> > >(derived(), ValueExpr<internal::FixedInt<-N> >()); return AddExpr<Derived, ValueExpr<internal::FixedInt<-N>>>(derived(), ValueExpr<internal::FixedInt<-N>>());
} }
template <int N> template <int N>
constexpr ProductExpr<Derived, ValueExpr<internal::FixedInt<N>>> operator*(internal::FixedInt<N>) const { constexpr ProductExpr<Derived, ValueExpr<internal::FixedInt<N>>> operator*(internal::FixedInt<N>) const {
return ProductExpr<Derived, ValueExpr<internal::FixedInt<N> > >(derived(), ValueExpr<internal::FixedInt<N> >()); return ProductExpr<Derived, ValueExpr<internal::FixedInt<N>>>(derived(), ValueExpr<internal::FixedInt<N>>());
} }
template <int N> template <int N>
constexpr QuotientExpr<Derived, ValueExpr<internal::FixedInt<N>>> operator/(internal::FixedInt<N>) const { constexpr QuotientExpr<Derived, ValueExpr<internal::FixedInt<N>>> operator/(internal::FixedInt<N>) const {
return QuotientExpr<Derived, ValueExpr<internal::FixedInt<N> > >(derived(), ValueExpr<internal::FixedInt<N> >()); return QuotientExpr<Derived, ValueExpr<internal::FixedInt<N>>>(derived(), ValueExpr<internal::FixedInt<N>>());
} }
template <int N> template <int N>
friend constexpr AddExpr<Derived, ValueExpr<internal::FixedInt<N>>> operator+(internal::FixedInt<N>, friend constexpr AddExpr<Derived, ValueExpr<internal::FixedInt<N>>> operator+(internal::FixedInt<N>,
const BaseExpr& b) { const BaseExpr& b) {
return AddExpr<Derived, ValueExpr<internal::FixedInt<N> > >(b.derived(), ValueExpr<internal::FixedInt<N> >()); return AddExpr<Derived, ValueExpr<internal::FixedInt<N>>>(b.derived(), ValueExpr<internal::FixedInt<N>>());
} }
template <int N> template <int N>
friend constexpr AddExpr<NegateExpr<Derived>, ValueExpr<internal::FixedInt<N>>> operator-(internal::FixedInt<N>, friend constexpr AddExpr<NegateExpr<Derived>, ValueExpr<internal::FixedInt<N>>> operator-(internal::FixedInt<N>,
const BaseExpr& b) { const BaseExpr& b) {
return AddExpr<NegateExpr<Derived>, ValueExpr<internal::FixedInt<N> > >(-b.derived(), return AddExpr<NegateExpr<Derived>, ValueExpr<internal::FixedInt<N>>>(-b.derived(),
ValueExpr<internal::FixedInt<N> >()); ValueExpr<internal::FixedInt<N>>());
} }
template <int N> template <int N>
friend constexpr ProductExpr<ValueExpr<internal::FixedInt<N>>, Derived> operator*(internal::FixedInt<N>, friend constexpr ProductExpr<ValueExpr<internal::FixedInt<N>>, Derived> operator*(internal::FixedInt<N>,
const BaseExpr& b) { const BaseExpr& b) {
return ProductExpr<ValueExpr<internal::FixedInt<N> >, Derived>(ValueExpr<internal::FixedInt<N> >(), b.derived()); return ProductExpr<ValueExpr<internal::FixedInt<N>>, Derived>(ValueExpr<internal::FixedInt<N>>(), b.derived());
} }
template <int N> template <int N>
friend constexpr QuotientExpr<ValueExpr<internal::FixedInt<N>>, Derived> operator/(internal::FixedInt<N>, friend constexpr QuotientExpr<ValueExpr<internal::FixedInt<N>>, Derived> operator/(internal::FixedInt<N>,
const BaseExpr& b) { const BaseExpr& b) {
return QuotientExpr<ValueExpr<internal::FixedInt<N> >, Derived>(ValueExpr<internal::FixedInt<N> >(), b.derived()); return QuotientExpr<ValueExpr<internal::FixedInt<N>>, Derived>(ValueExpr<internal::FixedInt<N>>(), b.derived());
} }
template <typename OtherDerived> template <typename OtherDerived>
@ -161,7 +161,7 @@ class BaseExpr {
template <typename OtherDerived> template <typename OtherDerived>
constexpr AddExpr<Derived, NegateExpr<OtherDerived>> operator-(const BaseExpr<OtherDerived>& b) const { constexpr AddExpr<Derived, NegateExpr<OtherDerived>> operator-(const BaseExpr<OtherDerived>& b) const {
return AddExpr<Derived, NegateExpr<OtherDerived> >(derived(), -b.derived()); return AddExpr<Derived, NegateExpr<OtherDerived>>(derived(), -b.derived());
} }
template <typename OtherDerived> template <typename OtherDerived>
@ -179,7 +179,7 @@ template <typename T>
struct is_symbolic { struct is_symbolic {
// BaseExpr has no conversion ctor, so we only have to check whether T can be statically cast to its base class // BaseExpr has no conversion ctor, so we only have to check whether T can be statically cast to its base class
// BaseExpr<T>. // BaseExpr<T>.
enum { value = internal::is_convertible<T, BaseExpr<T> >::value }; enum { value = internal::is_convertible<T, BaseExpr<T>>::value };
}; };
// A simple wrapper around an integral value to provide the eval method. // A simple wrapper around an integral value to provide the eval method.
@ -317,7 +317,7 @@ struct EvalSymbolValueHelper<Tag, T1, OtherTypes...> {
/** Expression of a symbol uniquely identified by the template parameter type \c tag */ /** Expression of a symbol uniquely identified by the template parameter type \c tag */
template <typename tag> template <typename tag>
class SymbolExpr : public BaseExpr<SymbolExpr<tag> > { class SymbolExpr : public BaseExpr<SymbolExpr<tag>> {
public: public:
/** Alias to the template parameter \c tag */ /** Alias to the template parameter \c tag */
typedef tag Tag; typedef tag Tag;
@ -349,7 +349,7 @@ class SymbolExpr : public BaseExpr<SymbolExpr<tag> > {
}; };
template <typename Arg0> template <typename Arg0>
class NegateExpr : public BaseExpr<NegateExpr<Arg0> > { class NegateExpr : public BaseExpr<NegateExpr<Arg0>> {
public: public:
constexpr NegateExpr() = default; constexpr NegateExpr() = default;
constexpr NegateExpr(const Arg0& arg0) : m_arg0(arg0) {} constexpr NegateExpr(const Arg0& arg0) : m_arg0(arg0) {}
@ -370,7 +370,7 @@ class NegateExpr : public BaseExpr<NegateExpr<Arg0> > {
}; };
template <typename Arg0, typename Arg1> template <typename Arg0, typename Arg1>
class AddExpr : public BaseExpr<AddExpr<Arg0, Arg1> > { class AddExpr : public BaseExpr<AddExpr<Arg0, Arg1>> {
public: public:
constexpr AddExpr() = default; constexpr AddExpr() = default;
constexpr AddExpr(const Arg0& arg0, const Arg1& arg1) : m_arg0(arg0), m_arg1(arg1) {} constexpr AddExpr(const Arg0& arg0, const Arg1& arg1) : m_arg0(arg0), m_arg1(arg1) {}
@ -393,7 +393,7 @@ class AddExpr : public BaseExpr<AddExpr<Arg0, Arg1> > {
}; };
template <typename Arg0, typename Arg1> template <typename Arg0, typename Arg1>
class ProductExpr : public BaseExpr<ProductExpr<Arg0, Arg1> > { class ProductExpr : public BaseExpr<ProductExpr<Arg0, Arg1>> {
public: public:
constexpr ProductExpr() = default; constexpr ProductExpr() = default;
constexpr ProductExpr(const Arg0& arg0, const Arg1& arg1) : m_arg0(arg0), m_arg1(arg1) {} constexpr ProductExpr(const Arg0& arg0, const Arg1& arg1) : m_arg0(arg0), m_arg1(arg1) {}
@ -416,7 +416,7 @@ class ProductExpr : public BaseExpr<ProductExpr<Arg0, Arg1> > {
}; };
template <typename Arg0, typename Arg1> template <typename Arg0, typename Arg1>
class QuotientExpr : public BaseExpr<QuotientExpr<Arg0, Arg1> > { class QuotientExpr : public BaseExpr<QuotientExpr<Arg0, Arg1>> {
public: public:
constexpr QuotientExpr() = default; constexpr QuotientExpr() = default;
constexpr QuotientExpr(const Arg0& arg0, const Arg1& arg1) : m_arg0(arg0), m_arg1(arg1) {} constexpr QuotientExpr(const Arg0& arg0, const Arg1& arg1) : m_arg0(arg0), m_arg1(arg1) {}

View File

@ -1424,8 +1424,7 @@ void BDCSVD<MatrixType, Options>::deflation(Index firstCol, Index lastCol, Index
if ((diag(i) - diag(i - 1)) < epsilon_strict) { if ((diag(i) - diag(i - 1)) < epsilon_strict) {
#ifdef EIGEN_BDCSVD_DEBUG_VERBOSE #ifdef EIGEN_BDCSVD_DEBUG_VERBOSE
std::cout << "deflation 4.4 with i = " << i << " because " << diag(i) << " - " << diag(i - 1) std::cout << "deflation 4.4 with i = " << i << " because " << diag(i) << " - " << diag(i - 1)
<< " == " << (diag(i) - diag(i - 1)) << " < " << " == " << (diag(i) - diag(i - 1)) << " < " << epsilon_strict << "\n";
<< epsilon_strict << "\n";
#endif #endif
eigen_internal_assert(abs(diag(i) - diag(i - 1)) < epsilon_coarse && eigen_internal_assert(abs(diag(i) - diag(i - 1)) < epsilon_coarse &&
" diagonal entries are not properly sorted"); " diagonal entries are not properly sorted");

11
scripts/format.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
# Format files with extensions, excluding plugins because they're partial files that don't contain valid syntax
find . -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.cu' -o -name '*.cxx' -o -name '*.h' -o -name '*.inc' -not -path '*/plugins/*' \) | xargs -n 1 -P 0 clang-format-17 -i
# Format main headers without extensions
find Eigen -maxdepth 1 -type f | xargs -n 1 -P 0 clang-format-17 -i
find unsupported/Eigen -maxdepth 2 -type f -not -name '*.txt' | xargs -n 1 -P 0 clang-format-17 -i
# Format examples
find doc/examples -type f -name '*.cpp.*' | xargs -n 1 -P 0 clang-format-17 -i

View File

@ -960,9 +960,9 @@ void array_complex(const ArrayType& m) {
// Check for larger magnitude complex numbers that expm1 matches exp - 1. // Check for larger magnitude complex numbers that expm1 matches exp - 1.
VERIFY_IS_APPROX(expm1(10. * m1), exp(10. * m1) - 1.); VERIFY_IS_APPROX(expm1(10. * m1), exp(10. * m1) - 1.);
VERIFY_IS_APPROX(sinh(m1), 0.5*(exp(m1)-exp(-m1))); VERIFY_IS_APPROX(sinh(m1), 0.5 * (exp(m1) - exp(-m1)));
VERIFY_IS_APPROX(cosh(m1), 0.5*(exp(m1)+exp(-m1))); VERIFY_IS_APPROX(cosh(m1), 0.5 * (exp(m1) + exp(-m1)));
VERIFY_IS_APPROX(tanh(m1), (0.5*(exp(m1)-exp(-m1)))/(0.5*(exp(m1)+exp(-m1)))); VERIFY_IS_APPROX(tanh(m1), (0.5 * (exp(m1) - exp(-m1))) / (0.5 * (exp(m1) + exp(-m1))));
VERIFY_IS_APPROX(logistic(m1), (1.0 / (1.0 + exp(-m1)))); VERIFY_IS_APPROX(logistic(m1), (1.0 / (1.0 + exp(-m1))));
if (m1.size() > 0) { if (m1.size() > 0) {
// Complex exponential overflow edge-case. // Complex exponential overflow edge-case.

View File

@ -140,7 +140,8 @@ void comparisons(const MatrixType& m) {
// and/or // and/or
VERIFY(((m1.array() < RealScalar(0)).matrix() && (m1.array() > RealScalar(0)).matrix()).count() == 0); VERIFY(((m1.array() < RealScalar(0)).matrix() && (m1.array() > RealScalar(0)).matrix()).count() == 0);
VERIFY(((m1.array() < RealScalar(0)).matrix() || (m1.array() >= RealScalar(0)).matrix()).count() == rows * cols); VERIFY(((m1.array() < RealScalar(0)).matrix() || (m1.array() >= RealScalar(0)).matrix()).count() == rows * cols);
VERIFY(((m1.array() < -mid).matrix() || (m1.array() > mid).matrix()).count() == (m1.cwiseAbs().array() > mid).count()); VERIFY(((m1.array() < -mid).matrix() || (m1.array() > mid).matrix()).count() ==
(m1.cwiseAbs().array() > mid).count());
typedef Matrix<Index, Dynamic, 1> VectorOfIndices; typedef Matrix<Index, Dynamic, 1> VectorOfIndices;

View File

@ -239,18 +239,16 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(const Self& other) : Base(other), m_storage(other.m_storage) {} EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(const Self& other) : Base(other), m_storage(other.m_storage) {}
template<typename... IndexTypes> template <typename... IndexTypes>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(Index firstDimension, IndexTypes... otherDimensions) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(Index firstDimension, IndexTypes... otherDimensions)
: m_storage(firstDimension, otherDimensions...) : m_storage(firstDimension, otherDimensions...) {
{ // The number of dimensions used to construct a tensor must be equal to the rank of the tensor.
// The number of dimensions used to construct a tensor must be equal to the rank of the tensor. EIGEN_STATIC_ASSERT(sizeof...(otherDimensions) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
EIGEN_STATIC_ASSERT(sizeof...(otherDimensions) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE) }
}
/** Normal Dimension */ /** Normal Dimension */
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit Tensor(const array<Index, NumIndices>& dimensions) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit Tensor(const array<Index, NumIndices>& dimensions)
: m_storage(internal::array_prod(dimensions), dimensions) : m_storage(internal::array_prod(dimensions), dimensions) {
{
EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
} }

View File

@ -215,14 +215,13 @@ struct DSizes : array<DenseIndex, NumDims> {
} }
template <typename... IndexTypes> template <typename... IndexTypes>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit DSizes(DenseIndex firstDimension, DenseIndex secondDimension, EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit DSizes(DenseIndex firstDimension, DenseIndex secondDimension,
IndexTypes... otherDimensions) IndexTypes... otherDimensions)
: Base({{firstDimension, secondDimension, otherDimensions...}}){EIGEN_STATIC_ASSERT( : Base({{firstDimension, secondDimension, otherDimensions...}}) {
sizeof...(otherDimensions) + 2 == NumDims, YOU_MADE_A_PROGRAMMING_MISTAKE)} EIGEN_STATIC_ASSERT(sizeof...(otherDimensions) + 2 == NumDims, YOU_MADE_A_PROGRAMMING_MISTAKE)
}
EIGEN_DEVICE_FUNC DSizes EIGEN_DEVICE_FUNC DSizes& operator=(const array<DenseIndex, NumDims>& other) {
&
operator=(const array<DenseIndex, NumDims>& other) {
*static_cast<Base*>(this) = other; *static_cast<Base*>(this) = other;
return *this; return *this;
} }

View File

@ -367,7 +367,8 @@ struct TensorPrinter<Tensor, rank, TensorIOFormatLegacy, std::enable_if_t<rank !
const IndexType total_size = internal::array_prod(tensor.dimensions()); const IndexType total_size = internal::array_prod(tensor.dimensions());
if (total_size > 0) { if (total_size > 0) {
const IndexType first_dim = Eigen::internal::array_get<0>(tensor.dimensions()); const IndexType first_dim = Eigen::internal::array_get<0>(tensor.dimensions());
Map<const Array<Scalar, Dynamic, Dynamic, Tensor::Layout>> matrix(tensor.data(), first_dim, total_size / first_dim); Map<const Array<Scalar, Dynamic, Dynamic, Tensor::Layout>> matrix(tensor.data(), first_dim,
total_size / first_dim);
s << matrix; s << matrix;
return; return;
} }

View File

@ -79,14 +79,14 @@ class TensorMap : public TensorBase<TensorMap<PlainObjectType, Options_, MakePoi
template <typename... IndexTypes> template <typename... IndexTypes>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorMap(StoragePointerType dataPtr, Index firstDimension, EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorMap(StoragePointerType dataPtr, Index firstDimension,
IndexTypes... otherDimensions) IndexTypes... otherDimensions)
: m_data(dataPtr), : m_data(dataPtr), m_dimensions(firstDimension, otherDimensions...) {
m_dimensions(firstDimension, otherDimensions...){ // The number of dimensions used to construct a tensor must be equal to the rank of the tensor.
// The number of dimensions used to construct a tensor must be equal to the rank of the tensor. EIGEN_STATIC_ASSERT((sizeof...(otherDimensions) + 1 == NumIndices || NumIndices == Dynamic),
EIGEN_STATIC_ASSERT((sizeof...(otherDimensions) + 1 == NumIndices || NumIndices == Dynamic), YOU_MADE_A_PROGRAMMING_MISTAKE)
YOU_MADE_A_PROGRAMMING_MISTAKE)} }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorMap(StoragePointerType dataPtr, EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorMap(StoragePointerType dataPtr,
const array<Index, NumIndices>& dimensions) const array<Index, NumIndices>& dimensions)
: m_data(dataPtr), m_dimensions(dimensions) {} : m_data(dataPtr), m_dimensions(dimensions) {}
template <typename Dimensions> template <typename Dimensions>