Medial Code Documentation
Loading...
Searching...
No Matches
CwiseUnaryView.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
5//
6// This Source Code Form is subject to the terms of the Mozilla
7// Public License v. 2.0. If a copy of the MPL was not distributed
8// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10#ifndef EIGEN_CWISE_UNARY_VIEW_H
11#define EIGEN_CWISE_UNARY_VIEW_H
12
13namespace Eigen {
14
29namespace internal {
30template<typename ViewOp, typename MatrixType>
31struct traits<CwiseUnaryView<ViewOp, MatrixType> >
32 : traits<MatrixType>
33{
34 typedef typename result_of<
36 >::type Scalar;
37 typedef typename MatrixType::Nested MatrixTypeNested;
39 enum {
40 FlagsLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0,
41 Flags = traits<_MatrixTypeNested>::Flags & (RowMajorBit | FlagsLvalueBit | DirectAccessBit), // FIXME DirectAccessBit should not be handled by expressions
43 // need to cast the sizeof's from size_t to int explicitly, otherwise:
44 // "error: no integral type can represent all of the enumerator values
45 InnerStrideAtCompileTime = MatrixTypeInnerStride == Dynamic
46 ? int(Dynamic)
47 : int(MatrixTypeInnerStride) * int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar)),
48 OuterStrideAtCompileTime = outer_stride_at_compile_time<MatrixType>::ret == Dynamic
49 ? int(Dynamic)
50 : outer_stride_at_compile_time<MatrixType>::ret * int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar))
51 };
52};
53}
54
55template<typename ViewOp, typename MatrixType, typename StorageKind>
57
58template<typename ViewOp, typename MatrixType>
59class CwiseUnaryView : public CwiseUnaryViewImpl<ViewOp, MatrixType, typename internal::traits<MatrixType>::StorageKind>
60{
61 public:
62
64 EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryView)
66
67 explicit inline CwiseUnaryView(MatrixType& mat, const ViewOp& func = ViewOp())
68 : m_matrix(mat), m_functor(func) {}
69
70 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryView)
71
72 EIGEN_STRONG_INLINE Index rows() const { return m_matrix.rows(); }
73 EIGEN_STRONG_INLINE Index cols() const { return m_matrix.cols(); }
74
76 const ViewOp& functor() const { return m_functor; }
77
80 nestedExpression() const { return m_matrix; }
81
84 nestedExpression() { return m_matrix.const_cast_derived(); }
85
86 protected:
88 ViewOp m_functor;
89};
90
91// Generic API dispatcher
92template<typename ViewOp, typename XprType, typename StorageKind>
94 : public internal::generic_xpr_base<CwiseUnaryView<ViewOp, XprType> >::type
95{
96public:
98};
99
100template<typename ViewOp, typename MatrixType>
102 : public internal::dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type
103{
104 public:
105
108
109 EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
110 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryViewImpl)
111
112 EIGEN_DEVICE_FUNC inline Scalar* data() { return &(this->coeffRef(0)); }
113 EIGEN_DEVICE_FUNC inline const Scalar* data() const { return &(this->coeff(0)); }
114
115 EIGEN_DEVICE_FUNC inline Index innerStride() const
116 {
117 return derived().nestedExpression().innerStride() * sizeof(typename internal::traits<MatrixType>::Scalar) / sizeof(Scalar);
118 }
119
120 EIGEN_DEVICE_FUNC inline Index outerStride() const
121 {
122 return derived().nestedExpression().outerStride() * sizeof(typename internal::traits<MatrixType>::Scalar) / sizeof(Scalar);
123 }
124};
125
126} // end namespace Eigen
127
128#endif // EIGEN_CWISE_UNARY_VIEW_H
Definition CwiseUnaryView.h:95
Generic lvalue expression of a coefficient-wise unary operator of a matrix or a vector.
Definition CwiseUnaryView.h:60
const internal::remove_all< typenameMatrixType::Nested >::type & nestedExpression() const
Definition CwiseUnaryView.h:80
const ViewOp & functor() const
Definition CwiseUnaryView.h:76
internal::remove_all< typenameMatrixType::Nested >::type & nestedExpression()
Definition CwiseUnaryView.h:84
Pseudo expression representing a solving operation.
Definition Solve.h:63
const unsigned int DirectAccessBit
Means that the underlying array of coefficients can be directly accessed as a plain strided array.
Definition Constants.h:149
const unsigned int LvalueBit
Means the expression has a coeffRef() method, i.e.
Definition Constants.h:138
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:61
The type used to identify a dense storage.
Definition Constants.h:490
Definition XprHelper.h:428
Definition XprHelper.h:445
Definition DenseCoeffsBase.h:631
Definition XprHelper.h:628
Definition DenseCoeffsBase.h:643
Definition Meta.h:253
Definition ForwardDeclarations.h:17
Definition Meta.h:30