12#ifndef EIGEN_COREEVALUATORS_H
13#define EIGEN_COREEVALUATORS_H
16#include "./InternalHeaderCheck.h"
24template <
typename StorageKind>
25struct storage_kind_to_evaluator_kind {
26 typedef IndexBased Kind;
31template <
typename StorageKind>
32struct storage_kind_to_shape;
35struct storage_kind_to_shape<Dense> {
36 typedef DenseShape Shape;
39struct storage_kind_to_shape<SolverStorage> {
40 typedef SolverShape Shape;
43struct storage_kind_to_shape<PermutationStorage> {
44 typedef PermutationShape Shape;
47struct storage_kind_to_shape<TranspositionsStorage> {
48 typedef TranspositionsShape Shape;
66template <typename T, typename Arg1Kind = typename evaluator_traits<typename T::Arg1>::Kind,
67 typename Arg2Kind =
typename evaluator_traits<typename T::Arg2>::Kind,
68 typename Arg3Kind =
typename evaluator_traits<typename T::Arg3>::Kind,
69 typename Arg1Scalar =
typename traits<typename T::Arg1>::Scalar,
70 typename Arg2Scalar =
typename traits<typename T::Arg2>::Scalar,
71 typename Arg3Scalar =
typename traits<typename T::Arg3>::Scalar>
72struct ternary_evaluator;
74template <typename T, typename LhsKind = typename evaluator_traits<typename T::Lhs>::Kind,
75 typename RhsKind =
typename evaluator_traits<typename T::Rhs>::Kind,
76 typename LhsScalar =
typename traits<typename T::Lhs>::Scalar,
77 typename RhsScalar =
typename traits<typename T::Rhs>::Scalar>
78struct binary_evaluator;
80template <typename T, typename Kind = typename evaluator_traits<typename T::NestedExpression>::Kind,
81 typename Scalar =
typename T::Scalar>
82struct unary_evaluator;
87struct evaluator_traits_base {
89 typedef typename storage_kind_to_evaluator_kind<typename traits<T>::StorageKind>::Kind Kind;
90 typedef typename storage_kind_to_shape<typename traits<T>::StorageKind>::Shape Shape;
95struct evaluator_traits :
public evaluator_traits_base<T> {};
97template <typename T, typename Shape = typename evaluator_traits<T>::Shape>
98struct evaluator_assume_aliasing {
99 static const bool value =
false;
104struct evaluator :
public unary_evaluator<T> {
105 typedef unary_evaluator<T> Base;
106 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit evaluator(
const T& xpr) : Base(xpr) {}
111struct evaluator<const T> : evaluator<T> {
112 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit evaluator(
const T& xpr) : evaluator<T>(xpr) {}
117template <
typename ExpressionType>
118struct evaluator_base {
121 typedef traits<ExpressionType> ExpressionTraits;
123 enum { Alignment = 0 };
127 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr evaluator_base() =
default;
130 EIGEN_DEVICE_FUNC evaluator_base(
const evaluator_base&);
131 EIGEN_DEVICE_FUNC
const evaluator_base& operator=(
const evaluator_base&);
142template <
typename Scalar,
int OuterStr
ide>
143class plainobjectbase_evaluator_data {
145 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr plainobjectbase_evaluator_data(
const Scalar* ptr,
Index outerStride)
147#ifndef EIGEN_INTERNAL_DEBUGGING
148 EIGEN_UNUSED_VARIABLE(outerStride);
150 eigen_internal_assert(outerStride == OuterStride);
152 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index outerStride() const noexcept {
return OuterStride; }
156template <
typename Scalar>
157class plainobjectbase_evaluator_data<Scalar,
Dynamic> {
159 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr plainobjectbase_evaluator_data(
const Scalar* ptr,
Index outerStride)
160 : data(ptr), m_outerStride(outerStride) {}
161 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index outerStride()
const {
return m_outerStride; }
168template <
typename Derived>
169struct evaluator<PlainObjectBase<Derived>> : evaluator_base<Derived> {
170 typedef PlainObjectBase<Derived> PlainObjectType;
171 typedef typename PlainObjectType::Scalar Scalar;
172 typedef typename PlainObjectType::CoeffReturnType CoeffReturnType;
175 IsRowMajor = PlainObjectType::IsRowMajor,
176 IsVectorAtCompileTime = PlainObjectType::IsVectorAtCompileTime,
177 RowsAtCompileTime = PlainObjectType::RowsAtCompileTime,
178 ColsAtCompileTime = PlainObjectType::ColsAtCompileTime,
180 CoeffReadCost = NumTraits<Scalar>::ReadCost,
181 Flags = traits<Derived>::EvaluatorFlags,
182 Alignment = traits<Derived>::Alignment
186 OuterStrideAtCompileTime = IsVectorAtCompileTime ? 0
187 : int(IsRowMajor) ? ColsAtCompileTime
191 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr evaluator() : m_d(0, OuterStrideAtCompileTime) {
192 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
195 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr explicit evaluator(
const PlainObjectType& m)
196 : m_d(m.data(), IsVectorAtCompileTime ? 0 : m.outerStride()) {
197 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
200 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr CoeffReturnType coeff(
Index row,
Index col)
const {
201 return coeff(getIndex(row, col));
204 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr CoeffReturnType coeff(
Index index)
const {
return m_d.data[index]; }
206 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Scalar& coeffRef(
Index row,
Index col) {
207 return coeffRef(getIndex(row, col));
210 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Scalar& coeffRef(
Index index) {
211 return const_cast<Scalar*
>(m_d.data)[index];
214 template <
int LoadMode,
typename PacketType>
215 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(
Index row,
Index col)
const {
216 return packet<LoadMode, PacketType>(getIndex(row, col));
219 template <
int LoadMode,
typename PacketType>
220 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(
Index index)
const {
221 return ploadt<PacketType, LoadMode>(m_d.data + index);
224 template <
int StoreMode,
typename PacketType>
225 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacket(
Index row,
Index col,
const PacketType& x) {
226 writePacket<StoreMode, PacketType>(getIndex(row, col), x);
229 template <
int StoreMode,
typename PacketType>
230 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacket(
Index index,
const PacketType& x) {
231 pstoret<Scalar, PacketType, StoreMode>(
const_cast<Scalar*
>(m_d.data) + index, x);
234 template <
int LoadMode,
typename PacketType>
235 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(
Index row,
Index col,
Index begin,
Index count)
const {
236 return packetSegment<LoadMode, PacketType>(getIndex(row, col), begin, count);
239 template <
int LoadMode,
typename PacketType>
240 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(
Index index,
Index begin,
Index count)
const {
241 return ploadtSegment<PacketType, LoadMode>(m_d.data + index, begin, count);
244 template <
int StoreMode,
typename PacketType>
245 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacketSegment(
Index row,
Index col,
const PacketType& x,
Index begin,
247 writePacketSegment<StoreMode, PacketType>(getIndex(row, col), x, begin, count);
250 template <
int StoreMode,
typename PacketType>
251 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacketSegment(
Index index,
const PacketType& x,
Index begin,
253 pstoretSegment<Scalar, PacketType, StoreMode>(
const_cast<Scalar*
>(m_d.data) + index, x, begin, count);
257 plainobjectbase_evaluator_data<Scalar, OuterStrideAtCompileTime> m_d;
260 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Index constexpr getIndex(
Index row,
Index col)
const {
261 return IsRowMajor ? row * m_d.outerStride() + col : row + col * m_d.outerStride();
265template <
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
266struct evaluator<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>
267 : evaluator<PlainObjectBase<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>> {
268 typedef Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> XprType;
270 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr evaluator() =
default;
272 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr explicit evaluator(
const XprType& m)
273 : evaluator<PlainObjectBase<XprType>>(m) {}
276template <
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
277struct evaluator<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>
278 : evaluator<PlainObjectBase<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>> {
279 typedef Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> XprType;
281 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr evaluator() =
default;
283 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr explicit evaluator(
const XprType& m)
284 : evaluator<PlainObjectBase<XprType>>(m) {}
289template <
typename ArgType>
290struct unary_evaluator<Transpose<ArgType>, IndexBased> : evaluator_base<Transpose<ArgType>> {
291 typedef Transpose<ArgType> XprType;
294 CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
296 Alignment = evaluator<ArgType>::Alignment
299 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit unary_evaluator(
const XprType& t) : m_argImpl(t.nestedExpression()) {}
301 typedef typename XprType::Scalar Scalar;
302 typedef typename XprType::CoeffReturnType CoeffReturnType;
304 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(
Index row,
Index col)
const {
305 return m_argImpl.coeff(col, row);
308 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(
Index index)
const {
return m_argImpl.coeff(index); }
310 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(
Index row,
Index col) {
return m_argImpl.coeffRef(col, row); }
312 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
typename XprType::Scalar& coeffRef(
Index index) {
313 return m_argImpl.coeffRef(index);
316 template <
int LoadMode,
typename PacketType>
317 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(
Index row,
Index col)
const {
318 return m_argImpl.template packet<LoadMode, PacketType>(col, row);
321 template <
int LoadMode,
typename PacketType>
322 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(
Index index)
const {
323 return m_argImpl.template packet<LoadMode, PacketType>(index);
326 template <
int StoreMode,
typename PacketType>
327 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacket(
Index row,
Index col,
const PacketType& x) {
328 m_argImpl.template writePacket<StoreMode, PacketType>(col, row, x);
331 template <
int StoreMode,
typename PacketType>
332 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacket(
Index index,
const PacketType& x) {
333 m_argImpl.template writePacket<StoreMode, PacketType>(index, x);
336 template <
int LoadMode,
typename PacketType>
337 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(
Index row,
Index col,
Index begin,
Index count)
const {
338 return m_argImpl.template packetSegment<LoadMode, PacketType>(col, row, begin, count);
341 template <
int LoadMode,
typename PacketType>
342 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(
Index index,
Index begin,
Index count)
const {
343 return m_argImpl.template packetSegment<LoadMode, PacketType>(index, begin, count);
346 template <
int StoreMode,
typename PacketType>
347 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacketSegment(
Index row,
Index col,
const PacketType& x,
Index begin,
349 m_argImpl.template writePacketSegment<StoreMode, PacketType>(col, row, x, begin, count);
352 template <
int StoreMode,
typename PacketType>
353 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacketSegment(
Index index,
const PacketType& x,
Index begin,
355 m_argImpl.template writePacketSegment<StoreMode, PacketType>(index, x, begin, count);
359 evaluator<ArgType> m_argImpl;
366template <typename Scalar, typename NullaryOp, bool has_nullary = has_nullary_operator<NullaryOp>::value,
367 bool has_unary = has_unary_operator<NullaryOp>::value,
368 bool has_binary = has_binary_operator<NullaryOp>::value>
369struct nullary_wrapper {
370 template <
typename IndexType>
371 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i, IndexType j)
const {
374 template <
typename IndexType>
375 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i)
const {
379 template <
typename T,
typename IndexType>
380 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i, IndexType j)
const {
381 return op.template packetOp<T>(i, j);
383 template <
typename T,
typename IndexType>
384 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i)
const {
385 return op.template packetOp<T>(i);
389template <
typename Scalar,
typename NullaryOp>
390struct nullary_wrapper<Scalar, NullaryOp, true, false, false> {
391 template <
typename IndexType>
392 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType = 0, IndexType = 0)
const {
395 template <
typename T,
typename IndexType>
396 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType = 0, IndexType = 0)
const {
397 return op.template packetOp<T>();
401template <
typename Scalar,
typename NullaryOp>
402struct nullary_wrapper<Scalar, NullaryOp, false, false, true> {
403 template <
typename IndexType>
404 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i, IndexType j = 0)
const {
407 template <
typename T,
typename IndexType>
408 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i, IndexType j = 0)
const {
409 return op.template packetOp<T>(i, j);
416template <
typename Scalar,
typename NullaryOp>
417struct nullary_wrapper<Scalar, NullaryOp, false, true, false> {
418 template <
typename IndexType>
419 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i, IndexType j)
const {
420 eigen_assert(i == 0 || j == 0);
423 template <
typename T,
typename IndexType>
424 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i, IndexType j)
const {
425 eigen_assert(i == 0 || j == 0);
426 return op.template packetOp<T>(i + j);
429 template <
typename IndexType>
430 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i)
const {
433 template <
typename T,
typename IndexType>
434 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i)
const {
435 return op.template packetOp<T>(i);
439template <
typename Scalar,
typename NullaryOp>
440struct nullary_wrapper<Scalar, NullaryOp, false, false, false> {};
442#if 0 && EIGEN_COMP_MSVC > 0
460template<
typename T>
struct nullary_wrapper_workaround_msvc {
461 nullary_wrapper_workaround_msvc(
const T&);
465template<
typename Scalar,
typename NullaryOp>
466struct nullary_wrapper<Scalar,NullaryOp,true,true,true>
468 template <
typename IndexType>
469 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i, IndexType j)
const {
470 return nullary_wrapper<Scalar,NullaryOp,
471 has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,
472 has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,
473 has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().
operator()(op,i,j);
475 template <
typename IndexType>
476 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i)
const {
477 return nullary_wrapper<Scalar,NullaryOp,
478 has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,
479 has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,
480 has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().
operator()(op,i);
483 template <
typename T,
typename IndexType>
484 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i, IndexType j)
const {
485 return nullary_wrapper<Scalar,NullaryOp,
486 has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,
487 has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,
488 has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().
template packetOp<T>(op,i,j);
490 template <
typename T,
typename IndexType>
491 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i)
const {
492 return nullary_wrapper<Scalar,NullaryOp,
493 has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,
494 has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,
495 has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().
template packetOp<T>(op,i);
500template <
typename NullaryOp,
typename PlainObjectType>
501struct evaluator<CwiseNullaryOp<NullaryOp, PlainObjectType>>
502 : evaluator_base<CwiseNullaryOp<NullaryOp, PlainObjectType>> {
503 typedef CwiseNullaryOp<NullaryOp, PlainObjectType> XprType;
504 typedef remove_all_t<PlainObjectType> PlainObjectTypeCleaned;
507 CoeffReadCost = functor_traits<NullaryOp>::Cost,
509 Flags = (evaluator<PlainObjectTypeCleaned>::Flags &
510 (HereditaryBits | (functor_has_linear_access<NullaryOp>::ret ?
LinearAccessBit : 0) |
513 Alignment = AlignedMax
516 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& n) : m_functor(n.functor()), m_wrapper() {
517 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
520 typedef typename XprType::CoeffReturnType CoeffReturnType;
522 template <
typename IndexType>
523 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(IndexType row, IndexType col)
const {
524 return m_wrapper(m_functor, row, col);
527 template <
typename IndexType>
528 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(IndexType index)
const {
529 return m_wrapper(m_functor, index);
532 template <
int LoadMode,
typename PacketType,
typename IndexType>
533 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(IndexType row, IndexType col)
const {
534 return m_wrapper.template packetOp<PacketType>(m_functor, row, col);
537 template <
int LoadMode,
typename PacketType,
typename IndexType>
538 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(IndexType index)
const {
539 return m_wrapper.template packetOp<PacketType>(m_functor, index);
542 template <
int LoadMode,
typename PacketType,
typename IndexType>
543 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(IndexType row, IndexType col,
Index ,
545 return packet<LoadMode, PacketType, IndexType>(row, col);
548 template <
int LoadMode,
typename PacketType,
typename IndexType>
549 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(IndexType index,
Index ,
551 return packet<LoadMode, PacketType, IndexType>(index);
555 const NullaryOp m_functor;
556 const nullary_wrapper<CoeffReturnType, NullaryOp> m_wrapper;
561template <
typename UnaryOp,
typename ArgType>
562struct unary_evaluator<CwiseUnaryOp<UnaryOp, ArgType>, IndexBased> : evaluator_base<CwiseUnaryOp<UnaryOp, ArgType>> {
563 typedef CwiseUnaryOp<UnaryOp, ArgType> XprType;
566 CoeffReadCost = int(evaluator<ArgType>::CoeffReadCost) + int(functor_traits<UnaryOp>::Cost),
568 Flags = evaluator<ArgType>::Flags &
570 Alignment = evaluator<ArgType>::Alignment
573 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit unary_evaluator(
const XprType& op) : m_d(op) {
574 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<UnaryOp>::Cost);
575 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
578 typedef typename XprType::CoeffReturnType CoeffReturnType;
580 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(
Index row,
Index col)
const {
581 return m_d.func()(m_d.argImpl.coeff(row, col));
584 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(
Index index)
const {
585 return m_d.func()(m_d.argImpl.coeff(index));
588 template <
int LoadMode,
typename PacketType>
589 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(
Index row,
Index col)
const {
590 return m_d.func().packetOp(m_d.argImpl.template packet<LoadMode, PacketType>(row, col));
593 template <
int LoadMode,
typename PacketType>
594 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(
Index index)
const {
595 return m_d.func().packetOp(m_d.argImpl.template packet<LoadMode, PacketType>(index));
598 template <
int LoadMode,
typename PacketType>
599 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(
Index row,
Index col,
Index begin,
Index count)
const {
600 return m_d.func().packetOp(m_d.argImpl.template packetSegment<LoadMode, PacketType>(row, col, begin, count));
603 template <
int LoadMode,
typename PacketType>
604 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(
Index index,
Index begin,
Index count)
const {
605 return m_d.func().packetOp(m_d.argImpl.template packetSegment<LoadMode, PacketType>(index, begin, count));
611 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Data(
const XprType& xpr)
612 : op(xpr.functor()), argImpl(xpr.nestedExpression()) {}
613 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const UnaryOp& func()
const {
return op; }
615 evaluator<ArgType> argImpl;
623template <
typename SrcType,
typename DstType,
typename ArgType>
624struct unary_evaluator<CwiseUnaryOp<core_cast_op<SrcType, DstType>, ArgType>, IndexBased> {
625 using CastOp = core_cast_op<SrcType, DstType>;
626 using XprType = CwiseUnaryOp<CastOp, ArgType>;
629 using SrcPacketType =
typename packet_traits<SrcType>::type;
630 static constexpr int SrcPacketSize = unpacket_traits<SrcPacketType>::size;
631 static constexpr int SrcPacketBytes = SrcPacketSize *
sizeof(SrcType);
634 CoeffReadCost = int(evaluator<ArgType>::CoeffReadCost) + int(functor_traits<CastOp>::Cost),
635 PacketAccess = functor_traits<CastOp>::PacketAccess,
638 IsRowMajor = (evaluator<ArgType>::Flags &
RowMajorBit),
639 Alignment = evaluator<ArgType>::Alignment
642 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit unary_evaluator(
const XprType& xpr)
643 : m_argImpl(xpr.nestedExpression()), m_rows(xpr.rows()), m_cols(xpr.cols()) {
644 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<CastOp>::Cost);
645 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
648 template <
typename DstPacketType>
649 using AltSrcScalarOp = std::enable_if_t<(unpacket_traits<DstPacketType>::size < SrcPacketSize &&
650 !find_packet_by_size<SrcType, unpacket_traits<DstPacketType>::size>::value),
652 template <
typename DstPacketType>
653 using SrcPacketArgs1 =
654 std::enable_if_t<(find_packet_by_size<SrcType, unpacket_traits<DstPacketType>::size>::value),
bool>;
655 template <
typename DstPacketType>
656 using SrcPacketArgs2 = std::enable_if_t<(unpacket_traits<DstPacketType>::size) == (2 * SrcPacketSize),
bool>;
657 template <
typename DstPacketType>
658 using SrcPacketArgs4 = std::enable_if_t<(unpacket_traits<DstPacketType>::size) == (4 * SrcPacketSize),
bool>;
659 template <
typename DstPacketType>
660 using SrcPacketArgs8 = std::enable_if_t<(unpacket_traits<DstPacketType>::size) == (8 * SrcPacketSize),
bool>;
662 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
bool check_array_bounds(
Index row,
Index col,
Index begin,
Index count)
const {
663 return IsRowMajor ? (col + count + begin <= cols()) : (row + count + begin <= rows());
665 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
bool check_array_bounds(
Index index,
Index begin,
Index count)
const {
666 return index + count + begin <= size();
669 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE SrcType srcCoeff(
Index row,
Index col,
Index offset)
const {
670 Index actualRow = IsRowMajor ? row : row + offset;
671 Index actualCol = IsRowMajor ? col + offset : col;
672 return m_argImpl.coeff(actualRow, actualCol);
674 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE SrcType srcCoeff(
Index index,
Index offset)
const {
675 Index actualIndex = index + offset;
676 return m_argImpl.coeff(actualIndex);
679 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstType coeff(
Index row,
Index col)
const {
680 return cast<SrcType, DstType>(srcCoeff(row, col, 0));
682 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstType coeff(
Index index)
const {
683 return cast<SrcType, DstType>(srcCoeff(index, 0));
686 template <
int LoadMode,
typename PacketType = SrcPacketType>
687 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType srcPacket(
Index row,
Index col,
Index offset)
const {
688 constexpr int PacketSize = unpacket_traits<PacketType>::size;
689 Index packetOffset = offset * PacketSize;
690 Index actualRow = IsRowMajor ? row : row + packetOffset;
691 Index actualCol = IsRowMajor ? col + packetOffset : col;
692 eigen_assert(check_array_bounds(actualRow, actualCol, 0, PacketSize) &&
"Array index out of bounds");
693 return m_argImpl.template packet<LoadMode, PacketType>(actualRow, actualCol);
695 template <
int LoadMode,
typename PacketType = SrcPacketType>
696 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType srcPacket(
Index index,
Index offset)
const {
697 constexpr int PacketSize = unpacket_traits<PacketType>::size;
698 Index packetOffset = offset * PacketSize;
699 Index actualIndex = index + packetOffset;
700 eigen_assert(check_array_bounds(actualIndex, 0, PacketSize) &&
"Array index out of bounds");
701 return m_argImpl.template packet<LoadMode, PacketType>(actualIndex);
703 template <
int LoadMode,
typename PacketType = SrcPacketType>
704 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType srcPacketSegment(
Index row,
Index col,
Index begin,
Index count,
705 Index offset)
const {
706 constexpr int PacketSize = unpacket_traits<PacketType>::size;
707 Index packetOffset = offset * PacketSize;
708 Index actualRow = IsRowMajor ? row : row + packetOffset;
709 Index actualCol = IsRowMajor ? col + packetOffset : col;
710 eigen_assert(check_array_bounds(actualRow, actualCol, begin, count) &&
"Array index out of bounds");
711 return m_argImpl.template packetSegment<LoadMode, PacketType>(actualRow, actualCol, begin, count);
713 template <
int LoadMode,
typename PacketType = SrcPacketType>
714 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType srcPacketSegment(
Index index,
Index begin,
Index count,
715 Index offset)
const {
716 constexpr int PacketSize = unpacket_traits<PacketType>::size;
717 Index packetOffset = offset * PacketSize;
718 Index actualIndex = index + packetOffset;
719 eigen_assert(check_array_bounds(actualIndex, begin, count) &&
"Array index out of bounds");
720 return m_argImpl.template packetSegment<LoadMode, PacketType>(actualIndex, begin, count);
723 template <
int NumPackets,
int LoadMode,
typename PacketType = SrcPacketType>
724 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketBlock<PacketType, NumPackets> srcPacketSegmentHelper(
Index row,
Index col,
727 constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
728 PacketBlock<PacketType, NumPackets> packets;
729 for (
Index i = 0; i < NumPackets; i++) packets.packet[i] = pzero(PacketType());
730 Index offset = begin / SrcPacketSize;
731 Index actualBegin = begin % SrcPacketSize;
732 for (; offset < NumPackets; offset++) {
733 Index actualCount = numext::mini(SrcPacketSize - actualBegin, count);
734 packets.packet[offset] = srcPacketSegment<SrcLoadMode>(row, col, actualBegin, actualCount, offset);
735 if (count == actualCount)
break;
737 count -= actualCount;
741 template <
int NumPackets,
int LoadMode,
typename PacketType = SrcPacketType>
742 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketBlock<PacketType, NumPackets> srcPacketSegmentHelper(
Index index,
745 constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
746 PacketBlock<PacketType, NumPackets> packets;
747 for (
Index i = 0; i < NumPackets; i++) packets.packet[i] = pzero(PacketType());
748 Index offset = begin / SrcPacketSize;
749 Index actualBegin = begin % SrcPacketSize;
750 for (; offset < NumPackets; offset++) {
751 Index actualCount = numext::mini(SrcPacketSize - actualBegin, count);
752 packets.packet[offset] = srcPacketSegment<SrcLoadMode>(index, actualBegin, actualCount, offset);
753 if (count == actualCount)
break;
755 count -= actualCount;
765 template <
int LoadMode,
typename DstPacketType, AltSrcScalarOp<DstPacketType> = true>
766 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(
Index row,
Index col)
const {
767 constexpr int DstPacketSize = unpacket_traits<DstPacketType>::size;
768 constexpr int SrcBytesIncrement = DstPacketSize *
sizeof(SrcType);
769 constexpr int SrcLoadMode = plain_enum_min(SrcBytesIncrement, LoadMode);
770 return pcast<SrcPacketType, DstPacketType>(srcPacketSegment<SrcLoadMode>(row, col, 0, DstPacketSize, 0));
773 template <
int LoadMode,
typename DstPacketType, SrcPacketArgs1<DstPacketType> = true>
774 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(
Index row,
Index col)
const {
775 constexpr int DstPacketSize = unpacket_traits<DstPacketType>::size;
776 using SizedSrcPacketType =
typename find_packet_by_size<SrcType, DstPacketSize>::type;
777 constexpr int SrcBytesIncrement = DstPacketSize *
sizeof(SrcType);
778 constexpr int SrcLoadMode = plain_enum_min(SrcBytesIncrement, LoadMode);
779 return pcast<SizedSrcPacketType, DstPacketType>(srcPacket<SrcLoadMode, SizedSrcPacketType>(row, col, 0));
782 template <
int LoadMode,
typename DstPacketType, SrcPacketArgs2<DstPacketType> = true>
783 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(
Index row,
Index col)
const {
784 constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
785 return pcast<SrcPacketType, DstPacketType>(srcPacket<SrcLoadMode>(row, col, 0),
786 srcPacket<SrcLoadMode>(row, col, 1));
789 template <
int LoadMode,
typename DstPacketType, SrcPacketArgs4<DstPacketType> = true>
790 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(
Index row,
Index col)
const {
791 constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
792 return pcast<SrcPacketType, DstPacketType>(srcPacket<SrcLoadMode>(row, col, 0), srcPacket<SrcLoadMode>(row, col, 1),
793 srcPacket<SrcLoadMode>(row, col, 2),
794 srcPacket<SrcLoadMode>(row, col, 3));
797 template <
int LoadMode,
typename DstPacketType, SrcPacketArgs8<DstPacketType> = true>
798 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(
Index row,
Index col)
const {
799 constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
800 return pcast<SrcPacketType, DstPacketType>(
801 srcPacket<SrcLoadMode>(row, col, 0), srcPacket<SrcLoadMode>(row, col, 1), srcPacket<SrcLoadMode>(row, col, 2),
802 srcPacket<SrcLoadMode>(row, col, 3), srcPacket<SrcLoadMode>(row, col, 4), srcPacket<SrcLoadMode>(row, col, 5),
803 srcPacket<SrcLoadMode>(row, col, 6), srcPacket<SrcLoadMode>(row, col, 7));
807 template <
int LoadMode,
typename DstPacketType, AltSrcScalarOp<DstPacketType> = true>
808 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(
Index row,
Index col,
Index begin,
810 constexpr int DstPacketSize = unpacket_traits<DstPacketType>::size;
811 constexpr int SrcBytesIncrement = DstPacketSize *
sizeof(SrcType);
812 constexpr int SrcLoadMode = plain_enum_min(SrcBytesIncrement, LoadMode);
813 return pcast<SrcPacketType, DstPacketType>(srcPacketSegment<SrcLoadMode>(row, col, begin, count, 0));
816 template <
int LoadMode,
typename DstPacketType, SrcPacketArgs1<DstPacketType> = true>
817 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(
Index row,
Index col,
Index begin,
819 constexpr int DstPacketSize = unpacket_traits<DstPacketType>::size;
820 using SizedSrcPacketType =
typename find_packet_by_size<SrcType, DstPacketSize>::type;
821 constexpr int SrcBytesIncrement = DstPacketSize *
sizeof(SrcType);
822 constexpr int SrcLoadMode = plain_enum_min(SrcBytesIncrement, LoadMode);
823 return pcast<SizedSrcPacketType, DstPacketType>(
824 srcPacketSegment<SrcLoadMode, SizedSrcPacketType>(row, col, begin, count, 0));
827 template <
int LoadMode,
typename DstPacketType, SrcPacketArgs2<DstPacketType> = true>
828 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(
Index row,
Index col,
Index begin,
830 constexpr int NumPackets = 2;
831 constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
832 PacketBlock<SrcPacketType, NumPackets> packets =
833 srcPacketSegmentHelper<NumPackets, SrcLoadMode>(row, col, begin, count);
834 return pcast<SrcPacketType, DstPacketType>(packets.packet[0], packets.packet[1]);
837 template <
int LoadMode,
typename DstPacketType, SrcPacketArgs4<DstPacketType> = true>
838 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(
Index row,
Index col,
Index begin,
840 constexpr int NumPackets = 4;
841 constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
842 PacketBlock<SrcPacketType, NumPackets> packets =
843 srcPacketSegmentHelper<NumPackets, SrcLoadMode>(row, col, begin, count);
844 return pcast<SrcPacketType, DstPacketType>(packets.packet[0], packets.packet[1], packets.packet[2],
848 template <
int LoadMode,
typename DstPacketType, SrcPacketArgs8<DstPacketType> = true>
849 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(
Index row,
Index col,
Index begin,
851 constexpr int NumPackets = 8;
852 constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
853 PacketBlock<SrcPacketType, NumPackets> packets =
854 srcPacketSegmentHelper<NumPackets, SrcLoadMode>(row, col, begin, count);
855 return pcast<SrcPacketType, DstPacketType>(packets.packet[0], packets.packet[1], packets.packet[2],
856 packets.packet[3], packets.packet[4], packets.packet[5],
857 packets.packet[6], packets.packet[7]);
861 template <
int LoadMode,
typename DstPacketType, AltSrcScalarOp<DstPacketType> = true>
862 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(
Index index)
const {
863 constexpr int DstPacketSize = unpacket_traits<DstPacketType>::size;
864 constexpr int SrcBytesIncrement = DstPacketSize *
sizeof(SrcType);
865 constexpr int SrcLoadMode = plain_enum_min(SrcBytesIncrement, LoadMode);
866 return pcast<SrcPacketType, DstPacketType>(srcPacketSegment<SrcLoadMode>(index, 0, DstPacketSize, 0));
868 template <
int LoadMode,
typename DstPacketType, SrcPacketArgs1<DstPacketType> = true>
869 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(
Index index)
const {
870 constexpr int DstPacketSize = unpacket_traits<DstPacketType>::size;
871 using SizedSrcPacketType =
typename find_packet_by_size<SrcType, DstPacketSize>::type;
872 constexpr int SrcBytesIncrement = DstPacketSize *
sizeof(SrcType);
873 constexpr int SrcLoadMode = plain_enum_min(SrcBytesIncrement, LoadMode);
874 return pcast<SizedSrcPacketType, DstPacketType>(srcPacket<SrcLoadMode, SizedSrcPacketType>(index, 0));
876 template <
int LoadMode,
typename DstPacketType, SrcPacketArgs2<DstPacketType> = true>
877 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(
Index index)
const {
878 constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
879 return pcast<SrcPacketType, DstPacketType>(srcPacket<SrcLoadMode>(index, 0), srcPacket<SrcLoadMode>(index, 1));
881 template <
int LoadMode,
typename DstPacketType, SrcPacketArgs4<DstPacketType> = true>
882 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(
Index index)
const {
883 constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
884 return pcast<SrcPacketType, DstPacketType>(srcPacket<SrcLoadMode>(index, 0), srcPacket<SrcLoadMode>(index, 1),
885 srcPacket<SrcLoadMode>(index, 2), srcPacket<SrcLoadMode>(index, 3));
887 template <
int LoadMode,
typename DstPacketType, SrcPacketArgs8<DstPacketType> = true>
888 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(
Index index)
const {
889 constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
890 return pcast<SrcPacketType, DstPacketType>(srcPacket<SrcLoadMode>(index, 0), srcPacket<SrcLoadMode>(index, 1),
891 srcPacket<SrcLoadMode>(index, 2), srcPacket<SrcLoadMode>(index, 3),
892 srcPacket<SrcLoadMode>(index, 4), srcPacket<SrcLoadMode>(index, 5),
893 srcPacket<SrcLoadMode>(index, 6), srcPacket<SrcLoadMode>(index, 7));
897 template <
int LoadMode,
typename DstPacketType, AltSrcScalarOp<DstPacketType> = true>
898 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(
Index index,
Index begin,
Index count)
const {
899 constexpr int DstPacketSize = unpacket_traits<DstPacketType>::size;
900 constexpr int SrcBytesIncrement = DstPacketSize *
sizeof(SrcType);
901 constexpr int SrcLoadMode = plain_enum_min(SrcBytesIncrement, LoadMode);
902 return pcast<SrcPacketType, DstPacketType>(srcPacketSegment<SrcLoadMode>(index, begin, count, 0));
905 template <
int LoadMode,
typename DstPacketType, SrcPacketArgs1<DstPacketType> = true>
906 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(
Index index,
Index begin,
Index count)
const {
907 constexpr int DstPacketSize = unpacket_traits<DstPacketType>::size;
908 using SizedSrcPacketType =
typename find_packet_by_size<SrcType, DstPacketSize>::type;
909 constexpr int SrcBytesIncrement = DstPacketSize *
sizeof(SrcType);
910 constexpr int SrcLoadMode = plain_enum_min(SrcBytesIncrement, LoadMode);
911 return pcast<SizedSrcPacketType, DstPacketType>(
912 srcPacketSegment<SrcLoadMode, SizedSrcPacketType>(index, begin, count, 0));
915 template <
int LoadMode,
typename DstPacketType, SrcPacketArgs2<DstPacketType> = true>
916 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(
Index index,
Index begin,
Index count)
const {
917 constexpr int NumPackets = 2;
918 constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
919 PacketBlock<SrcPacketType, NumPackets> packets =
920 srcPacketSegmentHelper<NumPackets, SrcLoadMode>(index, begin, count);
921 return pcast<SrcPacketType, DstPacketType>(packets.packet[0], packets.packet[1]);
924 template <
int LoadMode,
typename DstPacketType, SrcPacketArgs4<DstPacketType> = true>
925 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(
Index index,
Index begin,
Index count)
const {
926 constexpr int NumPackets = 4;
927 constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
928 PacketBlock<SrcPacketType, NumPackets> packets =
929 srcPacketSegmentHelper<NumPackets, SrcLoadMode>(index, begin, count);
930 return pcast<SrcPacketType, DstPacketType>(packets.packet[0], packets.packet[1], packets.packet[2],
934 template <
int LoadMode,
typename DstPacketType, SrcPacketArgs8<DstPacketType> = true>
935 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(
Index index,
Index begin,
Index count)
const {
936 constexpr int NumPackets = 8;
937 constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
938 PacketBlock<SrcPacketType, NumPackets> packets =
939 srcPacketSegmentHelper<NumPackets, SrcLoadMode>(index, begin, count);
940 return pcast<SrcPacketType, DstPacketType>(packets.packet[0], packets.packet[1], packets.packet[2],
941 packets.packet[3], packets.packet[4], packets.packet[5],
942 packets.packet[6], packets.packet[7]);
945 constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Index rows()
const {
return m_rows; }
946 constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Index cols()
const {
return m_cols; }
947 constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Index size()
const {
return m_rows * m_cols; }
950 const evaluator<ArgType> m_argImpl;
951 const variable_if_dynamic<Index, XprType::RowsAtCompileTime> m_rows;
952 const variable_if_dynamic<Index, XprType::ColsAtCompileTime> m_cols;
958template <
typename TernaryOp,
typename Arg1,
typename Arg2,
typename Arg3>
959struct evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>>
960 :
public ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> {
961 typedef CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> XprType;
962 typedef ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> Base;
964 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& xpr) : Base(xpr) {}
967template <
typename TernaryOp,
typename Arg1,
typename Arg2,
typename Arg3>
968struct ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>, IndexBased, IndexBased>
969 : evaluator_base<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> {
970 typedef CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> XprType;
973 CoeffReadCost = int(evaluator<Arg1>::CoeffReadCost) + int(evaluator<Arg2>::CoeffReadCost) +
974 int(evaluator<Arg3>::CoeffReadCost) + int(functor_traits<TernaryOp>::Cost),
976 Arg1Flags = evaluator<Arg1>::Flags,
977 Arg2Flags = evaluator<Arg2>::Flags,
978 Arg3Flags = evaluator<Arg3>::Flags,
979 SameType = is_same<typename Arg1::Scalar, typename Arg2::Scalar>::value &&
980 is_same<typename Arg1::Scalar, typename Arg3::Scalar>::value,
983 Flags0 = (int(Arg1Flags) | int(Arg2Flags) | int(Arg3Flags)) &
985 (
int(Arg1Flags) &
int(Arg2Flags) &
int(Arg3Flags) &
987 (functor_traits<TernaryOp>::PacketAccess && StorageOrdersAgree && SameType ?
PacketAccessBit : 0)))),
988 Flags = (Flags0 & ~RowMajorBit) | (Arg1Flags &
RowMajorBit),
989 Alignment = plain_enum_min(plain_enum_min(evaluator<Arg1>::Alignment, evaluator<Arg2>::Alignment),
990 evaluator<Arg3>::Alignment)
993 EIGEN_DEVICE_FUNC
explicit ternary_evaluator(
const XprType& xpr) : m_d(xpr) {
994 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<TernaryOp>::Cost);
995 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
998 typedef typename XprType::CoeffReturnType CoeffReturnType;
1000 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(
Index row,
Index col)
const {
1001 return m_d.func()(m_d.arg1Impl.coeff(row, col), m_d.arg2Impl.coeff(row, col), m_d.arg3Impl.coeff(row, col));
1004 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(
Index index)
const {
1005 return m_d.func()(m_d.arg1Impl.coeff(index), m_d.arg2Impl.coeff(index), m_d.arg3Impl.coeff(index));
1008 template <
int LoadMode,
typename PacketType>
1009 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(
Index row,
Index col)
const {
1010 return m_d.func().packetOp(m_d.arg1Impl.template packet<LoadMode, PacketType>(row, col),
1011 m_d.arg2Impl.template packet<LoadMode, PacketType>(row, col),
1012 m_d.arg3Impl.template packet<LoadMode, PacketType>(row, col));
1015 template <
int LoadMode,
typename PacketType>
1016 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(
Index index)
const {
1017 return m_d.func().packetOp(m_d.arg1Impl.template packet<LoadMode, PacketType>(index),
1018 m_d.arg2Impl.template packet<LoadMode, PacketType>(index),
1019 m_d.arg3Impl.template packet<LoadMode, PacketType>(index));
1022 template <
int LoadMode,
typename PacketType>
1023 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(
Index row,
Index col,
Index begin,
Index count)
const {
1024 return m_d.func().packetOp(m_d.arg1Impl.template packetSegment<LoadMode, PacketType>(row, col, begin, count),
1025 m_d.arg2Impl.template packetSegment<LoadMode, PacketType>(row, col, begin, count),
1026 m_d.arg3Impl.template packetSegment<LoadMode, PacketType>(row, col, begin, count));
1029 template <
int LoadMode,
typename PacketType>
1030 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(
Index index,
Index begin,
Index count)
const {
1031 return m_d.func().packetOp(m_d.arg1Impl.template packetSegment<LoadMode, PacketType>(index, begin, count),
1032 m_d.arg2Impl.template packetSegment<LoadMode, PacketType>(index, begin, count),
1033 m_d.arg3Impl.template packetSegment<LoadMode, PacketType>(index, begin, count));
1039 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Data(
const XprType& xpr)
1040 : op(xpr.functor()), arg1Impl(xpr.arg1()), arg2Impl(xpr.arg2()), arg3Impl(xpr.arg3()) {}
1041 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const TernaryOp& func()
const {
return op; }
1043 evaluator<Arg1> arg1Impl;
1044 evaluator<Arg2> arg2Impl;
1045 evaluator<Arg3> arg3Impl;
1051template <
typename Arg1,
typename Arg2,
typename Scalar,
typename CmpLhsType,
typename CmpRhsType, ComparisonName cmp>
1052struct scalar_boolean_select_spec {
1053 using DummyTernaryOp = scalar_boolean_select_op<Scalar, Scalar, bool>;
1054 using DummyArg3 = CwiseBinaryOp<scalar_cmp_op<Scalar, Scalar, cmp, false>, CmpLhsType, CmpRhsType>;
1055 using DummyXprType = CwiseTernaryOp<DummyTernaryOp, Arg1, Arg2, DummyArg3>;
1058 static constexpr bool UseTyped = functor_traits<scalar_cmp_op<Scalar, Scalar, cmp, true>>::PacketAccess;
1059 using CondScalar = std::conditional_t<UseTyped, Scalar, bool>;
1061 using TernaryOp = scalar_boolean_select_op<Scalar, Scalar, CondScalar>;
1062 using Arg3 = CwiseBinaryOp<scalar_cmp_op<Scalar, Scalar, cmp, UseTyped>, CmpLhsType, CmpRhsType>;
1063 using XprType = CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>;
1065 using Base = ternary_evaluator<XprType>;
1069template <
typename Arg1,
typename Arg2,
typename Scalar,
typename CmpLhsType,
typename CmpRhsType, ComparisonName cmp>
1070struct evaluator<CwiseTernaryOp<scalar_boolean_select_op<Scalar, Scalar, bool>, Arg1, Arg2,
1071 CwiseBinaryOp<scalar_cmp_op<Scalar, Scalar, cmp, false>, CmpLhsType, CmpRhsType>>>
1072 :
public scalar_boolean_select_spec<Arg1, Arg2, Scalar, CmpLhsType, CmpRhsType, cmp>::Base {
1073 using Helper = scalar_boolean_select_spec<Arg1, Arg2, Scalar, CmpLhsType, CmpRhsType, cmp>;
1074 using Base =
typename Helper::Base;
1075 using DummyXprType =
typename Helper::DummyXprType;
1076 using Arg3 =
typename Helper::Arg3;
1077 using XprType =
typename Helper::XprType;
1079 EIGEN_DEVICE_FUNC
explicit evaluator(
const DummyXprType& xpr)
1080 : Base(XprType(xpr.arg1(), xpr.arg2(), Arg3(xpr.arg3().lhs(), xpr.arg3().rhs()))) {}
1086template <
typename BinaryOp,
typename Lhs,
typename Rhs>
1087struct evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> :
public binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> {
1088 typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;
1089 typedef binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> Base;
1091 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit evaluator(
const XprType& xpr) : Base(xpr) {}
1094template <
typename BinaryOp,
typename Lhs,
typename Rhs>
1095struct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IndexBased, IndexBased>
1096 : evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> {
1097 typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;
1101 int(evaluator<Lhs>::CoeffReadCost) + int(evaluator<Rhs>::CoeffReadCost) + int(functor_traits<BinaryOp>::Cost),
1103 LhsFlags = evaluator<Lhs>::Flags,
1104 RhsFlags = evaluator<Rhs>::Flags,
1105 SameType = is_same<typename Lhs::Scalar, typename Rhs::Scalar>::value,
1107 Flags0 = (int(LhsFlags) | int(RhsFlags)) &
1109 (
int(LhsFlags) &
int(RhsFlags) &
1111 (functor_traits<BinaryOp>::PacketAccess && StorageOrdersAgree && SameType ?
PacketAccessBit : 0)))),
1112 Flags = (Flags0 & ~RowMajorBit) | (LhsFlags &
RowMajorBit),
1113 Alignment = plain_enum_min(evaluator<Lhs>::Alignment, evaluator<Rhs>::Alignment)
1116 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit binary_evaluator(
const XprType& xpr) : m_d(xpr) {
1117 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
1118 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
1121 typedef typename XprType::CoeffReturnType CoeffReturnType;
1123 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(
Index row,
Index col)
const {
1124 return m_d.func()(m_d.lhsImpl.coeff(row, col), m_d.rhsImpl.coeff(row, col));
1127 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(
Index index)
const {
1128 return m_d.func()(m_d.lhsImpl.coeff(index), m_d.rhsImpl.coeff(index));
1131 template <
int LoadMode,
typename PacketType>
1132 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(
Index row,
Index col)
const {
1133 return m_d.func().packetOp(m_d.lhsImpl.template packet<LoadMode, PacketType>(row, col),
1134 m_d.rhsImpl.template packet<LoadMode, PacketType>(row, col));
1137 template <
int LoadMode,
typename PacketType>
1138 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(
Index index)
const {
1139 return m_d.func().packetOp(m_d.lhsImpl.template packet<LoadMode, PacketType>(index),
1140 m_d.rhsImpl.template packet<LoadMode, PacketType>(index));
1143 template <
int LoadMode,
typename PacketType>
1144 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(
Index row,
Index col,
Index begin,
Index count)
const {
1145 return m_d.func().packetOp(m_d.lhsImpl.template packetSegment<LoadMode, PacketType>(row, col, begin, count),
1146 m_d.rhsImpl.template packetSegment<LoadMode, PacketType>(row, col, begin, count));
1149 template <
int LoadMode,
typename PacketType>
1150 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(
Index index,
Index begin,
Index count)
const {
1151 return m_d.func().packetOp(m_d.lhsImpl.template packetSegment<LoadMode, PacketType>(index, begin, count),
1152 m_d.rhsImpl.template packetSegment<LoadMode, PacketType>(index, begin, count));
1158 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Data(
const XprType& xpr)
1159 : op(xpr.functor()), lhsImpl(xpr.lhs()), rhsImpl(xpr.rhs()) {}
1160 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const BinaryOp& func()
const {
return op; }
1162 evaluator<Lhs> lhsImpl;
1163 evaluator<Rhs> rhsImpl;
1171template <
typename UnaryOp,
typename ArgType,
typename Str
ideType>
1172struct unary_evaluator<CwiseUnaryView<UnaryOp, ArgType, StrideType>, IndexBased>
1173 : evaluator_base<CwiseUnaryView<UnaryOp, ArgType, StrideType>> {
1174 typedef CwiseUnaryView<UnaryOp, ArgType, StrideType> XprType;
1177 CoeffReadCost = int(evaluator<ArgType>::CoeffReadCost) + int(functor_traits<UnaryOp>::Cost),
1184 EIGEN_DEVICE_FUNC
explicit unary_evaluator(
const XprType& op) : m_d(op) {
1185 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<UnaryOp>::Cost);
1186 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
1189 typedef typename XprType::Scalar Scalar;
1190 typedef typename XprType::CoeffReturnType CoeffReturnType;
1192 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(
Index row,
Index col)
const {
1193 return m_d.func()(m_d.argImpl.coeff(row, col));
1196 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(
Index index)
const {
1197 return m_d.func()(m_d.argImpl.coeff(index));
1200 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(
Index row,
Index col) {
1201 return m_d.func()(m_d.argImpl.coeffRef(row, col));
1204 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(
Index index) {
1205 return m_d.func()(m_d.argImpl.coeffRef(index));
1211 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Data(
const XprType& xpr)
1212 : op(xpr.functor()), argImpl(xpr.nestedExpression()) {}
1213 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const UnaryOp& func()
const {
return op; }
1215 evaluator<ArgType> argImpl;
1225template <
typename Derived,
typename PlainObjectType>
1226struct mapbase_evaluator;
1228template <
typename Derived,
typename PlainObjectType>
1229struct mapbase_evaluator : evaluator_base<Derived> {
1230 typedef Derived XprType;
1231 typedef typename XprType::PointerType PointerType;
1232 typedef typename XprType::Scalar Scalar;
1233 typedef typename XprType::CoeffReturnType CoeffReturnType;
1236 IsRowMajor = XprType::RowsAtCompileTime,
1237 ColsAtCompileTime = XprType::ColsAtCompileTime,
1238 CoeffReadCost = NumTraits<Scalar>::ReadCost
1241 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit mapbase_evaluator(
const XprType& map)
1242 : m_data(const_cast<PointerType>(map.data())),
1243 m_innerStride(map.innerStride()),
1244 m_outerStride(map.outerStride()) {
1245 EIGEN_STATIC_ASSERT(check_implication((evaluator<Derived>::Flags &
PacketAccessBit) != 0,
1246 inner_stride_at_compile_time<Derived>::ret == 1),
1247 PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1);
1248 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
1251 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(
Index row,
Index col)
const {
1252 return m_data[col * colStride() + row * rowStride()];
1255 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(
Index index)
const {
1256 return m_data[index * m_innerStride.value()];
1259 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(
Index row,
Index col) {
1260 return m_data[col * colStride() + row * rowStride()];
1263 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(
Index index) {
return m_data[index * m_innerStride.value()]; }
1265 template <
int LoadMode,
typename PacketType>
1266 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(
Index row,
Index col)
const {
1267 PointerType ptr = m_data + row * rowStride() + col * colStride();
1268 return ploadt<PacketType, LoadMode>(ptr);
1271 template <
int LoadMode,
typename PacketType>
1272 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(
Index index)
const {
1273 return ploadt<PacketType, LoadMode>(m_data + index * m_innerStride.value());
1276 template <
int StoreMode,
typename PacketType>
1277 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacket(
Index row,
Index col,
const PacketType& x) {
1278 PointerType ptr = m_data + row * rowStride() + col * colStride();
1279 pstoret<Scalar, PacketType, StoreMode>(ptr, x);
1282 template <
int StoreMode,
typename PacketType>
1283 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacket(
Index index,
const PacketType& x) {
1284 pstoret<Scalar, PacketType, StoreMode>(m_data + index * m_innerStride.value(), x);
1287 template <
int LoadMode,
typename PacketType>
1288 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(
Index row,
Index col,
Index begin,
Index count)
const {
1289 PointerType ptr = m_data + row * rowStride() + col * colStride();
1290 return ploadtSegment<PacketType, LoadMode>(ptr, begin, count);
1293 template <
int LoadMode,
typename PacketType>
1294 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(
Index index,
Index begin,
Index count)
const {
1295 return ploadtSegment<PacketType, LoadMode>(m_data + index * m_innerStride.value(), begin, count);
1298 template <
int StoreMode,
typename PacketType>
1299 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacketSegment(
Index row,
Index col,
const PacketType& x,
Index begin,
1301 PointerType ptr = m_data + row * rowStride() + col * colStride();
1302 pstoretSegment<Scalar, PacketType, StoreMode>(ptr, x, begin, count);
1305 template <
int StoreMode,
typename PacketType>
1306 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacketSegment(
Index index,
const PacketType& x,
Index begin,
1308 pstoretSegment<Scalar, PacketType, StoreMode>(m_data + index * m_innerStride.value(), x, begin, count);
1312 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rowStride() const noexcept {
1313 return XprType::IsRowMajor ? m_outerStride.value() : m_innerStride.value();
1315 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index colStride() const noexcept {
1316 return XprType::IsRowMajor ? m_innerStride.value() : m_outerStride.value();
1320 const variable_if_dynamic<Index, XprType::InnerStrideAtCompileTime> m_innerStride;
1321 const variable_if_dynamic<Index, XprType::OuterStrideAtCompileTime> m_outerStride;
1324template <
typename PlainObjectType,
int MapOptions,
typename Str
ideType>
1325struct evaluator<Map<PlainObjectType, MapOptions, StrideType>>
1326 :
public mapbase_evaluator<Map<PlainObjectType, MapOptions, StrideType>, PlainObjectType> {
1327 typedef Map<PlainObjectType, MapOptions, StrideType> XprType;
1328 typedef typename XprType::Scalar Scalar;
1330 typedef typename packet_traits<Scalar>::type PacketScalar;
1333 InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0
1334 ? int(PlainObjectType::InnerStrideAtCompileTime)
1335 : int(StrideType::InnerStrideAtCompileTime),
1336 OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0
1337 ? int(PlainObjectType::OuterStrideAtCompileTime)
1338 : int(StrideType::OuterStrideAtCompileTime),
1339 HasNoInnerStride = InnerStrideAtCompileTime == 1,
1340 HasNoOuterStride = StrideType::OuterStrideAtCompileTime == 0,
1341 HasNoStride = HasNoInnerStride && HasNoOuterStride,
1342 IsDynamicSize = PlainObjectType::SizeAtCompileTime ==
Dynamic,
1344 PacketAccessMask = bool(HasNoInnerStride) ? ~int(0) : ~int(
PacketAccessBit),
1346 bool(HasNoStride) || bool(PlainObjectType::IsVectorAtCompileTime) ? ~int(0) : ~int(
LinearAccessBit),
1347 Flags = int(evaluator<PlainObjectType>::Flags) & (LinearAccessMask & PacketAccessMask),
1349 Alignment = int(MapOptions) & int(AlignedMask)
1352 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& map) : mapbase_evaluator<XprType, PlainObjectType>(map) {}
1357template <
typename PlainObjectType,
int RefOptions,
typename Str
ideType>
1358struct evaluator<Ref<PlainObjectType, RefOptions, StrideType>>
1359 :
public mapbase_evaluator<Ref<PlainObjectType, RefOptions, StrideType>, PlainObjectType> {
1360 typedef Ref<PlainObjectType, RefOptions, StrideType> XprType;
1363 Flags = evaluator<Map<PlainObjectType, RefOptions, StrideType>>::Flags,
1364 Alignment = evaluator<Map<PlainObjectType, RefOptions, StrideType>>::Alignment
1367 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit evaluator(
const XprType& ref)
1368 : mapbase_evaluator<XprType, PlainObjectType>(ref) {}
1373template <
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel,
1374 bool HasDirectAccess = has_direct_access<ArgType>::ret>
1375struct block_evaluator;
1377template <
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel>
1378struct evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>>
1379 : block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel> {
1380 typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
1381 typedef typename XprType::Scalar Scalar;
1383 typedef typename packet_traits<Scalar>::type PacketScalar;
1386 CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
1388 RowsAtCompileTime = traits<XprType>::RowsAtCompileTime,
1389 ColsAtCompileTime = traits<XprType>::ColsAtCompileTime,
1390 MaxRowsAtCompileTime = traits<XprType>::MaxRowsAtCompileTime,
1391 MaxColsAtCompileTime = traits<XprType>::MaxColsAtCompileTime,
1393 ArgTypeIsRowMajor = (int(evaluator<ArgType>::Flags) &
RowMajorBit) != 0,
1394 IsRowMajor = (MaxRowsAtCompileTime == 1 && MaxColsAtCompileTime != 1) ? 1
1395 : (MaxColsAtCompileTime == 1 && MaxRowsAtCompileTime != 1) ? 0
1396 : ArgTypeIsRowMajor,
1397 HasSameStorageOrderAsArgType = (IsRowMajor == ArgTypeIsRowMajor),
1398 InnerSize = IsRowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
1399 InnerStrideAtCompileTime = HasSameStorageOrderAsArgType ? int(inner_stride_at_compile_time<ArgType>::ret)
1400 : int(outer_stride_at_compile_time<ArgType>::ret),
1401 OuterStrideAtCompileTime = HasSameStorageOrderAsArgType ? int(outer_stride_at_compile_time<ArgType>::ret)
1402 : int(inner_stride_at_compile_time<ArgType>::ret),
1403 MaskPacketAccessBit = (InnerStrideAtCompileTime == 1 || HasSameStorageOrderAsArgType) ?
PacketAccessBit : 0,
1405 FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1 ||
1411 Flags = Flags0 | FlagsLinearAccessBit | FlagsRowMajorBit,
1413 PacketAlignment = unpacket_traits<PacketScalar>::alignment,
1414 Alignment0 = (InnerPanel && (OuterStrideAtCompileTime !=
Dynamic) && (OuterStrideAtCompileTime != 0) &&
1415 (((OuterStrideAtCompileTime * int(sizeof(Scalar))) % int(PacketAlignment)) == 0))
1416 ? int(PacketAlignment)
1418 Alignment = plain_enum_min(evaluator<ArgType>::Alignment, Alignment0)
1420 typedef block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel> block_evaluator_type;
1421 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit evaluator(
const XprType& block) : block_evaluator_type(block) {
1422 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
1427template <
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel>
1428struct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, false>
1429 : unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>> {
1430 typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
1432 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit block_evaluator(
const XprType& block)
1433 : unary_evaluator<XprType>(block) {}
1436template <
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel>
1437struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBased>
1438 : evaluator_base<Block<ArgType, BlockRows, BlockCols, InnerPanel>> {
1439 typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
1441 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit unary_evaluator(
const XprType& block)
1442 : m_argImpl(block.nestedExpression()),
1443 m_startRow(block.startRow()),
1444 m_startCol(block.startCol()),
1445 m_linear_offset(ForwardLinearAccess
1446 ? (ArgType::IsRowMajor
1447 ? block.startRow() * block.nestedExpression().cols() + block.startCol()
1448 : block.startCol() * block.nestedExpression().rows() + block.startRow())
1451 typedef typename XprType::Scalar Scalar;
1452 typedef typename XprType::CoeffReturnType CoeffReturnType;
1455 RowsAtCompileTime = XprType::RowsAtCompileTime,
1456 ForwardLinearAccess = (InnerPanel || int(XprType::IsRowMajor) == int(ArgType::IsRowMajor)) &&
1457 bool(evaluator<ArgType>::Flags & LinearAccessBit)
1460 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col)
const {
1461 return m_argImpl.coeff(m_startRow.value() + row, m_startCol.value() + col);
1464 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index)
const {
1465 return linear_coeff_impl(index, bool_constant<ForwardLinearAccess>());
1468 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) {
1469 return m_argImpl.coeffRef(m_startRow.value() + row, m_startCol.value() + col);
1472 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) {
1473 return linear_coeffRef_impl(index, bool_constant<ForwardLinearAccess>());
1476 template <
int LoadMode,
typename PacketType>
1477 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index row, Index col)
const {
1478 return m_argImpl.template packet<LoadMode, PacketType>(m_startRow.value() + row, m_startCol.value() + col);
1481 template <
int LoadMode,
typename PacketType>
1482 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index)
const {
1483 if (ForwardLinearAccess)
1484 return m_argImpl.template packet<LoadMode, PacketType>(m_linear_offset.value() + index);
1486 return packet<LoadMode, PacketType>(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
1489 template <
int StoreMode,
typename PacketType>
1490 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacket(Index row, Index col,
const PacketType& x) {
1491 return m_argImpl.template writePacket<StoreMode, PacketType>(m_startRow.value() + row, m_startCol.value() + col, x);
1494 template <
int StoreMode,
typename PacketType>
1495 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacket(Index index,
const PacketType& x) {
1496 if (ForwardLinearAccess)
1497 return m_argImpl.template writePacket<StoreMode, PacketType>(m_linear_offset.value() + index, x);
1499 return writePacket<StoreMode, PacketType>(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0,
1503 template <
int LoadMode,
typename PacketType>
1504 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index row, Index col, Index begin, Index count)
const {
1505 return m_argImpl.template packetSegment<LoadMode, PacketType>(m_startRow.value() + row, m_startCol.value() + col,
1509 template <
int LoadMode,
typename PacketType>
1510 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index index, Index begin, Index count)
const {
1511 if (ForwardLinearAccess)
1512 return m_argImpl.template packetSegment<LoadMode, PacketType>(m_linear_offset.value() + index, begin, count);
1514 return packetSegment<LoadMode, PacketType>(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0,
1518 template <
int StoreMode,
typename PacketType>
1519 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacketSegment(Index row, Index col,
const PacketType& x, Index begin,
1521 return m_argImpl.template writePacketSegment<StoreMode, PacketType>(m_startRow.value() + row,
1522 m_startCol.value() + col, x, begin, count);
1525 template <
int StoreMode,
typename PacketType>
1526 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacketSegment(Index index,
const PacketType& x, Index begin,
1528 if (ForwardLinearAccess)
1529 return m_argImpl.template writePacketSegment<StoreMode, PacketType>(m_linear_offset.value() + index, x, begin,
1532 return writePacketSegment<StoreMode, PacketType>(RowsAtCompileTime == 1 ? 0 : index,
1533 RowsAtCompileTime == 1 ? index : 0, x, begin, count);
1537 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType
1538 linear_coeff_impl(Index index, internal::true_type )
const {
1539 return m_argImpl.coeff(m_linear_offset.value() + index);
1541 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType
1542 linear_coeff_impl(Index index, internal::false_type )
const {
1543 return coeff(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
1546 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& linear_coeffRef_impl(Index index,
1547 internal::true_type ) {
1548 return m_argImpl.coeffRef(m_linear_offset.value() + index);
1550 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& linear_coeffRef_impl(
1551 Index index, internal::false_type ) {
1552 return coeffRef(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
1555 evaluator<ArgType> m_argImpl;
1556 const variable_if_dynamic<
Index, (ArgType::RowsAtCompileTime == 1 && BlockRows == 1) ? 0 :
Dynamic> m_startRow;
1557 const variable_if_dynamic<
Index, (ArgType::ColsAtCompileTime == 1 && BlockCols == 1) ? 0 :
Dynamic> m_startCol;
1558 const variable_if_dynamic<Index, ForwardLinearAccess ? Dynamic : 0> m_linear_offset;
1564template <
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel>
1565struct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, true>
1566 : mapbase_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>,
1567 typename Block<ArgType, BlockRows, BlockCols, InnerPanel>::PlainObject> {
1568 typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
1569 typedef typename XprType::Scalar Scalar;
1571 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit block_evaluator(
const XprType& block)
1572 : mapbase_evaluator<XprType, typename XprType::PlainObject>(block) {
1573 eigen_internal_assert((internal::is_constant_evaluated() ||
1574 (std::uintptr_t(block.data()) % plain_enum_max(1, evaluator<XprType>::Alignment)) == 0) &&
1575 "data is not aligned");
1581template <
typename ArgType,
int RowFactor,
int ColFactor>
1582struct unary_evaluator<Replicate<ArgType, RowFactor, ColFactor>>
1583 : evaluator_base<Replicate<ArgType, RowFactor, ColFactor>> {
1584 typedef Replicate<ArgType, RowFactor, ColFactor> XprType;
1585 typedef typename XprType::CoeffReturnType CoeffReturnType;
1586 enum { Factor = (RowFactor ==
Dynamic || ColFactor ==
Dynamic) ? Dynamic : RowFactor * ColFactor };
1587 typedef typename nested_eval<ArgType, Factor>::type ArgTypeNested;
1588 typedef remove_all_t<ArgTypeNested> ArgTypeNestedCleaned;
1591 CoeffReadCost = evaluator<ArgTypeNestedCleaned>::CoeffReadCost,
1592 LinearAccessMask = XprType::IsVectorAtCompileTime ?
LinearAccessBit : 0,
1593 Flags = (evaluator<ArgTypeNestedCleaned>::Flags & (HereditaryBits | LinearAccessMask) & ~RowMajorBit) |
1594 (traits<XprType>::Flags & RowMajorBit),
1596 Alignment = evaluator<ArgTypeNestedCleaned>::Alignment
1599 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit unary_evaluator(
const XprType& replicate)
1600 : m_arg(replicate.nestedExpression()),
1602 m_rows(replicate.nestedExpression().rows()),
1603 m_cols(replicate.nestedExpression().cols()) {}
1605 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col)
const {
1607 const Index actual_row = traits<XprType>::RowsAtCompileTime == 1 ? 0 : RowFactor == 1 ? row : row % m_rows.value();
1608 const Index actual_col = traits<XprType>::ColsAtCompileTime == 1 ? 0 : ColFactor == 1 ? col : col % m_cols.value();
1610 return m_argImpl.coeff(actual_row, actual_col);
1613 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index)
const {
1615 const Index actual_index = traits<XprType>::RowsAtCompileTime == 1
1616 ? (ColFactor == 1 ? index : index % m_cols.value())
1617 : (RowFactor == 1 ? index : index % m_rows.value());
1619 return m_argImpl.coeff(actual_index);
1622 template <
int LoadMode,
typename PacketType>
1623 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index row, Index col)
const {
1624 const Index actual_row = traits<XprType>::RowsAtCompileTime == 1 ? 0 : RowFactor == 1 ? row : row % m_rows.value();
1625 const Index actual_col = traits<XprType>::ColsAtCompileTime == 1 ? 0 : ColFactor == 1 ? col : col % m_cols.value();
1627 return m_argImpl.template packet<LoadMode, PacketType>(actual_row, actual_col);
1630 template <
int LoadMode,
typename PacketType>
1631 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index)
const {
1632 const Index actual_index = traits<XprType>::RowsAtCompileTime == 1
1633 ? (ColFactor == 1 ? index : index % m_cols.value())
1634 : (RowFactor == 1 ? index : index % m_rows.value());
1636 return m_argImpl.template packet<LoadMode, PacketType>(actual_index);
1639 template <
int LoadMode,
typename PacketType>
1640 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index row, Index col, Index begin, Index count)
const {
1641 const Index actual_row = traits<XprType>::RowsAtCompileTime == 1 ? 0 : RowFactor == 1 ? row : row % m_rows.value();
1642 const Index actual_col = traits<XprType>::ColsAtCompileTime == 1 ? 0 : ColFactor == 1 ? col : col % m_cols.value();
1644 return m_argImpl.template packetSegment<LoadMode, PacketType>(actual_row, actual_col, begin, count);
1647 template <
int LoadMode,
typename PacketType>
1648 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index index, Index begin, Index count)
const {
1649 const Index actual_index = traits<XprType>::RowsAtCompileTime == 1
1650 ? (ColFactor == 1 ? index : index % m_cols.value())
1651 : (RowFactor == 1 ? index : index % m_rows.value());
1653 return m_argImpl.template packetSegment<LoadMode, PacketType>(actual_index, begin, count);
1657 const ArgTypeNested m_arg;
1658 evaluator<ArgTypeNestedCleaned> m_argImpl;
1659 const variable_if_dynamic<Index, ArgType::RowsAtCompileTime> m_rows;
1660 const variable_if_dynamic<Index, ArgType::ColsAtCompileTime> m_cols;
1668template <
typename XprType>
1669struct evaluator_wrapper_base : evaluator_base<XprType> {
1670 typedef remove_all_t<typename XprType::NestedExpressionType> ArgType;
1672 CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
1673 Flags = evaluator<ArgType>::Flags,
1674 Alignment = evaluator<ArgType>::Alignment
1677 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit evaluator_wrapper_base(
const ArgType& arg) : m_argImpl(
arg) {}
1679 typedef typename ArgType::Scalar Scalar;
1680 typedef typename ArgType::CoeffReturnType CoeffReturnType;
1682 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col)
const {
1683 return m_argImpl.coeff(row, col);
1686 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index)
const {
return m_argImpl.coeff(index); }
1688 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) {
return m_argImpl.coeffRef(row, col); }
1690 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) {
return m_argImpl.coeffRef(index); }
1692 template <
int LoadMode,
typename PacketType>
1693 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index row, Index col)
const {
1694 return m_argImpl.template packet<LoadMode, PacketType>(row, col);
1697 template <
int LoadMode,
typename PacketType>
1698 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index)
const {
1699 return m_argImpl.template packet<LoadMode, PacketType>(index);
1702 template <
int StoreMode,
typename PacketType>
1703 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacket(Index row, Index col,
const PacketType& x) {
1704 m_argImpl.template writePacket<StoreMode>(row, col, x);
1707 template <
int StoreMode,
typename PacketType>
1708 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacket(Index index,
const PacketType& x) {
1709 m_argImpl.template writePacket<StoreMode>(index, x);
1712 template <
int LoadMode,
typename PacketType>
1713 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index row, Index col, Index begin, Index count)
const {
1714 return m_argImpl.template packetSegment<LoadMode, PacketType>(row, col, begin, count);
1717 template <
int LoadMode,
typename PacketType>
1718 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index index, Index begin, Index count)
const {
1719 return m_argImpl.template packetSegment<LoadMode, PacketType>(index, begin, count);
1722 template <
int StoreMode,
typename PacketType>
1723 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacketSegment(Index row, Index col,
const PacketType& x, Index begin,
1725 m_argImpl.template writePacketSegment<StoreMode>(row, col, x, begin, count);
1728 template <
int StoreMode,
typename PacketType>
1729 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacketSegment(Index index,
const PacketType& x, Index begin,
1731 m_argImpl.template writePacketSegment<StoreMode>(index, x, begin, count);
1735 evaluator<ArgType> m_argImpl;
1738template <
typename TArgType>
1739struct unary_evaluator<MatrixWrapper<TArgType>> : evaluator_wrapper_base<MatrixWrapper<TArgType>> {
1740 typedef MatrixWrapper<TArgType> XprType;
1742 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit unary_evaluator(
const XprType& wrapper)
1743 : evaluator_wrapper_base<MatrixWrapper<TArgType>>(wrapper.nestedExpression()) {}
1746template <
typename TArgType>
1747struct unary_evaluator<ArrayWrapper<TArgType>> : evaluator_wrapper_base<ArrayWrapper<TArgType>> {
1748 typedef ArrayWrapper<TArgType> XprType;
1750 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit unary_evaluator(
const XprType& wrapper)
1751 : evaluator_wrapper_base<ArrayWrapper<TArgType>>(wrapper.nestedExpression()) {}
1757template <
typename PacketType,
bool ReversePacket>
1758struct reverse_packet_cond;
1760template <
typename ArgType,
int Direction>
1761struct unary_evaluator<Reverse<ArgType, Direction>> : evaluator_base<Reverse<ArgType, Direction>> {
1762 typedef Reverse<ArgType, Direction> XprType;
1763 typedef typename XprType::Scalar Scalar;
1764 typedef typename XprType::CoeffReturnType CoeffReturnType;
1767 IsRowMajor = XprType::IsRowMajor,
1768 IsColMajor = !IsRowMajor,
1769 ReverseRow = (Direction ==
Vertical) || (Direction == BothDirections),
1770 ReverseCol = (Direction ==
Horizontal) || (Direction == BothDirections),
1771 ReversePacket = (Direction ==
BothDirections) || ((Direction == Vertical) && IsColMajor) ||
1774 CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
1778 Flags0 = evaluator<ArgType>::Flags,
1780 ((Direction == BothDirections) && (
int(Flags0) & PacketAccessBit)) ||
1781 ((ReverseRow && XprType::ColsAtCompileTime == 1) || (ReverseCol && XprType::RowsAtCompileTime == 1))
1785 Flags = int(Flags0) & (HereditaryBits |
PacketAccessBit | LinearAccess),
1790 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit unary_evaluator(
const XprType& reverse)
1791 : m_argImpl(reverse.nestedExpression()),
1792 m_rows(ReverseRow ? reverse.nestedExpression().rows() : 1),
1793 m_cols(ReverseCol ? reverse.nestedExpression().cols() : 1) {}
1795 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col)
const {
1796 return m_argImpl.coeff(ReverseRow ? m_rows.value() - row - 1 : row, ReverseCol ? m_cols.value() - col - 1 : col);
1799 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index)
const {
1800 return m_argImpl.coeff(m_rows.value() * m_cols.value() - index - 1);
1803 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) {
1804 return m_argImpl.coeffRef(ReverseRow ? m_rows.value() - row - 1 : row, ReverseCol ? m_cols.value() - col - 1 : col);
1807 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) {
1808 return m_argImpl.coeffRef(m_rows.value() * m_cols.value() - index - 1);
1811 template <
int LoadMode,
typename PacketType>
1812 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index row, Index col)
const {
1813 static constexpr int PacketSize = unpacket_traits<PacketType>::size;
1814 static constexpr int OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1;
1815 static constexpr int OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1;
1816 using reverse_packet = reverse_packet_cond<PacketType, ReversePacket>;
1818 Index actualRow = ReverseRow ? m_rows.value() - row - OffsetRow : row;
1819 Index actualCol = ReverseCol ? m_cols.value() - col - OffsetCol : col;
1821 return reverse_packet::run(m_argImpl.template packet<LoadMode, PacketType>(actualRow, actualCol));
1824 template <
int LoadMode,
typename PacketType>
1825 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index)
const {
1826 static constexpr int PacketSize = unpacket_traits<PacketType>::size;
1828 Index actualIndex = m_rows.value() * m_cols.value() - index - PacketSize;
1830 return preverse(m_argImpl.template packet<LoadMode, PacketType>(actualIndex));
1833 template <
int LoadMode,
typename PacketType>
1834 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacket(Index row, Index col,
const PacketType& x) {
1835 static constexpr int PacketSize = unpacket_traits<PacketType>::size;
1836 static constexpr int OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1;
1837 static constexpr int OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1;
1838 using reverse_packet = reverse_packet_cond<PacketType, ReversePacket>;
1840 Index actualRow = ReverseRow ? m_rows.value() - row - OffsetRow : row;
1841 Index actualCol = ReverseCol ? m_cols.value() - col - OffsetCol : col;
1843 m_argImpl.template writePacket<LoadMode>(actualRow, actualCol, reverse_packet::run(x));
1846 template <
int LoadMode,
typename PacketType>
1847 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacket(Index index,
const PacketType& x) {
1848 static constexpr int PacketSize = unpacket_traits<PacketType>::size;
1850 Index actualIndex = m_rows.value() * m_cols.value() - index - PacketSize;
1852 m_argImpl.template writePacket<LoadMode>(actualIndex, preverse(x));
1855 template <
int LoadMode,
typename PacketType>
1856 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index row, Index col, Index begin, Index count)
const {
1857 static constexpr int PacketSize = unpacket_traits<PacketType>::size;
1858 static constexpr int OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1;
1859 static constexpr int OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1;
1860 using reverse_packet = reverse_packet_cond<PacketType, ReversePacket>;
1862 Index actualRow = ReverseRow ? m_rows.value() - row - OffsetRow : row;
1863 Index actualCol = ReverseCol ? m_cols.value() - col - OffsetCol : col;
1864 Index actualBegin = ReversePacket ? (PacketSize - count - begin) : begin;
1866 return reverse_packet::run(
1867 m_argImpl.template packetSegment<LoadMode, PacketType>(actualRow, actualCol, actualBegin, count));
1870 template <
int LoadMode,
typename PacketType>
1871 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index index, Index begin, Index count)
const {
1872 static constexpr int PacketSize = unpacket_traits<PacketType>::size;
1874 Index actualIndex = m_rows.value() * m_cols.value() - index - PacketSize;
1875 Index actualBegin = PacketSize - count - begin;
1877 return preverse(m_argImpl.template packetSegment<LoadMode, PacketType>(actualIndex, actualBegin, count));
1880 template <
int LoadMode,
typename PacketType>
1881 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacketSegment(Index row, Index col,
const PacketType& x, Index begin,
1883 static constexpr int PacketSize = unpacket_traits<PacketType>::size;
1884 static constexpr int OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1;
1885 static constexpr int OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1;
1886 using reverse_packet = reverse_packet_cond<PacketType, ReversePacket>;
1888 Index actualRow = ReverseRow ? m_rows.value() - row - OffsetRow : row;
1889 Index actualCol = ReverseCol ? m_cols.value() - col - OffsetCol : col;
1890 Index actualBegin = ReversePacket ? (PacketSize - count - begin) : begin;
1892 m_argImpl.template writePacketSegment<LoadMode>(actualRow, actualCol, reverse_packet::run(x), actualBegin, count);
1895 template <
int LoadMode,
typename PacketType>
1896 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void writePacketSegment(Index index,
const PacketType& x, Index begin,
1898 static constexpr int PacketSize = unpacket_traits<PacketType>::size;
1900 Index actualIndex = m_rows.value() * m_cols.value() - index - PacketSize;
1901 Index actualBegin = PacketSize - count - begin;
1903 m_argImpl.template writePacketSegment<LoadMode>(actualIndex, preverse(x), actualBegin, count);
1907 evaluator<ArgType> m_argImpl;
1911 const variable_if_dynamic<Index, ReverseRow ? ArgType::RowsAtCompileTime : 1> m_rows;
1912 const variable_if_dynamic<Index, ReverseCol ? ArgType::ColsAtCompileTime : 1> m_cols;
1917template <
typename ArgType,
int DiagIndex>
1918struct evaluator<Diagonal<ArgType, DiagIndex>> : evaluator_base<Diagonal<ArgType, DiagIndex>> {
1919 typedef Diagonal<ArgType, DiagIndex> XprType;
1922 CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
1925 (
unsigned int)(evaluator<ArgType>::Flags & (HereditaryBits | DirectAccessBit) & ~RowMajorBit) |
LinearAccessBit,
1930 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit evaluator(
const XprType& diagonal)
1931 : m_argImpl(diagonal.nestedExpression()), m_index(diagonal.index()) {}
1933 typedef typename XprType::Scalar Scalar;
1934 typedef typename XprType::CoeffReturnType CoeffReturnType;
1936 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index)
const {
1937 return m_argImpl.coeff(row + rowOffset(), row + colOffset());
1940 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index)
const {
1941 return m_argImpl.coeff(index + rowOffset(), index + colOffset());
1944 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index) {
1945 return m_argImpl.coeffRef(row + rowOffset(), row + colOffset());
1948 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) {
1949 return m_argImpl.coeffRef(index + rowOffset(), index + colOffset());
1953 evaluator<ArgType> m_argImpl;
1954 const variable_if_dynamicindex<Index, XprType::DiagIndex> m_index;
1957 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rowOffset()
const {
1958 return m_index.value() > 0 ? 0 : -m_index.value();
1960 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index colOffset()
const {
1961 return m_index.value() > 0 ? m_index.value() : 0;
1973template <
typename ArgType>
1976template <
typename ArgType>
1977struct traits<EvalToTemp<ArgType>> :
public traits<ArgType> {};
1979template <
typename ArgType>
1980class EvalToTemp :
public dense_xpr_base<EvalToTemp<ArgType>>::type {
1982 typedef typename dense_xpr_base<EvalToTemp>::type Base;
1983 EIGEN_GENERIC_PUBLIC_INTERFACE(EvalToTemp)
1985 explicit EvalToTemp(
const ArgType& arg) : m_arg(
arg) {}
1987 const ArgType&
arg()
const {
return m_arg; }
1989 constexpr Index rows() const noexcept {
return m_arg.rows(); }
1991 constexpr Index cols() const noexcept {
return m_arg.cols(); }
1994 const ArgType& m_arg;
1997template <
typename ArgType>
1998struct evaluator<EvalToTemp<ArgType>> :
public evaluator<typename ArgType::PlainObject> {
1999 typedef EvalToTemp<ArgType> XprType;
2000 typedef typename ArgType::PlainObject PlainObject;
2001 typedef evaluator<PlainObject> Base;
2003 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& xpr) : m_result(xpr.
arg()) {
2004 internal::construct_at<Base>(
this, m_result);
2008 EIGEN_DEVICE_FUNC evaluator(
const ArgType& arg) : m_result(
arg) { internal::construct_at<Base>(
this, m_result); }
2011 PlainObject m_result;
@ BothDirections
Definition Constants.h:272
@ Horizontal
Definition Constants.h:269
@ Vertical
Definition Constants.h:266
const unsigned int ActualPacketAccessBit
Definition Constants.h:108
const unsigned int PacketAccessBit
Definition Constants.h:97
const unsigned int LinearAccessBit
Definition Constants.h:133
const unsigned int EvalBeforeNestingBit
Definition Constants.h:74
const unsigned int DirectAccessBit
Definition Constants.h:159
const unsigned int RowMajorBit
Definition Constants.h:70
Namespace containing all symbols from the Eigen library.
Definition B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_arg_op< typename Derived::Scalar >, const Derived > arg(const Eigen::ArrayBase< Derived > &x)
const int Dynamic
Definition Constants.h:25