File indexing completed on 2025-01-18 09:56:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef EIGEN_CWISE_UNARY_OP_H
0012 #define EIGEN_CWISE_UNARY_OP_H
0013
0014 namespace Eigen {
0015
0016 namespace internal {
0017 template<typename UnaryOp, typename XprType>
0018 struct traits<CwiseUnaryOp<UnaryOp, XprType> >
0019 : traits<XprType>
0020 {
0021 typedef typename result_of<
0022 UnaryOp(const typename XprType::Scalar&)
0023 >::type Scalar;
0024 typedef typename XprType::Nested XprTypeNested;
0025 typedef typename remove_reference<XprTypeNested>::type _XprTypeNested;
0026 enum {
0027 Flags = _XprTypeNested::Flags & RowMajorBit
0028 };
0029 };
0030 }
0031
0032 template<typename UnaryOp, typename XprType, typename StorageKind>
0033 class CwiseUnaryOpImpl;
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 template<typename UnaryOp, typename XprType>
0055 class CwiseUnaryOp : public CwiseUnaryOpImpl<UnaryOp, XprType, typename internal::traits<XprType>::StorageKind>, internal::no_assignment_operator
0056 {
0057 public:
0058
0059 typedef typename CwiseUnaryOpImpl<UnaryOp, XprType,typename internal::traits<XprType>::StorageKind>::Base Base;
0060 EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryOp)
0061 typedef typename internal::ref_selector<XprType>::type XprTypeNested;
0062 typedef typename internal::remove_all<XprType>::type NestedExpression;
0063
0064 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0065 explicit CwiseUnaryOp(const XprType& xpr, const UnaryOp& func = UnaryOp())
0066 : m_xpr(xpr), m_functor(func) {}
0067
0068 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
0069 Index rows() const EIGEN_NOEXCEPT { return m_xpr.rows(); }
0070 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
0071 Index cols() const EIGEN_NOEXCEPT { return m_xpr.cols(); }
0072
0073
0074 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0075 const UnaryOp& functor() const { return m_functor; }
0076
0077
0078 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0079 const typename internal::remove_all<XprTypeNested>::type&
0080 nestedExpression() const { return m_xpr; }
0081
0082
0083 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0084 typename internal::remove_all<XprTypeNested>::type&
0085 nestedExpression() { return m_xpr; }
0086
0087 protected:
0088 XprTypeNested m_xpr;
0089 const UnaryOp m_functor;
0090 };
0091
0092
0093 template<typename UnaryOp, typename XprType, typename StorageKind>
0094 class CwiseUnaryOpImpl
0095 : public internal::generic_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type
0096 {
0097 public:
0098 typedef typename internal::generic_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type Base;
0099 };
0100
0101 }
0102
0103 #endif