13 #ifndef EIGEN_COREEVALUATORS_H
14 #define EIGEN_COREEVALUATORS_H
22 template<
typename StorageKind>
83 template<typename T, typename Shape = typename evaluator_traits<T>::Shape >
85 static const bool value =
false;
93 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
103 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
109 template<
typename ExpressionType>
138 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
141 #ifndef EIGEN_INTERNAL_DEBUGGING
142 EIGEN_UNUSED_VARIABLE(outerStride);
146 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
153 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
155 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
156 Index outerStride()
const {
return m_outerStride; }
162 template<
typename Derived>
167 typedef typename PlainObjectType::Scalar Scalar;
168 typedef typename PlainObjectType::CoeffReturnType CoeffReturnType;
171 IsRowMajor = PlainObjectType::IsRowMajor,
172 IsVectorAtCompileTime = PlainObjectType::IsVectorAtCompileTime,
173 RowsAtCompileTime = PlainObjectType::RowsAtCompileTime,
174 ColsAtCompileTime = PlainObjectType::ColsAtCompileTime,
182 OuterStrideAtCompileTime = IsVectorAtCompileTime ? 0
183 : int(IsRowMajor) ? ColsAtCompileTime
187 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
189 : m_d(0,OuterStrideAtCompileTime)
191 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
194 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
196 : m_d(m.
data(),IsVectorAtCompileTime ? 0 : m.outerStride())
198 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
201 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
202 CoeffReturnType coeff(
Index row,
Index col)
const
205 return m_d.data[row * m_d.outerStride() + col];
207 return m_d.data[row + col * m_d.outerStride()];
210 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
211 CoeffReturnType coeff(
Index index)
const
213 return m_d.data[index];
216 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
220 return const_cast<Scalar*
>(m_d.data)[row * m_d.outerStride() + col];
222 return const_cast<Scalar*
>(m_d.data)[row + col * m_d.outerStride()];
225 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
226 Scalar& coeffRef(
Index index)
228 return const_cast<Scalar*
>(m_d.data)[index];
231 template<
int LoadMode,
typename PacketType>
236 return ploadt<PacketType, LoadMode>(m_d.data + row * m_d.outerStride() + col);
238 return ploadt<PacketType, LoadMode>(m_d.data + row + col * m_d.outerStride());
241 template<
int LoadMode,
typename PacketType>
243 PacketType packet(
Index index)
const
245 return ploadt<PacketType, LoadMode>(m_d.data + index);
248 template<
int StoreMode,
typename PacketType>
250 void writePacket(
Index row,
Index col,
const PacketType& x)
253 return pstoret<Scalar, PacketType, StoreMode>
254 (
const_cast<Scalar*
>(m_d.data) + row * m_d.outerStride() + col, x);
256 return pstoret<Scalar, PacketType, StoreMode>
257 (
const_cast<Scalar*
>(m_d.data) + row + col * m_d.outerStride(), x);
260 template<
int StoreMode,
typename PacketType>
262 void writePacket(
Index index,
const PacketType& x)
264 return pstoret<Scalar, PacketType, StoreMode>(
const_cast<Scalar*
>(m_d.data) + index, x);
272 template<
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
274 :
evaluator<PlainObjectBase<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > >
278 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
281 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
287 template<
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
289 :
evaluator<PlainObjectBase<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > >
293 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
296 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
304 template<
typename ArgType>
316 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
319 typedef typename XprType::Scalar Scalar;
320 typedef typename XprType::CoeffReturnType CoeffReturnType;
322 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
323 CoeffReturnType coeff(
Index row,
Index col)
const
325 return m_argImpl.coeff(col, row);
328 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
329 CoeffReturnType coeff(
Index index)
const
331 return m_argImpl.coeff(index);
334 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
337 return m_argImpl.coeffRef(col, row);
340 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
341 typename XprType::Scalar& coeffRef(
Index index)
343 return m_argImpl.coeffRef(index);
346 template<
int LoadMode,
typename PacketType>
350 return m_argImpl.template packet<LoadMode,PacketType>(col, row);
353 template<
int LoadMode,
typename PacketType>
355 PacketType packet(
Index index)
const
357 return m_argImpl.template packet<LoadMode,PacketType>(index);
360 template<
int StoreMode,
typename PacketType>
362 void writePacket(
Index row,
Index col,
const PacketType& x)
364 m_argImpl.template writePacket<StoreMode,PacketType>(col, row, x);
367 template<
int StoreMode,
typename PacketType>
369 void writePacket(
Index index,
const PacketType& x)
371 m_argImpl.template writePacket<StoreMode,PacketType>(index, x);
382 template<
typename Scalar,
typename NullaryOp,
388 template <
typename IndexType>
389 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i, IndexType j)
const {
return op(i,j); }
390 template <
typename IndexType>
391 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i)
const {
return op(i); }
393 template <
typename T,
typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i, IndexType j)
const {
return op.template packetOp<T>(i,j); }
394 template <
typename T,
typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i)
const {
return op.template packetOp<T>(i); }
397 template<
typename Scalar,
typename NullaryOp>
400 template <
typename IndexType>
401 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType=0, IndexType=0)
const {
return op(); }
402 template <
typename T,
typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType=0, IndexType=0)
const {
return op.template packetOp<T>(); }
405 template<
typename Scalar,
typename NullaryOp>
408 template <
typename IndexType>
409 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i, IndexType j=0)
const {
return op(i,j); }
410 template <
typename T,
typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i, IndexType j=0)
const {
return op.template packetOp<T>(i,j); }
416 template<
typename Scalar,
typename NullaryOp>
419 template <
typename IndexType>
420 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i, IndexType j)
const {
421 eigen_assert(i==0 || j==0);
424 template <
typename T,
typename IndexType> 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 {
return op(i); }
431 template <
typename T,
typename IndexType>
432 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i)
const {
return op.template packetOp<T>(i); }
435 template<
typename Scalar,
typename NullaryOp>
438 #if 0 && EIGEN_COMP_MSVC>0
456 template<
typename T>
struct nullary_wrapper_workaround_msvc {
457 nullary_wrapper_workaround_msvc(
const T&);
461 template<
typename Scalar,
typename NullaryOp>
462 struct nullary_wrapper<Scalar,NullaryOp,true,true,true>
464 template <
typename IndexType>
465 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i, IndexType j)
const {
466 return nullary_wrapper<Scalar,NullaryOp,
467 has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,
468 has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,
469 has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().
operator()(op,i,j);
471 template <
typename IndexType>
472 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i)
const {
473 return nullary_wrapper<Scalar,NullaryOp,
474 has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,
475 has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,
476 has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().
operator()(op,i);
479 template <
typename T,
typename IndexType>
480 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i, IndexType j)
const {
481 return nullary_wrapper<Scalar,NullaryOp,
482 has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,
483 has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,
484 has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().
template packetOp<T>(op,i,j);
486 template <
typename T,
typename IndexType>
487 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i)
const {
488 return nullary_wrapper<Scalar,NullaryOp,
489 has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,
490 has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,
491 has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().
template packetOp<T>(op,i);
494 #endif // MSVC workaround
496 template<
typename NullaryOp,
typename PlainObjectType>
501 typedef typename internal::remove_all<PlainObjectType>::type PlainObjectTypeCleaned;
511 Alignment = AlignedMax
515 : 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
524 CoeffReturnType coeff(IndexType row, IndexType col)
const
526 return m_wrapper(m_functor, row, col);
529 template <
typename IndexType>
530 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
531 CoeffReturnType coeff(IndexType index)
const
533 return m_wrapper(m_functor,index);
536 template<
int LoadMode,
typename PacketType,
typename IndexType>
538 PacketType packet(IndexType row, IndexType col)
const
540 return m_wrapper.template packetOp<PacketType>(m_functor, row, col);
543 template<
int LoadMode,
typename PacketType,
typename IndexType>
545 PacketType packet(IndexType index)
const
547 return m_wrapper.template packetOp<PacketType>(m_functor, index);
551 const NullaryOp m_functor;
557 template<
typename UnaryOp,
typename ArgType>
571 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
575 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
578 typedef typename XprType::CoeffReturnType CoeffReturnType;
580 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
581 CoeffReturnType coeff(
Index row,
Index col)
const
583 return m_d.func()(m_d.argImpl.coeff(row, col));
586 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
587 CoeffReturnType coeff(
Index index)
const
589 return m_d.func()(m_d.argImpl.coeff(index));
592 template<
int LoadMode,
typename PacketType>
596 return m_d.func().packetOp(m_d.argImpl.template packet<LoadMode, PacketType>(row, col));
599 template<
int LoadMode,
typename PacketType>
601 PacketType packet(
Index index)
const
603 return m_d.func().packetOp(m_d.argImpl.template packet<LoadMode, PacketType>(index));
609 class Data :
private UnaryOp
612 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
614 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
615 const UnaryOp& func()
const {
return static_cast<const UnaryOp&
>(*this); }
625 template<
typename TernaryOp,
typename Arg1,
typename Arg2,
typename Arg3>
635 template<
typename TernaryOp,
typename Arg1,
typename Arg2,
typename Arg3>
649 Flags0 = (
int(Arg1Flags) | int(Arg2Flags) | int(Arg3Flags)) & (
651 | (
int(Arg1Flags) &
int(Arg2Flags) &
int(Arg3Flags) &
658 Alignment = EIGEN_PLAIN_ENUM_MIN(
666 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
669 typedef typename XprType::CoeffReturnType CoeffReturnType;
671 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
672 CoeffReturnType coeff(
Index row,
Index col)
const
674 return m_d.func()(m_d.arg1Impl.coeff(row, col), m_d.arg2Impl.coeff(row, col), m_d.arg3Impl.coeff(row, col));
677 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
678 CoeffReturnType coeff(
Index index)
const
680 return m_d.func()(m_d.arg1Impl.coeff(index), m_d.arg2Impl.coeff(index), m_d.arg3Impl.coeff(index));
683 template<
int LoadMode,
typename PacketType>
687 return m_d.func().packetOp(m_d.arg1Impl.template packet<LoadMode,PacketType>(row, col),
688 m_d.arg2Impl.template packet<LoadMode,PacketType>(row, col),
689 m_d.arg3Impl.template packet<LoadMode,PacketType>(row, col));
692 template<
int LoadMode,
typename PacketType>
694 PacketType packet(
Index index)
const
696 return m_d.func().packetOp(m_d.arg1Impl.template packet<LoadMode,PacketType>(index),
697 m_d.arg2Impl.template packet<LoadMode,PacketType>(index),
698 m_d.arg3Impl.template packet<LoadMode,PacketType>(index));
703 struct Data :
private TernaryOp
705 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
707 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
708 const TernaryOp& func()
const {
return static_cast<const TernaryOp&
>(*this); }
720 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
727 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
731 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
744 Flags0 = (
int(LhsFlags) | int(RhsFlags)) & (
746 | (
int(LhsFlags) &
int(RhsFlags) &
756 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
760 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
763 typedef typename XprType::CoeffReturnType CoeffReturnType;
765 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
766 CoeffReturnType coeff(
Index row,
Index col)
const
768 return m_d.func()(m_d.lhsImpl.coeff(row, col), m_d.rhsImpl.coeff(row, col));
771 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
772 CoeffReturnType coeff(
Index index)
const
774 return m_d.func()(m_d.lhsImpl.coeff(index), m_d.rhsImpl.coeff(index));
777 template<
int LoadMode,
typename PacketType>
781 return m_d.func().packetOp(m_d.lhsImpl.template packet<LoadMode,PacketType>(row, col),
782 m_d.rhsImpl.template packet<LoadMode,PacketType>(row, col));
785 template<
int LoadMode,
typename PacketType>
787 PacketType packet(
Index index)
const
789 return m_d.func().packetOp(m_d.lhsImpl.template packet<LoadMode,PacketType>(index),
790 m_d.rhsImpl.template packet<LoadMode,PacketType>(index));
796 struct Data :
private BinaryOp
798 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
800 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
801 const BinaryOp& func()
const {
return static_cast<const BinaryOp&
>(*this); }
811 template<
typename UnaryOp,
typename ArgType>
828 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
831 typedef typename XprType::Scalar Scalar;
832 typedef typename XprType::CoeffReturnType CoeffReturnType;
834 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
835 CoeffReturnType coeff(
Index row,
Index col)
const
837 return m_d.func()(m_d.argImpl.coeff(row, col));
840 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
841 CoeffReturnType coeff(
Index index)
const
843 return m_d.func()(m_d.argImpl.coeff(index));
846 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
849 return m_d.func()(m_d.argImpl.coeffRef(row, col));
852 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
853 Scalar& coeffRef(
Index index)
855 return m_d.func()(m_d.argImpl.coeffRef(index));
861 struct Data :
private UnaryOp
863 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
865 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
866 const UnaryOp& func()
const {
return static_cast<const UnaryOp&
>(*this); }
877 template<
typename Derived,
typename PlainObjectType>
880 template<
typename Derived,
typename PlainObjectType>
883 typedef Derived XprType;
884 typedef typename XprType::PointerType PointerType;
885 typedef typename XprType::Scalar Scalar;
886 typedef typename XprType::CoeffReturnType CoeffReturnType;
889 IsRowMajor = XprType::RowsAtCompileTime,
890 ColsAtCompileTime = XprType::ColsAtCompileTime,
894 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
896 : m_data(
const_cast<PointerType
>(map.data())),
897 m_innerStride(map.innerStride()),
898 m_outerStride(map.outerStride())
901 PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1);
902 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
905 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
906 CoeffReturnType coeff(
Index row,
Index col)
const
908 return m_data[col * colStride() + row * rowStride()];
911 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
912 CoeffReturnType coeff(
Index index)
const
914 return m_data[index * m_innerStride.value()];
917 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
920 return m_data[col * colStride() + row * rowStride()];
923 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
924 Scalar& coeffRef(
Index index)
926 return m_data[index * m_innerStride.value()];
929 template<
int LoadMode,
typename PacketType>
933 PointerType ptr = m_data + row * rowStride() + col * colStride();
934 return internal::ploadt<PacketType, LoadMode>(ptr);
937 template<
int LoadMode,
typename PacketType>
939 PacketType packet(
Index index)
const
941 return internal::ploadt<PacketType, LoadMode>(m_data + index * m_innerStride.value());
944 template<
int StoreMode,
typename PacketType>
946 void writePacket(
Index row,
Index col,
const PacketType& x)
948 PointerType ptr = m_data + row * rowStride() + col * colStride();
949 return internal::pstoret<Scalar, PacketType, StoreMode>(ptr, x);
952 template<
int StoreMode,
typename PacketType>
954 void writePacket(
Index index,
const PacketType& x)
956 internal::pstoret<Scalar, PacketType, StoreMode>(m_data + index * m_innerStride.value(), x);
959 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
960 Index rowStride()
const {
return XprType::IsRowMajor ? m_outerStride.value() : m_innerStride.value(); }
961 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
962 Index colStride()
const {
return XprType::IsRowMajor ? m_innerStride.value() : m_outerStride.value(); }
969 template<
typename PlainObjectType,
int MapOptions,
typename Str
ideType>
971 :
public mapbase_evaluator<Map<PlainObjectType, MapOptions, StrideType>, PlainObjectType>
974 typedef typename XprType::Scalar Scalar;
976 typedef typename packet_traits<Scalar>::type PacketScalar;
979 InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0
980 ? int(PlainObjectType::InnerStrideAtCompileTime)
981 : int(StrideType::InnerStrideAtCompileTime),
982 OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0
983 ? int(PlainObjectType::OuterStrideAtCompileTime)
984 : int(StrideType::OuterStrideAtCompileTime),
985 HasNoInnerStride = InnerStrideAtCompileTime == 1,
986 HasNoOuterStride = StrideType::OuterStrideAtCompileTime == 0,
987 HasNoStride = HasNoInnerStride && HasNoOuterStride,
988 IsDynamicSize = PlainObjectType::SizeAtCompileTime==
Dynamic,
990 PacketAccessMask = bool(HasNoInnerStride) ? ~int(0) : ~int(
PacketAccessBit),
991 LinearAccessMask = bool(HasNoStride) || bool(PlainObjectType::IsVectorAtCompileTime) ? ~int(0) : ~int(
LinearAccessBit),
994 Alignment =
int(MapOptions)&int(AlignedMask)
1004 template<
typename PlainObjectType,
int RefOptions,
typename Str
ideType>
1006 :
public mapbase_evaluator<Ref<PlainObjectType, RefOptions, StrideType>, PlainObjectType>
1015 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1023 template<
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel,
1026 template<
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel>
1031 typedef typename XprType::Scalar Scalar;
1033 typedef typename packet_traits<Scalar>::type PacketScalar;
1044 IsRowMajor = (MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1) ? 1
1045 : (MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1) ? 0
1046 : ArgTypeIsRowMajor,
1047 HasSameStorageOrderAsArgType = (IsRowMajor == ArgTypeIsRowMajor),
1048 InnerSize = IsRowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
1049 InnerStrideAtCompileTime = HasSameStorageOrderAsArgType
1052 OuterStrideAtCompileTime = HasSameStorageOrderAsArgType
1055 MaskPacketAccessBit = (InnerStrideAtCompileTime == 1 || HasSameStorageOrderAsArgType) ?
PacketAccessBit : 0,
1061 MaskPacketAccessBit),
1062 Flags = Flags0 | FlagsLinearAccessBit | FlagsRowMajorBit,
1065 Alignment0 = (InnerPanel && (OuterStrideAtCompileTime!=
Dynamic)
1066 && (OuterStrideAtCompileTime!=0)
1067 && (((OuterStrideAtCompileTime *
int(
sizeof(Scalar))) %
int(PacketAlignment)) == 0)) ? int(PacketAlignment) : 0,
1071 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1074 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
1079 template<
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel>
1085 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1091 template<
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel>
1093 :
evaluator_base<Block<ArgType, BlockRows, BlockCols, InnerPanel> >
1097 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1099 : m_argImpl(block.nestedExpression()),
1100 m_startRow(block.startRow()),
1101 m_startCol(block.startCol()),
1102 m_linear_offset(ForwardLinearAccess?(ArgType::IsRowMajor ? block.startRow()*block.nestedExpression().cols() + block.startCol() : block.startCol()*block.nestedExpression().rows() + block.startRow()):0)
1105 typedef typename XprType::Scalar Scalar;
1106 typedef typename XprType::CoeffReturnType CoeffReturnType;
1109 RowsAtCompileTime = XprType::RowsAtCompileTime,
1113 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1114 CoeffReturnType coeff(
Index row,
Index col)
const
1116 return m_argImpl.coeff(m_startRow.value() + row, m_startCol.value() + col);
1119 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1120 CoeffReturnType coeff(
Index index)
const
1125 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1128 return m_argImpl.coeffRef(m_startRow.value() + row, m_startCol.value() + col);
1131 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1132 Scalar& coeffRef(
Index index)
1137 template<
int LoadMode,
typename PacketType>
1139 PacketType packet(
Index row,
Index col)
const
1141 return m_argImpl.template packet<LoadMode,PacketType>(m_startRow.value() + row, m_startCol.value() + col);
1144 template<
int LoadMode,
typename PacketType>
1146 PacketType packet(
Index index)
const
1148 if (ForwardLinearAccess)
1149 return m_argImpl.template packet<LoadMode,PacketType>(m_linear_offset.value() + index);
1151 return packet<LoadMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
1152 RowsAtCompileTime == 1 ? index : 0);
1155 template<
int StoreMode,
typename PacketType>
1157 void writePacket(
Index row,
Index col,
const PacketType& x)
1159 return m_argImpl.template writePacket<StoreMode,PacketType>(m_startRow.value() + row, m_startCol.value() + col, x);
1162 template<
int StoreMode,
typename PacketType>
1164 void writePacket(
Index index,
const PacketType& x)
1166 if (ForwardLinearAccess)
1167 return m_argImpl.template writePacket<StoreMode,PacketType>(m_linear_offset.value() + index, x);
1169 return writePacket<StoreMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
1170 RowsAtCompileTime == 1 ? index : 0,
1175 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1178 return m_argImpl.coeff(m_linear_offset.value() + index);
1180 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1183 return coeff(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
1186 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1189 return m_argImpl.coeffRef(m_linear_offset.value() + index);
1191 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1194 return coeffRef(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
1206 template<
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel>
1209 typename Block<ArgType, BlockRows, BlockCols, InnerPanel>::PlainObject>
1212 typedef typename XprType::Scalar Scalar;
1214 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1228 template<
typename ConditionMatrixType,
typename ThenMatrixType,
typename ElseMatrixType>
1230 :
evaluator_base<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
1243 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1245 : m_conditionImpl(select.conditionMatrix()),
1246 m_thenImpl(select.thenMatrix()),
1247 m_elseImpl(select.elseMatrix())
1249 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
1252 typedef typename XprType::CoeffReturnType CoeffReturnType;
1254 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1255 CoeffReturnType coeff(
Index row,
Index col)
const
1257 if (m_conditionImpl.coeff(row, col))
1258 return m_thenImpl.coeff(row, col);
1260 return m_elseImpl.coeff(row, col);
1263 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1264 CoeffReturnType coeff(
Index index)
const
1266 if (m_conditionImpl.coeff(index))
1267 return m_thenImpl.coeff(index);
1269 return m_elseImpl.coeff(index);
1281 template<
typename ArgType,
int RowFactor,
int ColFactor>
1286 typedef typename XprType::CoeffReturnType CoeffReturnType;
1291 typedef typename internal::remove_all<ArgTypeNested>::type ArgTypeNestedCleaned;
1295 LinearAccessMask = XprType::IsVectorAtCompileTime ?
LinearAccessBit : 0,
1301 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1303 : m_arg(replicate.nestedExpression()),
1305 m_rows(replicate.nestedExpression().rows()),
1306 m_cols(replicate.nestedExpression().cols())
1309 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1310 CoeffReturnType coeff(
Index row,
Index col)
const
1314 : RowFactor==1 ? row
1315 : row % m_rows.value();
1317 : ColFactor==1 ? col
1318 : col % m_cols.value();
1320 return m_argImpl.coeff(actual_row, actual_col);
1323 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1324 CoeffReturnType coeff(
Index index)
const
1328 ? (ColFactor==1 ? index : index%m_cols.value())
1329 : (RowFactor==1 ? index : index%m_rows.value());
1331 return m_argImpl.coeff(actual_index);
1334 template<
int LoadMode,
typename PacketType>
1336 PacketType packet(
Index row,
Index col)
const
1339 : RowFactor==1 ? row
1340 : row % m_rows.value();
1342 : ColFactor==1 ? col
1343 : col % m_cols.value();
1345 return m_argImpl.template packet<LoadMode,PacketType>(actual_row, actual_col);
1348 template<
int LoadMode,
typename PacketType>
1350 PacketType packet(
Index index)
const
1353 ? (ColFactor==1 ? index : index%m_cols.value())
1354 : (RowFactor==1 ? index : index%m_rows.value());
1356 return m_argImpl.template packet<LoadMode,PacketType>(actual_index);
1371 template<
typename XprType>
1375 typedef typename remove_all<typename XprType::NestedExpressionType>::type ArgType;
1382 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1385 typedef typename ArgType::Scalar Scalar;
1386 typedef typename ArgType::CoeffReturnType CoeffReturnType;
1388 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1389 CoeffReturnType coeff(
Index row,
Index col)
const
1391 return m_argImpl.coeff(row, col);
1394 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1395 CoeffReturnType coeff(
Index index)
const
1397 return m_argImpl.coeff(index);
1400 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1403 return m_argImpl.coeffRef(row, col);
1406 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1407 Scalar& coeffRef(
Index index)
1409 return m_argImpl.coeffRef(index);
1412 template<
int LoadMode,
typename PacketType>
1414 PacketType packet(
Index row,
Index col)
const
1416 return m_argImpl.template packet<LoadMode,PacketType>(row, col);
1419 template<
int LoadMode,
typename PacketType>
1421 PacketType packet(
Index index)
const
1423 return m_argImpl.template packet<LoadMode,PacketType>(index);
1426 template<
int StoreMode,
typename PacketType>
1428 void writePacket(
Index row,
Index col,
const PacketType& x)
1430 m_argImpl.template writePacket<StoreMode>(row, col, x);
1433 template<
int StoreMode,
typename PacketType>
1435 void writePacket(
Index index,
const PacketType& x)
1437 m_argImpl.template writePacket<StoreMode>(index, x);
1444 template<
typename TArgType>
1450 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1456 template<
typename TArgType>
1462 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1474 template<
typename ArgType,
int Direction>
1479 typedef typename XprType::Scalar Scalar;
1480 typedef typename XprType::CoeffReturnType CoeffReturnType;
1483 IsRowMajor = XprType::IsRowMajor,
1484 IsColMajor = !IsRowMajor,
1488 || ((Direction ==
Vertical) && IsColMajor)
1489 || ((Direction ==
Horizontal) && IsRowMajor),
1497 || ((ReverseRow && XprType::ColsAtCompileTime==1) || (ReverseCol && XprType::RowsAtCompileTime==1))
1500 Flags =
int(Flags0) & (HereditaryBits |
PacketAccessBit | LinearAccess),
1505 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1507 : m_argImpl(reverse.nestedExpression()),
1508 m_rows(ReverseRow ? reverse.nestedExpression().rows() : 1),
1509 m_cols(ReverseCol ? reverse.nestedExpression().cols() : 1)
1512 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1513 CoeffReturnType coeff(
Index row,
Index col)
const
1515 return m_argImpl.coeff(ReverseRow ? m_rows.value() - row - 1 : row,
1516 ReverseCol ? m_cols.value() - col - 1 : col);
1519 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1520 CoeffReturnType coeff(
Index index)
const
1522 return m_argImpl.coeff(m_rows.value() * m_cols.value() - index - 1);
1525 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1528 return m_argImpl.coeffRef(ReverseRow ? m_rows.value() - row - 1 : row,
1529 ReverseCol ? m_cols.value() - col - 1 : col);
1532 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1533 Scalar& coeffRef(
Index index)
1535 return m_argImpl.coeffRef(m_rows.value() * m_cols.value() - index - 1);
1538 template<
int LoadMode,
typename PacketType>
1540 PacketType packet(
Index row,
Index col)
const
1544 OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1,
1545 OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1
1548 return reverse_packet::run(m_argImpl.template packet<LoadMode,PacketType>(
1549 ReverseRow ? m_rows.value() - row - OffsetRow : row,
1550 ReverseCol ? m_cols.value() - col - OffsetCol : col));
1553 template<
int LoadMode,
typename PacketType>
1555 PacketType packet(
Index index)
const
1558 return preverse(m_argImpl.template packet<LoadMode,PacketType>(m_rows.value() * m_cols.value() - index - PacketSize));
1561 template<
int LoadMode,
typename PacketType>
1563 void writePacket(
Index row,
Index col,
const PacketType& x)
1568 OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1,
1569 OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1
1572 m_argImpl.template writePacket<LoadMode>(
1573 ReverseRow ? m_rows.value() - row - OffsetRow : row,
1574 ReverseCol ? m_cols.value() - col - OffsetCol : col,
1575 reverse_packet::run(x));
1578 template<
int LoadMode,
typename PacketType>
1580 void writePacket(
Index index,
const PacketType& x)
1583 m_argImpl.template writePacket<LoadMode>
1584 (m_rows.value() * m_cols.value() - index - PacketSize, preverse(x));
1599 template<
typename ArgType,
int DiagIndex>
1613 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1615 : m_argImpl(diagonal.nestedExpression()),
1616 m_index(diagonal.index())
1619 typedef typename XprType::Scalar Scalar;
1620 typedef typename XprType::CoeffReturnType CoeffReturnType;
1622 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1623 CoeffReturnType coeff(
Index row,
Index)
const
1625 return m_argImpl.coeff(row + rowOffset(), row + colOffset());
1628 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1629 CoeffReturnType coeff(
Index index)
const
1631 return m_argImpl.coeff(index + rowOffset(), index + colOffset());
1634 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1637 return m_argImpl.coeffRef(row + rowOffset(), row + colOffset());
1640 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1641 Scalar& coeffRef(
Index index)
1643 return m_argImpl.coeffRef(index + rowOffset(), index + colOffset());
1651 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Index rowOffset()
const {
return m_index.value() > 0 ? 0 : -m_index.value(); }
1652 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Index colOffset()
const {
return m_index.value() > 0 ? m_index.value() : 0; }
1666 template<
typename ArgType>
1671 template<
typename ArgType>
1684 const ArgType& arg()
const
1691 return m_arg.rows();
1696 return m_arg.cols();
1700 const ArgType& m_arg;
1703 template<
typename ArgType>
1705 :
public evaluator<typename ArgType::PlainObject>
1708 typedef typename ArgType::PlainObject PlainObject;
1712 : m_result(xpr.arg())
1714 ::new (
static_cast<Base*
>(
this))
Base(m_result);
1718 EIGEN_DEVICE_FUNC
evaluator(
const ArgType& arg)
1721 ::new (
static_cast<Base*
>(
this))
Base(m_result);
1725 PlainObject m_result;
1732 #endif // EIGEN_COREEVALUATORS_H