10 #ifndef EIGEN_CWISE_UNARY_VIEW_H
11 #define EIGEN_CWISE_UNARY_VIEW_H
13 #include "./InternalHeaderCheck.h"
18 template<
typename ViewOp,
typename MatrixType,
typename Str
ideType>
19 struct traits<CwiseUnaryView<ViewOp, MatrixType, StrideType> >
22 typedef typename result_of<
23 ViewOp(
const typename traits<MatrixType>::Scalar&)
25 typedef typename MatrixType::Nested MatrixTypeNested;
26 typedef remove_all_t<MatrixTypeNested> MatrixTypeNested_;
28 FlagsLvalueBit = is_lvalue<MatrixType>::value ?
LvalueBit : 0,
30 MatrixTypeInnerStride = inner_stride_at_compile_time<MatrixType>::ret,
33 InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0
34 ? (MatrixTypeInnerStride ==
Dynamic
36 : int(MatrixTypeInnerStride) * int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar)))
37 : int(StrideType::InnerStrideAtCompileTime),
39 OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0
40 ? (outer_stride_at_compile_time<MatrixType>::ret ==
Dynamic
42 : outer_stride_at_compile_time<MatrixType>::ret * int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar)))
43 : int(StrideType::OuterStrideAtCompileTime)
48 template<
typename ViewOp,
typename MatrixType,
typename Str
ideType,
typename StorageKind>
49 class CwiseUnaryViewImpl;
64 template<
typename ViewOp,
typename MatrixType,
typename Str
ideType>
65 class CwiseUnaryView :
public CwiseUnaryViewImpl<ViewOp, MatrixType, StrideType, typename internal::traits<MatrixType>::StorageKind>
69 typedef typename CwiseUnaryViewImpl<ViewOp, MatrixType, StrideType, typename internal::traits<MatrixType>::StorageKind>::Base Base;
71 typedef typename internal::ref_selector<MatrixType>::non_const_type MatrixTypeNested;
72 typedef internal::remove_all_t<MatrixType> NestedExpression;
74 explicit EIGEN_DEVICE_FUNC
inline CwiseUnaryView(MatrixType& mat,
const ViewOp& func = ViewOp())
75 : m_matrix(mat), m_functor(func) {}
79 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
80 Index rows()
const EIGEN_NOEXCEPT {
return m_matrix.rows(); }
81 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
82 Index cols()
const EIGEN_NOEXCEPT {
return m_matrix.cols(); }
85 EIGEN_DEVICE_FUNC
const ViewOp&
functor()
const {
return m_functor; }
88 EIGEN_DEVICE_FUNC
const internal::remove_all_t<MatrixTypeNested>&
92 EIGEN_DEVICE_FUNC std::remove_reference_t<MatrixTypeNested>&
96 MatrixTypeNested m_matrix;
101 template<
typename ViewOp,
typename XprType,
typename Str
ideType,
typename StorageKind>
102 class CwiseUnaryViewImpl
103 :
public internal::generic_xpr_base<CwiseUnaryView<ViewOp, XprType, StrideType> >::type
106 typedef typename internal::generic_xpr_base<CwiseUnaryView<ViewOp, XprType, StrideType> >::type Base;
109 template<
typename ViewOp,
typename MatrixType,
typename Str
ideType>
110 class CwiseUnaryViewImpl<ViewOp,MatrixType,StrideType,Dense>
111 :
public internal::dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType, StrideType> >::type
115 typedef CwiseUnaryView<ViewOp, MatrixType,StrideType> Derived;
116 typedef typename internal::dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType,StrideType> >::type Base;
118 EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
119 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryViewImpl)
121 EIGEN_DEVICE_FUNC
inline Scalar* data() {
return &(this->coeffRef(0)); }
122 EIGEN_DEVICE_FUNC
inline const Scalar* data()
const {
return &(this->coeff(0)); }
124 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index innerStride()
const
126 return StrideType::InnerStrideAtCompileTime != 0
127 ? int(StrideType::InnerStrideAtCompileTime)
128 : derived().nestedExpression().innerStride() * sizeof(typename internal::traits<MatrixType>::Scalar) / sizeof(Scalar);
131 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index outerStride()
const
133 return StrideType::OuterStrideAtCompileTime != 0
134 ? int(StrideType::OuterStrideAtCompileTime)
135 : derived().nestedExpression().outerStride() * sizeof(typename internal::traits<MatrixType>::Scalar) / sizeof(Scalar);
138 EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(CwiseUnaryViewImpl)
Generic lvalue expression of a coefficient-wise unary operator of a matrix or a vector.
Definition: CwiseUnaryView.h:66
const ViewOp & functor() const
Definition: CwiseUnaryView.h:85
std::remove_reference_t< MatrixTypeNested > & nestedExpression()
Definition: CwiseUnaryView.h:93
const internal::remove_all_t< MatrixTypeNested > & nestedExpression() const
Definition: CwiseUnaryView.h:89
const unsigned int DirectAccessBit
Definition: Constants.h:157
const unsigned int LvalueBit
Definition: Constants.h:146
const unsigned int RowMajorBit
Definition: Constants.h:68
Namespace containing all symbols from the Eigen library.
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:59
const int Dynamic
Definition: Constants.h:24