CwiseUnaryView.h
Go to the documentation of this file.
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 
13 namespace Eigen {
14 
15 namespace internal {
16 template<typename ViewOp, typename MatrixType>
17 struct traits<CwiseUnaryView<ViewOp, MatrixType> >
18  : traits<MatrixType>
19 {
20  typedef typename result_of<
21  ViewOp(const typename traits<MatrixType>::Scalar&)
23  typedef typename MatrixType::Nested MatrixTypeNested;
25  enum {
26  FlagsLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0,
27  Flags = traits<_MatrixTypeNested>::Flags & (RowMajorBit | FlagsLvalueBit | DirectAccessBit), // FIXME DirectAccessBit should not be handled by expressions
29  // need to cast the sizeof's from size_t to int explicitly, otherwise:
30  // "error: no integral type can represent all of the enumerator values
31  InnerStrideAtCompileTime = MatrixTypeInnerStride == Dynamic
32  ? int(Dynamic)
33  : int(MatrixTypeInnerStride) * int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar)),
35  ? int(Dynamic)
36  : outer_stride_at_compile_time<MatrixType>::ret * int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar))
37  };
38 };
39 }
40 
41 template<typename ViewOp, typename MatrixType, typename StorageKind>
43 
57 template<typename ViewOp, typename MatrixType>
58 class CwiseUnaryView : public CwiseUnaryViewImpl<ViewOp, MatrixType, typename internal::traits<MatrixType>::StorageKind>
59 {
60  public:
61 
64  typedef typename internal::ref_selector<MatrixType>::non_const_type MatrixTypeNested;
65  typedef typename internal::remove_all<MatrixType>::type NestedExpression;
66 
67  explicit EIGEN_DEVICE_FUNC inline CwiseUnaryView(MatrixType& mat, const ViewOp& func = ViewOp())
68  : m_matrix(mat), m_functor(func) {}
69 
71 
73  Index rows() const EIGEN_NOEXCEPT { return m_matrix.rows(); }
75  Index cols() const EIGEN_NOEXCEPT { return m_matrix.cols(); }
76 
78  EIGEN_DEVICE_FUNC const ViewOp& functor() const { return m_functor; }
79 
82  nestedExpression() const { return m_matrix; }
83 
86  nestedExpression() { return m_matrix; }
87 
88  protected:
90  ViewOp m_functor;
91 };
92 
93 // Generic API dispatcher
94 template<typename ViewOp, typename XprType, typename StorageKind>
96  : public internal::generic_xpr_base<CwiseUnaryView<ViewOp, XprType> >::type
97 {
98 public:
100 };
101 
102 template<typename ViewOp, typename MatrixType>
104  : public internal::dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type
105 {
106  public:
107 
110 
113 
114  EIGEN_DEVICE_FUNC inline Scalar* data() { return &(this->coeffRef(0)); }
115  EIGEN_DEVICE_FUNC inline const Scalar* data() const { return &(this->coeff(0)); }
116 
118  {
119  return derived().nestedExpression().innerStride() * sizeof(typename internal::traits<MatrixType>::Scalar) / sizeof(Scalar);
120  }
121 
123  {
124  return derived().nestedExpression().outerStride() * sizeof(typename internal::traits<MatrixType>::Scalar) / sizeof(Scalar);
125  }
126  protected:
128 };
129 
130 } // end namespace Eigen
131 
132 #endif // EIGEN_CWISE_UNARY_VIEW_H
Eigen::CwiseUnaryView::nestedExpression
EIGEN_DEVICE_FUNC internal::remove_reference< MatrixTypeNested >::type & nestedExpression()
Definition: CwiseUnaryView.h:86
gtsam.examples.DogLegOptimizerExample.int
int
Definition: DogLegOptimizerExample.py:111
Eigen::CwiseUnaryViewImpl< ViewOp, MatrixType, Dense >::outerStride
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index outerStride() const
Definition: CwiseUnaryView.h:122
EIGEN_DEVICE_FUNC
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
Eigen::CwiseUnaryViewImpl::Base
internal::generic_xpr_base< CwiseUnaryView< ViewOp, XprType > >::type Base
Definition: CwiseUnaryView.h:99
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR
#define EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(Derived)
Definition: Macros.h:1247
MatrixType
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
Eigen::internal::dense_xpr_base
Definition: XprHelper.h:483
Eigen::internal::is_lvalue
Definition: XprHelper.h:659
Eigen::RowMajorBit
const unsigned int RowMajorBit
Definition: Constants.h:66
ret
DenseIndex ret
Definition: level1_cplx_impl.h:44
EIGEN_CONSTEXPR
#define EIGEN_CONSTEXPR
Definition: Macros.h:787
Eigen::CwiseUnaryViewImpl
Definition: CwiseUnaryView.h:42
type
Definition: pytypes.h:1525
Eigen::CwiseUnaryView::functor
const EIGEN_DEVICE_FUNC ViewOp & functor() const
Definition: CwiseUnaryView.h:78
EIGEN_DENSE_PUBLIC_INTERFACE
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1283
mat
MatrixXf mat
Definition: Tutorial_AdvancedInitialization_CommaTemporary.cpp:1
Eigen::CwiseUnaryView
Generic lvalue expression of a coefficient-wise unary operator of a matrix or a vector.
Definition: CwiseUnaryView.h:58
Eigen::DirectAccessBit
const unsigned int DirectAccessBit
Definition: Constants.h:155
Eigen::CwiseUnaryViewImpl< ViewOp, MatrixType, Dense >::Base
internal::dense_xpr_base< CwiseUnaryView< ViewOp, MatrixType > >::type Base
Definition: CwiseUnaryView.h:109
Eigen::internal::true_type
Definition: Meta.h:96
EIGEN_GENERIC_PUBLIC_INTERFACE
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1264
data
int data[]
Definition: Map_placement_new.cpp:1
Eigen::LvalueBit
const unsigned int LvalueBit
Definition: Constants.h:144
Eigen::Dynamic
const int Dynamic
Definition: Constants.h:22
Eigen::CwiseUnaryViewImpl< ViewOp, MatrixType, Dense >::Derived
CwiseUnaryView< ViewOp, MatrixType > Derived
Definition: CwiseUnaryView.h:108
Eigen::internal::generic_xpr_base
Definition: XprHelper.h:501
EIGEN_STRONG_INLINE
#define EIGEN_STRONG_INLINE
Definition: Macros.h:917
Eigen::internal::outer_stride_at_compile_time
Definition: DenseCoeffsBase.h:670
Eigen::CwiseUnaryViewImpl< ViewOp, MatrixType, Dense >::innerStride
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index innerStride() const
Definition: CwiseUnaryView.h:117
Eigen::Triplet< double >
Eigen::internal::inner_stride_at_compile_time
Definition: DenseCoeffsBase.h:658
Eigen::CwiseUnaryView::rows
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: CwiseUnaryView.h:73
Eigen::CwiseUnaryView::m_functor
ViewOp m_functor
Definition: CwiseUnaryView.h:90
Eigen::internal::traits
Definition: ForwardDeclarations.h:17
Eigen::internal::result_of
Definition: Meta.h:513
Eigen::internal::traits< CwiseUnaryView< ViewOp, MatrixType > >::Scalar
result_of< ViewOp(const typename traits< MatrixType >::Scalar &) >::type Scalar
Definition: CwiseUnaryView.h:22
Eigen::internal::traits< CwiseUnaryView< ViewOp, MatrixType > >::_MatrixTypeNested
remove_all< MatrixTypeNested >::type _MatrixTypeNested
Definition: CwiseUnaryView.h:24
Eigen::CwiseUnaryView::nestedExpression
const EIGEN_DEVICE_FUNC internal::remove_all< MatrixTypeNested >::type & nestedExpression() const
Definition: CwiseUnaryView.h:82
EIGEN_NOEXCEPT
#define EIGEN_NOEXCEPT
Definition: Macros.h:1418
internal
Definition: BandTriangularSolver.h:13
Eigen::internal::traits< CwiseUnaryView< ViewOp, MatrixType > >::MatrixTypeNested
MatrixType::Nested MatrixTypeNested
Definition: CwiseUnaryView.h:23
Eigen::CwiseUnaryView::Base
CwiseUnaryViewImpl< ViewOp, MatrixType, typename internal::traits< MatrixType >::StorageKind >::Base Base
Definition: CwiseUnaryView.h:62
func
Definition: benchGeometry.cpp:23
EIGEN_INHERIT_ASSIGNMENT_OPERATORS
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
Definition: Macros.h:1231
Eigen::CwiseUnaryViewImpl< ViewOp, MatrixType, Dense >::data
const EIGEN_DEVICE_FUNC Scalar * data() const
Definition: CwiseUnaryView.h:115
Eigen::CwiseUnaryView::m_matrix
MatrixTypeNested m_matrix
Definition: CwiseUnaryView.h:89
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
Eigen::CwiseUnaryView::cols
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: CwiseUnaryView.h:75
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Eigen::Dense
Definition: Constants.h:507


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:32:19