11 #ifndef EIGEN_CWISE_UNARY_OP_H
12 #define EIGEN_CWISE_UNARY_OP_H
37 template<
typename UnaryOp,
typename XprType>
38 struct traits<CwiseUnaryOp<UnaryOp, XprType> >
41 typedef typename result_of<
42 UnaryOp(
typename XprType::Scalar)
44 typedef typename XprType::Nested XprTypeNested;
45 typedef typename remove_reference<XprTypeNested>::type _XprTypeNested;
47 Flags = _XprTypeNested::Flags & (
50 CoeffReadCost = EIGEN_ADD_COST(_XprTypeNested::CoeffReadCost, functor_traits<UnaryOp>::Cost)
55 template<
typename UnaryOp,
typename XprType,
typename StorageKind>
56 class CwiseUnaryOpImpl;
58 template<
typename UnaryOp,
typename XprType>
60 public CwiseUnaryOpImpl<UnaryOp, XprType, typename internal::traits<XprType>::StorageKind>
64 typedef typename CwiseUnaryOpImpl<UnaryOp, XprType,typename internal::traits<XprType>::StorageKind>::Base Base;
67 inline CwiseUnaryOp(
const XprType& xpr,
const UnaryOp& func = UnaryOp())
68 : m_xpr(xpr), m_functor(func) {}
70 EIGEN_STRONG_INLINE Index rows()
const {
return m_xpr.rows(); }
71 EIGEN_STRONG_INLINE Index cols()
const {
return m_xpr.cols(); }
74 const UnaryOp&
functor()
const {
return m_functor; }
77 const typename internal::remove_all<typename XprType::Nested>::type&
81 typename internal::remove_all<typename XprType::Nested>::type&
85 typename XprType::Nested m_xpr;
86 const UnaryOp m_functor;
91 template<
typename UnaryOp,
typename XprType>
92 class CwiseUnaryOpImpl<UnaryOp,XprType,Dense>
93 :
public internal::dense_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type
97 typedef CwiseUnaryOp<UnaryOp, XprType> Derived;
98 typedef typename internal::dense_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type Base;
99 EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
101 EIGEN_STRONG_INLINE const Scalar coeff(Index rowId, Index colId)
const
103 return derived().functor()(derived().nestedExpression().coeff(rowId, colId));
106 template<
int LoadMode>
107 EIGEN_STRONG_INLINE PacketScalar packet(Index rowId, Index colId)
const
109 return derived().functor().packetOp(derived().nestedExpression().
template packet<LoadMode>(rowId, colId));
112 EIGEN_STRONG_INLINE
const Scalar coeff(Index index)
const
114 return derived().functor()(derived().nestedExpression().coeff(index));
117 template<
int LoadMode>
118 EIGEN_STRONG_INLINE PacketScalar packet(Index index)
const
120 return derived().functor().packetOp(derived().nestedExpression().
template packet<LoadMode>(index));
126 #endif // EIGEN_CWISE_UNARY_OP_H
const UnaryOp & functor() const
Definition: CwiseUnaryOp.h:74
internal::remove_all< typename XprType::Nested >::type & nestedExpression()
Definition: CwiseUnaryOp.h:82
const unsigned int PacketAccessBit
Definition: Constants.h:81
const unsigned int LinearAccessBit
Definition: Constants.h:117
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:59
const unsigned int AlignedBit
Definition: Constants.h:147
const internal::remove_all< typename XprType::Nested >::type & nestedExpression() const
Definition: CwiseUnaryOp.h:78