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
explicit evaluator(
const T& xpr) : Base(xpr) {}
108 template<
typename ExpressionType>
126 template<
typename Derived>
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,
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>
204 return ploadt<PacketType, LoadMode>(m_data + index);
207 template<
int StoreMode,
typename PacketType>
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>
223 return pstoret<Scalar, PacketType, StoreMode>(
const_cast<Scalar*
>(m_data) + index, x);
227 const Scalar *m_data;
231 : int(IsRowMajor) ? ColsAtCompileTime
232 : RowsAtCompileTime> m_outerStride;
235 template<
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
237 :
evaluator<PlainObjectBase<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > >
243 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& m)
248 template<
typename Scalar,
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
250 :
evaluator<PlainObjectBase<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > >
256 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& m)
263 template<
typename ArgType>
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>
315 return m_argImpl.template packet<LoadMode,PacketType>(index);
318 template<
int StoreMode,
typename PacketType>
322 m_argImpl.template writePacket<StoreMode,PacketType>(col, row, x);
325 template<
int StoreMode,
typename PacketType>
329 m_argImpl.template writePacket<StoreMode,PacketType>(index, x);
340 template<
typename Scalar,
typename NullaryOp,
346 template <
typename IndexType>
347 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i, IndexType j)
const {
return op(i,j); }
348 template <
typename IndexType>
349 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i)
const {
return op(i); }
351 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); }
352 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); }
355 template<
typename Scalar,
typename NullaryOp>
358 template <
typename IndexType>
359 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType=0, IndexType=0)
const {
return op(); }
360 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>(); }
363 template<
typename Scalar,
typename NullaryOp>
366 template <
typename IndexType>
367 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i, IndexType j=0)
const {
return op(i,j); }
368 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); }
374 template<
typename Scalar,
typename NullaryOp>
377 template <
typename IndexType>
378 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i, IndexType j)
const {
379 eigen_assert(i==0 || j==0);
382 template <
typename T,
typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i, IndexType j)
const {
383 eigen_assert(i==0 || j==0);
384 return op.template packetOp<T>(i+j);
387 template <
typename IndexType>
388 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i)
const {
return op(i); }
389 template <
typename T,
typename IndexType>
390 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i)
const {
return op.template packetOp<T>(i); }
393 template<
typename Scalar,
typename NullaryOp>
396 #if 0 && EIGEN_COMP_MSVC>0 414 template<
typename T>
struct nullary_wrapper_workaround_msvc {
415 nullary_wrapper_workaround_msvc(
const T&);
419 template<
typename Scalar,
typename NullaryOp>
422 template <
typename IndexType>
423 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i, IndexType j)
const {
429 template <
typename IndexType>
430 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(
const NullaryOp& op, IndexType i)
const {
437 template <
typename T,
typename IndexType>
438 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i, IndexType j)
const {
444 template <
typename T,
typename IndexType>
445 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(
const NullaryOp& op, IndexType i)
const {
452 #endif // MSVC workaround 454 template<
typename NullaryOp,
typename PlainObjectType>
469 Alignment = AlignedMax
472 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& n)
473 : m_functor(n.
functor()), m_wrapper()
475 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
478 typedef typename XprType::CoeffReturnType CoeffReturnType;
480 template <
typename IndexType>
481 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
482 CoeffReturnType coeff(IndexType row, IndexType col)
const 484 return m_wrapper(m_functor, row, col);
487 template <
typename IndexType>
488 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
489 CoeffReturnType coeff(IndexType index)
const 491 return m_wrapper(m_functor,index);
494 template<
int LoadMode,
typename PacketType,
typename IndexType>
496 PacketType packet(IndexType row, IndexType col)
const 498 return m_wrapper.template packetOp<PacketType>(m_functor, row, col);
501 template<
int LoadMode,
typename PacketType,
typename IndexType>
505 return m_wrapper.template packetOp<PacketType>(m_functor, index);
509 const NullaryOp m_functor;
515 template<
typename UnaryOp,
typename ArgType>
529 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
535 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
538 typedef typename XprType::CoeffReturnType CoeffReturnType;
540 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
541 CoeffReturnType coeff(
Index row,
Index col)
const 543 return m_functor(m_argImpl.coeff(row, col));
546 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
547 CoeffReturnType coeff(
Index index)
const 549 return m_functor(m_argImpl.coeff(index));
552 template<
int LoadMode,
typename PacketType>
556 return m_functor.packetOp(m_argImpl.template packet<LoadMode, PacketType>(row, col));
559 template<
int LoadMode,
typename PacketType>
563 return m_functor.packetOp(m_argImpl.template packet<LoadMode, PacketType>(index));
567 const UnaryOp m_functor;
574 template<
typename TernaryOp,
typename Arg1,
typename Arg2,
typename Arg3>
581 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& xpr) : Base(xpr) {}
584 template<
typename TernaryOp,
typename Arg1,
typename Arg2,
typename Arg3>
598 Flags0 = (
int(Arg1Flags) | int(Arg2Flags) | int(Arg3Flags)) & (
600 | (
int(Arg1Flags) &
int(Arg2Flags) &
int(Arg3Flags) &
607 Alignment = EIGEN_PLAIN_ENUM_MIN(
614 m_arg1Impl(xpr.
arg1()),
615 m_arg2Impl(xpr.
arg2()),
616 m_arg3Impl(xpr.
arg3())
619 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
622 typedef typename XprType::CoeffReturnType CoeffReturnType;
624 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
625 CoeffReturnType coeff(
Index row,
Index col)
const 627 return m_functor(m_arg1Impl.coeff(row, col), m_arg2Impl.coeff(row, col), m_arg3Impl.coeff(row, col));
630 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
631 CoeffReturnType coeff(
Index index)
const 633 return m_functor(m_arg1Impl.coeff(index), m_arg2Impl.coeff(index), m_arg3Impl.coeff(index));
636 template<
int LoadMode,
typename PacketType>
640 return m_functor.packetOp(m_arg1Impl.template packet<LoadMode,PacketType>(row, col),
641 m_arg2Impl.template packet<LoadMode,PacketType>(row, col),
642 m_arg3Impl.template packet<LoadMode,PacketType>(row, col));
645 template<
int LoadMode,
typename PacketType>
649 return m_functor.packetOp(m_arg1Impl.template packet<LoadMode,PacketType>(index),
650 m_arg2Impl.template packet<LoadMode,PacketType>(index),
651 m_arg3Impl.template packet<LoadMode,PacketType>(index));
655 const TernaryOp m_functor;
664 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
671 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& xpr) : Base(xpr) {}
674 template<
typename BinaryOp,
typename Lhs,
typename Rhs>
687 Flags0 = (
int(LhsFlags) | int(RhsFlags)) & (
689 | (
int(LhsFlags) &
int(RhsFlags) &
701 m_lhsImpl(xpr.
lhs()),
705 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
708 typedef typename XprType::CoeffReturnType CoeffReturnType;
710 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
711 CoeffReturnType coeff(
Index row,
Index col)
const 713 return m_functor(m_lhsImpl.coeff(row, col), m_rhsImpl.coeff(row, col));
716 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
717 CoeffReturnType coeff(
Index index)
const 719 return m_functor(m_lhsImpl.coeff(index), m_rhsImpl.coeff(index));
722 template<
int LoadMode,
typename PacketType>
726 return m_functor.packetOp(m_lhsImpl.template packet<LoadMode,PacketType>(row, col),
727 m_rhsImpl.template packet<LoadMode,PacketType>(row, col));
730 template<
int LoadMode,
typename PacketType>
734 return m_functor.packetOp(m_lhsImpl.template packet<LoadMode,PacketType>(index),
735 m_rhsImpl.template packet<LoadMode,PacketType>(index));
739 const BinaryOp m_functor;
746 template<
typename UnaryOp,
typename ArgType>
765 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
768 typedef typename XprType::Scalar Scalar;
769 typedef typename XprType::CoeffReturnType CoeffReturnType;
771 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
772 CoeffReturnType coeff(
Index row,
Index col)
const 774 return m_unaryOp(m_argImpl.coeff(row, col));
777 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
778 CoeffReturnType coeff(
Index index)
const 780 return m_unaryOp(m_argImpl.coeff(index));
783 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
786 return m_unaryOp(m_argImpl.coeffRef(row, col));
789 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
790 Scalar& coeffRef(
Index index)
792 return m_unaryOp(m_argImpl.coeffRef(index));
796 const UnaryOp m_unaryOp;
804 template<
typename Derived,
typename PlainObjectType>
807 template<
typename Derived,
typename PlainObjectType>
810 typedef Derived XprType;
811 typedef typename XprType::PointerType PointerType;
812 typedef typename XprType::Scalar Scalar;
813 typedef typename XprType::CoeffReturnType CoeffReturnType;
816 IsRowMajor = XprType::RowsAtCompileTime,
817 ColsAtCompileTime = XprType::ColsAtCompileTime,
822 : m_data(const_cast<PointerType>(map.data())),
823 m_innerStride(map.innerStride()),
824 m_outerStride(map.outerStride())
827 PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1);
828 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
831 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
832 CoeffReturnType coeff(
Index row,
Index col)
const 834 return m_data[col * colStride() + row * rowStride()];
837 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
838 CoeffReturnType coeff(
Index index)
const 840 return m_data[index * m_innerStride.value()];
843 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
846 return m_data[col * colStride() + row * rowStride()];
849 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
850 Scalar& coeffRef(
Index index)
852 return m_data[index * m_innerStride.value()];
855 template<
int LoadMode,
typename PacketType>
859 PointerType ptr = m_data + row * rowStride() + col * colStride();
860 return internal::ploadt<PacketType, LoadMode>(ptr);
863 template<
int LoadMode,
typename PacketType>
867 return internal::ploadt<PacketType, LoadMode>(m_data + index * m_innerStride.value());
870 template<
int StoreMode,
typename PacketType>
874 PointerType ptr = m_data + row * rowStride() + col * colStride();
875 return internal::pstoret<Scalar, PacketType, StoreMode>(ptr, x);
878 template<
int StoreMode,
typename PacketType>
882 internal::pstoret<Scalar, PacketType, StoreMode>(m_data + index * m_innerStride.value(), x);
886 inline Index rowStride()
const {
return XprType::IsRowMajor ? m_outerStride.value() : m_innerStride.value(); }
888 inline Index colStride()
const {
return XprType::IsRowMajor ? m_innerStride.value() : m_outerStride.value(); }
895 template<
typename PlainObjectType,
int MapOptions,
typename Str
ideType>
897 :
public mapbase_evaluator<Map<PlainObjectType, MapOptions, StrideType>, PlainObjectType>
900 typedef typename XprType::Scalar Scalar;
905 InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0
906 ? int(PlainObjectType::InnerStrideAtCompileTime)
907 : int(StrideType::InnerStrideAtCompileTime),
908 OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0
909 ? int(PlainObjectType::OuterStrideAtCompileTime)
910 : int(StrideType::OuterStrideAtCompileTime),
911 HasNoInnerStride = InnerStrideAtCompileTime == 1,
912 HasNoOuterStride = StrideType::OuterStrideAtCompileTime == 0,
913 HasNoStride = HasNoInnerStride && HasNoOuterStride,
914 IsDynamicSize = PlainObjectType::SizeAtCompileTime==
Dynamic,
916 PacketAccessMask = bool(HasNoInnerStride) ? ~int(0) : ~int(
PacketAccessBit),
917 LinearAccessMask = bool(HasNoStride) || bool(PlainObjectType::IsVectorAtCompileTime) ? ~int(0) : ~int(
LinearAccessBit),
920 Alignment =
int(MapOptions)&int(AlignedMask)
923 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& map)
930 template<
typename PlainObjectType,
int RefOptions,
typename Str
ideType>
932 :
public mapbase_evaluator<Ref<PlainObjectType, RefOptions, StrideType>, PlainObjectType>
941 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& ref)
948 template<
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel,
951 template<
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel>
956 typedef typename XprType::Scalar Scalar;
969 IsRowMajor = (MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1) ? 1
970 : (MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1) ? 0
972 HasSameStorageOrderAsArgType = (IsRowMajor == ArgTypeIsRowMajor),
973 InnerSize = IsRowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
974 InnerStrideAtCompileTime = HasSameStorageOrderAsArgType
977 OuterStrideAtCompileTime = HasSameStorageOrderAsArgType
980 MaskPacketAccessBit = (InnerStrideAtCompileTime == 1) ?
PacketAccessBit : 0,
986 MaskPacketAccessBit),
987 Flags = Flags0 | FlagsLinearAccessBit | FlagsRowMajorBit,
990 Alignment0 = (InnerPanel && (OuterStrideAtCompileTime!=
Dynamic) && (((OuterStrideAtCompileTime * int(
sizeof(Scalar))) %
int(PacketAlignment)) == 0)) ?
int(PacketAlignment) : 0,
994 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& block) : block_evaluator_type(block)
996 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
1001 template<
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel>
1012 template<
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel>
1014 :
evaluator_base<Block<ArgType, BlockRows, BlockCols, InnerPanel> >
1019 : m_argImpl(block.nestedExpression()),
1020 m_startRow(block.startRow()),
1021 m_startCol(block.startCol())
1024 typedef typename XprType::Scalar Scalar;
1025 typedef typename XprType::CoeffReturnType CoeffReturnType;
1028 RowsAtCompileTime = XprType::RowsAtCompileTime
1031 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1032 CoeffReturnType coeff(
Index row,
Index col)
const 1034 return m_argImpl.coeff(m_startRow.value() + row, m_startCol.value() + col);
1037 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1038 CoeffReturnType coeff(
Index index)
const 1040 return coeff(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
1043 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1046 return m_argImpl.coeffRef(m_startRow.value() + row, m_startCol.value() + col);
1049 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1050 Scalar& coeffRef(
Index index)
1052 return coeffRef(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
1055 template<
int LoadMode,
typename PacketType>
1059 return m_argImpl.template packet<LoadMode,PacketType>(m_startRow.value() + row, m_startCol.value() + col);
1062 template<
int LoadMode,
typename PacketType>
1066 return packet<LoadMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
1067 RowsAtCompileTime == 1 ? index : 0);
1070 template<
int StoreMode,
typename PacketType>
1074 return m_argImpl.template writePacket<StoreMode,PacketType>(m_startRow.value() + row, m_startCol.value() + col, x);
1077 template<
int StoreMode,
typename PacketType>
1081 return writePacket<StoreMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
1082 RowsAtCompileTime == 1 ? index : 0,
1095 template<
typename ArgType,
int BlockRows,
int BlockCols,
bool InnerPanel>
1097 : mapbase_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>,
1098 typename Block<ArgType, BlockRows, BlockCols, InnerPanel>::PlainObject>
1101 typedef typename XprType::Scalar Scalar;
1116 template<
typename ConditionMatrixType,
typename ThenMatrixType,
typename ElseMatrixType>
1118 :
evaluator_base<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
1131 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& select)
1132 : m_conditionImpl(select.conditionMatrix()),
1133 m_thenImpl(select.thenMatrix()),
1134 m_elseImpl(select.elseMatrix())
1136 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
1139 typedef typename XprType::CoeffReturnType CoeffReturnType;
1141 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1142 CoeffReturnType coeff(
Index row,
Index col)
const 1144 if (m_conditionImpl.coeff(row, col))
1145 return m_thenImpl.coeff(row, col);
1147 return m_elseImpl.coeff(row, col);
1150 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1151 CoeffReturnType coeff(
Index index)
const 1153 if (m_conditionImpl.coeff(index))
1154 return m_thenImpl.coeff(index);
1156 return m_elseImpl.coeff(index);
1168 template<
typename ArgType,
int RowFactor,
int ColFactor>
1173 typedef typename XprType::CoeffReturnType CoeffReturnType;
1182 LinearAccessMask = XprType::IsVectorAtCompileTime ?
LinearAccessBit : 0,
1189 : m_arg(replicate.nestedExpression()),
1191 m_rows(replicate.nestedExpression().rows()),
1192 m_cols(replicate.nestedExpression().cols())
1195 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1196 CoeffReturnType coeff(
Index row,
Index col)
const 1200 : RowFactor==1 ? row
1201 : row % m_rows.value();
1203 : ColFactor==1 ? col
1204 : col % m_cols.value();
1206 return m_argImpl.coeff(actual_row, actual_col);
1209 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1210 CoeffReturnType coeff(
Index index)
const 1214 ? (ColFactor==1 ? index : index%m_cols.value())
1215 : (RowFactor==1 ? index : index%m_rows.value());
1217 return m_argImpl.coeff(actual_index);
1220 template<
int LoadMode,
typename PacketType>
1225 : RowFactor==1 ? row
1226 : row % m_rows.value();
1228 : ColFactor==1 ? col
1229 : col % m_cols.value();
1231 return m_argImpl.template packet<LoadMode,PacketType>(actual_row, actual_col);
1234 template<
int LoadMode,
typename PacketType>
1239 ? (ColFactor==1 ? index : index%m_cols.value())
1240 : (RowFactor==1 ? index : index%m_rows.value());
1242 return m_argImpl.template packet<LoadMode,PacketType>(actual_index);
1246 const ArgTypeNested m_arg;
1255 template<
typename ArgType,
typename MemberOp,
int Direction>
1257 :
evaluator_base<PartialReduxExpr<ArgType, MemberOp, Direction> >
1262 typedef typename ArgType::Scalar InputScalar;
1263 typedef typename XprType::Scalar Scalar;
1265 TraversalSize = Direction==int(
Vertical) ? int(ArgType::RowsAtCompileTime) : int(ArgType::ColsAtCompileTime)
1267 typedef typename MemberOp::template Cost<InputScalar,int(TraversalSize)> CostOpType;
1277 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType xpr)
1278 : m_arg(xpr.nestedExpression()), m_functor(xpr.functor())
1280 EIGEN_INTERNAL_CHECK_COST_VALUE(TraversalSize==
Dynamic ?
HugeCost :
int(CostOpType::value));
1281 EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
1284 typedef typename XprType::CoeffReturnType CoeffReturnType;
1286 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1290 return m_functor(m_arg.col(j));
1292 return m_functor(m_arg.row(i));
1295 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1296 const Scalar coeff(
Index index)
const 1299 return m_functor(m_arg.col(index));
1301 return m_functor(m_arg.row(index));
1305 typename internal::add_const_on_value_type<ArgTypeNested>::type m_arg;
1306 const MemberOp m_functor;
1315 template<
typename XprType>
1319 typedef typename remove_all<typename XprType::NestedExpressionType>::type
ArgType;
1328 typedef typename ArgType::Scalar Scalar;
1329 typedef typename ArgType::CoeffReturnType CoeffReturnType;
1331 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1332 CoeffReturnType coeff(
Index row,
Index col)
const 1334 return m_argImpl.coeff(row, col);
1337 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1338 CoeffReturnType coeff(
Index index)
const 1340 return m_argImpl.coeff(index);
1343 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1346 return m_argImpl.coeffRef(row, col);
1349 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1350 Scalar& coeffRef(
Index index)
1352 return m_argImpl.coeffRef(index);
1355 template<
int LoadMode,
typename PacketType>
1359 return m_argImpl.template packet<LoadMode,PacketType>(row, col);
1362 template<
int LoadMode,
typename PacketType>
1366 return m_argImpl.template packet<LoadMode,PacketType>(index);
1369 template<
int StoreMode,
typename PacketType>
1373 m_argImpl.template writePacket<StoreMode>(row, col, x);
1376 template<
int StoreMode,
typename PacketType>
1380 m_argImpl.template writePacket<StoreMode>(index, x);
1387 template<
typename TArgType>
1398 template<
typename TArgType>
1415 template<
typename ArgType,
int Direction>
1420 typedef typename XprType::Scalar Scalar;
1421 typedef typename XprType::CoeffReturnType CoeffReturnType;
1424 IsRowMajor = XprType::IsRowMajor,
1425 IsColMajor = !IsRowMajor,
1429 || ((Direction ==
Vertical) && IsColMajor)
1430 || ((Direction ==
Horizontal) && IsRowMajor),
1438 || ((ReverseRow && XprType::ColsAtCompileTime==1) || (ReverseCol && XprType::RowsAtCompileTime==1))
1441 Flags =
int(Flags0) & (HereditaryBits |
PacketAccessBit | LinearAccess),
1447 : m_argImpl(reverse.nestedExpression()),
1448 m_rows(ReverseRow ? reverse.nestedExpression().rows() : 1),
1449 m_cols(ReverseCol ? reverse.nestedExpression().cols() : 1)
1452 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1453 CoeffReturnType coeff(
Index row,
Index col)
const 1455 return m_argImpl.coeff(ReverseRow ? m_rows.value() - row - 1 : row,
1456 ReverseCol ? m_cols.value() - col - 1 : col);
1459 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1460 CoeffReturnType coeff(
Index index)
const 1462 return m_argImpl.coeff(m_rows.value() * m_cols.value() - index - 1);
1465 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1468 return m_argImpl.coeffRef(ReverseRow ? m_rows.value() - row - 1 : row,
1469 ReverseCol ? m_cols.value() - col - 1 : col);
1472 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1473 Scalar& coeffRef(
Index index)
1475 return m_argImpl.coeffRef(m_rows.value() * m_cols.value() - index - 1);
1478 template<
int LoadMode,
typename PacketType>
1484 OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1,
1485 OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1
1488 return reverse_packet::run(m_argImpl.template packet<LoadMode,PacketType>(
1489 ReverseRow ? m_rows.value() - row - OffsetRow : row,
1490 ReverseCol ? m_cols.value() - col - OffsetCol : col));
1493 template<
int LoadMode,
typename PacketType>
1498 return preverse(m_argImpl.template packet<LoadMode,PacketType>(m_rows.value() * m_cols.value() - index - PacketSize));
1501 template<
int LoadMode,
typename PacketType>
1508 OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1,
1509 OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1
1512 m_argImpl.template writePacket<LoadMode>(
1513 ReverseRow ? m_rows.value() - row - OffsetRow : row,
1514 ReverseCol ? m_cols.value() - col - OffsetCol : col,
1515 reverse_packet::run(x));
1518 template<
int LoadMode,
typename PacketType>
1523 m_argImpl.template writePacket<LoadMode>
1524 (m_rows.value() * m_cols.value() - index - PacketSize, preverse(x));
1539 template<
typename ArgType,
int DiagIndex>
1553 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& diagonal)
1554 : m_argImpl(diagonal.nestedExpression()),
1555 m_index(diagonal.index())
1558 typedef typename XprType::Scalar Scalar;
1561 typename XprType::CoeffReturnType,Scalar>::type CoeffReturnType;
1563 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1564 CoeffReturnType coeff(
Index row,
Index)
const 1566 return m_argImpl.coeff(row + rowOffset(), row + colOffset());
1569 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1570 CoeffReturnType coeff(
Index index)
const 1572 return m_argImpl.coeff(index + rowOffset(), index + colOffset());
1575 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1578 return m_argImpl.coeffRef(row + rowOffset(), row + colOffset());
1581 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1582 Scalar& coeffRef(
Index index)
1584 return m_argImpl.coeffRef(index + rowOffset(), index + colOffset());
1592 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Index rowOffset()
const {
return m_index.value() > 0 ? 0 : -m_index.value(); }
1593 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Index colOffset()
const {
return m_index.value() > 0 ? m_index.value() : 0; }
1607 template<
typename ArgType>
1612 template<
typename ArgType>
1625 const ArgType& arg()
const 1632 return m_arg.rows();
1637 return m_arg.cols();
1641 const ArgType& m_arg;
1644 template<
typename ArgType>
1646 :
public evaluator<typename ArgType::PlainObject>
1649 typedef typename ArgType::PlainObject PlainObject;
1652 EIGEN_DEVICE_FUNC
explicit evaluator(
const XprType& xpr)
1653 : m_result(xpr.arg())
1655 ::new (static_cast<Base*>(
this)) Base(m_result);
1659 EIGEN_DEVICE_FUNC evaluator(
const ArgType& arg)
1662 ::new (static_cast<Base*>(
this)) Base(m_result);
1666 PlainObject m_result;
1673 #endif // EIGEN_COREEVALUATORS_H const internal::remove_all< MatrixTypeNested >::type & nestedExpression() const
Definition: CwiseUnaryView.h:80
Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:60
Definition: DenseCoeffsBase.h:654
Definition: CoreEvaluators.h:949
Definition: Constants.h:526
Definition: CoreEvaluators.h:344
const int HugeCost
This value means that the cost to evaluate an expression coefficient is either very expensive or cann...
Definition: Constants.h:39
Expression of a mathematical vector or matrix as an array object.
Definition: ArrayWrapper.h:41
EIGEN_DEVICE_FUNC const TernaryOp & functor() const
Definition: CwiseTernaryOp.h:175
Definition: XprHelper.h:158
For Reverse, all columns are reversed; for PartialReduxExpr and VectorwiseOp, act on columns...
Definition: Constants.h:265
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
Definition: PlainObjectBase.h:249
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:88
Expression of the transpose of a matrix.
Definition: Transpose.h:52
const unsigned int DirectAccessBit
Means that the underlying array of coefficients can be directly accessed as a plain strided array...
Definition: Constants.h:150
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const UnaryOp & functor() const
Definition: CwiseUnaryOp.h:75
The type used to identify a permutation storage.
Definition: Constants.h:500
Definition: CoreEvaluators.h:90
Definition: CoreEvaluators.h:65
const ViewOp & functor() const
Definition: CwiseUnaryView.h:76
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
Definition: NullaryFunctors.h:151
Generic expression of a partially reduxed matrix.
Definition: ForwardDeclarations.h:244
Holds information about the various numeric (i.e.
Definition: NumTraits.h:150
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:61
Definition: Constants.h:512
Definition: CoreEvaluators.h:29
const unsigned int PacketAccessBit
Short version: means the expression might be vectorized.
Definition: Constants.h:89
EIGEN_DEVICE_FUNC const _RhsNested & rhs() const
Definition: CwiseBinaryOp.h:135
EIGEN_DEVICE_FUNC const internal::remove_all< MatrixTypeNested >::type & nestedExpression() const
Definition: Transpose.h:74
Definition: XprHelper.h:127
Definition: XprHelper.h:463
Definition: CoreEvaluators.h:109
Definition: GenericPacketMath.h:96
Generic lvalue expression of a coefficient-wise unary operator of a matrix or a vector.
Definition: CwiseUnaryView.h:58
Expression of an array as a mathematical vector or matrix.
Definition: ArrayBase.h:15
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:77
Definition: CoreEvaluators.h:1316
Definition: CoreEvaluators.h:55
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Definition: XprHelper.h:106
Dense storage base class for matrices and arrays.
Definition: PlainObjectBase.h:92
Generic expression where a coefficient-wise ternary operator is applied to two expressions.
Definition: CwiseTernaryOp.h:84
EIGEN_DEVICE_FUNC const NullaryOp & functor() const
Definition: CwiseNullaryOp.h:84
EIGEN_DEVICE_FUNC const _Arg1Nested & arg1() const
Definition: CwiseTernaryOp.h:166
Expression of the multiple replication of a matrix or vector.
Definition: Replicate.h:61
Definition: ForwardDeclarations.h:25
Definition: CoreEvaluators.h:1413
EIGEN_DEVICE_FUNC const _Arg3Nested & arg3() const
Definition: CwiseTernaryOp.h:172
Definition: CoreEvaluators.h:61
For Reverse, all rows are reversed; for PartialReduxExpr and VectorwiseOp, act on rows...
Definition: Constants.h:268
A matrix or vector expression mapping an existing expression.
Definition: Ref.h:190
For Reverse, both rows and columns are reversed; not used for PartialReduxExpr and VectorwiseOp...
Definition: Constants.h:271
EIGEN_DEVICE_FUNC const BinaryOp & functor() const
Definition: CwiseBinaryOp.h:138
Definition: BandTriangularSolver.h:13
Definition: CoreEvaluators.h:79
Definition: XprHelper.h:146
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
Definition: DenseCoeffsBase.h:666
Definition: CoreEvaluators.h:84
The type used to identify a general solver (factored) storage.
Definition: Constants.h:497
Definition: CoreEvaluators.h:23
General-purpose arrays with easy API for coefficient-wise operations.
Definition: Array.h:45
The type used to identify a dense storage.
Definition: Constants.h:491
The type used to identify a permutation storage.
Definition: Constants.h:503
Definition: CoreEvaluators.h:805
Expression of a diagonal/subdiagonal/superdiagonal in a matrix.
Definition: Diagonal.h:63
EIGEN_DEVICE_FUNC const _Arg2Nested & arg2() const
Definition: CwiseTernaryOp.h:169
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time, and that instead the value is stored in some runtime variable.
Definition: Constants.h:21
const unsigned int EvalBeforeNestingBit
means the expression should be evaluated by the calling expression
Definition: Constants.h:65
Definition: CoreEvaluators.h:1605
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:55
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const internal::remove_all< XprTypeNested >::type & nestedExpression() const
Definition: CwiseUnaryOp.h:80
Definition: TensorMeta.h:50
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:178
Expression of the reverse of a vector or matrix.
Definition: Reverse.h:63
Definition: Constants.h:513
const unsigned int LinearAccessBit
Short version: means the expression can be seen as 1D vector.
Definition: Constants.h:125
Definition: ForwardDeclarations.h:17
EIGEN_DEVICE_FUNC const _LhsNested & lhs() const
Definition: CwiseBinaryOp.h:132
Definition: CoreEvaluators.h:70
Definition: Constants.h:520
Definition: TensorRef.h:78
Expression of a coefficient wise version of the C++ ternary operator ?:
Definition: Select.h:52
Definition: Constants.h:519