10 #ifndef EIGEN_SPARSE_CWISE_UNARY_OP_H
11 #define EIGEN_SPARSE_CWISE_UNARY_OP_H
19 template<
typename UnaryOp,
typename ArgType>
20 struct unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>
21 :
public evaluator_base<CwiseUnaryOp<UnaryOp,ArgType> >
24 typedef CwiseUnaryOp<UnaryOp, ArgType> XprType;
29 CoeffReadCost = int(evaluator<ArgType>::CoeffReadCost) + int(functor_traits<UnaryOp>::Cost),
30 Flags = XprType::Flags
33 explicit unary_evaluator(
const XprType& op) : m_functor(op.functor()), m_argImpl(op.nestedExpression())
39 inline Index nonZerosEstimate()
const {
40 return m_argImpl.nonZerosEstimate();
44 typedef typename evaluator<ArgType>::InnerIterator
EvalIterator;
46 const UnaryOp m_functor;
47 evaluator<ArgType> m_argImpl;
50 template<
typename UnaryOp,
typename ArgType>
51 class unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>::InnerIterator
52 :
public unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>
::EvalIterator
55 typedef typename XprType::Scalar Scalar;
56 typedef typename unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>
::EvalIterator Base;
59 EIGEN_STRONG_INLINE InnerIterator(
const unary_evaluator& unaryOp,
Index outer)
60 : Base(unaryOp.m_argImpl,outer), m_functor(unaryOp.m_functor)
63 EIGEN_STRONG_INLINE InnerIterator&
operator++()
66 EIGEN_STRONG_INLINE Scalar value()
const {
return m_functor(Base::value()); }
69 const UnaryOp m_functor;
74 template<
typename ViewOp,
typename ArgType>
75 struct unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>
76 :
public evaluator_base<CwiseUnaryView<ViewOp,ArgType> >
79 typedef CwiseUnaryView<ViewOp, ArgType> XprType;
84 CoeffReadCost = int(evaluator<ArgType>::CoeffReadCost) + int(functor_traits<ViewOp>::Cost),
85 Flags = XprType::Flags
88 explicit unary_evaluator(
const XprType& op) : m_functor(op.functor()), m_argImpl(op.nestedExpression())
95 typedef typename evaluator<ArgType>::InnerIterator
EvalIterator;
97 const ViewOp m_functor;
98 evaluator<ArgType> m_argImpl;
101 template<
typename ViewOp,
typename ArgType>
102 class unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>::InnerIterator
103 :
public unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>
::EvalIterator
106 typedef typename XprType::Scalar Scalar;
107 typedef typename unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>
::EvalIterator Base;
110 EIGEN_STRONG_INLINE InnerIterator(
const unary_evaluator& unaryOp,
Index outer)
111 : Base(unaryOp.m_argImpl,outer), m_functor(unaryOp.m_functor)
114 EIGEN_STRONG_INLINE InnerIterator&
operator++()
117 EIGEN_STRONG_INLINE Scalar value()
const {
return m_functor(Base::value()); }
118 EIGEN_STRONG_INLINE Scalar& valueRef() {
return m_functor(Base::valueRef()); }
121 const ViewOp m_functor;
126 template<
typename Derived>
127 EIGEN_STRONG_INLINE Derived&
130 typedef typename internal::evaluator<Derived>::InnerIterator
EvalIterator;
131 internal::evaluator<Derived> thisEval(derived());
134 i.valueRef() *= other;
138 template<
typename Derived>
139 EIGEN_STRONG_INLINE Derived&
142 typedef typename internal::evaluator<Derived>::InnerIterator
EvalIterator;
143 internal::evaluator<Derived> thisEval(derived());
146 i.valueRef() /= other;
#define EIGEN_INTERNAL_CHECK_COST_VALUE(C)
Derived & operator*=(const Scalar &other)
Derived & operator/=(const Scalar &other)
internal::traits< Derived >::Scalar Scalar
bfloat16 operator++(bfloat16 &a)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Eigen::Index Index
The interface type of indices.