13 #ifndef EIGEN_COREEVALUATORS_H 14 #define EIGEN_COREEVALUATORS_H 22 template<
typename StorageKind>
23 struct storage_kind_to_evaluator_kind {
24 typedef IndexBased Kind;
29 template<
typename StorageKind>
struct storage_kind_to_shape;
31 template<>
struct storage_kind_to_shape<Dense> {
typedef DenseShape Shape; };
32 template<>
struct storage_kind_to_shape<SolverStorage> {
typedef SolverShape Shape; };
33 template<>
struct storage_kind_to_shape<PermutationStorage> {
typedef PermutationShape Shape; };
34 template<>
struct storage_kind_to_shape<TranspositionsStorage> {
typedef TranspositionsShape Shape; };
50 typename Arg1Kind =
typename evaluator_traits<typename T::Arg1>::Kind,
51 typename Arg2Kind =
typename evaluator_traits<typename T::Arg2>::Kind,
52 typename Arg3Kind =
typename evaluator_traits<typename T::Arg3>::Kind,
53 typename Arg1Scalar =
typename traits<typename T::Arg1>::Scalar,
54 typename Arg2Scalar =
typename traits<typename T::Arg2>::Scalar,
55 typename Arg3Scalar =
typename traits<typename T::Arg3>::Scalar>
struct ternary_evaluator;
58 typename LhsKind =
typename evaluator_traits<typename T::Lhs>::Kind,
59 typename RhsKind =
typename evaluator_traits<typename T::Rhs>::Kind,
60 typename LhsScalar =
typename traits<typename T::Lhs>::Scalar,
61 typename RhsScalar =
typename traits<typename T::Rhs>::Scalar>
struct binary_evaluator;
64 typename Kind =
typename evaluator_traits<typename T::NestedExpression>::Kind,
65 typename Scalar =
typename T::Scalar>
struct unary_evaluator;
70 struct evaluator_traits_base
73 typedef typename storage_kind_to_evaluator_kind<typename traits<T>::StorageKind>::Kind Kind;
74 typedef typename storage_kind_to_shape<typename traits<T>::StorageKind>::Shape Shape;
79 struct evaluator_traits :
public evaluator_traits_base<T>
83 template<typename T, typename Shape = typename evaluator_traits<T>::Shape >
84 struct evaluator_assume_aliasing {
85 static const bool value =
false;
90 struct evaluator :
public unary_evaluator<T>
92 typedef unary_evaluator<T> Base;
93 EIGEN_DEVICE_FUNC
explicit evaluator(
const T& xpr) : Base(xpr) {}
99 struct evaluator<const T>
103 explicit evaluator(
const T& xpr) : evaluator<T>(xpr) {}
108 template<
typename ExpressionType>
109 struct evaluator_base :
public noncopyable
112 typedef traits<ExpressionType> ExpressionTraits;
126 template<
typename Derived>
127 struct evaluator<PlainObjectBase<Derived> >
128 : evaluator_base<Derived>
130 typedef PlainObjectBase<Derived> PlainObjectType;
131 typedef typename PlainObjectType::Scalar Scalar;
132 typedef typename PlainObjectType::CoeffReturnType CoeffReturnType;
135 IsRowMajor = PlainObjectType::IsRowMajor,
136 IsVectorAtCompileTime = PlainObjectType::IsVectorAtCompileTime,
137 RowsAtCompileTime = PlainObjectType::RowsAtCompileTime,
138 ColsAtCompileTime = PlainObjectType::ColsAtCompileTime,
140 CoeffReadCost = NumTraits<Scalar>::ReadCost,
141 Flags = traits<Derived>::EvaluatorFlags,
142 Alignment = traits<Derived>::Alignment
145 EIGEN_DEVICE_FUNC evaluator()
147 m_outerStride(IsVectorAtCompileTime ? 0
148 : int(IsRowMajor) ? ColsAtCompileTime
151 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
154 EIGEN_DEVICE_FUNC
explicit evaluator(
const PlainObjectType& m)
155 : m_data(m.data()), m_outerStride(IsVectorAtCompileTime ? 0 : m.outerStride())
157 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
160 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
161 CoeffReturnType coeff(
Index row,
Index col)
const 164 return m_data[row * m_outerStride.value() + col];
166 return m_data[row + col * m_outerStride.value()];
169 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
170 CoeffReturnType coeff(
Index index)
const 172 return m_data[index];
175 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
179 return const_cast<Scalar*
>(m_data)[row * m_outerStride.value() + col];
181 return const_cast<Scalar*
>(m_data)[row + col * m_outerStride.value()];
184 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
185 Scalar& coeffRef(
Index index)
187 return const_cast<Scalar*
>(m_data)[index];
190 template<
int LoadMode,
typename PacketType>
195 return ploadt<PacketType, LoadMode>(m_data + row * m_outerStride.value() + col);
197 return ploadt<PacketType, LoadMode>(m_data + row + col * m_outerStride.value());
200 template<
int LoadMode,
typename PacketType>
202 PacketType packet(
Index index)
const 204 return ploadt<PacketType, LoadMode>(m_data + index);
207 template<
int StoreMode,
typename PacketType>
209 void writePacket(
Index row,
Index col,
const PacketType& x)
212 return pstoret<Scalar, PacketType, StoreMode>
213 (
const_cast<Scalar*
>(m_data) + row * m_outerStride.value() + col, x);
215 return pstoret<Scalar, PacketType, StoreMode>
216 (
const_cast<Scalar*
>(m_data) + row + col * m_outerStride.value(), x);
219 template<
int StoreMode,
typename PacketType>
221 void writePacket(
Index index,
const PacketType& x)
223 return pstoret<Scalar, PacketType, StoreMode>(
const_cast<Scalar*
>(m_data) + index, x);
227 const Scalar *m_data;
230 variable_if_dynamic<
Index, IsVectorAtCompileTime ? 0
231 : int(IsRowMajor) ? ColsAtCompileTime
232 : RowsAtCompileTime> m_outerStride;
235 template<
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
236 struct evaluator<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> >
237 : evaluator<PlainObjectBase<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > >
239 typedef Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> XprType;
241 EIGEN_DEVICE_FUNC evaluator() {}
243 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& m)
244 : evaluator<PlainObjectBase<XprType> >(m)
248 template<
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
249 struct evaluator<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> >
250 : evaluator<PlainObjectBase<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > >
252 typedef Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> XprType;
254 EIGEN_DEVICE_FUNC evaluator() {}
256 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& m)
257 : evaluator<PlainObjectBase<XprType> >(m)
263 template<
typename ArgType>
264 struct unary_evaluator<Transpose<ArgType>, IndexBased>
265 : evaluator_base<Transpose<ArgType> >
267 typedef Transpose<ArgType> XprType;
270 CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
272 Alignment = evaluator<ArgType>::Alignment
275 EIGEN_DEVICE_FUNC
explicit unary_evaluator(
const XprType& t) : m_argImpl(t.nestedExpression()) {}
277 typedef typename XprType::Scalar Scalar;
278 typedef typename XprType::CoeffReturnType CoeffReturnType;
280 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
281 CoeffReturnType coeff(
Index row,
Index col)
const 283 return m_argImpl.coeff(col, row);
286 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
287 CoeffReturnType coeff(
Index index)
const 289 return m_argImpl.coeff(index);
292 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
295 return m_argImpl.coeffRef(col, row);
298 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
299 typename XprType::Scalar& coeffRef(
Index index)
301 return m_argImpl.coeffRef(index);
304 template<
int LoadMode,
typename PacketType>
308 return m_argImpl.template packet<LoadMode,PacketType>(col, row);
311 template<
int LoadMode,
typename PacketType>
313 PacketType packet(
Index index)
const 315 return m_argImpl.template packet<LoadMode,PacketType>(index);
318 template<
int StoreMode,
typename PacketType>
320 void writePacket(
Index row,
Index col,
const PacketType& x)
322 m_argImpl.template writePacket<StoreMode,PacketType>(col, row, x);
325 template<
int StoreMode,
typename PacketType>
327 void writePacket(
Index index,
const PacketType& x)
329 m_argImpl.template writePacket<StoreMode,PacketType>(index, x);
333 evaluator<ArgType> m_argImpl;
340 template<
typename NullaryOp,
typename PlainObjectType>
341 struct evaluator<CwiseNullaryOp<NullaryOp,PlainObjectType> >
342 : evaluator_base<CwiseNullaryOp<NullaryOp,PlainObjectType> >
344 typedef CwiseNullaryOp<NullaryOp,PlainObjectType> XprType;
345 typedef typename internal::remove_all<PlainObjectType>::type PlainObjectTypeCleaned;
348 CoeffReadCost = internal::functor_traits<NullaryOp>::Cost,
350 Flags = (evaluator<PlainObjectTypeCleaned>::Flags
355 Alignment = AlignedMax
358 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& n)
359 : m_functor(n.functor())
361 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
364 typedef typename XprType::CoeffReturnType CoeffReturnType;
366 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
367 CoeffReturnType coeff(
Index row,
Index col)
const 369 return m_functor(row, col);
372 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
373 CoeffReturnType coeff(
Index index)
const 375 return m_functor(index);
378 template<
int LoadMode,
typename PacketType>
382 return m_functor.template packetOp<Index,PacketType>(row, col);
385 template<
int LoadMode,
typename PacketType>
387 PacketType packet(
Index index)
const 389 return m_functor.template packetOp<Index,PacketType>(index);
393 const NullaryOp m_functor;
398 template<
typename UnaryOp,
typename ArgType>
399 struct unary_evaluator<CwiseUnaryOp<UnaryOp, ArgType>, IndexBased >
400 : evaluator_base<CwiseUnaryOp<UnaryOp, ArgType> >
402 typedef CwiseUnaryOp<UnaryOp, ArgType> XprType;
405 CoeffReadCost = evaluator<ArgType>::CoeffReadCost + functor_traits<UnaryOp>::Cost,
407 Flags = evaluator<ArgType>::Flags
409 Alignment = evaluator<ArgType>::Alignment
412 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
413 explicit unary_evaluator(
const XprType& op)
414 : m_functor(op.functor()),
415 m_argImpl(op.nestedExpression())
417 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<UnaryOp>::Cost);
418 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
421 typedef typename XprType::CoeffReturnType CoeffReturnType;
423 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
424 CoeffReturnType coeff(
Index row,
Index col)
const 426 return m_functor(m_argImpl.coeff(row, col));
429 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
430 CoeffReturnType coeff(
Index index)
const 432 return m_functor(m_argImpl.coeff(index));
435 template<
int LoadMode,
typename PacketType>
439 return m_functor.packetOp(m_argImpl.template packet<LoadMode, PacketType>(row, col));
442 template<
int LoadMode,
typename PacketType>
444 PacketType packet(
Index index)
const 446 return m_functor.packetOp(m_argImpl.template packet<LoadMode, PacketType>(index));
450 const UnaryOp m_functor;
451 evaluator<ArgType> m_argImpl;
457 template<
typename TernaryOp,
typename Arg1,
typename Arg2,
typename Arg3>
458 struct evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> >
459 :
public ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> >
461 typedef CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> XprType;
462 typedef ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> > Base;
464 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& xpr) : Base(xpr) {}
467 template<
typename TernaryOp,
typename Arg1,
typename Arg2,
typename Arg3>
468 struct ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>, IndexBased, IndexBased>
469 : evaluator_base<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> >
471 typedef CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> XprType;
474 CoeffReadCost = evaluator<Arg1>::CoeffReadCost + evaluator<Arg2>::CoeffReadCost + evaluator<Arg3>::CoeffReadCost + functor_traits<TernaryOp>::Cost,
476 Arg1Flags = evaluator<Arg1>::Flags,
477 Arg2Flags = evaluator<Arg2>::Flags,
478 Arg3Flags = evaluator<Arg3>::Flags,
479 SameType = is_same<typename Arg1::Scalar,typename Arg2::Scalar>::value && is_same<typename Arg1::Scalar,typename Arg3::Scalar>::value,
481 Flags0 = (
int(Arg1Flags) | int(Arg2Flags) | int(Arg3Flags)) & (
483 | (
int(Arg1Flags) &
int(Arg2Flags) &
int(Arg3Flags) &
485 | (functor_traits<TernaryOp>::PacketAccess && StorageOrdersAgree && SameType ?
PacketAccessBit : 0)
490 Alignment = EIGEN_PLAIN_ENUM_MIN(
491 EIGEN_PLAIN_ENUM_MIN(evaluator<Arg1>::Alignment, evaluator<Arg2>::Alignment),
492 evaluator<Arg3>::Alignment)
495 EIGEN_DEVICE_FUNC
explicit ternary_evaluator(
const XprType& xpr)
496 : m_functor(xpr.functor()),
497 m_arg1Impl(xpr.arg1()),
498 m_arg2Impl(xpr.arg2()),
499 m_arg3Impl(xpr.arg3())
501 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<TernaryOp>::Cost);
502 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
505 typedef typename XprType::CoeffReturnType CoeffReturnType;
507 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
508 CoeffReturnType coeff(
Index row,
Index col)
const 510 return m_functor(m_arg1Impl.coeff(row, col), m_arg2Impl.coeff(row, col), m_arg3Impl.coeff(row, col));
513 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
514 CoeffReturnType coeff(
Index index)
const 516 return m_functor(m_arg1Impl.coeff(index), m_arg2Impl.coeff(index), m_arg3Impl.coeff(index));
519 template<
int LoadMode,
typename PacketType>
523 return m_functor.packetOp(m_arg1Impl.template packet<LoadMode,PacketType>(row, col),
524 m_arg2Impl.template packet<LoadMode,PacketType>(row, col),
525 m_arg3Impl.template packet<LoadMode,PacketType>(row, col));
528 template<
int LoadMode,
typename PacketType>
530 PacketType packet(
Index index)
const 532 return m_functor.packetOp(m_arg1Impl.template packet<LoadMode,PacketType>(index),
533 m_arg2Impl.template packet<LoadMode,PacketType>(index),
534 m_arg3Impl.template packet<LoadMode,PacketType>(index));
538 const TernaryOp m_functor;
539 evaluator<Arg1> m_arg1Impl;
540 evaluator<Arg2> m_arg2Impl;
541 evaluator<Arg3> m_arg3Impl;
547 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
548 struct evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
549 :
public binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
551 typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;
552 typedef binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > Base;
554 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& xpr) : Base(xpr) {}
557 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
558 struct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IndexBased, IndexBased>
559 : evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
561 typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;
564 CoeffReadCost = evaluator<Lhs>::CoeffReadCost + evaluator<Rhs>::CoeffReadCost + functor_traits<BinaryOp>::Cost,
566 LhsFlags = evaluator<Lhs>::Flags,
567 RhsFlags = evaluator<Rhs>::Flags,
568 SameType = is_same<typename Lhs::Scalar,typename Rhs::Scalar>::value,
570 Flags0 = (
int(LhsFlags) | int(RhsFlags)) & (
572 | (
int(LhsFlags) &
int(RhsFlags) &
573 ( (StorageOrdersAgree ? LinearAccessBit : 0)
574 | (functor_traits<BinaryOp>::PacketAccess && StorageOrdersAgree && SameType ? PacketAccessBit : 0)
579 Alignment = EIGEN_PLAIN_ENUM_MIN(evaluator<Lhs>::Alignment,evaluator<Rhs>::Alignment)
582 EIGEN_DEVICE_FUNC
explicit binary_evaluator(
const XprType& xpr)
583 : m_functor(xpr.functor()),
584 m_lhsImpl(xpr.lhs()),
587 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
588 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
591 typedef typename XprType::CoeffReturnType CoeffReturnType;
593 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
594 CoeffReturnType coeff(
Index row,
Index col)
const 596 return m_functor(m_lhsImpl.coeff(row, col), m_rhsImpl.coeff(row, col));
599 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
600 CoeffReturnType coeff(
Index index)
const 602 return m_functor(m_lhsImpl.coeff(index), m_rhsImpl.coeff(index));
605 template<
int LoadMode,
typename PacketType>
609 return m_functor.packetOp(m_lhsImpl.template packet<LoadMode,PacketType>(row, col),
610 m_rhsImpl.template packet<LoadMode,PacketType>(row, col));
613 template<
int LoadMode,
typename PacketType>
615 PacketType packet(
Index index)
const 617 return m_functor.packetOp(m_lhsImpl.template packet<LoadMode,PacketType>(index),
618 m_rhsImpl.template packet<LoadMode,PacketType>(index));
622 const BinaryOp m_functor;
623 evaluator<Lhs> m_lhsImpl;
624 evaluator<Rhs> m_rhsImpl;
629 template<
typename UnaryOp,
typename ArgType>
630 struct unary_evaluator<CwiseUnaryView<UnaryOp, ArgType>, IndexBased>
631 : evaluator_base<CwiseUnaryView<UnaryOp, ArgType> >
633 typedef CwiseUnaryView<UnaryOp, ArgType> XprType;
636 CoeffReadCost = evaluator<ArgType>::CoeffReadCost + functor_traits<UnaryOp>::Cost,
638 Flags = (evaluator<ArgType>::Flags & (HereditaryBits | LinearAccessBit |
DirectAccessBit)),
643 EIGEN_DEVICE_FUNC
explicit unary_evaluator(
const XprType& op)
644 : m_unaryOp(op.functor()),
645 m_argImpl(op.nestedExpression())
647 EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<UnaryOp>::Cost);
648 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
651 typedef typename XprType::Scalar Scalar;
652 typedef typename XprType::CoeffReturnType CoeffReturnType;
654 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
655 CoeffReturnType coeff(
Index row,
Index col)
const 657 return m_unaryOp(m_argImpl.coeff(row, col));
660 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
661 CoeffReturnType coeff(
Index index)
const 663 return m_unaryOp(m_argImpl.coeff(index));
666 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
669 return m_unaryOp(m_argImpl.coeffRef(row, col));
672 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
673 Scalar& coeffRef(
Index index)
675 return m_unaryOp(m_argImpl.coeffRef(index));
679 const UnaryOp m_unaryOp;
680 evaluator<ArgType> m_argImpl;
687 template<
typename Derived,
typename PlainObjectType>
688 struct mapbase_evaluator;
690 template<
typename Derived,
typename PlainObjectType>
691 struct mapbase_evaluator : evaluator_base<Derived>
693 typedef Derived XprType;
694 typedef typename XprType::PointerType PointerType;
695 typedef typename XprType::Scalar Scalar;
696 typedef typename XprType::CoeffReturnType CoeffReturnType;
699 IsRowMajor = XprType::RowsAtCompileTime,
700 ColsAtCompileTime = XprType::ColsAtCompileTime,
701 CoeffReadCost = NumTraits<Scalar>::ReadCost
704 EIGEN_DEVICE_FUNC
explicit mapbase_evaluator(
const XprType& map)
705 : m_data(const_cast<PointerType>(map.data())),
708 EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(evaluator<Derived>::Flags&PacketAccessBit, internal::inner_stride_at_compile_time<Derived>::ret==1),
709 PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1);
710 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
713 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
714 CoeffReturnType coeff(
Index row,
Index col)
const 716 return m_data[col * m_xpr.colStride() + row * m_xpr.rowStride()];
719 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
720 CoeffReturnType coeff(
Index index)
const 722 return m_data[index * m_xpr.innerStride()];
725 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
728 return m_data[col * m_xpr.colStride() + row * m_xpr.rowStride()];
731 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
732 Scalar& coeffRef(
Index index)
734 return m_data[index * m_xpr.innerStride()];
737 template<
int LoadMode,
typename PacketType>
741 PointerType ptr = m_data + row * m_xpr.rowStride() + col * m_xpr.colStride();
742 return internal::ploadt<PacketType, LoadMode>(ptr);
745 template<
int LoadMode,
typename PacketType>
747 PacketType packet(
Index index)
const 749 return internal::ploadt<PacketType, LoadMode>(m_data + index * m_xpr.innerStride());
752 template<
int StoreMode,
typename PacketType>
754 void writePacket(
Index row,
Index col,
const PacketType& x)
756 PointerType ptr = m_data + row * m_xpr.rowStride() + col * m_xpr.colStride();
757 return internal::pstoret<Scalar, PacketType, StoreMode>(ptr, x);
760 template<
int StoreMode,
typename PacketType>
762 void writePacket(
Index index,
const PacketType& x)
764 internal::pstoret<Scalar, PacketType, StoreMode>(m_data + index * m_xpr.innerStride(), x);
769 const XprType& m_xpr;
772 template<
typename PlainObjectType,
int MapOptions,
typename Str
ideType>
773 struct evaluator<Map<PlainObjectType, MapOptions, StrideType> >
774 :
public mapbase_evaluator<Map<PlainObjectType, MapOptions, StrideType>, PlainObjectType>
776 typedef Map<PlainObjectType, MapOptions, StrideType> XprType;
777 typedef typename XprType::Scalar Scalar;
779 typedef typename packet_traits<Scalar>::type PacketScalar;
782 InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0
783 ? int(PlainObjectType::InnerStrideAtCompileTime)
784 : int(StrideType::InnerStrideAtCompileTime),
785 OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0
786 ? int(PlainObjectType::OuterStrideAtCompileTime)
787 : int(StrideType::OuterStrideAtCompileTime),
788 HasNoInnerStride = InnerStrideAtCompileTime == 1,
789 HasNoOuterStride = StrideType::OuterStrideAtCompileTime == 0,
790 HasNoStride = HasNoInnerStride && HasNoOuterStride,
791 IsDynamicSize = PlainObjectType::SizeAtCompileTime==
Dynamic,
793 PacketAccessMask = bool(HasNoInnerStride) ? ~int(0) : ~int(PacketAccessBit),
794 LinearAccessMask = bool(HasNoStride) || bool(PlainObjectType::IsVectorAtCompileTime) ? ~int(0) : ~int(LinearAccessBit),
795 Flags = int( evaluator<PlainObjectType>::Flags) & (LinearAccessMask&PacketAccessMask),
797 Alignment = int(MapOptions)&int(AlignedMask)
800 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& map)
801 : mapbase_evaluator<XprType, PlainObjectType>(map)
807 template<
typename PlainObjectType,
int RefOptions,
typename Str
ideType>
808 struct evaluator<Ref<PlainObjectType, RefOptions, StrideType> >
809 :
public mapbase_evaluator<Ref<PlainObjectType, RefOptions, StrideType>, PlainObjectType>
811 typedef Ref<PlainObjectType, RefOptions, StrideType> XprType;
814 Flags = evaluator<Map<PlainObjectType, RefOptions, StrideType> >::Flags,
815 Alignment = evaluator<Map<PlainObjectType, RefOptions, StrideType> >::Alignment
818 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& ref)
819 : mapbase_evaluator<XprType, PlainObjectType>(ref)
825 template<
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel,
826 bool HasDirectAccess = internal::has_direct_access<ArgType>::ret>
struct block_evaluator;
828 template<
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel>
829 struct evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel> >
830 : block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel>
832 typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
833 typedef typename XprType::Scalar Scalar;
835 typedef typename packet_traits<Scalar>::type PacketScalar;
838 CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
840 RowsAtCompileTime = traits<XprType>::RowsAtCompileTime,
841 ColsAtCompileTime = traits<XprType>::ColsAtCompileTime,
842 MaxRowsAtCompileTime = traits<XprType>::MaxRowsAtCompileTime,
843 MaxColsAtCompileTime = traits<XprType>::MaxColsAtCompileTime,
845 ArgTypeIsRowMajor = (int(evaluator<ArgType>::Flags)&
RowMajorBit) != 0,
846 IsRowMajor = (MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1) ? 1
847 : (MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1) ? 0
849 HasSameStorageOrderAsArgType = (IsRowMajor == ArgTypeIsRowMajor),
850 InnerSize = IsRowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
851 InnerStrideAtCompileTime = HasSameStorageOrderAsArgType
852 ? int(inner_stride_at_compile_time<ArgType>::ret)
853 : int(outer_stride_at_compile_time<ArgType>::ret),
854 OuterStrideAtCompileTime = HasSameStorageOrderAsArgType
855 ? int(outer_stride_at_compile_time<ArgType>::ret)
856 : int(inner_stride_at_compile_time<ArgType>::ret),
857 MaskPacketAccessBit = (InnerStrideAtCompileTime == 1) ? PacketAccessBit : 0,
859 FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1 || (InnerPanel && (evaluator<ArgType>::Flags&LinearAccessBit))) ? LinearAccessBit : 0,
861 Flags0 = evaluator<ArgType>::Flags & ( (HereditaryBits & ~
RowMajorBit) |
863 MaskPacketAccessBit),
864 Flags = Flags0 | FlagsLinearAccessBit | FlagsRowMajorBit,
866 PacketAlignment = unpacket_traits<PacketScalar>::alignment,
867 Alignment0 = (InnerPanel && (OuterStrideAtCompileTime!=
Dynamic) && (((OuterStrideAtCompileTime * int(sizeof(Scalar))) % int(PacketAlignment)) == 0)) ? int(PacketAlignment) : 0,
868 Alignment = EIGEN_PLAIN_ENUM_MIN(evaluator<ArgType>::Alignment, Alignment0)
870 typedef block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel> block_evaluator_type;
871 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& block) : block_evaluator_type(block)
873 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
878 template<
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel>
879 struct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, false>
880 : unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel> >
882 typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
884 EIGEN_DEVICE_FUNC
explicit block_evaluator(
const XprType& block)
885 : unary_evaluator<XprType>(block)
889 template<
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel>
890 struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBased>
891 : evaluator_base<Block<ArgType, BlockRows, BlockCols, InnerPanel> >
893 typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
895 EIGEN_DEVICE_FUNC
explicit unary_evaluator(
const XprType& block)
896 : m_argImpl(block.nestedExpression()),
897 m_startRow(block.startRow()),
898 m_startCol(block.startCol())
901 typedef typename XprType::Scalar Scalar;
902 typedef typename XprType::CoeffReturnType CoeffReturnType;
905 RowsAtCompileTime = XprType::RowsAtCompileTime
908 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
909 CoeffReturnType coeff(
Index row,
Index col)
const 911 return m_argImpl.coeff(m_startRow.value() + row, m_startCol.value() + col);
914 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
915 CoeffReturnType coeff(
Index index)
const 917 return coeff(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
920 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
923 return m_argImpl.coeffRef(m_startRow.value() + row, m_startCol.value() + col);
926 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
927 Scalar& coeffRef(
Index index)
929 return coeffRef(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
932 template<
int LoadMode,
typename PacketType>
936 return m_argImpl.template packet<LoadMode,PacketType>(m_startRow.value() + row, m_startCol.value() + col);
939 template<
int LoadMode,
typename PacketType>
941 PacketType packet(
Index index)
const 943 return packet<LoadMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
944 RowsAtCompileTime == 1 ? index : 0);
947 template<
int StoreMode,
typename PacketType>
949 void writePacket(
Index row,
Index col,
const PacketType& x)
951 return m_argImpl.template writePacket<StoreMode,PacketType>(m_startRow.value() + row, m_startCol.value() + col, x);
954 template<
int StoreMode,
typename PacketType>
956 void writePacket(
Index index,
const PacketType& x)
958 return writePacket<StoreMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
959 RowsAtCompileTime == 1 ? index : 0,
964 evaluator<ArgType> m_argImpl;
965 const variable_if_dynamic<Index, (ArgType::RowsAtCompileTime == 1 && BlockRows==1) ? 0 : Dynamic> m_startRow;
966 const variable_if_dynamic<Index, (ArgType::ColsAtCompileTime == 1 && BlockCols==1) ? 0 : Dynamic> m_startCol;
972 template<
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel>
973 struct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, true>
974 : mapbase_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>,
975 typename Block<ArgType, BlockRows, BlockCols, InnerPanel>::PlainObject>
977 typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
978 typedef typename XprType::Scalar Scalar;
980 EIGEN_DEVICE_FUNC
explicit block_evaluator(
const XprType& block)
981 : mapbase_evaluator<XprType, typename XprType::PlainObject>(block)
984 eigen_assert(((internal::UIntPtr(block.data()) % EIGEN_PLAIN_ENUM_MAX(1,evaluator<XprType>::Alignment)) == 0) &&
"data is not aligned");
993 template<
typename ConditionMatrixType,
typename ThenMatrixType,
typename ElseMatrixType>
994 struct evaluator<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
995 : evaluator_base<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
997 typedef Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> XprType;
999 CoeffReadCost = evaluator<ConditionMatrixType>::CoeffReadCost
1000 + EIGEN_PLAIN_ENUM_MAX(evaluator<ThenMatrixType>::CoeffReadCost,
1001 evaluator<ElseMatrixType>::CoeffReadCost),
1003 Flags = (
unsigned int)evaluator<ThenMatrixType>::Flags & evaluator<ElseMatrixType>::Flags & HereditaryBits,
1005 Alignment = EIGEN_PLAIN_ENUM_MIN(evaluator<ThenMatrixType>::Alignment, evaluator<ElseMatrixType>::Alignment)
1008 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& select)
1009 : m_conditionImpl(select.conditionMatrix()),
1010 m_thenImpl(select.thenMatrix()),
1011 m_elseImpl(select.elseMatrix())
1013 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
1016 typedef typename XprType::CoeffReturnType CoeffReturnType;
1018 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1019 CoeffReturnType coeff(
Index row,
Index col)
const 1021 if (m_conditionImpl.coeff(row, col))
1022 return m_thenImpl.coeff(row, col);
1024 return m_elseImpl.coeff(row, col);
1027 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1028 CoeffReturnType coeff(
Index index)
const 1030 if (m_conditionImpl.coeff(index))
1031 return m_thenImpl.coeff(index);
1033 return m_elseImpl.coeff(index);
1037 evaluator<ConditionMatrixType> m_conditionImpl;
1038 evaluator<ThenMatrixType> m_thenImpl;
1039 evaluator<ElseMatrixType> m_elseImpl;
1045 template<
typename ArgType,
int RowFactor,
int ColFactor>
1046 struct unary_evaluator<Replicate<ArgType, RowFactor, ColFactor> >
1047 : evaluator_base<Replicate<ArgType, RowFactor, ColFactor> >
1049 typedef Replicate<ArgType, RowFactor, ColFactor> XprType;
1050 typedef typename XprType::CoeffReturnType CoeffReturnType;
1054 typedef typename internal::nested_eval<ArgType,Factor>::type ArgTypeNested;
1055 typedef typename internal::remove_all<ArgTypeNested>::type ArgTypeNestedCleaned;
1058 CoeffReadCost = evaluator<ArgTypeNestedCleaned>::CoeffReadCost,
1059 LinearAccessMask = XprType::IsVectorAtCompileTime ? LinearAccessBit : 0,
1060 Flags = (evaluator<ArgTypeNestedCleaned>::Flags & (HereditaryBits|LinearAccessMask) & ~
RowMajorBit) | (traits<XprType>::Flags &
RowMajorBit),
1062 Alignment = evaluator<ArgTypeNestedCleaned>::Alignment
1065 EIGEN_DEVICE_FUNC
explicit unary_evaluator(
const XprType& replicate)
1066 : m_arg(replicate.nestedExpression()),
1068 m_rows(replicate.nestedExpression().rows()),
1069 m_cols(replicate.nestedExpression().cols())
1072 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1073 CoeffReturnType coeff(
Index row,
Index col)
const 1076 const Index actual_row = internal::traits<XprType>::RowsAtCompileTime==1 ? 0
1077 : RowFactor==1 ? row
1078 : row % m_rows.value();
1079 const Index actual_col = internal::traits<XprType>::ColsAtCompileTime==1 ? 0
1080 : ColFactor==1 ? col
1081 : col % m_cols.value();
1083 return m_argImpl.coeff(actual_row, actual_col);
1086 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1087 CoeffReturnType coeff(
Index index)
const 1090 const Index actual_index = internal::traits<XprType>::RowsAtCompileTime==1
1091 ? (ColFactor==1 ? index : index%m_cols.value())
1092 : (RowFactor==1 ? index : index%m_rows.value());
1094 return m_argImpl.coeff(actual_index);
1097 template<
int LoadMode,
typename PacketType>
1099 PacketType packet(
Index row,
Index col)
const 1101 const Index actual_row = internal::traits<XprType>::RowsAtCompileTime==1 ? 0
1102 : RowFactor==1 ? row
1103 : row % m_rows.value();
1104 const Index actual_col = internal::traits<XprType>::ColsAtCompileTime==1 ? 0
1105 : ColFactor==1 ? col
1106 : col % m_cols.value();
1108 return m_argImpl.template packet<LoadMode,PacketType>(actual_row, actual_col);
1111 template<
int LoadMode,
typename PacketType>
1113 PacketType packet(
Index index)
const 1115 const Index actual_index = internal::traits<XprType>::RowsAtCompileTime==1
1116 ? (ColFactor==1 ? index : index%m_cols.value())
1117 : (RowFactor==1 ? index : index%m_rows.value());
1119 return m_argImpl.template packet<LoadMode,PacketType>(actual_index);
1123 const ArgTypeNested m_arg;
1124 evaluator<ArgTypeNestedCleaned> m_argImpl;
1125 const variable_if_dynamic<Index, ArgType::RowsAtCompileTime> m_rows;
1126 const variable_if_dynamic<Index, ArgType::ColsAtCompileTime> m_cols;
1132 template<
typename ArgType,
typename MemberOp,
int Direction>
1133 struct evaluator<PartialReduxExpr<ArgType, MemberOp, Direction> >
1134 : evaluator_base<PartialReduxExpr<ArgType, MemberOp, Direction> >
1136 typedef PartialReduxExpr<ArgType, MemberOp, Direction> XprType;
1137 typedef typename internal::nested_eval<ArgType,1>::type ArgTypeNested;
1138 typedef typename internal::remove_all<ArgTypeNested>::type ArgTypeNestedCleaned;
1139 typedef typename ArgType::Scalar InputScalar;
1140 typedef typename XprType::Scalar Scalar;
1142 TraversalSize = Direction==int(
Vertical) ? int(ArgType::RowsAtCompileTime) : int(ArgType::ColsAtCompileTime)
1144 typedef typename MemberOp::template Cost<InputScalar,int(TraversalSize)> CostOpType;
1147 : TraversalSize * evaluator<ArgType>::CoeffReadCost + int(CostOpType::value),
1149 Flags = (traits<XprType>::Flags&
RowMajorBit) | (evaluator<ArgType>::Flags&(HereditaryBits&(~
RowMajorBit))) | LinearAccessBit,
1154 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType xpr)
1155 : m_arg(xpr.nestedExpression()), m_functor(xpr.functor())
1157 EIGEN_INTERNAL_CHECK_COST_VALUE(TraversalSize==
Dynamic ?
HugeCost :
int(CostOpType::value));
1158 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
1161 typedef typename XprType::CoeffReturnType CoeffReturnType;
1163 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1167 return m_functor(m_arg.col(j));
1169 return m_functor(m_arg.row(i));
1172 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1173 const Scalar coeff(
Index index)
const 1176 return m_functor(m_arg.col(index));
1178 return m_functor(m_arg.row(index));
1182 const ArgTypeNested m_arg;
1183 const MemberOp m_functor;
1192 template<
typename XprType>
1193 struct evaluator_wrapper_base
1194 : evaluator_base<XprType>
1196 typedef typename remove_all<typename XprType::NestedExpressionType>::type ArgType;
1198 CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
1199 Flags = evaluator<ArgType>::Flags,
1200 Alignment = evaluator<ArgType>::Alignment
1203 EIGEN_DEVICE_FUNC
explicit evaluator_wrapper_base(
const ArgType&
arg) : m_argImpl(arg) {}
1205 typedef typename ArgType::Scalar Scalar;
1206 typedef typename ArgType::CoeffReturnType CoeffReturnType;
1208 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1209 CoeffReturnType coeff(
Index row,
Index col)
const 1211 return m_argImpl.coeff(row, col);
1214 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1215 CoeffReturnType coeff(
Index index)
const 1217 return m_argImpl.coeff(index);
1220 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1223 return m_argImpl.coeffRef(row, col);
1226 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1227 Scalar& coeffRef(
Index index)
1229 return m_argImpl.coeffRef(index);
1232 template<
int LoadMode,
typename PacketType>
1234 PacketType packet(
Index row,
Index col)
const 1236 return m_argImpl.template packet<LoadMode,PacketType>(row, col);
1239 template<
int LoadMode,
typename PacketType>
1241 PacketType packet(
Index index)
const 1243 return m_argImpl.template packet<LoadMode,PacketType>(index);
1246 template<
int StoreMode,
typename PacketType>
1248 void writePacket(
Index row,
Index col,
const PacketType& x)
1250 m_argImpl.template writePacket<StoreMode>(row, col, x);
1253 template<
int StoreMode,
typename PacketType>
1255 void writePacket(
Index index,
const PacketType& x)
1257 m_argImpl.template writePacket<StoreMode>(index, x);
1261 evaluator<ArgType> m_argImpl;
1264 template<
typename TArgType>
1265 struct unary_evaluator<MatrixWrapper<TArgType> >
1266 : evaluator_wrapper_base<MatrixWrapper<TArgType> >
1268 typedef MatrixWrapper<TArgType> XprType;
1270 EIGEN_DEVICE_FUNC
explicit unary_evaluator(
const XprType& wrapper)
1271 : evaluator_wrapper_base<MatrixWrapper<TArgType> >(wrapper.nestedExpression())
1275 template<
typename TArgType>
1276 struct unary_evaluator<ArrayWrapper<TArgType> >
1277 : evaluator_wrapper_base<ArrayWrapper<TArgType> >
1279 typedef ArrayWrapper<TArgType> XprType;
1281 EIGEN_DEVICE_FUNC
explicit unary_evaluator(
const XprType& wrapper)
1282 : evaluator_wrapper_base<ArrayWrapper<TArgType> >(wrapper.nestedExpression())
1290 template<
typename PacketType,
bool ReversePacket>
struct reverse_packet_cond;
1292 template<
typename ArgType,
int Direction>
1293 struct unary_evaluator<Reverse<ArgType, Direction> >
1294 : evaluator_base<Reverse<ArgType, Direction> >
1296 typedef Reverse<ArgType, Direction> XprType;
1297 typedef typename XprType::Scalar Scalar;
1298 typedef typename XprType::CoeffReturnType CoeffReturnType;
1301 IsRowMajor = XprType::IsRowMajor,
1302 IsColMajor = !IsRowMajor,
1306 || ((Direction ==
Vertical) && IsColMajor)
1307 || ((Direction ==
Horizontal) && IsRowMajor),
1309 CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
1313 Flags0 = evaluator<ArgType>::Flags,
1315 || ((ReverseRow && XprType::ColsAtCompileTime==1) || (ReverseCol && XprType::RowsAtCompileTime==1))
1316 ? LinearAccessBit : 0,
1318 Flags =
int(Flags0) & (HereditaryBits | PacketAccessBit | LinearAccess),
1323 EIGEN_DEVICE_FUNC
explicit unary_evaluator(
const XprType& reverse)
1324 : m_argImpl(reverse.nestedExpression()),
1325 m_rows(ReverseRow ? reverse.nestedExpression().rows() : 1),
1326 m_cols(ReverseCol ? reverse.nestedExpression().cols() : 1)
1329 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1330 CoeffReturnType coeff(
Index row,
Index col)
const 1332 return m_argImpl.coeff(ReverseRow ? m_rows.value() - row - 1 : row,
1333 ReverseCol ? m_cols.value() - col - 1 : col);
1336 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1337 CoeffReturnType coeff(
Index index)
const 1339 return m_argImpl.coeff(m_rows.value() * m_cols.value() - index - 1);
1342 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1345 return m_argImpl.coeffRef(ReverseRow ? m_rows.value() - row - 1 : row,
1346 ReverseCol ? m_cols.value() - col - 1 : col);
1349 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1350 Scalar& coeffRef(
Index index)
1352 return m_argImpl.coeffRef(m_rows.value() * m_cols.value() - index - 1);
1355 template<
int LoadMode,
typename PacketType>
1357 PacketType packet(
Index row,
Index col)
const 1360 PacketSize = unpacket_traits<PacketType>::size,
1361 OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1,
1362 OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1
1364 typedef internal::reverse_packet_cond<PacketType,ReversePacket> reverse_packet;
1365 return reverse_packet::run(m_argImpl.template packet<LoadMode,PacketType>(
1366 ReverseRow ? m_rows.value() - row - OffsetRow : row,
1367 ReverseCol ? m_cols.value() - col - OffsetCol : col));
1370 template<
int LoadMode,
typename PacketType>
1372 PacketType packet(
Index index)
const 1374 enum { PacketSize = unpacket_traits<PacketType>::size };
1375 return preverse(m_argImpl.template packet<LoadMode,PacketType>(m_rows.value() * m_cols.value() - index - PacketSize));
1378 template<
int LoadMode,
typename PacketType>
1380 void writePacket(
Index row,
Index col,
const PacketType& x)
1384 PacketSize = unpacket_traits<PacketType>::size,
1385 OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1,
1386 OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1
1388 typedef internal::reverse_packet_cond<PacketType,ReversePacket> reverse_packet;
1389 m_argImpl.template writePacket<LoadMode>(
1390 ReverseRow ? m_rows.value() - row - OffsetRow : row,
1391 ReverseCol ? m_cols.value() - col - OffsetCol : col,
1392 reverse_packet::run(x));
1395 template<
int LoadMode,
typename PacketType>
1397 void writePacket(
Index index,
const PacketType& x)
1399 enum { PacketSize = unpacket_traits<PacketType>::size };
1400 m_argImpl.template writePacket<LoadMode>
1401 (m_rows.value() * m_cols.value() - index - PacketSize, preverse(x));
1405 evaluator<ArgType> m_argImpl;
1409 const variable_if_dynamic<Index, ReverseRow ? ArgType::RowsAtCompileTime : 1> m_rows;
1410 const variable_if_dynamic<Index, ReverseCol ? ArgType::ColsAtCompileTime : 1> m_cols;
1416 template<
typename ArgType,
int DiagIndex>
1417 struct evaluator<Diagonal<ArgType, DiagIndex> >
1418 : evaluator_base<Diagonal<ArgType, DiagIndex> >
1420 typedef Diagonal<ArgType, DiagIndex> XprType;
1423 CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
1430 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& diagonal)
1431 : m_argImpl(diagonal.nestedExpression()),
1432 m_index(diagonal.index())
1435 typedef typename XprType::Scalar Scalar;
1437 typedef typename internal::conditional<!internal::is_same<typename ArgType::StorageKind,Sparse>::value,
1438 typename XprType::CoeffReturnType,Scalar>::type CoeffReturnType;
1440 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1441 CoeffReturnType coeff(
Index row,
Index)
const 1443 return m_argImpl.coeff(row + rowOffset(), row + colOffset());
1446 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1447 CoeffReturnType coeff(
Index index)
const 1449 return m_argImpl.coeff(index + rowOffset(), index + colOffset());
1452 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1455 return m_argImpl.coeffRef(row + rowOffset(), row + colOffset());
1458 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1459 Scalar& coeffRef(
Index index)
1461 return m_argImpl.coeffRef(index + rowOffset(), index + colOffset());
1465 evaluator<ArgType> m_argImpl;
1466 const internal::variable_if_dynamicindex<Index, XprType::DiagIndex> m_index;
1469 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Index rowOffset()
const {
return m_index.value() > 0 ? 0 : -m_index.value(); }
1470 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Index colOffset()
const {
return m_index.value() > 0 ? m_index.value() : 0; }
1482 template<
typename ArgType>
class EvalToTemp;
1484 template<
typename ArgType>
1485 struct traits<EvalToTemp<ArgType> >
1486 :
public traits<ArgType>
1489 template<
typename ArgType>
1491 :
public dense_xpr_base<EvalToTemp<ArgType> >::type
1495 typedef typename dense_xpr_base<EvalToTemp>::type Base;
1496 EIGEN_GENERIC_PUBLIC_INTERFACE(EvalToTemp)
1498 explicit EvalToTemp(const ArgType&
arg)
1502 const ArgType&
arg()
const 1509 return m_arg.rows();
1514 return m_arg.cols();
1518 const ArgType& m_arg;
1521 template<
typename ArgType>
1522 struct evaluator<EvalToTemp<ArgType> >
1523 :
public evaluator<typename ArgType::PlainObject>
1525 typedef EvalToTemp<ArgType> XprType;
1526 typedef typename ArgType::PlainObject PlainObject;
1527 typedef evaluator<PlainObject> Base;
1529 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& xpr)
1530 : m_result(xpr.
arg())
1532 ::new (static_cast<Base*>(
this)) Base(m_result);
1536 EIGEN_DEVICE_FUNC evaluator(const ArgType&
arg)
1539 ::new (static_cast<Base*>(
this)) Base(m_result);
1543 PlainObject m_result;
1550 #endif // EIGEN_COREEVALUATORS_H const int HugeCost
Definition: Constants.h:39
Definition: Constants.h:265
const unsigned int DirectAccessBit
Definition: Constants.h:150
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_arg_op< typename Derived::Scalar >, const Derived > arg(const Eigen::ArrayBase< Derived > &x)
Namespace containing all symbols from the Eigen library.
Definition: Core:271
const unsigned int RowMajorBit
Definition: Constants.h:61
const unsigned int PacketAccessBit
Definition: Constants.h:89
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: XprHelper.h:35
Definition: Constants.h:268
Definition: Constants.h:271
Definition: Eigen_Colamd.h:50
const int Dynamic
Definition: Constants.h:21
const unsigned int EvalBeforeNestingBit
Definition: Constants.h:65
const unsigned int LinearAccessBit
Definition: Constants.h:125