Map.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) 2007-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
5 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_MAP_H
12 #define EIGEN_MAP_H
13 
14 namespace Eigen {
15 
16 namespace internal {
17 template<typename PlainObjectType, int MapOptions, typename StrideType>
18 struct traits<Map<PlainObjectType, MapOptions, StrideType> >
19  : public traits<PlainObjectType>
20 {
22  enum {
23  PlainObjectTypeInnerSize = ((traits<PlainObjectType>::Flags&RowMajorBit)==RowMajorBit)
24  ? PlainObjectType::ColsAtCompileTime
25  : PlainObjectType::RowsAtCompileTime,
26 
27  InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0
28  ? int(PlainObjectType::InnerStrideAtCompileTime)
29  : int(StrideType::InnerStrideAtCompileTime),
30  OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0
31  ? (InnerStrideAtCompileTime==Dynamic || PlainObjectTypeInnerSize==Dynamic
32  ? Dynamic
33  : int(InnerStrideAtCompileTime) * int(PlainObjectTypeInnerSize))
34  : int(StrideType::OuterStrideAtCompileTime),
35  Alignment = int(MapOptions)&int(AlignedMask),
36  Flags0 = TraitsBase::Flags & (~NestByRefBit),
37  Flags = is_lvalue<PlainObjectType>::value ? int(Flags0) : (int(Flags0) & ~LvalueBit)
38  };
39 private:
40  enum { Options }; // Expressions don't have Options
41 };
42 }
43 
94 template<typename PlainObjectType, int MapOptions, typename StrideType> class Map
95  : public MapBase<Map<PlainObjectType, MapOptions, StrideType> >
96 {
97  public:
98 
99  typedef MapBase<Map> Base;
101 
102  typedef typename Base::PointerType PointerType;
105  inline PointerType cast_to_pointer_type(PointerArgType ptr) { return ptr; }
106 
108  inline Index innerStride() const
109  {
110  return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1;
111  }
112 
114  inline Index outerStride() const
115  {
116  return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer()
118  : IsVectorAtCompileTime ? (this->size() * innerStride())
119  : int(Flags)&RowMajorBit ? (this->cols() * innerStride())
120  : (this->rows() * innerStride());
121  }
122 
129  explicit inline Map(PointerArgType dataPtr, const StrideType& stride = StrideType())
130  : Base(cast_to_pointer_type(dataPtr)), m_stride(stride)
131  {
132  PlainObjectType::Base::_check_template_params();
133  }
134 
142  inline Map(PointerArgType dataPtr, Index size, const StrideType& stride = StrideType())
143  : Base(cast_to_pointer_type(dataPtr), size), m_stride(stride)
144  {
145  PlainObjectType::Base::_check_template_params();
146  }
147 
156  inline Map(PointerArgType dataPtr, Index rows, Index cols, const StrideType& stride = StrideType())
157  : Base(cast_to_pointer_type(dataPtr), rows, cols), m_stride(stride)
158  {
159  PlainObjectType::Base::_check_template_params();
160  }
161 
163 
164  protected:
165  StrideType m_stride;
166 };
167 
168 
169 } // end namespace Eigen
170 
171 #endif // EIGEN_MAP_H
gtsam.examples.DogLegOptimizerExample.int
int
Definition: DogLegOptimizerExample.py:111
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::Map::Map
EIGEN_DEVICE_FUNC Map(PointerArgType dataPtr, Index rows, Index cols, const StrideType &stride=StrideType())
Definition: Map.h:156
Eigen::Map< const Matrix< StorageIndex, _Rows, _Cols, _Options, _MaxRows, _MaxCols >, AlignedMax >::PointerArgType
PointerType PointerArgType
Definition: Map.h:103
Eigen::Map::Base
MapBase< Map > Base
Definition: Map.h:99
Eigen::internal::is_lvalue
Definition: XprHelper.h:659
Eigen::RowMajorBit
const unsigned int RowMajorBit
Definition: Constants.h:66
EIGEN_CONSTEXPR
#define EIGEN_CONSTEXPR
Definition: Macros.h:787
EIGEN_DENSE_PUBLIC_INTERFACE
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1283
rows
int rows
Definition: Tutorial_commainit_02.cpp:1
Eigen::Map::innerStride
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index innerStride() const
Definition: Map.h:108
Eigen::Map::Map
EIGEN_DEVICE_FUNC Map(PointerArgType dataPtr, Index size, const StrideType &stride=StrideType())
Definition: Map.h:142
Eigen::LvalueBit
const unsigned int LvalueBit
Definition: Constants.h:144
Eigen::MapBase
Definition: ForwardDeclarations.h:112
Eigen::Dynamic
const int Dynamic
Definition: Constants.h:22
Eigen::Map::m_stride
StrideType m_stride
Definition: Map.h:165
Eigen::Map::outerStride
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index outerStride() const
Definition: Map.h:114
Eigen::Map
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:94
Eigen::internal::traits< Map< PlainObjectType, MapOptions, StrideType > >::TraitsBase
traits< PlainObjectType > TraitsBase
Definition: Map.h:21
Eigen::Map< const Matrix< StorageIndex, _Rows, _Cols, _Options, _MaxRows, _MaxCols >, AlignedMax >::PointerType
Base::PointerType PointerType
Definition: Map.h:102
Eigen::Map::Map
EIGEN_DEVICE_FUNC Map(PointerArgType dataPtr, const StrideType &stride=StrideType())
Definition: Map.h:129
Eigen::internal::traits
Definition: ForwardDeclarations.h:17
Eigen::AlignedMask
@ AlignedMask
Definition: Constants.h:239
internal
Definition: BandTriangularSolver.h:13
Eigen::internal::size
EIGEN_CONSTEXPR Index size(const T &x)
Definition: Meta.h:479
cols
int cols
Definition: Tutorial_commainit_02.cpp:1
Eigen::NestByRefBit
const unsigned int NestByRefBit
Definition: Constants.h:169
EIGEN_INHERIT_ASSIGNMENT_OPERATORS
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
Definition: Macros.h:1231
test_callbacks.value
value
Definition: test_callbacks.py:160
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:58