mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Modernize evaluator files
libeigen/eigen!2245 Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
@@ -654,15 +654,15 @@ struct dense_assignment_loop_impl<Kernel, SliceVectorizedTraversal, InnerUnrolli
|
||||
template <typename DstEvaluatorTypeT, typename SrcEvaluatorTypeT, typename Functor, int Version = Specialized>
|
||||
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<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor> AssignmentTraits;
|
||||
typedef typename AssignmentTraits::PacketType PacketType;
|
||||
using DstEvaluatorType = DstEvaluatorTypeT;
|
||||
using SrcEvaluatorType = SrcEvaluatorTypeT;
|
||||
using Scalar = typename DstEvaluatorType::Scalar;
|
||||
using AssignmentTraits = copy_using_evaluator_traits<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor>;
|
||||
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 <typename DstEvaluatorTypeT, typename SrcEvaluatorTypeT, typename Funct
|
||||
class restricted_packet_dense_assignment_kernel
|
||||
: public generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, BuiltIn> {
|
||||
protected:
|
||||
typedef generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, BuiltIn> Base;
|
||||
using Base = generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, BuiltIn>;
|
||||
|
||||
public:
|
||||
typedef typename Base::Scalar Scalar;
|
||||
typedef typename Base::DstXprType DstXprType;
|
||||
typedef copy_using_evaluator_traits<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, 4> AssignmentTraits;
|
||||
typedef typename AssignmentTraits::PacketType PacketType;
|
||||
using Scalar = typename Base::Scalar;
|
||||
using DstXprType = typename Base::DstXprType;
|
||||
using AssignmentTraits = copy_using_evaluator_traits<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, 4>;
|
||||
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 <typename DstXprType, typename SrcXprType, typename Functor>
|
||||
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE constexpr void call_dense_assignment_loop(DstXprType& dst, const SrcXprType& src,
|
||||
const Functor& func) {
|
||||
typedef evaluator<DstXprType> DstEvaluatorType;
|
||||
typedef evaluator<SrcXprType> SrcEvaluatorType;
|
||||
using DstEvaluatorType = evaluator<DstXprType>;
|
||||
using SrcEvaluatorType = evaluator<SrcXprType>;
|
||||
|
||||
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<DstEvaluatorType, SrcEvaluatorType, Functor> Kernel;
|
||||
using Kernel = generic_dense_assignment_kernel<DstEvaluatorType, SrcEvaluatorType, Functor>;
|
||||
Kernel kernel(dstEvaluator, srcEvaluator, func, dst.const_cast_derived());
|
||||
|
||||
dense_assignment_loop<Kernel>::run(kernel);
|
||||
@@ -861,11 +861,11 @@ struct EigenBase2EigenBase {};
|
||||
|
||||
template <typename, typename>
|
||||
struct AssignmentKind {
|
||||
typedef EigenBase2EigenBase Kind;
|
||||
using Kind = EigenBase2EigenBase;
|
||||
};
|
||||
template <>
|
||||
struct AssignmentKind<DenseShape, DenseShape> {
|
||||
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<NeedToTranspose, Transpose<Dst>, Dst> ActualDstTypeCleaned;
|
||||
typedef std::conditional_t<NeedToTranspose, Transpose<Dst>, Dst&> ActualDstType;
|
||||
using ActualDstTypeCleaned = std::conditional_t<NeedToTranspose, Transpose<Dst>, Dst>;
|
||||
using ActualDstType = std::conditional_t<NeedToTranspose, Transpose<Dst>, 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 <typename Dst, typename Src, typename Func>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_restricted_packet_assignment_no_alias(Dst& dst, const Src& src,
|
||||
const Func& func) {
|
||||
typedef evaluator<Dst> DstEvaluatorType;
|
||||
typedef evaluator<Src> SrcEvaluatorType;
|
||||
typedef restricted_packet_dense_assignment_kernel<DstEvaluatorType, SrcEvaluatorType, Func> Kernel;
|
||||
using DstEvaluatorType = evaluator<Dst>;
|
||||
using SrcEvaluatorType = evaluator<Src>;
|
||||
using Kernel = restricted_packet_dense_assignment_kernel<DstEvaluatorType, SrcEvaluatorType, Func>;
|
||||
|
||||
EIGEN_STATIC_ASSERT_LVALUE(Dst)
|
||||
EIGEN_CHECK_BINARY_COMPATIBILIY(Func, typename Dst::Scalar, typename Src::Scalar);
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace internal {
|
||||
// Default assumes index based accessors
|
||||
template <typename StorageKind>
|
||||
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<Dense> {
|
||||
typedef DenseShape Shape;
|
||||
using Shape = DenseShape;
|
||||
};
|
||||
template <>
|
||||
struct storage_kind_to_shape<SolverStorage> {
|
||||
typedef SolverShape Shape;
|
||||
using Shape = SolverShape;
|
||||
};
|
||||
template <>
|
||||
struct storage_kind_to_shape<PermutationStorage> {
|
||||
typedef PermutationShape Shape;
|
||||
using Shape = PermutationShape;
|
||||
};
|
||||
template <>
|
||||
struct storage_kind_to_shape<TranspositionsStorage> {
|
||||
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 <typename T>
|
||||
struct evaluator_traits_base {
|
||||
// by default, get evaluator kind and shape from storage
|
||||
typedef typename storage_kind_to_evaluator_kind<typename traits<T>::StorageKind>::Kind Kind;
|
||||
typedef typename storage_kind_to_shape<typename traits<T>::StorageKind>::Shape Shape;
|
||||
using Kind = typename storage_kind_to_evaluator_kind<typename traits<T>::StorageKind>::Kind;
|
||||
using Shape = typename storage_kind_to_shape<typename traits<T>::StorageKind>::Shape;
|
||||
};
|
||||
|
||||
// Default evaluator traits
|
||||
@@ -95,14 +95,12 @@ template <typename T>
|
||||
struct evaluator_traits : public evaluator_traits_base<T> {};
|
||||
|
||||
template <typename T, typename Shape = typename evaluator_traits<T>::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 <typename T>
|
||||
struct evaluator : public unary_evaluator<T> {
|
||||
typedef unary_evaluator<T> Base;
|
||||
using Base = unary_evaluator<T>;
|
||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit evaluator(const T& xpr) : Base(xpr) {}
|
||||
};
|
||||
|
||||
@@ -118,7 +116,7 @@ template <typename ExpressionType>
|
||||
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<ExpressionType> ExpressionTraits;
|
||||
using ExpressionTraits = traits<ExpressionType>;
|
||||
|
||||
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<Scalar, Dynamic> {
|
||||
|
||||
template <typename Derived>
|
||||
struct evaluator<PlainObjectBase<Derived>> : evaluator_base<Derived> {
|
||||
typedef PlainObjectBase<Derived> PlainObjectType;
|
||||
typedef typename PlainObjectType::Scalar Scalar;
|
||||
typedef typename PlainObjectType::CoeffReturnType CoeffReturnType;
|
||||
using PlainObjectType = PlainObjectBase<Derived>;
|
||||
using Scalar = typename PlainObjectType::Scalar;
|
||||
using CoeffReturnType = typename PlainObjectType::CoeffReturnType;
|
||||
|
||||
enum {
|
||||
IsRowMajor = PlainObjectType::IsRowMajor,
|
||||
@@ -264,7 +261,7 @@ struct evaluator<PlainObjectBase<Derived>> : evaluator_base<Derived> {
|
||||
template <typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>
|
||||
struct evaluator<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;
|
||||
using XprType = Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols>;
|
||||
|
||||
EIGEN_DEVICE_FUNC constexpr evaluator() = default;
|
||||
|
||||
@@ -274,7 +271,7 @@ struct evaluator<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>
|
||||
template <typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>
|
||||
struct evaluator<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;
|
||||
using XprType = Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols>;
|
||||
|
||||
EIGEN_DEVICE_FUNC constexpr evaluator() = default;
|
||||
|
||||
@@ -285,7 +282,7 @@ struct evaluator<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>
|
||||
|
||||
template <typename ArgType>
|
||||
struct unary_evaluator<Transpose<ArgType>, IndexBased> : evaluator_base<Transpose<ArgType>> {
|
||||
typedef Transpose<ArgType> XprType;
|
||||
using XprType = Transpose<ArgType>;
|
||||
|
||||
enum {
|
||||
CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
|
||||
@@ -296,8 +293,8 @@ struct unary_evaluator<Transpose<ArgType>, IndexBased> : evaluator_base<Transpos
|
||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& t)
|
||||
: m_argImpl(t.nestedExpression()) {}
|
||||
|
||||
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_argImpl.coeff(col, row);
|
||||
@@ -448,8 +445,8 @@ struct nullary_wrapper<Scalar, NullaryOp, false, false, false> {};
|
||||
template <typename NullaryOp, typename PlainObjectType>
|
||||
struct evaluator<CwiseNullaryOp<NullaryOp, PlainObjectType>>
|
||||
: evaluator_base<CwiseNullaryOp<NullaryOp, PlainObjectType>> {
|
||||
typedef CwiseNullaryOp<NullaryOp, PlainObjectType> XprType;
|
||||
typedef remove_all_t<PlainObjectType> PlainObjectTypeCleaned;
|
||||
using XprType = CwiseNullaryOp<NullaryOp, PlainObjectType>;
|
||||
using PlainObjectTypeCleaned = remove_all_t<PlainObjectType>;
|
||||
|
||||
enum {
|
||||
CoeffReadCost = functor_traits<NullaryOp>::Cost,
|
||||
@@ -465,7 +462,7 @@ struct evaluator<CwiseNullaryOp<NullaryOp, PlainObjectType>>
|
||||
EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
|
||||
}
|
||||
|
||||
typedef typename XprType::CoeffReturnType CoeffReturnType;
|
||||
using CoeffReturnType = typename XprType::CoeffReturnType;
|
||||
|
||||
template <typename IndexType>
|
||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(IndexType row, IndexType col) const {
|
||||
@@ -508,7 +505,7 @@ struct evaluator<CwiseNullaryOp<NullaryOp, PlainObjectType>>
|
||||
|
||||
template <typename UnaryOp, typename ArgType>
|
||||
struct unary_evaluator<CwiseUnaryOp<UnaryOp, ArgType>, IndexBased> : evaluator_base<CwiseUnaryOp<UnaryOp, ArgType>> {
|
||||
typedef CwiseUnaryOp<UnaryOp, ArgType> XprType;
|
||||
using XprType = CwiseUnaryOp<UnaryOp, ArgType>;
|
||||
|
||||
enum {
|
||||
CoeffReadCost = int(evaluator<ArgType>::CoeffReadCost) + int(functor_traits<UnaryOp>::Cost),
|
||||
@@ -523,7 +520,7 @@ struct unary_evaluator<CwiseUnaryOp<UnaryOp, ArgType>, 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<CwiseUnaryOp<core_cast_op<SrcType, DstType>, ArgType>, In
|
||||
template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3>
|
||||
struct evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>>
|
||||
: public ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> {
|
||||
typedef CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> XprType;
|
||||
typedef ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> Base;
|
||||
using XprType = CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>;
|
||||
using Base = ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>>;
|
||||
|
||||
EIGEN_DEVICE_FUNC constexpr explicit evaluator(const XprType& xpr) : Base(xpr) {}
|
||||
};
|
||||
@@ -915,7 +912,7 @@ struct evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>>
|
||||
template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3>
|
||||
struct ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>, IndexBased, IndexBased>
|
||||
: evaluator_base<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> {
|
||||
typedef CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> XprType;
|
||||
using XprType = CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>;
|
||||
|
||||
enum {
|
||||
CoeffReadCost = int(evaluator<Arg1>::CoeffReadCost) + int(evaluator<Arg2>::CoeffReadCost) +
|
||||
@@ -943,7 +940,7 @@ struct ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>, 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<CwiseTernaryOp<scalar_boolean_select_op<Scalar, Scalar, bool>,
|
||||
// this is a binary expression
|
||||
template <typename BinaryOp, typename Lhs, typename Rhs>
|
||||
struct evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> : public binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> {
|
||||
typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;
|
||||
typedef binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> Base;
|
||||
using XprType = CwiseBinaryOp<BinaryOp, Lhs, Rhs>;
|
||||
using Base = binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>>;
|
||||
|
||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit evaluator(const XprType& xpr) : Base(xpr) {}
|
||||
};
|
||||
@@ -1042,7 +1039,7 @@ struct evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> : public binary_evaluator<Cw
|
||||
template <typename BinaryOp, typename Lhs, typename Rhs>
|
||||
struct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IndexBased, IndexBased>
|
||||
: evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> {
|
||||
typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;
|
||||
using XprType = CwiseBinaryOp<BinaryOp, Lhs, Rhs>;
|
||||
|
||||
enum {
|
||||
CoeffReadCost =
|
||||
@@ -1066,7 +1063,7 @@ struct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, 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<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IndexBased, IndexBase
|
||||
template <typename UnaryOp, typename ArgType, typename StrideType>
|
||||
struct unary_evaluator<CwiseUnaryView<UnaryOp, ArgType, StrideType>, IndexBased>
|
||||
: evaluator_base<CwiseUnaryView<UnaryOp, ArgType, StrideType>> {
|
||||
typedef CwiseUnaryView<UnaryOp, ArgType, StrideType> XprType;
|
||||
using XprType = CwiseUnaryView<UnaryOp, ArgType, StrideType>;
|
||||
|
||||
enum {
|
||||
CoeffReadCost = int(evaluator<ArgType>::CoeffReadCost) + int(functor_traits<UnaryOp>::Cost),
|
||||
@@ -1134,8 +1131,8 @@ struct unary_evaluator<CwiseUnaryView<UnaryOp, ArgType, StrideType>, 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 <typename Derived, typename PlainObjectType>
|
||||
struct mapbase_evaluator : evaluator_base<Derived> {
|
||||
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<Derived> {
|
||||
template <typename PlainObjectType, int MapOptions, typename StrideType>
|
||||
struct evaluator<Map<PlainObjectType, MapOptions, StrideType>>
|
||||
: public mapbase_evaluator<Map<PlainObjectType, MapOptions, StrideType>, PlainObjectType> {
|
||||
typedef Map<PlainObjectType, MapOptions, StrideType> XprType;
|
||||
typedef typename XprType::Scalar Scalar;
|
||||
using XprType = Map<PlainObjectType, MapOptions, StrideType>;
|
||||
using Scalar = typename XprType::Scalar;
|
||||
// TODO: should check for smaller packet types once we can handle multi-sized packet types
|
||||
typedef typename packet_traits<Scalar>::type PacketScalar;
|
||||
using PacketScalar = typename packet_traits<Scalar>::type;
|
||||
|
||||
enum {
|
||||
InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0
|
||||
@@ -1308,7 +1305,7 @@ struct evaluator<Map<PlainObjectType, MapOptions, StrideType>>
|
||||
template <typename PlainObjectType, int RefOptions, typename StrideType>
|
||||
struct evaluator<Ref<PlainObjectType, RefOptions, StrideType>>
|
||||
: public mapbase_evaluator<Ref<PlainObjectType, RefOptions, StrideType>, PlainObjectType> {
|
||||
typedef Ref<PlainObjectType, RefOptions, StrideType> XprType;
|
||||
using XprType = Ref<PlainObjectType, RefOptions, StrideType>;
|
||||
|
||||
enum {
|
||||
Flags = evaluator<Map<PlainObjectType, RefOptions, StrideType>>::Flags,
|
||||
@@ -1328,10 +1325,10 @@ struct block_evaluator;
|
||||
template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
|
||||
struct evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>>
|
||||
: block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel> {
|
||||
typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
|
||||
typedef typename XprType::Scalar Scalar;
|
||||
using XprType = Block<ArgType, BlockRows, BlockCols, InnerPanel>;
|
||||
using Scalar = typename XprType::Scalar;
|
||||
// TODO: should check for smaller packet types once we can handle multi-sized packet types
|
||||
typedef typename packet_traits<Scalar>::type PacketScalar;
|
||||
using PacketScalar = typename packet_traits<Scalar>::type;
|
||||
|
||||
enum {
|
||||
CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
|
||||
@@ -1368,7 +1365,7 @@ struct evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>>
|
||||
: 0,
|
||||
Alignment = plain_enum_min(evaluator<ArgType>::Alignment, Alignment0)
|
||||
};
|
||||
typedef block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel> block_evaluator_type;
|
||||
using block_evaluator_type = block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel>;
|
||||
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<Block<ArgType, BlockRows, BlockCols, InnerPanel>>
|
||||
template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
|
||||
struct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, /*HasDirectAccess*/ false>
|
||||
: unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>> {
|
||||
typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
|
||||
using XprType = Block<ArgType, BlockRows, BlockCols, InnerPanel>;
|
||||
|
||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit block_evaluator(const XprType& block)
|
||||
: unary_evaluator<XprType>(block) {}
|
||||
@@ -1388,7 +1385,7 @@ struct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, /*HasDirectAcc
|
||||
template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
|
||||
struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBased>
|
||||
: evaluator_base<Block<ArgType, BlockRows, BlockCols, InnerPanel>> {
|
||||
typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
|
||||
using XprType = Block<ArgType, BlockRows, BlockCols, InnerPanel>;
|
||||
|
||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& block)
|
||||
: m_argImpl(block.nestedExpression()),
|
||||
@@ -1400,8 +1397,8 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, 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<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
|
||||
|
||||
template <int LoadMode, typename PacketType>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index) const {
|
||||
if (ForwardLinearAccess)
|
||||
return m_argImpl.template packet<LoadMode, PacketType>(m_linear_offset.value() + index);
|
||||
else
|
||||
return packet<LoadMode, PacketType>(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
|
||||
EIGEN_IF_CONSTEXPR(ForwardLinearAccess)
|
||||
return m_argImpl.template packet<LoadMode, PacketType>(m_linear_offset.value() + index);
|
||||
else return packet<LoadMode, PacketType>(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
|
||||
}
|
||||
|
||||
template <int StoreMode, typename PacketType>
|
||||
@@ -1445,11 +1441,10 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
|
||||
|
||||
template <int StoreMode, typename PacketType>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacket(Index index, const PacketType& x) {
|
||||
if (ForwardLinearAccess)
|
||||
return m_argImpl.template writePacket<StoreMode, PacketType>(m_linear_offset.value() + index, x);
|
||||
else
|
||||
return writePacket<StoreMode, PacketType>(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0,
|
||||
x);
|
||||
EIGEN_IF_CONSTEXPR(ForwardLinearAccess)
|
||||
return m_argImpl.template writePacket<StoreMode, PacketType>(m_linear_offset.value() + index, x);
|
||||
else return writePacket<StoreMode, PacketType>(RowsAtCompileTime == 1 ? 0 : index,
|
||||
RowsAtCompileTime == 1 ? index : 0, x);
|
||||
}
|
||||
|
||||
template <int LoadMode, typename PacketType>
|
||||
@@ -1460,11 +1455,10 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
|
||||
|
||||
template <int LoadMode, typename PacketType>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index index, Index begin, Index count) const {
|
||||
if (ForwardLinearAccess)
|
||||
return m_argImpl.template packetSegment<LoadMode, PacketType>(m_linear_offset.value() + index, begin, count);
|
||||
else
|
||||
return packetSegment<LoadMode, PacketType>(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0,
|
||||
begin, count);
|
||||
EIGEN_IF_CONSTEXPR(ForwardLinearAccess)
|
||||
return m_argImpl.template packetSegment<LoadMode, PacketType>(m_linear_offset.value() + index, begin, count);
|
||||
else return packetSegment<LoadMode, PacketType>(RowsAtCompileTime == 1 ? 0 : index,
|
||||
RowsAtCompileTime == 1 ? index : 0, begin, count);
|
||||
}
|
||||
|
||||
template <int StoreMode, typename PacketType>
|
||||
@@ -1477,12 +1471,11 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa
|
||||
template <int StoreMode, typename PacketType>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacketSegment(Index index, const PacketType& x, Index begin,
|
||||
Index count) {
|
||||
if (ForwardLinearAccess)
|
||||
return m_argImpl.template writePacketSegment<StoreMode, PacketType>(m_linear_offset.value() + index, x, begin,
|
||||
count);
|
||||
else
|
||||
return writePacketSegment<StoreMode, PacketType>(RowsAtCompileTime == 1 ? 0 : index,
|
||||
RowsAtCompileTime == 1 ? index : 0, x, begin, count);
|
||||
EIGEN_IF_CONSTEXPR(ForwardLinearAccess)
|
||||
return m_argImpl.template writePacketSegment<StoreMode, PacketType>(m_linear_offset.value() + index, x, begin,
|
||||
count);
|
||||
else return writePacketSegment<StoreMode, PacketType>(RowsAtCompileTime == 1 ? 0 : index,
|
||||
RowsAtCompileTime == 1 ? index : 0, x, begin, count);
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -1517,8 +1510,8 @@ template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
|
||||
struct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, /* HasDirectAccess */ true>
|
||||
: mapbase_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>,
|
||||
typename Block<ArgType, BlockRows, BlockCols, InnerPanel>::PlainObject> {
|
||||
typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
|
||||
typedef typename XprType::Scalar Scalar;
|
||||
using XprType = Block<ArgType, BlockRows, BlockCols, InnerPanel>;
|
||||
using Scalar = typename XprType::Scalar;
|
||||
|
||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit block_evaluator(const XprType& block)
|
||||
: mapbase_evaluator<XprType, typename XprType::PlainObject>(block) {
|
||||
@@ -1533,11 +1526,11 @@ struct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, /* HasDirectAc
|
||||
template <typename ArgType, int RowFactor, int ColFactor>
|
||||
struct unary_evaluator<Replicate<ArgType, RowFactor, ColFactor>>
|
||||
: evaluator_base<Replicate<ArgType, RowFactor, ColFactor>> {
|
||||
typedef Replicate<ArgType, RowFactor, ColFactor> XprType;
|
||||
typedef typename XprType::CoeffReturnType CoeffReturnType;
|
||||
using XprType = Replicate<ArgType, RowFactor, ColFactor>;
|
||||
using CoeffReturnType = typename XprType::CoeffReturnType;
|
||||
enum { Factor = (RowFactor == Dynamic || ColFactor == Dynamic) ? Dynamic : RowFactor * ColFactor };
|
||||
typedef typename nested_eval<ArgType, Factor>::type ArgTypeNested;
|
||||
typedef remove_all_t<ArgTypeNested> ArgTypeNestedCleaned;
|
||||
using ArgTypeNested = typename nested_eval<ArgType, Factor>::type;
|
||||
using ArgTypeNestedCleaned = remove_all_t<ArgTypeNested>;
|
||||
|
||||
enum {
|
||||
CoeffReadCost = evaluator<ArgTypeNestedCleaned>::CoeffReadCost,
|
||||
@@ -1619,7 +1612,7 @@ struct unary_evaluator<Replicate<ArgType, RowFactor, ColFactor>>
|
||||
|
||||
template <typename XprType>
|
||||
struct evaluator_wrapper_base : evaluator_base<XprType> {
|
||||
typedef remove_all_t<typename XprType::NestedExpressionType> ArgType;
|
||||
using ArgType = remove_all_t<typename XprType::NestedExpressionType>;
|
||||
enum {
|
||||
CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
|
||||
Flags = evaluator<ArgType>::Flags,
|
||||
@@ -1628,8 +1621,8 @@ struct evaluator_wrapper_base : evaluator_base<XprType> {
|
||||
|
||||
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<XprType> {
|
||||
|
||||
template <typename TArgType>
|
||||
struct unary_evaluator<MatrixWrapper<TArgType>> : evaluator_wrapper_base<MatrixWrapper<TArgType>> {
|
||||
typedef MatrixWrapper<TArgType> XprType;
|
||||
using XprType = MatrixWrapper<TArgType>;
|
||||
|
||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& wrapper)
|
||||
: evaluator_wrapper_base<MatrixWrapper<TArgType>>(wrapper.nestedExpression()) {}
|
||||
@@ -1701,7 +1694,7 @@ struct unary_evaluator<MatrixWrapper<TArgType>> : evaluator_wrapper_base<MatrixW
|
||||
|
||||
template <typename TArgType>
|
||||
struct unary_evaluator<ArrayWrapper<TArgType>> : evaluator_wrapper_base<ArrayWrapper<TArgType>> {
|
||||
typedef ArrayWrapper<TArgType> XprType;
|
||||
using XprType = ArrayWrapper<TArgType>;
|
||||
|
||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& wrapper)
|
||||
: evaluator_wrapper_base<ArrayWrapper<TArgType>>(wrapper.nestedExpression()) {}
|
||||
@@ -1715,9 +1708,9 @@ struct reverse_packet_cond;
|
||||
|
||||
template <typename ArgType, int Direction>
|
||||
struct unary_evaluator<Reverse<ArgType, Direction>> : evaluator_base<Reverse<ArgType, Direction>> {
|
||||
typedef Reverse<ArgType, Direction> XprType;
|
||||
typedef typename XprType::Scalar Scalar;
|
||||
typedef typename XprType::CoeffReturnType CoeffReturnType;
|
||||
using XprType = Reverse<ArgType, Direction>;
|
||||
using Scalar = typename XprType::Scalar;
|
||||
using CoeffReturnType = typename XprType::CoeffReturnType;
|
||||
|
||||
enum {
|
||||
IsRowMajor = XprType::IsRowMajor,
|
||||
@@ -1872,13 +1865,13 @@ struct unary_evaluator<Reverse<ArgType, Direction>> : evaluator_base<Reverse<Arg
|
||||
|
||||
template <typename ArgType, int DiagIndex>
|
||||
struct evaluator<Diagonal<ArgType, DiagIndex>> : evaluator_base<Diagonal<ArgType, DiagIndex>> {
|
||||
typedef Diagonal<ArgType, DiagIndex> XprType;
|
||||
using XprType = Diagonal<ArgType, DiagIndex>;
|
||||
|
||||
enum {
|
||||
CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
|
||||
|
||||
Flags =
|
||||
(unsigned int)(evaluator<ArgType>::Flags & (HereditaryBits | DirectAccessBit) & ~RowMajorBit) | LinearAccessBit,
|
||||
Flags = static_cast<unsigned int>(evaluator<ArgType>::Flags & (HereditaryBits | DirectAccessBit) & ~RowMajorBit) |
|
||||
LinearAccessBit,
|
||||
|
||||
Alignment = 0
|
||||
};
|
||||
@@ -1886,8 +1879,8 @@ struct evaluator<Diagonal<ArgType, DiagIndex>> : evaluator_base<Diagonal<ArgType
|
||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit evaluator(const XprType& diagonal)
|
||||
: m_argImpl(diagonal.nestedExpression()), m_index(diagonal.index()) {}
|
||||
|
||||
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) const {
|
||||
return m_argImpl.coeff(row + rowOffset(), row + colOffset());
|
||||
@@ -1931,7 +1924,7 @@ struct traits<EvalToTemp<ArgType>> : public traits<ArgType> {};
|
||||
template <typename ArgType>
|
||||
class EvalToTemp : public dense_xpr_base<EvalToTemp<ArgType>>::type {
|
||||
public:
|
||||
typedef typename dense_xpr_base<EvalToTemp>::type Base;
|
||||
using Base = typename dense_xpr_base<EvalToTemp>::type;
|
||||
EIGEN_GENERIC_PUBLIC_INTERFACE(EvalToTemp)
|
||||
|
||||
explicit EvalToTemp(const ArgType& arg) : m_arg(arg) {}
|
||||
@@ -1948,9 +1941,9 @@ class EvalToTemp : public dense_xpr_base<EvalToTemp<ArgType>>::type {
|
||||
|
||||
template <typename ArgType>
|
||||
struct evaluator<EvalToTemp<ArgType>> : public evaluator<typename ArgType::PlainObject> {
|
||||
typedef EvalToTemp<ArgType> XprType;
|
||||
typedef typename ArgType::PlainObject PlainObject;
|
||||
typedef evaluator<PlainObject> Base;
|
||||
using XprType = EvalToTemp<ArgType>;
|
||||
using PlainObject = typename ArgType::PlainObject;
|
||||
using Base = evaluator<PlainObject>;
|
||||
|
||||
EIGEN_DEVICE_FUNC constexpr explicit evaluator(const XprType& xpr) : m_result(xpr.arg()) {
|
||||
internal::construct_at<Base>(this, m_result);
|
||||
|
||||
@@ -311,9 +311,7 @@ struct unary_evaluator<IndexedView<ArgType, RowIndices, ColIndices>, IndexBased>
|
||||
|
||||
// Catch assignments to an IndexedView.
|
||||
template <typename ArgType, typename RowIndices, typename ColIndices>
|
||||
struct evaluator_assume_aliasing<IndexedView<ArgType, RowIndices, ColIndices>> {
|
||||
static const bool value = true;
|
||||
};
|
||||
struct evaluator_assume_aliasing<IndexedView<ArgType, RowIndices, ColIndices>> : std::true_type {};
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
|
||||
@@ -42,12 +42,12 @@ namespace internal {
|
||||
/* logic deciding a strategy for unrolling of vectorized paths */
|
||||
template <typename Func, typename Evaluator>
|
||||
struct packetwise_redux_traits {
|
||||
enum {
|
||||
OuterSize = int(Evaluator::IsRowMajor) ? Evaluator::RowsAtCompileTime : Evaluator::ColsAtCompileTime,
|
||||
Cost = OuterSize == Dynamic ? HugeCost
|
||||
: OuterSize * Evaluator::CoeffReadCost + (OuterSize - 1) * functor_traits<Func>::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<Func>::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 <typename Func, typename Evaluator>
|
||||
struct packetwise_redux_impl<Func, Evaluator, CompleteUnrolling> {
|
||||
typedef redux_novec_unroller<Func, Evaluator, 0, Evaluator::SizeAtCompileTime> Base;
|
||||
typedef typename Evaluator::Scalar Scalar;
|
||||
using Base = redux_novec_unroller<Func, Evaluator, 0, Evaluator::SizeAtCompileTime>;
|
||||
using Scalar = typename Evaluator::Scalar;
|
||||
|
||||
template <typename PacketType>
|
||||
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<Func, Evaluator, Start, 0> {
|
||||
/* Perform the actual reduction for dynamic sizes */
|
||||
template <typename Func, typename Evaluator>
|
||||
struct packetwise_redux_impl<Func, Evaluator, NoUnrolling> {
|
||||
typedef typename Evaluator::Scalar Scalar;
|
||||
typedef typename redux_traits<Func, Evaluator>::PacketType PacketScalar;
|
||||
using Scalar = typename Evaluator::Scalar;
|
||||
using PacketScalar = typename redux_traits<Func, Evaluator>::PacketType;
|
||||
|
||||
template <typename PacketType>
|
||||
EIGEN_DEVICE_FUNC static PacketType run(const Evaluator& eval, const Func& func, Index size) {
|
||||
@@ -122,8 +122,8 @@ struct packetwise_redux_impl<Func, Evaluator, NoUnrolling> {
|
||||
|
||||
template <typename Func, typename Evaluator>
|
||||
struct packetwise_segment_redux_impl {
|
||||
typedef typename Evaluator::Scalar Scalar;
|
||||
typedef typename redux_traits<Func, Evaluator>::PacketType PacketScalar;
|
||||
using Scalar = typename Evaluator::Scalar;
|
||||
using PacketScalar = typename redux_traits<Func, Evaluator>::PacketType;
|
||||
|
||||
template <typename PacketType>
|
||||
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 <typename ArgType, typename MemberOp, int Direction>
|
||||
struct evaluator<PartialReduxExpr<ArgType, MemberOp, Direction> >
|
||||
: evaluator_base<PartialReduxExpr<ArgType, MemberOp, Direction> > {
|
||||
typedef PartialReduxExpr<ArgType, MemberOp, Direction> XprType;
|
||||
typedef typename internal::nested_eval<ArgType, 1>::type ArgTypeNested;
|
||||
typedef add_const_on_value_type_t<ArgTypeNested> ConstArgTypeNested;
|
||||
typedef internal::remove_all_t<ArgTypeNested> ArgTypeNestedCleaned;
|
||||
typedef typename ArgType::Scalar InputScalar;
|
||||
typedef typename XprType::Scalar Scalar;
|
||||
using XprType = PartialReduxExpr<ArgType, MemberOp, Direction>;
|
||||
using ArgTypeNested = typename internal::nested_eval<ArgType, 1>::type;
|
||||
using ConstArgTypeNested = add_const_on_value_type_t<ArgTypeNested>;
|
||||
using ArgTypeNestedCleaned = internal::remove_all_t<ArgTypeNested>;
|
||||
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<int(TraversalSize)> CostOpType;
|
||||
using CostOpType = typename MemberOp::template Cost<int(TraversalSize)>;
|
||||
enum {
|
||||
CoeffReadCost = TraversalSize == Dynamic ? HugeCost
|
||||
: TraversalSize == 0
|
||||
@@ -174,7 +174,7 @@ struct evaluator<PartialReduxExpr<ArgType, MemberOp, Direction> >
|
||||
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<PartialReduxExpr<ArgType, MemberOp, Direction> >
|
||||
// See bug 1612, currently if PacketSize==1 (i.e. complex<double> 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<PacketType>(coeff(idx));
|
||||
EIGEN_IF_CONSTEXPR(PacketSize == 1) return internal::pset1<PacketType>(coeff(idx));
|
||||
|
||||
Index startRow = Direction == Vertical ? 0 : idx;
|
||||
Index startCol = Direction == Vertical ? idx : 0;
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace internal {
|
||||
*/
|
||||
template <typename Lhs, typename Rhs, int Options>
|
||||
struct evaluator<Product<Lhs, Rhs, Options>> : public product_evaluator<Product<Lhs, Rhs, Options>> {
|
||||
typedef Product<Lhs, Rhs, Options> XprType;
|
||||
typedef product_evaluator<XprType> Base;
|
||||
using XprType = Product<Lhs, Rhs, Options>;
|
||||
using Base = product_evaluator<XprType>;
|
||||
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& xpr) : Base(xpr) {}
|
||||
};
|
||||
@@ -40,19 +40,16 @@ struct evaluator<Product<Lhs, Rhs, Options>> : public product_evaluator<Product<
|
||||
template <typename Lhs, typename Rhs, typename Scalar1, typename Scalar2, typename Plain1>
|
||||
struct evaluator_assume_aliasing<CwiseBinaryOp<internal::scalar_product_op<Scalar1, Scalar2>,
|
||||
const CwiseNullaryOp<internal::scalar_constant_op<Scalar1>, Plain1>,
|
||||
const Product<Lhs, Rhs, DefaultProduct>>> {
|
||||
static const bool value = true;
|
||||
};
|
||||
const Product<Lhs, Rhs, DefaultProduct>>> : std::true_type {};
|
||||
template <typename Lhs, typename Rhs, typename Scalar1, typename Scalar2, typename Plain1>
|
||||
struct evaluator<CwiseBinaryOp<internal::scalar_product_op<Scalar1, Scalar2>,
|
||||
const CwiseNullaryOp<internal::scalar_constant_op<Scalar1>, Plain1>,
|
||||
const Product<Lhs, Rhs, DefaultProduct>>>
|
||||
: public evaluator<Product<EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar1, Lhs, product), Rhs, DefaultProduct>> {
|
||||
typedef CwiseBinaryOp<internal::scalar_product_op<Scalar1, Scalar2>,
|
||||
const CwiseNullaryOp<internal::scalar_constant_op<Scalar1>, Plain1>,
|
||||
const Product<Lhs, Rhs, DefaultProduct>>
|
||||
XprType;
|
||||
typedef evaluator<Product<EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar1, Lhs, product), Rhs, DefaultProduct>> Base;
|
||||
using XprType = CwiseBinaryOp<internal::scalar_product_op<Scalar1, Scalar2>,
|
||||
const CwiseNullaryOp<internal::scalar_constant_op<Scalar1>, Plain1>,
|
||||
const Product<Lhs, Rhs, DefaultProduct>>;
|
||||
using Base = evaluator<Product<EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar1, Lhs, product), Rhs, DefaultProduct>>;
|
||||
|
||||
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<CwiseBinaryOp<internal::scalar_product_op<Scalar1, Scalar2>,
|
||||
template <typename Lhs, typename Rhs, int DiagIndex>
|
||||
struct evaluator<Diagonal<const Product<Lhs, Rhs, DefaultProduct>, DiagIndex>>
|
||||
: public evaluator<Diagonal<const Product<Lhs, Rhs, LazyProduct>, DiagIndex>> {
|
||||
typedef Diagonal<const Product<Lhs, Rhs, DefaultProduct>, DiagIndex> XprType;
|
||||
typedef evaluator<Diagonal<const Product<Lhs, Rhs, LazyProduct>, DiagIndex>> Base;
|
||||
using XprType = Diagonal<const Product<Lhs, Rhs, DefaultProduct>, DiagIndex>;
|
||||
using Base = evaluator<Diagonal<const Product<Lhs, Rhs, LazyProduct>, DiagIndex>>;
|
||||
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& xpr)
|
||||
: Base(Diagonal<const Product<Lhs, Rhs, LazyProduct>, DiagIndex>(
|
||||
@@ -78,18 +75,16 @@ template <typename Lhs, typename Rhs, typename LhsShape = typename evaluator_tra
|
||||
struct generic_product_impl;
|
||||
|
||||
template <typename Lhs, typename Rhs>
|
||||
struct evaluator_assume_aliasing<Product<Lhs, Rhs, DefaultProduct>> {
|
||||
static const bool value = true;
|
||||
};
|
||||
struct evaluator_assume_aliasing<Product<Lhs, Rhs, DefaultProduct>> : std::true_type {};
|
||||
|
||||
// This is the default evaluator implementation for products:
|
||||
// It creates a temporary and call generic_product_impl
|
||||
template <typename Lhs, typename Rhs, int Options, int ProductTag, typename LhsShape, typename RhsShape>
|
||||
struct product_evaluator<Product<Lhs, Rhs, Options>, ProductTag, LhsShape, RhsShape>
|
||||
: public evaluator<typename Product<Lhs, Rhs, Options>::PlainObject> {
|
||||
typedef Product<Lhs, Rhs, Options> XprType;
|
||||
typedef typename XprType::PlainObject PlainObject;
|
||||
typedef evaluator<PlainObject> Base;
|
||||
using XprType = Product<Lhs, Rhs, Options>;
|
||||
using PlainObject = typename XprType::PlainObject;
|
||||
using Base = evaluator<PlainObject>;
|
||||
enum { Flags = Base::Flags | EvalBeforeNestingBit };
|
||||
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit product_evaluator(const XprType& xpr)
|
||||
@@ -123,7 +118,7 @@ struct product_evaluator<Product<Lhs, Rhs, Options>, ProductTag, LhsShape, RhsSh
|
||||
template <typename DstXprType, typename Lhs, typename Rhs, int Options, typename Scalar>
|
||||
struct Assignment<DstXprType, Product<Lhs, Rhs, Options>, internal::assign_op<Scalar, Scalar>, Dense2Dense,
|
||||
std::enable_if_t<(Options == DefaultProduct || Options == AliasFreeProduct)>> {
|
||||
typedef Product<Lhs, Rhs, Options> SrcXprType;
|
||||
using SrcXprType = Product<Lhs, Rhs, Options>;
|
||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(DstXprType& dst, const SrcXprType& src,
|
||||
const internal::assign_op<Scalar, Scalar>&) {
|
||||
Index dstRows = src.rows();
|
||||
@@ -138,7 +133,7 @@ struct Assignment<DstXprType, Product<Lhs, Rhs, Options>, internal::assign_op<Sc
|
||||
template <typename DstXprType, typename Lhs, typename Rhs, int Options, typename Scalar>
|
||||
struct Assignment<DstXprType, Product<Lhs, Rhs, Options>, internal::add_assign_op<Scalar, Scalar>, Dense2Dense,
|
||||
std::enable_if_t<(Options == DefaultProduct || Options == AliasFreeProduct)>> {
|
||||
typedef Product<Lhs, Rhs, Options> SrcXprType;
|
||||
using SrcXprType = Product<Lhs, Rhs, Options>;
|
||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(DstXprType& dst, const SrcXprType& src,
|
||||
const internal::add_assign_op<Scalar, Scalar>&) {
|
||||
eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols());
|
||||
@@ -151,7 +146,7 @@ struct Assignment<DstXprType, Product<Lhs, Rhs, Options>, internal::add_assign_o
|
||||
template <typename DstXprType, typename Lhs, typename Rhs, int Options, typename Scalar>
|
||||
struct Assignment<DstXprType, Product<Lhs, Rhs, Options>, internal::sub_assign_op<Scalar, Scalar>, Dense2Dense,
|
||||
std::enable_if_t<(Options == DefaultProduct || Options == AliasFreeProduct)>> {
|
||||
typedef Product<Lhs, Rhs, Options> SrcXprType;
|
||||
using SrcXprType = Product<Lhs, Rhs, Options>;
|
||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(DstXprType& dst, const SrcXprType& src,
|
||||
const internal::sub_assign_op<Scalar, Scalar>&) {
|
||||
eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols());
|
||||
@@ -170,10 +165,9 @@ struct Assignment<DstXprType,
|
||||
const CwiseNullaryOp<internal::scalar_constant_op<ScalarBis>, Plain>,
|
||||
const Product<Lhs, Rhs, DefaultProduct>>,
|
||||
AssignFunc, Dense2Dense> {
|
||||
typedef CwiseBinaryOp<internal::scalar_product_op<ScalarBis, Scalar>,
|
||||
const CwiseNullaryOp<internal::scalar_constant_op<ScalarBis>, Plain>,
|
||||
const Product<Lhs, Rhs, DefaultProduct>>
|
||||
SrcXprType;
|
||||
using SrcXprType = CwiseBinaryOp<internal::scalar_product_op<ScalarBis, Scalar>,
|
||||
const CwiseNullaryOp<internal::scalar_constant_op<ScalarBis>, Plain>,
|
||||
const Product<Lhs, Rhs, DefaultProduct>>;
|
||||
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<typename OtherXpr::Scalar, typename Product<Lhs, Rhs, DefaultProduct>::Scalar>,
|
||||
const OtherXpr, const Product<Lhs, Rhs, DefaultProduct>>,
|
||||
DenseShape> {
|
||||
static const bool value = true;
|
||||
};
|
||||
DenseShape> : std::true_type {};
|
||||
|
||||
template <typename OtherXpr, typename Lhs, typename Rhs>
|
||||
struct evaluator_assume_aliasing<
|
||||
CwiseBinaryOp<
|
||||
internal::scalar_difference_op<typename OtherXpr::Scalar, typename Product<Lhs, Rhs, DefaultProduct>::Scalar>,
|
||||
const OtherXpr, const Product<Lhs, Rhs, DefaultProduct>>,
|
||||
DenseShape> {
|
||||
static const bool value = true;
|
||||
};
|
||||
DenseShape> : std::true_type {};
|
||||
|
||||
template <typename DstXprType, typename OtherXpr, typename ProductType, typename Func1, typename Func2>
|
||||
struct assignment_from_xpr_op_product {
|
||||
@@ -284,7 +274,7 @@ template <typename Lhs, typename Rhs>
|
||||
struct generic_product_impl<Lhs, Rhs, DenseShape, DenseShape, OuterProduct> {
|
||||
template <typename T>
|
||||
struct is_row_major : bool_constant<(int(T::Flags) & RowMajorBit)> {};
|
||||
typedef typename Product<Lhs, Rhs>::Scalar Scalar;
|
||||
using Scalar = typename Product<Lhs, Rhs>::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<Lhs, Rhs, DenseShape, DenseShape, OuterProduct> {
|
||||
// This base class provides default implementations for evalTo, addTo, subTo, in terms of scaleAndAddTo
|
||||
template <typename Lhs, typename Rhs, typename Derived>
|
||||
struct generic_product_impl_base {
|
||||
typedef typename Product<Lhs, Rhs>::Scalar Scalar;
|
||||
using Scalar = typename Product<Lhs, Rhs>::Scalar;
|
||||
|
||||
template <typename Dst>
|
||||
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 <typename Lhs, typename Rhs>
|
||||
struct generic_product_impl<Lhs, Rhs, DenseShape, DenseShape, GemvProduct>
|
||||
: generic_product_impl_base<Lhs, Rhs, generic_product_impl<Lhs, Rhs, DenseShape, DenseShape, GemvProduct>> {
|
||||
typedef typename nested_eval<Lhs, 1>::type LhsNested;
|
||||
typedef typename nested_eval<Rhs, 1>::type RhsNested;
|
||||
typedef typename Product<Lhs, Rhs>::Scalar Scalar;
|
||||
using LhsNested = typename nested_eval<Lhs, 1>::type;
|
||||
using RhsNested = typename nested_eval<Rhs, 1>::type;
|
||||
using Scalar = typename Product<Lhs, Rhs>::Scalar;
|
||||
enum { Side = Lhs::IsVectorAtCompileTime ? OnTheLeft : OnTheRight };
|
||||
typedef internal::remove_all_t<std::conditional_t<int(Side) == OnTheRight, LhsNested, RhsNested>> MatrixType;
|
||||
using MatrixType = internal::remove_all_t<std::conditional_t<int(Side) == OnTheRight, LhsNested, RhsNested>>;
|
||||
|
||||
template <typename Dest>
|
||||
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<Lhs, Rhs, DenseShape, DenseShape, GemvProduct>
|
||||
|
||||
template <typename Lhs, typename Rhs>
|
||||
struct generic_product_impl<Lhs, Rhs, DenseShape, DenseShape, CoeffBasedProductMode> {
|
||||
typedef typename Product<Lhs, Rhs>::Scalar Scalar;
|
||||
using Scalar = typename Product<Lhs, Rhs>::Scalar;
|
||||
|
||||
template <typename Dst>
|
||||
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 <typename Lhs, typename Rhs, int ProductTag>
|
||||
struct product_evaluator<Product<Lhs, Rhs, LazyProduct>, ProductTag, DenseShape, DenseShape>
|
||||
: evaluator_base<Product<Lhs, Rhs, LazyProduct>> {
|
||||
typedef Product<Lhs, Rhs, LazyProduct> XprType;
|
||||
typedef typename XprType::Scalar Scalar;
|
||||
typedef typename XprType::CoeffReturnType CoeffReturnType;
|
||||
using XprType = Product<Lhs, Rhs, LazyProduct>;
|
||||
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<Product<Lhs, Rhs, LazyProduct>, ProductTag, DenseShape,
|
||||
|
||||
// Everything below here is taken from CoeffBasedProduct.h
|
||||
|
||||
typedef typename internal::nested_eval<Lhs, Rhs::ColsAtCompileTime>::type LhsNested;
|
||||
typedef typename internal::nested_eval<Rhs, Lhs::RowsAtCompileTime>::type RhsNested;
|
||||
using LhsNested = typename internal::nested_eval<Lhs, Rhs::ColsAtCompileTime>::type;
|
||||
using RhsNested = typename internal::nested_eval<Rhs, Lhs::RowsAtCompileTime>::type;
|
||||
|
||||
typedef internal::remove_all_t<LhsNested> LhsNestedCleaned;
|
||||
typedef internal::remove_all_t<RhsNested> RhsNestedCleaned;
|
||||
using LhsNestedCleaned = internal::remove_all_t<LhsNested>;
|
||||
using RhsNestedCleaned = internal::remove_all_t<RhsNested>;
|
||||
|
||||
typedef evaluator<LhsNestedCleaned> LhsEtorType;
|
||||
typedef evaluator<RhsNestedCleaned> RhsEtorType;
|
||||
using LhsEtorType = evaluator<LhsNestedCleaned>;
|
||||
using RhsEtorType = evaluator<RhsNestedCleaned>;
|
||||
|
||||
enum {
|
||||
RowsAtCompileTime = LhsNestedCleaned::RowsAtCompileTime,
|
||||
@@ -521,76 +511,75 @@ struct product_evaluator<Product<Lhs, Rhs, LazyProduct>, ProductTag, DenseShape,
|
||||
MaxColsAtCompileTime = RhsNestedCleaned::MaxColsAtCompileTime
|
||||
};
|
||||
|
||||
typedef typename find_best_packet<Scalar, RowsAtCompileTime>::type LhsVecPacketType;
|
||||
typedef typename find_best_packet<Scalar, ColsAtCompileTime>::type RhsVecPacketType;
|
||||
using LhsVecPacketType = typename find_best_packet<Scalar, RowsAtCompileTime>::type;
|
||||
using RhsVecPacketType = typename find_best_packet<Scalar, ColsAtCompileTime>::type;
|
||||
|
||||
enum {
|
||||
static constexpr int LhsCoeffReadCost = LhsEtorType::CoeffReadCost;
|
||||
static constexpr int RhsCoeffReadCost = RhsEtorType::CoeffReadCost;
|
||||
static constexpr int CoeffReadCost =
|
||||
InnerSize == 0 ? NumTraits<Scalar>::ReadCost
|
||||
: InnerSize == Dynamic
|
||||
? HugeCost
|
||||
: InnerSize * (NumTraits<Scalar>::MulCost + int(LhsCoeffReadCost) + int(RhsCoeffReadCost)) +
|
||||
(InnerSize - 1) * NumTraits<Scalar>::AddCost;
|
||||
|
||||
LhsCoeffReadCost = LhsEtorType::CoeffReadCost,
|
||||
RhsCoeffReadCost = RhsEtorType::CoeffReadCost,
|
||||
CoeffReadCost = InnerSize == 0 ? NumTraits<Scalar>::ReadCost
|
||||
: InnerSize == Dynamic
|
||||
? HugeCost
|
||||
: InnerSize * (NumTraits<Scalar>::MulCost + int(LhsCoeffReadCost) + int(RhsCoeffReadCost)) +
|
||||
(InnerSize - 1) * NumTraits<Scalar>::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<LhsVecPacketType>::size;
|
||||
static constexpr int RhsVecPacketSize = unpacket_traits<RhsVecPacketType>::size;
|
||||
|
||||
LhsVecPacketSize = unpacket_traits<LhsVecPacketType>::size,
|
||||
RhsVecPacketSize = unpacket_traits<RhsVecPacketType>::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<typename LhsNestedCleaned::Scalar, typename RhsNestedCleaned::Scalar>::value;
|
||||
|
||||
SameType = is_same<typename LhsNestedCleaned::Scalar, typename RhsNestedCleaned::Scalar>::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<Scalar>::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<Scalar>::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<Product<Lhs, Rhs, LazyProduct>, ProductTag, DenseShape,
|
||||
template <int LoadMode, typename PacketType>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const PacketType packet(Index row, Index col) const {
|
||||
PacketType res;
|
||||
typedef etor_product_packet_impl<bool(int(Flags) & RowMajorBit) ? RowMajor : ColMajor,
|
||||
Unroll ? int(InnerSize) : Dynamic, LhsEtorType, RhsEtorType, PacketType, LoadMode>
|
||||
PacketImpl;
|
||||
using PacketImpl =
|
||||
etor_product_packet_impl<bool(int(Flags) & RowMajorBit) ? RowMajor : ColMajor,
|
||||
Unroll ? int(InnerSize) : Dynamic, LhsEtorType, RhsEtorType, PacketType, LoadMode>;
|
||||
PacketImpl::run(row, col, m_lhsImpl, m_rhsImpl, m_innerDim, res);
|
||||
return res;
|
||||
}
|
||||
@@ -627,9 +616,9 @@ struct product_evaluator<Product<Lhs, Rhs, LazyProduct>, 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<bool(int(Flags) & RowMajorBit) ? RowMajor : ColMajor,
|
||||
Unroll ? int(InnerSize) : Dynamic, LhsEtorType, RhsEtorType, PacketType, LoadMode>
|
||||
PacketImpl;
|
||||
using PacketImpl =
|
||||
etor_product_packet_impl<bool(int(Flags) & RowMajorBit) ? RowMajor : ColMajor,
|
||||
Unroll ? int(InnerSize) : Dynamic, LhsEtorType, RhsEtorType, PacketType, LoadMode>;
|
||||
PacketImpl::run_segment(row, col, m_lhsImpl, m_rhsImpl, m_innerDim, res, begin, count);
|
||||
return res;
|
||||
}
|
||||
@@ -648,16 +637,15 @@ struct product_evaluator<Product<Lhs, Rhs, LazyProduct>, 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<Index, InnerSize> m_innerDim;
|
||||
};
|
||||
|
||||
template <typename Lhs, typename Rhs>
|
||||
struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, LazyCoeffBasedProductMode, DenseShape, DenseShape>
|
||||
: product_evaluator<Product<Lhs, Rhs, LazyProduct>, CoeffBasedProductMode, DenseShape, DenseShape> {
|
||||
typedef Product<Lhs, Rhs, DefaultProduct> XprType;
|
||||
typedef Product<Lhs, Rhs, LazyProduct> BaseProduct;
|
||||
typedef product_evaluator<BaseProduct, CoeffBasedProductMode, DenseShape, DenseShape> Base;
|
||||
using XprType = Product<Lhs, Rhs, DefaultProduct>;
|
||||
using BaseProduct = Product<Lhs, Rhs, LazyProduct>;
|
||||
using Base = product_evaluator<BaseProduct, CoeffBasedProductMode, DenseShape, DenseShape>;
|
||||
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 <typename Lhs, typename Rhs, int ProductTag>
|
||||
struct generic_product_impl<Lhs, Rhs, TriangularShape, DenseShape, ProductTag>
|
||||
: generic_product_impl_base<Lhs, Rhs, generic_product_impl<Lhs, Rhs, TriangularShape, DenseShape, ProductTag>> {
|
||||
typedef typename Product<Lhs, Rhs>::Scalar Scalar;
|
||||
using Scalar = typename Product<Lhs, Rhs>::Scalar;
|
||||
|
||||
template <typename Dest>
|
||||
static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha) {
|
||||
@@ -812,7 +800,7 @@ struct generic_product_impl<Lhs, Rhs, TriangularShape, DenseShape, ProductTag>
|
||||
template <typename Lhs, typename Rhs, int ProductTag>
|
||||
struct generic_product_impl<Lhs, Rhs, DenseShape, TriangularShape, ProductTag>
|
||||
: generic_product_impl_base<Lhs, Rhs, generic_product_impl<Lhs, Rhs, DenseShape, TriangularShape, ProductTag>> {
|
||||
typedef typename Product<Lhs, Rhs>::Scalar Scalar;
|
||||
using Scalar = typename Product<Lhs, Rhs>::Scalar;
|
||||
|
||||
template <typename Dest>
|
||||
static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha) {
|
||||
@@ -830,7 +818,7 @@ struct selfadjoint_product_impl;
|
||||
template <typename Lhs, typename Rhs, int ProductTag>
|
||||
struct generic_product_impl<Lhs, Rhs, SelfAdjointShape, DenseShape, ProductTag>
|
||||
: generic_product_impl_base<Lhs, Rhs, generic_product_impl<Lhs, Rhs, SelfAdjointShape, DenseShape, ProductTag>> {
|
||||
typedef typename Product<Lhs, Rhs>::Scalar Scalar;
|
||||
using Scalar = typename Product<Lhs, Rhs>::Scalar;
|
||||
|
||||
template <typename Dest>
|
||||
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<Lhs, Rhs, SelfAdjointShape, DenseShape, ProductTag>
|
||||
template <typename Lhs, typename Rhs, int ProductTag>
|
||||
struct generic_product_impl<Lhs, Rhs, DenseShape, SelfAdjointShape, ProductTag>
|
||||
: generic_product_impl_base<Lhs, Rhs, generic_product_impl<Lhs, Rhs, DenseShape, SelfAdjointShape, ProductTag>> {
|
||||
typedef typename Product<Lhs, Rhs>::Scalar Scalar;
|
||||
using Scalar = typename Product<Lhs, Rhs>::Scalar;
|
||||
|
||||
template <typename Dest>
|
||||
static void scaleAndAddTo(Dest& dst, const Lhs& lhs, const Rhs& rhs, const Scalar& alpha) {
|
||||
@@ -857,7 +845,7 @@ struct generic_product_impl<Lhs, Rhs, DenseShape, SelfAdjointShape, ProductTag>
|
||||
|
||||
template <typename MatrixType, typename DiagonalType, typename Derived, int ProductOrder>
|
||||
struct diagonal_product_evaluator_base : evaluator_base<Derived> {
|
||||
typedef typename ScalarBinaryOpTraits<typename MatrixType::Scalar, typename DiagonalType::Scalar>::ReturnType Scalar;
|
||||
using Scalar = typename ScalarBinaryOpTraits<typename MatrixType::Scalar, typename DiagonalType::Scalar>::ReturnType;
|
||||
|
||||
public:
|
||||
enum {
|
||||
@@ -884,8 +872,8 @@ struct diagonal_product_evaluator_base : evaluator_base<Derived> {
|
||||
(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<unsigned int>(MatrixFlags)) |
|
||||
(Vectorizable_ ? PacketAccessBit : 0),
|
||||
Alignment = evaluator<MatrixType>::Alignment,
|
||||
|
||||
AsScalarProduct =
|
||||
@@ -958,17 +946,16 @@ template <typename Lhs, typename Rhs, int ProductKind, int ProductTag>
|
||||
struct product_evaluator<Product<Lhs, Rhs, ProductKind>, ProductTag, DiagonalShape, DenseShape>
|
||||
: diagonal_product_evaluator_base<Rhs, typename Lhs::DiagonalVectorType, Product<Lhs, Rhs, LazyProduct>,
|
||||
OnTheLeft> {
|
||||
typedef diagonal_product_evaluator_base<Rhs, typename Lhs::DiagonalVectorType, Product<Lhs, Rhs, LazyProduct>,
|
||||
OnTheLeft>
|
||||
Base;
|
||||
using Base =
|
||||
diagonal_product_evaluator_base<Rhs, typename Lhs::DiagonalVectorType, Product<Lhs, Rhs, LazyProduct>, OnTheLeft>;
|
||||
using Base::coeff;
|
||||
using Base::m_diagImpl;
|
||||
using Base::m_matImpl;
|
||||
typedef typename Base::Scalar Scalar;
|
||||
using Scalar = typename Base::Scalar;
|
||||
|
||||
typedef Product<Lhs, Rhs, ProductKind> XprType;
|
||||
typedef typename XprType::PlainObject PlainObject;
|
||||
typedef typename Lhs::DiagonalVectorType DiagonalType;
|
||||
using XprType = Product<Lhs, Rhs, ProductKind>;
|
||||
using PlainObject = typename XprType::PlainObject;
|
||||
using DiagonalType = typename Lhs::DiagonalVectorType;
|
||||
|
||||
static constexpr int StorageOrder = Base::StorageOrder_;
|
||||
using IsRowMajor_t = bool_constant<StorageOrder == RowMajor>;
|
||||
@@ -1013,16 +1000,15 @@ template <typename Lhs, typename Rhs, int ProductKind, int ProductTag>
|
||||
struct product_evaluator<Product<Lhs, Rhs, ProductKind>, ProductTag, DenseShape, DiagonalShape>
|
||||
: diagonal_product_evaluator_base<Lhs, typename Rhs::DiagonalVectorType, Product<Lhs, Rhs, LazyProduct>,
|
||||
OnTheRight> {
|
||||
typedef diagonal_product_evaluator_base<Lhs, typename Rhs::DiagonalVectorType, Product<Lhs, Rhs, LazyProduct>,
|
||||
OnTheRight>
|
||||
Base;
|
||||
using Base = diagonal_product_evaluator_base<Lhs, typename Rhs::DiagonalVectorType, Product<Lhs, Rhs, LazyProduct>,
|
||||
OnTheRight>;
|
||||
using Base::coeff;
|
||||
using Base::m_diagImpl;
|
||||
using Base::m_matImpl;
|
||||
typedef typename Base::Scalar Scalar;
|
||||
using Scalar = typename Base::Scalar;
|
||||
|
||||
typedef Product<Lhs, Rhs, ProductKind> XprType;
|
||||
typedef typename XprType::PlainObject PlainObject;
|
||||
using XprType = Product<Lhs, Rhs, ProductKind>;
|
||||
using PlainObject = typename XprType::PlainObject;
|
||||
|
||||
static constexpr int StorageOrder = Base::StorageOrder_;
|
||||
using IsColMajor_t = bool_constant<StorageOrder == ColMajor>;
|
||||
@@ -1071,8 +1057,8 @@ struct permutation_matrix_product;
|
||||
|
||||
template <typename ExpressionType, int Side, bool Transposed>
|
||||
struct permutation_matrix_product<ExpressionType, Side, Transposed, DenseShape> {
|
||||
typedef typename nested_eval<ExpressionType, 1>::type MatrixType;
|
||||
typedef remove_all_t<MatrixType> MatrixTypeCleaned;
|
||||
using MatrixType = typename nested_eval<ExpressionType, 1>::type;
|
||||
using MatrixTypeCleaned = remove_all_t<MatrixType>;
|
||||
|
||||
template <typename Dest, typename PermutationType>
|
||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Dest& dst, const PermutationType& perm,
|
||||
@@ -1168,14 +1154,14 @@ struct generic_product_impl<Lhs, Inverse<Rhs>, MatrixShape, PermutationShape, Pr
|
||||
*/
|
||||
template <typename ExpressionType, int Side, bool Transposed, typename ExpressionShape>
|
||||
struct transposition_matrix_product {
|
||||
typedef typename nested_eval<ExpressionType, 1>::type MatrixType;
|
||||
typedef remove_all_t<MatrixType> MatrixTypeCleaned;
|
||||
using MatrixType = typename nested_eval<ExpressionType, 1>::type;
|
||||
using MatrixTypeCleaned = remove_all_t<MatrixType>;
|
||||
|
||||
template <typename Dest, typename TranspositionType>
|
||||
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user