From 732ebc8cc258f2a7fb7fb6aed0ac91766576c629 Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen <4643818-rmlarsen1@users.noreply.gitlab.com> Date: Sun, 29 Mar 2026 17:40:39 -0700 Subject: [PATCH] Modernize evaluator files libeigen/eigen!2245 Co-authored-by: Rasmus Munk Larsen --- Eigen/src/Core/AssignEvaluator.h | 48 ++--- Eigen/src/Core/CoreEvaluators.h | 189 +++++++++--------- Eigen/src/Core/IndexedView.h | 4 +- Eigen/src/Core/PartialReduxEvaluator.h | 42 ++-- Eigen/src/Core/ProductEvaluators.h | 266 ++++++++++++------------- 5 files changed, 263 insertions(+), 286 deletions(-) diff --git a/Eigen/src/Core/AssignEvaluator.h b/Eigen/src/Core/AssignEvaluator.h index 66efe8f51..53732227a 100644 --- a/Eigen/src/Core/AssignEvaluator.h +++ b/Eigen/src/Core/AssignEvaluator.h @@ -654,15 +654,15 @@ struct dense_assignment_loop_impl class generic_dense_assignment_kernel { protected: - typedef typename DstEvaluatorTypeT::XprType DstXprType; - typedef typename SrcEvaluatorTypeT::XprType SrcXprType; + using DstXprType = typename DstEvaluatorTypeT::XprType; + using SrcXprType = typename SrcEvaluatorTypeT::XprType; public: - typedef DstEvaluatorTypeT DstEvaluatorType; - typedef SrcEvaluatorTypeT SrcEvaluatorType; - typedef typename DstEvaluatorType::Scalar Scalar; - typedef copy_using_evaluator_traits AssignmentTraits; - typedef typename AssignmentTraits::PacketType PacketType; + using DstEvaluatorType = DstEvaluatorTypeT; + using SrcEvaluatorType = SrcEvaluatorTypeT; + using Scalar = typename DstEvaluatorType::Scalar; + using AssignmentTraits = copy_using_evaluator_traits; + using PacketType = typename AssignmentTraits::PacketType; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr generic_dense_assignment_kernel(DstEvaluatorType& dst, const SrcEvaluatorType& src, @@ -741,7 +741,7 @@ class generic_dense_assignment_kernel { } EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE constexpr Index rowIndexByOuterInner(Index outer, Index inner) { - typedef typename DstEvaluatorType::ExpressionTraits Traits; + using Traits = typename DstEvaluatorType::ExpressionTraits; return int(Traits::RowsAtCompileTime) == 1 ? 0 : int(Traits::ColsAtCompileTime) == 1 ? inner : int(DstEvaluatorType::Flags) & RowMajorBit ? outer @@ -749,7 +749,7 @@ class generic_dense_assignment_kernel { } EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE constexpr Index colIndexByOuterInner(Index outer, Index inner) { - typedef typename DstEvaluatorType::ExpressionTraits Traits; + using Traits = typename DstEvaluatorType::ExpressionTraits; return int(Traits::ColsAtCompileTime) == 1 ? 0 : int(Traits::RowsAtCompileTime) == 1 ? inner : int(DstEvaluatorType::Flags) & RowMajorBit ? inner @@ -774,13 +774,13 @@ template { protected: - typedef generic_dense_assignment_kernel Base; + using Base = generic_dense_assignment_kernel; public: - typedef typename Base::Scalar Scalar; - typedef typename Base::DstXprType DstXprType; - typedef copy_using_evaluator_traits AssignmentTraits; - typedef typename AssignmentTraits::PacketType PacketType; + using Scalar = typename Base::Scalar; + using DstXprType = typename Base::DstXprType; + using AssignmentTraits = copy_using_evaluator_traits; + using PacketType = typename AssignmentTraits::PacketType; EIGEN_DEVICE_FUNC restricted_packet_dense_assignment_kernel(DstEvaluatorTypeT& dst, const SrcEvaluatorTypeT& src, const Functor& func, DstXprType& dstExpr) @@ -823,8 +823,8 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void resize_if_allowed(DstXprTyp template EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE constexpr void call_dense_assignment_loop(DstXprType& dst, const SrcXprType& src, const Functor& func) { - typedef evaluator DstEvaluatorType; - typedef evaluator SrcEvaluatorType; + using DstEvaluatorType = evaluator; + using SrcEvaluatorType = evaluator; SrcEvaluatorType srcEvaluator(src); @@ -834,7 +834,7 @@ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE constexpr void call_dense_assignment_loop( DstEvaluatorType dstEvaluator(dst); - typedef generic_dense_assignment_kernel Kernel; + using Kernel = generic_dense_assignment_kernel; Kernel kernel(dstEvaluator, srcEvaluator, func, dst.const_cast_derived()); dense_assignment_loop::run(kernel); @@ -861,11 +861,11 @@ struct EigenBase2EigenBase {}; template struct AssignmentKind { - typedef EigenBase2EigenBase Kind; + using Kind = EigenBase2EigenBase; }; template <> struct AssignmentKind { - typedef Dense2Dense Kind; + using Kind = Dense2Dense; }; // This is the main assignment class @@ -920,8 +920,8 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void call_assignment_no_alias(Ds int(Dst::SizeAtCompileTime) != 1 }; - typedef std::conditional_t, Dst> ActualDstTypeCleaned; - typedef std::conditional_t, Dst&> ActualDstType; + using ActualDstTypeCleaned = std::conditional_t, Dst>; + using ActualDstType = std::conditional_t, Dst&>; ActualDstType actualDst(dst); // TODO: check whether this is the right place to perform these checks: @@ -935,9 +935,9 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void call_assignment_no_alias(Ds template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_restricted_packet_assignment_no_alias(Dst& dst, const Src& src, const Func& func) { - typedef evaluator DstEvaluatorType; - typedef evaluator SrcEvaluatorType; - typedef restricted_packet_dense_assignment_kernel Kernel; + using DstEvaluatorType = evaluator; + using SrcEvaluatorType = evaluator; + using Kernel = restricted_packet_dense_assignment_kernel; EIGEN_STATIC_ASSERT_LVALUE(Dst) EIGEN_CHECK_BINARY_COMPATIBILIY(Func, typename Dst::Scalar, typename Src::Scalar); diff --git a/Eigen/src/Core/CoreEvaluators.h b/Eigen/src/Core/CoreEvaluators.h index f1ee7c8ec..d619255b6 100644 --- a/Eigen/src/Core/CoreEvaluators.h +++ b/Eigen/src/Core/CoreEvaluators.h @@ -23,7 +23,7 @@ namespace internal { // Default assumes index based accessors template struct storage_kind_to_evaluator_kind { - typedef IndexBased Kind; + using Kind = IndexBased; }; // This class returns the evaluator shape from the expression storage kind. @@ -33,19 +33,19 @@ struct storage_kind_to_shape; template <> struct storage_kind_to_shape { - typedef DenseShape Shape; + using Shape = DenseShape; }; template <> struct storage_kind_to_shape { - typedef SolverShape Shape; + using Shape = SolverShape; }; template <> struct storage_kind_to_shape { - typedef PermutationShape Shape; + using Shape = PermutationShape; }; template <> struct storage_kind_to_shape { - typedef TranspositionsShape Shape; + using Shape = TranspositionsShape; }; // Evaluators have to be specialized with respect to various criteria such as: @@ -86,8 +86,8 @@ struct unary_evaluator; template struct evaluator_traits_base { // by default, get evaluator kind and shape from storage - typedef typename storage_kind_to_evaluator_kind::StorageKind>::Kind Kind; - typedef typename storage_kind_to_shape::StorageKind>::Shape Shape; + using Kind = typename storage_kind_to_evaluator_kind::StorageKind>::Kind; + using Shape = typename storage_kind_to_shape::StorageKind>::Shape; }; // Default evaluator traits @@ -95,14 +95,12 @@ template struct evaluator_traits : public evaluator_traits_base {}; template ::Shape> -struct evaluator_assume_aliasing { - static const bool value = false; -}; +struct evaluator_assume_aliasing : std::false_type {}; // By default, we assume a unary expression: template struct evaluator : public unary_evaluator { - typedef unary_evaluator Base; + using Base = unary_evaluator; EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit evaluator(const T& xpr) : Base(xpr) {} }; @@ -118,7 +116,7 @@ template struct evaluator_base { // TODO: find a way to avoid propagating all these traits. They are currently only needed to handle // outer,inner indices. - typedef traits ExpressionTraits; + using ExpressionTraits = traits; enum { Alignment = 0 }; // noncopyable: @@ -126,9 +124,8 @@ struct evaluator_base { // and make complex evaluator much larger than then should do. EIGEN_DEVICE_FUNC constexpr evaluator_base() = default; - private: - EIGEN_DEVICE_FUNC evaluator_base(const evaluator_base&); - EIGEN_DEVICE_FUNC const evaluator_base& operator=(const evaluator_base&); + evaluator_base(const evaluator_base&) = delete; + evaluator_base& operator=(const evaluator_base&) = delete; }; // -------------------- Matrix and Array -------------------- @@ -166,9 +163,9 @@ class plainobjectbase_evaluator_data { template struct evaluator> : evaluator_base { - typedef PlainObjectBase PlainObjectType; - typedef typename PlainObjectType::Scalar Scalar; - typedef typename PlainObjectType::CoeffReturnType CoeffReturnType; + using PlainObjectType = PlainObjectBase; + using Scalar = typename PlainObjectType::Scalar; + using CoeffReturnType = typename PlainObjectType::CoeffReturnType; enum { IsRowMajor = PlainObjectType::IsRowMajor, @@ -264,7 +261,7 @@ struct evaluator> : evaluator_base { template struct evaluator> : evaluator>> { - typedef Matrix XprType; + using XprType = Matrix; EIGEN_DEVICE_FUNC constexpr evaluator() = default; @@ -274,7 +271,7 @@ struct evaluator> template struct evaluator> : evaluator>> { - typedef Array XprType; + using XprType = Array; EIGEN_DEVICE_FUNC constexpr evaluator() = default; @@ -285,7 +282,7 @@ struct evaluator> template struct unary_evaluator, IndexBased> : evaluator_base> { - typedef Transpose XprType; + using XprType = Transpose; enum { CoeffReadCost = evaluator::CoeffReadCost, @@ -296,8 +293,8 @@ struct unary_evaluator, IndexBased> : evaluator_base {}; template struct evaluator> : evaluator_base> { - typedef CwiseNullaryOp XprType; - typedef remove_all_t PlainObjectTypeCleaned; + using XprType = CwiseNullaryOp; + using PlainObjectTypeCleaned = remove_all_t; enum { CoeffReadCost = functor_traits::Cost, @@ -465,7 +462,7 @@ struct evaluator> EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); } - typedef typename XprType::CoeffReturnType CoeffReturnType; + using CoeffReturnType = typename XprType::CoeffReturnType; template EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(IndexType row, IndexType col) const { @@ -508,7 +505,7 @@ struct evaluator> template struct unary_evaluator, IndexBased> : evaluator_base> { - typedef CwiseUnaryOp XprType; + using XprType = CwiseUnaryOp; enum { CoeffReadCost = int(evaluator::CoeffReadCost) + int(functor_traits::Cost), @@ -523,7 +520,7 @@ struct unary_evaluator, IndexBased> : evaluator_b EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); } - typedef typename XprType::CoeffReturnType CoeffReturnType; + using CoeffReturnType = typename XprType::CoeffReturnType; EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { return m_d.func()(m_d.argImpl.coeff(row, col)); @@ -906,8 +903,8 @@ struct unary_evaluator, ArgType>, In template struct evaluator> : public ternary_evaluator> { - typedef CwiseTernaryOp XprType; - typedef ternary_evaluator> Base; + using XprType = CwiseTernaryOp; + using Base = ternary_evaluator>; EIGEN_DEVICE_FUNC constexpr explicit evaluator(const XprType& xpr) : Base(xpr) {} }; @@ -915,7 +912,7 @@ struct evaluator> template struct ternary_evaluator, IndexBased, IndexBased> : evaluator_base> { - typedef CwiseTernaryOp XprType; + using XprType = CwiseTernaryOp; enum { CoeffReadCost = int(evaluator::CoeffReadCost) + int(evaluator::CoeffReadCost) + @@ -943,7 +940,7 @@ struct ternary_evaluator, IndexBased EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); } - typedef typename XprType::CoeffReturnType CoeffReturnType; + using CoeffReturnType = typename XprType::CoeffReturnType; EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { return m_d.func()(m_d.arg1Impl.coeff(row, col), m_d.arg2Impl.coeff(row, col), m_d.arg3Impl.coeff(row, col)); @@ -1033,8 +1030,8 @@ struct evaluator, // this is a binary expression template struct evaluator> : public binary_evaluator> { - typedef CwiseBinaryOp XprType; - typedef binary_evaluator> Base; + using XprType = CwiseBinaryOp; + using Base = binary_evaluator>; EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit evaluator(const XprType& xpr) : Base(xpr) {} }; @@ -1042,7 +1039,7 @@ struct evaluator> : public binary_evaluator struct binary_evaluator, IndexBased, IndexBased> : evaluator_base> { - typedef CwiseBinaryOp XprType; + using XprType = CwiseBinaryOp; enum { CoeffReadCost = @@ -1066,7 +1063,7 @@ struct binary_evaluator, IndexBased, IndexBase EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); } - typedef typename XprType::CoeffReturnType CoeffReturnType; + using CoeffReturnType = typename XprType::CoeffReturnType; EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { return m_d.func()(m_d.lhsImpl.coeff(row, col), m_d.rhsImpl.coeff(row, col)); @@ -1119,7 +1116,7 @@ struct binary_evaluator, IndexBased, IndexBase template struct unary_evaluator, IndexBased> : evaluator_base> { - typedef CwiseUnaryView XprType; + using XprType = CwiseUnaryView; enum { CoeffReadCost = int(evaluator::CoeffReadCost) + int(functor_traits::Cost), @@ -1134,8 +1131,8 @@ struct unary_evaluator, IndexBased> EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); } - typedef typename XprType::Scalar Scalar; - typedef typename XprType::CoeffReturnType CoeffReturnType; + using Scalar = typename XprType::Scalar; + using CoeffReturnType = typename XprType::CoeffReturnType; EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { return m_d.func()(m_d.argImpl.coeff(row, col)); @@ -1175,10 +1172,10 @@ struct mapbase_evaluator; template struct mapbase_evaluator : evaluator_base { - typedef Derived XprType; - typedef typename XprType::PointerType PointerType; - typedef typename XprType::Scalar Scalar; - typedef typename XprType::CoeffReturnType CoeffReturnType; + using XprType = Derived; + using PointerType = typename XprType::PointerType; + using Scalar = typename XprType::Scalar; + using CoeffReturnType = typename XprType::CoeffReturnType; enum { IsRowMajor = XprType::IsRowMajor, @@ -1274,10 +1271,10 @@ struct mapbase_evaluator : evaluator_base { template struct evaluator> : public mapbase_evaluator, PlainObjectType> { - typedef Map XprType; - typedef typename XprType::Scalar Scalar; + using XprType = Map; + using Scalar = typename XprType::Scalar; // TODO: should check for smaller packet types once we can handle multi-sized packet types - typedef typename packet_traits::type PacketScalar; + using PacketScalar = typename packet_traits::type; enum { InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0 @@ -1308,7 +1305,7 @@ struct evaluator> template struct evaluator> : public mapbase_evaluator, PlainObjectType> { - typedef Ref XprType; + using XprType = Ref; enum { Flags = evaluator>::Flags, @@ -1328,10 +1325,10 @@ struct block_evaluator; template struct evaluator> : block_evaluator { - typedef Block XprType; - typedef typename XprType::Scalar Scalar; + using XprType = Block; + using Scalar = typename XprType::Scalar; // TODO: should check for smaller packet types once we can handle multi-sized packet types - typedef typename packet_traits::type PacketScalar; + using PacketScalar = typename packet_traits::type; enum { CoeffReadCost = evaluator::CoeffReadCost, @@ -1368,7 +1365,7 @@ struct evaluator> : 0, Alignment = plain_enum_min(evaluator::Alignment, Alignment0) }; - typedef block_evaluator block_evaluator_type; + using block_evaluator_type = block_evaluator; EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit evaluator(const XprType& block) : block_evaluator_type(block) { EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); @@ -1379,7 +1376,7 @@ struct evaluator> template struct block_evaluator : unary_evaluator> { - typedef Block XprType; + using XprType = Block; EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit block_evaluator(const XprType& block) : unary_evaluator(block) {} @@ -1388,7 +1385,7 @@ struct block_evaluator struct unary_evaluator, IndexBased> : evaluator_base> { - typedef Block XprType; + using XprType = Block; EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& block) : m_argImpl(block.nestedExpression()), @@ -1400,8 +1397,8 @@ struct unary_evaluator, IndexBa : block.startCol() * block.nestedExpression().rows() + block.startRow()) : 0) {} - typedef typename XprType::Scalar Scalar; - typedef typename XprType::CoeffReturnType CoeffReturnType; + using Scalar = typename XprType::Scalar; + using CoeffReturnType = typename XprType::CoeffReturnType; enum { RowsAtCompileTime = XprType::RowsAtCompileTime, @@ -1432,10 +1429,9 @@ struct unary_evaluator, IndexBa template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index) const { - if (ForwardLinearAccess) - return m_argImpl.template packet(m_linear_offset.value() + index); - else - return packet(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0); + EIGEN_IF_CONSTEXPR(ForwardLinearAccess) + return m_argImpl.template packet(m_linear_offset.value() + index); + else return packet(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0); } template @@ -1445,11 +1441,10 @@ struct unary_evaluator, IndexBa template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacket(Index index, const PacketType& x) { - if (ForwardLinearAccess) - return m_argImpl.template writePacket(m_linear_offset.value() + index, x); - else - return writePacket(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0, - x); + EIGEN_IF_CONSTEXPR(ForwardLinearAccess) + return m_argImpl.template writePacket(m_linear_offset.value() + index, x); + else return writePacket(RowsAtCompileTime == 1 ? 0 : index, + RowsAtCompileTime == 1 ? index : 0, x); } template @@ -1460,11 +1455,10 @@ struct unary_evaluator, IndexBa template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index index, Index begin, Index count) const { - if (ForwardLinearAccess) - return m_argImpl.template packetSegment(m_linear_offset.value() + index, begin, count); - else - return packetSegment(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0, - begin, count); + EIGEN_IF_CONSTEXPR(ForwardLinearAccess) + return m_argImpl.template packetSegment(m_linear_offset.value() + index, begin, count); + else return packetSegment(RowsAtCompileTime == 1 ? 0 : index, + RowsAtCompileTime == 1 ? index : 0, begin, count); } template @@ -1477,12 +1471,11 @@ struct unary_evaluator, IndexBa template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacketSegment(Index index, const PacketType& x, Index begin, Index count) { - if (ForwardLinearAccess) - return m_argImpl.template writePacketSegment(m_linear_offset.value() + index, x, begin, - count); - else - return writePacketSegment(RowsAtCompileTime == 1 ? 0 : index, - RowsAtCompileTime == 1 ? index : 0, x, begin, count); + EIGEN_IF_CONSTEXPR(ForwardLinearAccess) + return m_argImpl.template writePacketSegment(m_linear_offset.value() + index, x, begin, + count); + else return writePacketSegment(RowsAtCompileTime == 1 ? 0 : index, + RowsAtCompileTime == 1 ? index : 0, x, begin, count); } protected: @@ -1517,8 +1510,8 @@ template struct block_evaluator : mapbase_evaluator, typename Block::PlainObject> { - typedef Block XprType; - typedef typename XprType::Scalar Scalar; + using XprType = Block; + using Scalar = typename XprType::Scalar; EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit block_evaluator(const XprType& block) : mapbase_evaluator(block) { @@ -1533,11 +1526,11 @@ struct block_evaluator struct unary_evaluator> : evaluator_base> { - typedef Replicate XprType; - typedef typename XprType::CoeffReturnType CoeffReturnType; + using XprType = Replicate; + using CoeffReturnType = typename XprType::CoeffReturnType; enum { Factor = (RowFactor == Dynamic || ColFactor == Dynamic) ? Dynamic : RowFactor * ColFactor }; - typedef typename nested_eval::type ArgTypeNested; - typedef remove_all_t ArgTypeNestedCleaned; + using ArgTypeNested = typename nested_eval::type; + using ArgTypeNestedCleaned = remove_all_t; enum { CoeffReadCost = evaluator::CoeffReadCost, @@ -1619,7 +1612,7 @@ struct unary_evaluator> template struct evaluator_wrapper_base : evaluator_base { - typedef remove_all_t ArgType; + using ArgType = remove_all_t; enum { CoeffReadCost = evaluator::CoeffReadCost, Flags = evaluator::Flags, @@ -1628,8 +1621,8 @@ struct evaluator_wrapper_base : evaluator_base { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator_wrapper_base(const ArgType& arg) : m_argImpl(arg) {} - typedef typename ArgType::Scalar Scalar; - typedef typename ArgType::CoeffReturnType CoeffReturnType; + using Scalar = typename ArgType::Scalar; + using CoeffReturnType = typename ArgType::CoeffReturnType; EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const { return m_argImpl.coeff(row, col); @@ -1693,7 +1686,7 @@ struct evaluator_wrapper_base : evaluator_base { template struct unary_evaluator> : evaluator_wrapper_base> { - typedef MatrixWrapper XprType; + using XprType = MatrixWrapper; EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& wrapper) : evaluator_wrapper_base>(wrapper.nestedExpression()) {} @@ -1701,7 +1694,7 @@ struct unary_evaluator> : evaluator_wrapper_base struct unary_evaluator> : evaluator_wrapper_base> { - typedef ArrayWrapper XprType; + using XprType = ArrayWrapper; EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& wrapper) : evaluator_wrapper_base>(wrapper.nestedExpression()) {} @@ -1715,9 +1708,9 @@ struct reverse_packet_cond; template struct unary_evaluator> : evaluator_base> { - typedef Reverse XprType; - typedef typename XprType::Scalar Scalar; - typedef typename XprType::CoeffReturnType CoeffReturnType; + using XprType = Reverse; + using Scalar = typename XprType::Scalar; + using CoeffReturnType = typename XprType::CoeffReturnType; enum { IsRowMajor = XprType::IsRowMajor, @@ -1872,13 +1865,13 @@ struct unary_evaluator> : evaluator_base struct evaluator> : evaluator_base> { - typedef Diagonal XprType; + using XprType = Diagonal; enum { CoeffReadCost = evaluator::CoeffReadCost, - Flags = - (unsigned int)(evaluator::Flags & (HereditaryBits | DirectAccessBit) & ~RowMajorBit) | LinearAccessBit, + Flags = static_cast(evaluator::Flags & (HereditaryBits | DirectAccessBit) & ~RowMajorBit) | + LinearAccessBit, Alignment = 0 }; @@ -1886,8 +1879,8 @@ struct evaluator> : evaluator_base> : public traits {}; template class EvalToTemp : public dense_xpr_base>::type { public: - typedef typename dense_xpr_base::type Base; + using Base = typename dense_xpr_base::type; EIGEN_GENERIC_PUBLIC_INTERFACE(EvalToTemp) explicit EvalToTemp(const ArgType& arg) : m_arg(arg) {} @@ -1948,9 +1941,9 @@ class EvalToTemp : public dense_xpr_base>::type { template struct evaluator> : public evaluator { - typedef EvalToTemp XprType; - typedef typename ArgType::PlainObject PlainObject; - typedef evaluator Base; + using XprType = EvalToTemp; + using PlainObject = typename ArgType::PlainObject; + using Base = evaluator; EIGEN_DEVICE_FUNC constexpr explicit evaluator(const XprType& xpr) : m_result(xpr.arg()) { internal::construct_at(this, m_result); diff --git a/Eigen/src/Core/IndexedView.h b/Eigen/src/Core/IndexedView.h index 44d5c020a..150565ad6 100644 --- a/Eigen/src/Core/IndexedView.h +++ b/Eigen/src/Core/IndexedView.h @@ -311,9 +311,7 @@ struct unary_evaluator, IndexBased> // Catch assignments to an IndexedView. template -struct evaluator_assume_aliasing> { - static const bool value = true; -}; +struct evaluator_assume_aliasing> : std::true_type {}; } // end namespace internal diff --git a/Eigen/src/Core/PartialReduxEvaluator.h b/Eigen/src/Core/PartialReduxEvaluator.h index 4d64df28e..d2c58513c 100644 --- a/Eigen/src/Core/PartialReduxEvaluator.h +++ b/Eigen/src/Core/PartialReduxEvaluator.h @@ -42,12 +42,12 @@ namespace internal { /* logic deciding a strategy for unrolling of vectorized paths */ template struct packetwise_redux_traits { - enum { - OuterSize = int(Evaluator::IsRowMajor) ? Evaluator::RowsAtCompileTime : Evaluator::ColsAtCompileTime, - Cost = OuterSize == Dynamic ? HugeCost - : OuterSize * Evaluator::CoeffReadCost + (OuterSize - 1) * functor_traits::Cost, - Unrolling = Cost <= EIGEN_UNROLLING_LIMIT ? CompleteUnrolling : NoUnrolling - }; + static constexpr int OuterSize = + int(Evaluator::IsRowMajor) ? Evaluator::RowsAtCompileTime : Evaluator::ColsAtCompileTime; + static constexpr int Cost = OuterSize == Dynamic + ? HugeCost + : OuterSize * Evaluator::CoeffReadCost + (OuterSize - 1) * functor_traits::Cost; + static constexpr int Unrolling = Cost <= EIGEN_UNROLLING_LIMIT ? CompleteUnrolling : NoUnrolling; }; /* Value to be returned when size==0 , by default let's return 0 */ @@ -70,8 +70,8 @@ struct packetwise_redux_impl; /* Perform the actual reduction with unrolling */ template struct packetwise_redux_impl { - typedef redux_novec_unroller Base; - typedef typename Evaluator::Scalar Scalar; + using Base = redux_novec_unroller; + using Scalar = typename Evaluator::Scalar; template EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE PacketType run(const Evaluator& eval, const Func& func, Index /*size*/) { @@ -96,8 +96,8 @@ struct redux_vec_unroller { /* Perform the actual reduction for dynamic sizes */ template struct packetwise_redux_impl { - typedef typename Evaluator::Scalar Scalar; - typedef typename redux_traits::PacketType PacketScalar; + using Scalar = typename Evaluator::Scalar; + using PacketScalar = typename redux_traits::PacketType; template EIGEN_DEVICE_FUNC static PacketType run(const Evaluator& eval, const Func& func, Index size) { @@ -122,8 +122,8 @@ struct packetwise_redux_impl { template struct packetwise_segment_redux_impl { - typedef typename Evaluator::Scalar Scalar; - typedef typename redux_traits::PacketType PacketScalar; + using Scalar = typename Evaluator::Scalar; + using PacketScalar = typename redux_traits::PacketType; template EIGEN_DEVICE_FUNC static PacketType run(const Evaluator& eval, const Func& func, Index size, Index begin, @@ -140,16 +140,16 @@ struct packetwise_segment_redux_impl { template struct evaluator > : evaluator_base > { - typedef PartialReduxExpr XprType; - typedef typename internal::nested_eval::type ArgTypeNested; - typedef add_const_on_value_type_t ConstArgTypeNested; - typedef internal::remove_all_t ArgTypeNestedCleaned; - typedef typename ArgType::Scalar InputScalar; - typedef typename XprType::Scalar Scalar; + using XprType = PartialReduxExpr; + using ArgTypeNested = typename internal::nested_eval::type; + using ConstArgTypeNested = add_const_on_value_type_t; + using ArgTypeNestedCleaned = internal::remove_all_t; + using InputScalar = typename ArgType::Scalar; + using Scalar = typename XprType::Scalar; enum { TraversalSize = Direction == int(Vertical) ? int(ArgType::RowsAtCompileTime) : int(ArgType::ColsAtCompileTime) }; - typedef typename MemberOp::template Cost CostOpType; + using CostOpType = typename MemberOp::template Cost; enum { CoeffReadCost = TraversalSize == Dynamic ? HugeCost : TraversalSize == 0 @@ -174,7 +174,7 @@ struct evaluator > EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); } - typedef typename XprType::CoeffReturnType CoeffReturnType; + using CoeffReturnType = typename XprType::CoeffReturnType; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar coeff(Index i, Index j) const { return coeff(Direction == Vertical ? j : i); @@ -203,7 +203,7 @@ struct evaluator > // See bug 1612, currently if PacketSize==1 (i.e. complex with 128bits registers) then the storage-order of // panel get reversed and methods like packetByOuterInner do not make sense anymore in this context. So let's just // by pass "vectorization" in this case: - if (PacketSize == 1) return internal::pset1(coeff(idx)); + EIGEN_IF_CONSTEXPR(PacketSize == 1) return internal::pset1(coeff(idx)); Index startRow = Direction == Vertical ? 0 : idx; Index startCol = Direction == Vertical ? idx : 0; diff --git a/Eigen/src/Core/ProductEvaluators.h b/Eigen/src/Core/ProductEvaluators.h index b157bc523..e02e669cc 100644 --- a/Eigen/src/Core/ProductEvaluators.h +++ b/Eigen/src/Core/ProductEvaluators.h @@ -29,8 +29,8 @@ namespace internal { */ template struct evaluator> : public product_evaluator> { - typedef Product XprType; - typedef product_evaluator Base; + using XprType = Product; + using Base = product_evaluator; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& xpr) : Base(xpr) {} }; @@ -40,19 +40,16 @@ struct evaluator> : public product_evaluator struct evaluator_assume_aliasing, const CwiseNullaryOp, Plain1>, - const Product>> { - static const bool value = true; -}; + const Product>> : std::true_type {}; template struct evaluator, const CwiseNullaryOp, Plain1>, const Product>> : public evaluator> { - typedef CwiseBinaryOp, - const CwiseNullaryOp, Plain1>, - const Product> - XprType; - typedef evaluator> Base; + using XprType = CwiseBinaryOp, + const CwiseNullaryOp, Plain1>, + const Product>; + using Base = evaluator>; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& xpr) : Base(xpr.lhs().functor().m_other * xpr.rhs().lhs() * xpr.rhs().rhs()) {} @@ -61,8 +58,8 @@ struct evaluator, template struct evaluator, DiagIndex>> : public evaluator, DiagIndex>> { - typedef Diagonal, DiagIndex> XprType; - typedef evaluator, DiagIndex>> Base; + using XprType = Diagonal, DiagIndex>; + using Base = evaluator, DiagIndex>>; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& xpr) : Base(Diagonal, DiagIndex>( @@ -78,18 +75,16 @@ template -struct evaluator_assume_aliasing> { - static const bool value = true; -}; +struct evaluator_assume_aliasing> : std::true_type {}; // This is the default evaluator implementation for products: // It creates a temporary and call generic_product_impl template struct product_evaluator, ProductTag, LhsShape, RhsShape> : public evaluator::PlainObject> { - typedef Product XprType; - typedef typename XprType::PlainObject PlainObject; - typedef evaluator Base; + using XprType = Product; + using PlainObject = typename XprType::PlainObject; + using Base = evaluator; enum { Flags = Base::Flags | EvalBeforeNestingBit }; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit product_evaluator(const XprType& xpr) @@ -123,7 +118,7 @@ struct product_evaluator, ProductTag, LhsShape, RhsSh template struct Assignment, internal::assign_op, Dense2Dense, std::enable_if_t<(Options == DefaultProduct || Options == AliasFreeProduct)>> { - typedef Product SrcXprType; + using SrcXprType = Product; static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(DstXprType& dst, const SrcXprType& src, const internal::assign_op&) { Index dstRows = src.rows(); @@ -138,7 +133,7 @@ struct Assignment, internal::assign_op struct Assignment, internal::add_assign_op, Dense2Dense, std::enable_if_t<(Options == DefaultProduct || Options == AliasFreeProduct)>> { - typedef Product SrcXprType; + using SrcXprType = Product; static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(DstXprType& dst, const SrcXprType& src, const internal::add_assign_op&) { eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); @@ -151,7 +146,7 @@ struct Assignment, internal::add_assign_o template struct Assignment, internal::sub_assign_op, Dense2Dense, std::enable_if_t<(Options == DefaultProduct || Options == AliasFreeProduct)>> { - typedef Product SrcXprType; + using SrcXprType = Product; static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(DstXprType& dst, const SrcXprType& src, const internal::sub_assign_op&) { eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); @@ -170,10 +165,9 @@ struct Assignment, Plain>, const Product>, AssignFunc, Dense2Dense> { - typedef CwiseBinaryOp, - const CwiseNullaryOp, Plain>, - const Product> - SrcXprType; + using SrcXprType = CwiseBinaryOp, + const CwiseNullaryOp, Plain>, + const Product>; static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(DstXprType& dst, const SrcXprType& src, const AssignFunc& func) { call_assignment_no_alias(dst, (src.lhs().functor().m_other * src.rhs().lhs()) * src.rhs().rhs(), func); @@ -189,18 +183,14 @@ struct evaluator_assume_aliasing< CwiseBinaryOp< internal::scalar_sum_op::Scalar>, const OtherXpr, const Product>, - DenseShape> { - static const bool value = true; -}; + DenseShape> : std::true_type {}; template struct evaluator_assume_aliasing< CwiseBinaryOp< internal::scalar_difference_op::Scalar>, const OtherXpr, const Product>, - DenseShape> { - static const bool value = true; -}; + DenseShape> : std::true_type {}; template struct assignment_from_xpr_op_product { @@ -284,7 +274,7 @@ template struct generic_product_impl { template struct is_row_major : bool_constant<(int(T::Flags) & RowMajorBit)> {}; - typedef typename Product::Scalar Scalar; + using Scalar = typename Product::Scalar; // TODO: it would be nice to be able to exploit our *_assign_op functors for that purpose struct set { @@ -343,7 +333,7 @@ struct generic_product_impl { // This base class provides default implementations for evalTo, addTo, subTo, in terms of scaleAndAddTo template struct generic_product_impl_base { - typedef typename Product::Scalar Scalar; + using Scalar = typename Product::Scalar; template static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void evalTo(Dst& dst, const Lhs& lhs, const Rhs& rhs) { @@ -371,11 +361,11 @@ struct generic_product_impl_base { template struct generic_product_impl : generic_product_impl_base> { - typedef typename nested_eval::type LhsNested; - typedef typename nested_eval::type RhsNested; - typedef typename Product::Scalar Scalar; + using LhsNested = typename nested_eval::type; + using RhsNested = typename nested_eval::type; + using Scalar = typename Product::Scalar; enum { Side = Lhs::IsVectorAtCompileTime ? OnTheLeft : OnTheRight }; - typedef internal::remove_all_t> MatrixType; + using MatrixType = internal::remove_all_t>; template static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, @@ -396,7 +386,7 @@ struct generic_product_impl template struct generic_product_impl { - typedef typename Product::Scalar Scalar; + using Scalar = typename Product::Scalar; template static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void evalTo(Dst& dst, const Lhs& lhs, const Rhs& rhs) { @@ -485,9 +475,9 @@ struct etor_product_packet_impl; template struct product_evaluator, ProductTag, DenseShape, DenseShape> : evaluator_base> { - typedef Product XprType; - typedef typename XprType::Scalar Scalar; - typedef typename XprType::CoeffReturnType CoeffReturnType; + using XprType = Product; + using Scalar = typename XprType::Scalar; + using CoeffReturnType = typename XprType::CoeffReturnType; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit product_evaluator(const XprType& xpr) : m_lhs(xpr.lhs()), @@ -504,14 +494,14 @@ struct product_evaluator, ProductTag, DenseShape, // Everything below here is taken from CoeffBasedProduct.h - typedef typename internal::nested_eval::type LhsNested; - typedef typename internal::nested_eval::type RhsNested; + using LhsNested = typename internal::nested_eval::type; + using RhsNested = typename internal::nested_eval::type; - typedef internal::remove_all_t LhsNestedCleaned; - typedef internal::remove_all_t RhsNestedCleaned; + using LhsNestedCleaned = internal::remove_all_t; + using RhsNestedCleaned = internal::remove_all_t; - typedef evaluator LhsEtorType; - typedef evaluator RhsEtorType; + using LhsEtorType = evaluator; + using RhsEtorType = evaluator; enum { RowsAtCompileTime = LhsNestedCleaned::RowsAtCompileTime, @@ -521,76 +511,75 @@ struct product_evaluator, ProductTag, DenseShape, MaxColsAtCompileTime = RhsNestedCleaned::MaxColsAtCompileTime }; - typedef typename find_best_packet::type LhsVecPacketType; - typedef typename find_best_packet::type RhsVecPacketType; + using LhsVecPacketType = typename find_best_packet::type; + using RhsVecPacketType = typename find_best_packet::type; - enum { + static constexpr int LhsCoeffReadCost = LhsEtorType::CoeffReadCost; + static constexpr int RhsCoeffReadCost = RhsEtorType::CoeffReadCost; + static constexpr int CoeffReadCost = + InnerSize == 0 ? NumTraits::ReadCost + : InnerSize == Dynamic + ? HugeCost + : InnerSize * (NumTraits::MulCost + int(LhsCoeffReadCost) + int(RhsCoeffReadCost)) + + (InnerSize - 1) * NumTraits::AddCost; - LhsCoeffReadCost = LhsEtorType::CoeffReadCost, - RhsCoeffReadCost = RhsEtorType::CoeffReadCost, - CoeffReadCost = InnerSize == 0 ? NumTraits::ReadCost - : InnerSize == Dynamic - ? HugeCost - : InnerSize * (NumTraits::MulCost + int(LhsCoeffReadCost) + int(RhsCoeffReadCost)) + - (InnerSize - 1) * NumTraits::AddCost, + static constexpr bool Unroll = CoeffReadCost <= EIGEN_UNROLLING_LIMIT; - Unroll = CoeffReadCost <= EIGEN_UNROLLING_LIMIT, + static constexpr int LhsFlags = LhsEtorType::Flags; + static constexpr int RhsFlags = RhsEtorType::Flags; - LhsFlags = LhsEtorType::Flags, - RhsFlags = RhsEtorType::Flags, + static constexpr int LhsRowMajor = LhsFlags & RowMajorBit; + static constexpr int RhsRowMajor = RhsFlags & RowMajorBit; - LhsRowMajor = LhsFlags & RowMajorBit, - RhsRowMajor = RhsFlags & RowMajorBit, + static constexpr int LhsVecPacketSize = unpacket_traits::size; + static constexpr int RhsVecPacketSize = unpacket_traits::size; - LhsVecPacketSize = unpacket_traits::size, - RhsVecPacketSize = unpacket_traits::size, + // Here, we don't care about alignment larger than the usable packet size. + static constexpr int LhsAlignment = + plain_enum_min(LhsEtorType::Alignment, LhsVecPacketSize* int(sizeof(typename LhsNestedCleaned::Scalar))); + static constexpr int RhsAlignment = + plain_enum_min(RhsEtorType::Alignment, RhsVecPacketSize* int(sizeof(typename RhsNestedCleaned::Scalar))); - // Here, we don't care about alignment larger than the usable packet size. - LhsAlignment = - plain_enum_min(LhsEtorType::Alignment, LhsVecPacketSize* int(sizeof(typename LhsNestedCleaned::Scalar))), - RhsAlignment = - plain_enum_min(RhsEtorType::Alignment, RhsVecPacketSize* int(sizeof(typename RhsNestedCleaned::Scalar))), + static constexpr bool SameType = is_same::value; - SameType = is_same::value, + static constexpr bool CanVectorizeRhs = bool(RhsRowMajor) && (RhsFlags & PacketAccessBit) && (ColsAtCompileTime != 1); + static constexpr bool CanVectorizeLhs = (!LhsRowMajor) && (LhsFlags & PacketAccessBit) && (RowsAtCompileTime != 1); - CanVectorizeRhs = bool(RhsRowMajor) && (RhsFlags & PacketAccessBit) && (ColsAtCompileTime != 1), - CanVectorizeLhs = (!LhsRowMajor) && (LhsFlags & PacketAccessBit) && (RowsAtCompileTime != 1), + static constexpr int EvalToRowMajor = (MaxRowsAtCompileTime == 1 && MaxColsAtCompileTime != 1) ? 1 + : (MaxColsAtCompileTime == 1 && MaxRowsAtCompileTime != 1) + ? 0 + : (bool(RhsRowMajor) && !CanVectorizeLhs); - EvalToRowMajor = (MaxRowsAtCompileTime == 1 && MaxColsAtCompileTime != 1) ? 1 - : (MaxColsAtCompileTime == 1 && MaxRowsAtCompileTime != 1) - ? 0 - : (bool(RhsRowMajor) && !CanVectorizeLhs), + static constexpr int Flags = ((int(LhsFlags) | int(RhsFlags)) & HereditaryBits & ~RowMajorBit) | + (EvalToRowMajor ? RowMajorBit : 0) + // TODO: enable vectorization for mixed types + | (SameType && (CanVectorizeLhs || CanVectorizeRhs) ? PacketAccessBit : 0) | + (XprType::IsVectorAtCompileTime ? LinearAccessBit : 0); - Flags = ((int(LhsFlags) | int(RhsFlags)) & HereditaryBits & ~RowMajorBit) | - (EvalToRowMajor ? RowMajorBit : 0) - // TODO: enable vectorization for mixed types - | (SameType && (CanVectorizeLhs || CanVectorizeRhs) ? PacketAccessBit : 0) | - (XprType::IsVectorAtCompileTime ? LinearAccessBit : 0), + static constexpr int LhsOuterStrideBytes = + int(LhsNestedCleaned::OuterStrideAtCompileTime) * int(sizeof(typename LhsNestedCleaned::Scalar)); + static constexpr int RhsOuterStrideBytes = + int(RhsNestedCleaned::OuterStrideAtCompileTime) * int(sizeof(typename RhsNestedCleaned::Scalar)); - LhsOuterStrideBytes = - int(LhsNestedCleaned::OuterStrideAtCompileTime) * int(sizeof(typename LhsNestedCleaned::Scalar)), - RhsOuterStrideBytes = - int(RhsNestedCleaned::OuterStrideAtCompileTime) * int(sizeof(typename RhsNestedCleaned::Scalar)), + static constexpr int Alignment = + bool(CanVectorizeLhs) + ? (LhsOuterStrideBytes <= 0 || (int(LhsOuterStrideBytes) % plain_enum_max(1, LhsAlignment)) != 0 + ? 0 + : LhsAlignment) + : bool(CanVectorizeRhs) + ? (RhsOuterStrideBytes <= 0 || (int(RhsOuterStrideBytes) % plain_enum_max(1, RhsAlignment)) != 0 + ? 0 + : RhsAlignment) + : 0; - Alignment = bool(CanVectorizeLhs) - ? (LhsOuterStrideBytes <= 0 || (int(LhsOuterStrideBytes) % plain_enum_max(1, LhsAlignment)) != 0 - ? 0 - : LhsAlignment) - : bool(CanVectorizeRhs) - ? (RhsOuterStrideBytes <= 0 || (int(RhsOuterStrideBytes) % plain_enum_max(1, RhsAlignment)) != 0 - ? 0 - : RhsAlignment) - : 0, - - /* CanVectorizeInner deserves special explanation. It does not affect the product flags. It is not used outside - * of Product. If the Product itself is not a packet-access expression, there is still a chance that the inner - * loop of the product might be vectorized. This is the meaning of CanVectorizeInner. Since it doesn't affect - * the Flags, it is safe to make this value depend on ActualPacketAccessBit, that doesn't affect the ABI. - */ - CanVectorizeInner = SameType && LhsRowMajor && (!RhsRowMajor) && - (int(LhsFlags) & int(RhsFlags) & ActualPacketAccessBit) && - (int(InnerSize) % packet_traits::size == 0) - }; + /* CanVectorizeInner deserves special explanation. It does not affect the product flags. It is not used outside + * of Product. If the Product itself is not a packet-access expression, there is still a chance that the inner + * loop of the product might be vectorized. This is the meaning of CanVectorizeInner. Since it doesn't affect + * the Flags, it is safe to make this value depend on ActualPacketAccessBit, that doesn't affect the ABI. + */ + static constexpr bool CanVectorizeInner = SameType && LhsRowMajor && (!RhsRowMajor) && + (int(LhsFlags) & int(RhsFlags) & ActualPacketAccessBit) && + (int(InnerSize) % packet_traits::size == 0); EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index row, Index col) const { return (m_lhs.row(row).transpose().cwiseProduct(m_rhs.col(col))).sum(); @@ -609,9 +598,9 @@ struct product_evaluator, ProductTag, DenseShape, template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const PacketType packet(Index row, Index col) const { PacketType res; - typedef etor_product_packet_impl - PacketImpl; + using PacketImpl = + etor_product_packet_impl; PacketImpl::run(row, col, m_lhsImpl, m_rhsImpl, m_innerDim, res); return res; } @@ -627,9 +616,9 @@ struct product_evaluator, ProductTag, DenseShape, EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const PacketType packetSegment(Index row, Index col, Index begin, Index count) const { PacketType res; - typedef etor_product_packet_impl - PacketImpl; + using PacketImpl = + etor_product_packet_impl; PacketImpl::run_segment(row, col, m_lhsImpl, m_rhsImpl, m_innerDim, res, begin, count); return res; } @@ -648,16 +637,15 @@ struct product_evaluator, ProductTag, DenseShape, LhsEtorType m_lhsImpl; RhsEtorType m_rhsImpl; - // TODO: Get rid of m_innerDim if known at compile time - Index m_innerDim; + variable_if_dynamic m_innerDim; }; template struct product_evaluator, LazyCoeffBasedProductMode, DenseShape, DenseShape> : product_evaluator, CoeffBasedProductMode, DenseShape, DenseShape> { - typedef Product XprType; - typedef Product BaseProduct; - typedef product_evaluator Base; + using XprType = Product; + using BaseProduct = Product; + using Base = product_evaluator; enum { Flags = Base::Flags | EvalBeforeNestingBit }; EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit product_evaluator(const XprType& xpr) : Base(BaseProduct(xpr.lhs(), xpr.rhs())) {} @@ -800,7 +788,7 @@ struct triangular_product_impl; template struct generic_product_impl : generic_product_impl_base> { - typedef typename Product::Scalar Scalar; + using Scalar = typename Product::Scalar; template static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha) { @@ -812,7 +800,7 @@ struct generic_product_impl template struct generic_product_impl : generic_product_impl_base> { - typedef typename Product::Scalar Scalar; + using Scalar = typename Product::Scalar; template static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha) { @@ -830,7 +818,7 @@ struct selfadjoint_product_impl; template struct generic_product_impl : generic_product_impl_base> { - typedef typename Product::Scalar Scalar; + using Scalar = typename Product::Scalar; template static EIGEN_DEVICE_FUNC void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha) { @@ -842,7 +830,7 @@ struct generic_product_impl template struct generic_product_impl : generic_product_impl_base> { - typedef typename Product::Scalar Scalar; + using Scalar = typename Product::Scalar; template static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha) { @@ -857,7 +845,7 @@ struct generic_product_impl template struct diagonal_product_evaluator_base : evaluator_base { - typedef typename ScalarBinaryOpTraits::ReturnType Scalar; + using Scalar = typename ScalarBinaryOpTraits::ReturnType; public: enum { @@ -884,8 +872,8 @@ struct diagonal_product_evaluator_base : evaluator_base { (ScalarAccessOnDiag_ || (bool(int(DiagFlags) & PacketAccessBit))), LinearAccessMask_ = (MatrixType::RowsAtCompileTime == 1 || MatrixType::ColsAtCompileTime == 1) ? LinearAccessBit : 0, - Flags = - ((HereditaryBits | LinearAccessMask_) & (unsigned int)(MatrixFlags)) | (Vectorizable_ ? PacketAccessBit : 0), + Flags = ((HereditaryBits | LinearAccessMask_) & static_cast(MatrixFlags)) | + (Vectorizable_ ? PacketAccessBit : 0), Alignment = evaluator::Alignment, AsScalarProduct = @@ -958,17 +946,16 @@ template struct product_evaluator, ProductTag, DiagonalShape, DenseShape> : diagonal_product_evaluator_base, OnTheLeft> { - typedef diagonal_product_evaluator_base, - OnTheLeft> - Base; + using Base = + diagonal_product_evaluator_base, OnTheLeft>; using Base::coeff; using Base::m_diagImpl; using Base::m_matImpl; - typedef typename Base::Scalar Scalar; + using Scalar = typename Base::Scalar; - typedef Product XprType; - typedef typename XprType::PlainObject PlainObject; - typedef typename Lhs::DiagonalVectorType DiagonalType; + using XprType = Product; + using PlainObject = typename XprType::PlainObject; + using DiagonalType = typename Lhs::DiagonalVectorType; static constexpr int StorageOrder = Base::StorageOrder_; using IsRowMajor_t = bool_constant; @@ -1013,16 +1000,15 @@ template struct product_evaluator, ProductTag, DenseShape, DiagonalShape> : diagonal_product_evaluator_base, OnTheRight> { - typedef diagonal_product_evaluator_base, - OnTheRight> - Base; + using Base = diagonal_product_evaluator_base, + OnTheRight>; using Base::coeff; using Base::m_diagImpl; using Base::m_matImpl; - typedef typename Base::Scalar Scalar; + using Scalar = typename Base::Scalar; - typedef Product XprType; - typedef typename XprType::PlainObject PlainObject; + using XprType = Product; + using PlainObject = typename XprType::PlainObject; static constexpr int StorageOrder = Base::StorageOrder_; using IsColMajor_t = bool_constant; @@ -1071,8 +1057,8 @@ struct permutation_matrix_product; template struct permutation_matrix_product { - typedef typename nested_eval::type MatrixType; - typedef remove_all_t MatrixTypeCleaned; + using MatrixType = typename nested_eval::type; + using MatrixTypeCleaned = remove_all_t; template static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Dest& dst, const PermutationType& perm, @@ -1168,14 +1154,14 @@ struct generic_product_impl, MatrixShape, PermutationShape, Pr */ template struct transposition_matrix_product { - typedef typename nested_eval::type MatrixType; - typedef remove_all_t MatrixTypeCleaned; + using MatrixType = typename nested_eval::type; + using MatrixTypeCleaned = remove_all_t; template static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Dest& dst, const TranspositionType& tr, const ExpressionType& xpr) { MatrixType mat(xpr); - typedef typename TranspositionType::StorageIndex StorageIndex; + using StorageIndex = typename TranspositionType::StorageIndex; const Index size = tr.size(); StorageIndex j = 0;