10 #ifndef EIGEN_PARTIALREDUX_H
11 #define EIGEN_PARTIALREDUX_H
44 template<
typename Func,
typename Evaluator>
45 struct packetwise_redux_traits
48 OuterSize = int(Evaluator::IsRowMajor) ? Evaluator::RowsAtCompileTime : Evaluator::ColsAtCompileTime,
50 : OuterSize * Evaluator::CoeffReadCost + (OuterSize-1) * functor_traits<Func>::Cost,
57 template<
typename PacketType,
typename Func>
60 const typename unpacket_traits<PacketType>::type zero(0);
61 return pset1<PacketType>(zero);
65 template<
typename PacketType,
typename Scalar>
68 return pset1<PacketType>(Scalar(1));
72 template<
typename Func,
typename Evaluator,
73 int Unrolling = packetwise_redux_traits<Func, Evaluator>::Unrolling
75 struct packetwise_redux_impl;
78 template<
typename Func,
typename Evaluator>
81 typedef redux_novec_unroller<Func,Evaluator, 0, Evaluator::SizeAtCompileTime> Base;
82 typedef typename Evaluator::Scalar Scalar;
84 template<
typename PacketType>
86 PacketType run(
const Evaluator &eval,
const Func& func,
Index )
88 return redux_vec_unroller<Func, Evaluator, 0, packetwise_redux_traits<Func, Evaluator>::OuterSize>::template run<PacketType>(eval,func);
96 template<
typename Func,
typename Evaluator, Index Start>
97 struct redux_vec_unroller<Func, Evaluator, Start, 0>
99 template<
typename PacketType>
101 static EIGEN_STRONG_INLINE PacketType run(
const Evaluator &,
const Func& f)
103 return packetwise_redux_empty_value<PacketType>(f);
108 template<
typename Func,
typename Evaluator>
109 struct packetwise_redux_impl<Func, Evaluator,
NoUnrolling>
111 typedef typename Evaluator::Scalar Scalar;
112 typedef typename redux_traits<Func, Evaluator>::PacketType PacketScalar;
114 template<
typename PacketType>
116 static PacketType run(
const Evaluator &eval,
const Func& func,
Index size)
119 return packetwise_redux_empty_value<PacketType>(func);
122 PacketType
p = eval.template packetByOuterInner<Unaligned,PacketType>(0,0);
130 func.packetOp(eval.template packetByOuterInner<Unaligned,PacketType>(
i+0,0),eval.template packetByOuterInner<Unaligned,PacketType>(
i+1,0)),
131 func.packetOp(eval.template packetByOuterInner<Unaligned,PacketType>(
i+2,0),eval.template packetByOuterInner<Unaligned,PacketType>(
i+3,0))));
133 p = func.packetOp(
p, eval.template packetByOuterInner<Unaligned,PacketType>(
i,0));
138 template<
typename ArgType,
typename MemberOp,
int Direction>
139 struct evaluator<PartialReduxExpr<ArgType, MemberOp, Direction> >
140 : evaluator_base<PartialReduxExpr<ArgType, MemberOp, Direction> >
142 typedef PartialReduxExpr<ArgType, MemberOp, Direction> XprType;
143 typedef typename internal::nested_eval<ArgType,1>::type ArgTypeNested;
144 typedef add_const_on_value_type_t<ArgTypeNested> ConstArgTypeNested;
145 typedef internal::remove_all_t<ArgTypeNested> ArgTypeNestedCleaned;
146 typedef typename ArgType::Scalar InputScalar;
147 typedef typename XprType::Scalar Scalar;
149 TraversalSize = Direction==int(
Vertical) ? int(ArgType::RowsAtCompileTime) : int(ArgType::ColsAtCompileTime)
151 typedef typename MemberOp::template Cost<int(TraversalSize)> CostOpType;
154 : TraversalSize==0 ? 1
155 : int(TraversalSize) * int(evaluator<ArgType>::CoeffReadCost) + int(CostOpType::value),
157 ArgFlags_ = evaluator<ArgType>::Flags,
160 &&
bool(MemberOp::Vectorizable)
162 && (TraversalSize!=0),
173 : m_arg(xpr.nestedExpression()), m_functor(xpr.functor())
179 typedef typename XprType::CoeffReturnType CoeffReturnType;
188 const Scalar coeff(
Index index)
const
193 template<
int LoadMode,
typename PacketType>
197 return packet<LoadMode,PacketType>(Direction==
Vertical ?
j :
i);
200 template<
int LoadMode,
typename PacketType>
202 PacketType packet(
Index idx)
const
205 typedef Block<
const ArgTypeNestedCleaned,
206 Direction==
Vertical ? int(ArgType::RowsAtCompileTime) : int(PacketSize),
207 Direction==
Vertical ? int(PacketSize) : int(ArgType::ColsAtCompileTime),
210 PanelType panel(m_arg,
221 return internal::pset1<PacketType>(coeff(idx));
223 typedef typename internal::redux_evaluator<PanelType> PanelEvaluator;
224 PanelEvaluator panel_eval(panel);
225 typedef typename MemberOp::BinaryOp
BinaryOp;
226 PacketType
p = internal::packetwise_redux_impl<BinaryOp,PanelEvaluator>::template run<PacketType>(panel_eval,m_functor.binaryFunc(),m_arg.outerSize());
231 ConstArgTypeNested m_arg;
232 const MemberOp m_functor;
std::conditional_t< Direction==Vertical, ColXpr, RowXpr > subVector(Index i)
#define EIGEN_DEVICE_FUNC
#define EIGEN_UNROLLING_LIMIT
#define EIGEN_INTERNAL_CHECK_COST_VALUE(C)
const unsigned int PacketAccessBit
const unsigned int LinearAccessBit
const unsigned int RowMajorBit
PacketType packetwise_redux_empty_value(const Func &)
const unsigned int HereditaryBits
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.