10#ifndef EIGEN_CWISE_UNARY_VIEW_H
11#define EIGEN_CWISE_UNARY_VIEW_H
13#include "./InternalHeaderCheck.h"
18template<
typename ViewOp,
typename MatrixType>
19struct traits<CwiseUnaryView<ViewOp, MatrixType> >
22 typedef typename result_of<
23 ViewOp(
const typename traits<MatrixType>::Scalar&)
25 typedef typename MatrixType::Nested MatrixTypeNested;
26 typedef typename remove_all<MatrixTypeNested>::type _MatrixTypeNested;
28 FlagsLvalueBit = is_lvalue<MatrixType>::value ?
LvalueBit : 0,
30 MatrixTypeInnerStride = inner_stride_at_compile_time<MatrixType>::ret,
33 InnerStrideAtCompileTime = MatrixTypeInnerStride ==
Dynamic
35 : int(MatrixTypeInnerStride) * int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar)),
36 OuterStrideAtCompileTime = outer_stride_at_compile_time<MatrixType>::ret ==
Dynamic
38 : outer_stride_at_compile_time<MatrixType>::ret * int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar))
43template<
typename ViewOp,
typename MatrixType,
typename StorageKind>
44class CwiseUnaryViewImpl;
59template<
typename ViewOp,
typename MatrixType>
60class CwiseUnaryView :
public CwiseUnaryViewImpl<ViewOp, MatrixType, typename internal::traits<MatrixType>::StorageKind>
64 typedef typename CwiseUnaryViewImpl<ViewOp, MatrixType,typename internal::traits<MatrixType>::StorageKind>::Base Base;
66 typedef typename internal::ref_selector<MatrixType>::non_const_type MatrixTypeNested;
67 typedef typename internal::remove_all<MatrixType>::type NestedExpression;
69 explicit EIGEN_DEVICE_FUNC
inline CwiseUnaryView(MatrixType& mat,
const ViewOp& func = ViewOp())
70 : m_matrix(mat), m_functor(func) {}
74 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
75 Index rows()
const EIGEN_NOEXCEPT {
return m_matrix.rows(); }
76 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
77 Index cols()
const EIGEN_NOEXCEPT {
return m_matrix.cols(); }
80 EIGEN_DEVICE_FUNC
const ViewOp&
functor()
const {
return m_functor; }
83 EIGEN_DEVICE_FUNC
const typename internal::remove_all<MatrixTypeNested>::type&
87 EIGEN_DEVICE_FUNC
typename internal::remove_reference<MatrixTypeNested>::type&
91 MatrixTypeNested m_matrix;
96template<
typename ViewOp,
typename XprType,
typename StorageKind>
97class CwiseUnaryViewImpl
98 :
public internal::generic_xpr_base<CwiseUnaryView<ViewOp, XprType> >::type
101 typedef typename internal::generic_xpr_base<CwiseUnaryView<ViewOp, XprType> >::type Base;
104template<
typename ViewOp,
typename MatrixType>
105class CwiseUnaryViewImpl<ViewOp,MatrixType,Dense>
106 :
public internal::dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type
110 typedef CwiseUnaryView<ViewOp, MatrixType> Derived;
111 typedef typename internal::dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type Base;
113 EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
114 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryViewImpl)
116 EIGEN_DEVICE_FUNC
inline Scalar* data() {
return &(this->coeffRef(0)); }
117 EIGEN_DEVICE_FUNC
inline const Scalar* data()
const {
return &(this->coeff(0)); }
119 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index innerStride()
const
121 return derived().nestedExpression().innerStride() *
sizeof(
typename internal::traits<MatrixType>::Scalar) /
sizeof(Scalar);
124 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index outerStride()
const
126 return derived().nestedExpression().outerStride() *
sizeof(
typename internal::traits<MatrixType>::Scalar) /
sizeof(Scalar);
129 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:61
const ViewOp & functor() const
Definition: CwiseUnaryView.h:80
internal::remove_reference< MatrixTypeNested >::type & nestedExpression()
Definition: CwiseUnaryView.h:88
const internal::remove_all< MatrixTypeNested >::type & nestedExpression() const
Definition: CwiseUnaryView.h:84
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: B01_Experimental.dox:1
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