10 #ifndef EIGEN_CWISE_UNARY_VIEW_H
11 #define EIGEN_CWISE_UNARY_VIEW_H
30 template<
typename ViewOp,
typename MatrixType>
31 struct traits<CwiseUnaryView<ViewOp, MatrixType> >
34 typedef typename result_of<
35 ViewOp(
typename traits<MatrixType>::Scalar)
37 typedef typename MatrixType::Nested MatrixTypeNested;
38 typedef typename remove_all<MatrixTypeNested>::type _MatrixTypeNested;
41 CoeffReadCost = traits<_MatrixTypeNested>::CoeffReadCost + functor_traits<ViewOp>::Cost,
42 MatrixTypeInnerStride = inner_stride_at_compile_time<MatrixType>::ret,
45 InnerStrideAtCompileTime = MatrixTypeInnerStride ==
Dynamic
47 : int(MatrixTypeInnerStride) * int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar)),
48 OuterStrideAtCompileTime = outer_stride_at_compile_time<MatrixType>::ret ==
Dynamic
50 : outer_stride_at_compile_time<MatrixType>::ret * int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar))
55 template<
typename ViewOp,
typename MatrixType,
typename StorageKind>
56 class CwiseUnaryViewImpl;
58 template<
typename ViewOp,
typename MatrixType>
60 public CwiseUnaryViewImpl<ViewOp, MatrixType, typename internal::traits<MatrixType>::StorageKind>
64 typedef typename CwiseUnaryViewImpl<ViewOp, MatrixType,typename internal::traits<MatrixType>::StorageKind>::Base Base;
67 inline CwiseUnaryView(
const MatrixType& mat,
const ViewOp& func = ViewOp())
68 : m_matrix(mat), m_functor(func) {}
72 EIGEN_STRONG_INLINE Index rows()
const {
return m_matrix.rows(); }
73 EIGEN_STRONG_INLINE Index cols()
const {
return m_matrix.cols(); }
76 const ViewOp&
functor()
const {
return m_functor; }
79 const typename internal::remove_all<typename MatrixType::Nested>::type&
83 typename internal::remove_all<typename MatrixType::Nested>::type&
88 typename internal::nested<MatrixType>::type m_matrix;
92 template<
typename ViewOp,
typename MatrixType>
93 class CwiseUnaryViewImpl<ViewOp,MatrixType,Dense>
94 :
public internal::dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type
98 typedef CwiseUnaryView<ViewOp, MatrixType> Derived;
99 typedef typename internal::dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type Base;
101 EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
103 inline Index innerStride()
const
105 return derived().nestedExpression().innerStride() *
sizeof(
typename internal::traits<MatrixType>::Scalar) /
sizeof(Scalar);
108 inline Index outerStride()
const
110 return derived().nestedExpression().outerStride() *
sizeof(
typename internal::traits<MatrixType>::Scalar) /
sizeof(Scalar);
113 EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col)
const
115 return derived().functor()(derived().nestedExpression().coeff(row, col));
118 EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index)
const
120 return derived().functor()(derived().nestedExpression().coeff(index));
123 EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col)
125 return derived().functor()(const_cast_derived().nestedExpression().coeffRef(row, col));
128 EIGEN_STRONG_INLINE Scalar& coeffRef(Index index)
130 return derived().functor()(const_cast_derived().nestedExpression().coeffRef(index));
136 #endif // EIGEN_CWISE_UNARY_VIEW_H