ArrayWrapper.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_ARRAYWRAPPER_H
11 #define EIGEN_ARRAYWRAPPER_H
12 
13 namespace Eigen {
14 
26 namespace internal {
27 template<typename ExpressionType>
28 struct traits<ArrayWrapper<ExpressionType> >
29  : public traits<typename remove_all<typename ExpressionType::Nested>::type >
30 {
31  typedef ArrayXpr XprKind;
32  // Let's remove NestByRefBit
33  enum {
36  Flags = (Flags0 & ~(NestByRefBit | LvalueBit)) | LvalueBitFlag
37  };
38 };
39 }
40 
41 template<typename ExpressionType>
42 class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> >
43 {
44  public:
48  typedef typename internal::remove_all<ExpressionType>::type NestedExpression;
49 
50  typedef typename internal::conditional<
51  internal::is_lvalue<ExpressionType>::value,
52  Scalar,
53  const Scalar
55 
56  typedef typename internal::ref_selector<ExpressionType>::non_const_type NestedExpressionType;
57 
58  using Base::coeffRef;
59 
61  explicit EIGEN_STRONG_INLINE ArrayWrapper(ExpressionType& matrix) : m_expression(matrix) {}
62 
64  inline Index rows() const EIGEN_NOEXCEPT { return m_expression.rows(); }
66  inline Index cols() const EIGEN_NOEXCEPT { return m_expression.cols(); }
68  inline Index outerStride() const EIGEN_NOEXCEPT { return m_expression.outerStride(); }
70  inline Index innerStride() const EIGEN_NOEXCEPT { return m_expression.innerStride(); }
71 
73  inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); }
75  inline const Scalar* data() const { return m_expression.data(); }
76 
78  inline const Scalar& coeffRef(Index rowId, Index colId) const
79  {
80  return m_expression.coeffRef(rowId, colId);
81  }
82 
84  inline const Scalar& coeffRef(Index index) const
85  {
86  return m_expression.coeffRef(index);
87  }
88 
89  template<typename Dest>
91  inline void evalTo(Dest& dst) const { dst = m_expression; }
92 
96  {
97  return m_expression;
98  }
99 
103  void resize(Index newSize) { m_expression.resize(newSize); }
108 
109  protected:
111 };
112 
124 namespace internal {
125 template<typename ExpressionType>
126 struct traits<MatrixWrapper<ExpressionType> >
127  : public traits<typename remove_all<typename ExpressionType::Nested>::type >
128 {
130  // Let's remove NestByRefBit
131  enum {
134  Flags = (Flags0 & ~(NestByRefBit | LvalueBit)) | LvalueBitFlag
135  };
136 };
137 }
138 
139 template<typename ExpressionType>
140 class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> >
141 {
142  public:
146  typedef typename internal::remove_all<ExpressionType>::type NestedExpression;
147 
148  typedef typename internal::conditional<
149  internal::is_lvalue<ExpressionType>::value,
150  Scalar,
151  const Scalar
153 
154  typedef typename internal::ref_selector<ExpressionType>::non_const_type NestedExpressionType;
155 
156  using Base::coeffRef;
157 
159  explicit inline MatrixWrapper(ExpressionType& matrix) : m_expression(matrix) {}
160 
162  inline Index rows() const EIGEN_NOEXCEPT { return m_expression.rows(); }
164  inline Index cols() const EIGEN_NOEXCEPT { return m_expression.cols(); }
166  inline Index outerStride() const EIGEN_NOEXCEPT { return m_expression.outerStride(); }
168  inline Index innerStride() const EIGEN_NOEXCEPT { return m_expression.innerStride(); }
169 
171  inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); }
173  inline const Scalar* data() const { return m_expression.data(); }
174 
176  inline const Scalar& coeffRef(Index rowId, Index colId) const
177  {
178  return m_expression.derived().coeffRef(rowId, colId);
179  }
180 
182  inline const Scalar& coeffRef(Index index) const
183  {
184  return m_expression.coeffRef(index);
185  }
186 
190  {
191  return m_expression;
192  }
193 
197  void resize(Index newSize) { m_expression.resize(newSize); }
202 
203  protected:
205 };
206 
207 } // end namespace Eigen
208 
209 #endif // EIGEN_ARRAYWRAPPER_H
Eigen::MatrixWrapper::Base
MatrixBase< MatrixWrapper< ExpressionType > > Base
Definition: ArrayWrapper.h:143
Eigen::ArrayWrapper::data
EIGEN_DEVICE_FUNC ScalarWithConstIfNotLvalue * data()
Definition: ArrayWrapper.h:73
Eigen::MatrixWrapper::innerStride
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index innerStride() const EIGEN_NOEXCEPT
Definition: ArrayWrapper.h:168
Eigen::MatrixXpr
Definition: Constants.h:522
EIGEN_DEVICE_FUNC
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Eigen::ArrayWrapper::evalTo
EIGEN_DEVICE_FUNC void evalTo(Dest &dst) const
Definition: ArrayWrapper.h:91
Eigen::MatrixWrapper::nestedExpression
const EIGEN_DEVICE_FUNC internal::remove_all< NestedExpressionType >::type & nestedExpression() const
Definition: ArrayWrapper.h:189
Eigen::internal::is_lvalue
Definition: XprHelper.h:659
EIGEN_CONSTEXPR
#define EIGEN_CONSTEXPR
Definition: Macros.h:787
type
Definition: pytypes.h:1491
EIGEN_DENSE_PUBLIC_INTERFACE
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1283
Eigen::ArrayWrapper
Expression of a mathematical vector or matrix as an array object.
Definition: ArrayWrapper.h:42
Eigen::ArrayWrapper::nestedExpression
const EIGEN_DEVICE_FUNC internal::remove_all< NestedExpressionType >::type & nestedExpression() const
Definition: ArrayWrapper.h:95
Eigen::ArrayWrapper::data
const EIGEN_DEVICE_FUNC Scalar * data() const
Definition: ArrayWrapper.h:75
Eigen::MatrixWrapper::data
EIGEN_DEVICE_FUNC ScalarWithConstIfNotLvalue * data()
Definition: ArrayWrapper.h:171
Eigen::internal::traits< ArrayWrapper< ExpressionType > >::XprKind
ArrayXpr XprKind
Definition: ArrayWrapper.h:31
Eigen::ArrayWrapper::coeffRef
const EIGEN_DEVICE_FUNC Scalar & coeffRef(Index index) const
Definition: ArrayWrapper.h:84
Eigen::ArrayWrapper::cols
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: ArrayWrapper.h:66
Eigen::ArrayXpr
Definition: Constants.h:525
Eigen::MatrixWrapper::resize
EIGEN_DEVICE_FUNC void resize(Index rows, Index cols)
Definition: ArrayWrapper.h:201
Eigen::internal::true_type
Definition: Meta.h:96
Eigen::LvalueBit
const unsigned int LvalueBit
Definition: Constants.h:144
Eigen::MatrixWrapper::m_expression
NestedExpressionType m_expression
Definition: ArrayWrapper.h:204
Eigen::ArrayWrapper::coeffRef
const EIGEN_DEVICE_FUNC Scalar & coeffRef(Index rowId, Index colId) const
Definition: ArrayWrapper.h:78
Eigen::MatrixWrapper::rows
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: ArrayWrapper.h:162
Eigen::MatrixWrapper::cols
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: ArrayWrapper.h:164
EIGEN_STRONG_INLINE
#define EIGEN_STRONG_INLINE
Definition: Macros.h:917
Eigen::ArrayWrapper::Base
ArrayBase< ArrayWrapper > Base
Definition: ArrayWrapper.h:45
Eigen::Triplet< double >
Eigen::ArrayBase< ArrayWrapper< ExpressionType > >::Scalar
internal::traits< ArrayWrapper< ExpressionType > >::Scalar Scalar
Definition: ArrayBase.h:50
Eigen::ArrayBase
Base class for all 1D and 2D array, and related expressions.
Definition: ArrayBase.h:39
matrix
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: gtsam/3rdparty/Eigen/blas/common.h:110
Eigen::MatrixWrapper::coeffRef
const EIGEN_DEVICE_FUNC Scalar & coeffRef(Index rowId, Index colId) const
Definition: ArrayWrapper.h:176
Eigen::ArrayWrapper::outerStride
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index outerStride() const EIGEN_NOEXCEPT
Definition: ArrayWrapper.h:68
Eigen::ArrayWrapper::rows
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: ArrayWrapper.h:64
Eigen::internal::traits
Definition: ForwardDeclarations.h:17
Eigen::ArrayWrapper::resize
EIGEN_DEVICE_FUNC void resize(Index newSize)
Definition: ArrayWrapper.h:103
Eigen::internal::traits< MatrixWrapper< ExpressionType > >::XprKind
MatrixXpr XprKind
Definition: ArrayWrapper.h:129
EIGEN_NOEXCEPT
#define EIGEN_NOEXCEPT
Definition: Macros.h:1418
internal
Definition: BandTriangularSolver.h:13
Eigen::MatrixBase
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Eigen::MatrixWrapper::resize
EIGEN_DEVICE_FUNC void resize(Index newSize)
Definition: ArrayWrapper.h:197
Eigen::ArrayBase< ArrayWrapper< ExpressionType > >::matrix
EIGEN_DEVICE_FUNC MatrixWrapper< ArrayWrapper< ExpressionType > > matrix()
Definition: ArrayBase.h:148
Eigen::ArrayWrapper::resize
EIGEN_DEVICE_FUNC void resize(Index rows, Index cols)
Definition: ArrayWrapper.h:107
Eigen::MatrixWrapper
Expression of an array as a mathematical vector or matrix.
Definition: ArrayBase.h:15
Eigen::ArrayWrapper::innerStride
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index innerStride() const EIGEN_NOEXCEPT
Definition: ArrayWrapper.h:70
Eigen::NestByRefBit
const unsigned int NestByRefBit
Definition: Constants.h:169
Eigen::MatrixWrapper::data
const EIGEN_DEVICE_FUNC Scalar * data() const
Definition: ArrayWrapper.h:173
EIGEN_INHERIT_ASSIGNMENT_OPERATORS
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
Definition: Macros.h:1231
test_callbacks.value
value
Definition: test_callbacks.py:158
Eigen::MatrixWrapper::outerStride
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index outerStride() const EIGEN_NOEXCEPT
Definition: ArrayWrapper.h:166
Eigen::ArrayWrapper::m_expression
NestedExpressionType m_expression
Definition: ArrayWrapper.h:110
Eigen::DenseBase< ArrayWrapper< ExpressionType > >::value
EIGEN_DEVICE_FUNC CoeffReturnType value() const
Definition: DenseBase.h:526
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Eigen::MatrixWrapper::coeffRef
const EIGEN_DEVICE_FUNC Scalar & coeffRef(Index index) const
Definition: ArrayWrapper.h:182


gtsam
Author(s):
autogenerated on Sat Jun 1 2024 03:01:10