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 
67 namespace internal {
68 template<typename PlainObjectType, int MapOptions, typename StrideType>
69 struct traits<Map<PlainObjectType, MapOptions, StrideType> >
70  : public traits<PlainObjectType>
71 {
73  typedef typename PlainObjectType::Index Index;
74  typedef typename PlainObjectType::Scalar Scalar;
75  enum {
76  InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0
77  ? int(PlainObjectType::InnerStrideAtCompileTime)
78  : int(StrideType::InnerStrideAtCompileTime),
79  OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0
80  ? int(PlainObjectType::OuterStrideAtCompileTime)
81  : int(StrideType::OuterStrideAtCompileTime),
82  HasNoInnerStride = InnerStrideAtCompileTime == 1,
83  HasNoOuterStride = StrideType::OuterStrideAtCompileTime == 0,
84  HasNoStride = HasNoInnerStride && HasNoOuterStride,
85  IsAligned = bool(EIGEN_ALIGN) && ((int(MapOptions)&Aligned)==Aligned),
86  IsDynamicSize = PlainObjectType::SizeAtCompileTime==Dynamic,
87  KeepsPacketAccess = bool(HasNoInnerStride)
88  && ( bool(IsDynamicSize)
89  || HasNoOuterStride
90  || ( OuterStrideAtCompileTime!=Dynamic
91  && ((static_cast<int>(sizeof(Scalar))*OuterStrideAtCompileTime)%16)==0 ) ),
92  Flags0 = TraitsBase::Flags & (~NestByRefBit),
93  Flags1 = IsAligned ? (int(Flags0) | AlignedBit) : (int(Flags0) & ~AlignedBit),
94  Flags2 = (bool(HasNoStride) || bool(PlainObjectType::IsVectorAtCompileTime))
95  ? int(Flags1) : int(Flags1 & ~LinearAccessBit),
96  Flags3 = is_lvalue<PlainObjectType>::value ? int(Flags2) : (int(Flags2) & ~LvalueBit),
97  Flags = KeepsPacketAccess ? int(Flags3) : (int(Flags3) & ~PacketAccessBit)
98  };
99 private:
100  enum { Options }; // Expressions don't have Options
101 };
102 }
103 
104 template<typename PlainObjectType, int MapOptions, typename StrideType> class Map
105  : public MapBase<Map<PlainObjectType, MapOptions, StrideType> >
106 {
107  public:
108 
111 
112  typedef typename Base::PointerType PointerType;
113 #if EIGEN2_SUPPORT_STAGE <= STAGE30_FULL_EIGEN3_API
114  typedef const Scalar* PointerArgType;
115  inline PointerType cast_to_pointer_type(PointerArgType ptr) { return const_cast<PointerType>(ptr); }
116 #else
117  typedef PointerType PointerArgType;
118  inline PointerType cast_to_pointer_type(PointerArgType ptr) { return ptr; }
119 #endif
120 
121  inline Index innerStride() const
122  {
123  return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1;
124  }
125 
126  inline Index outerStride() const
127  {
128  return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer()
129  : IsVectorAtCompileTime ? this->size()
130  : int(Flags)&RowMajorBit ? this->cols()
131  : this->rows();
132  }
133 
139  inline Map(PointerArgType dataPtr, const StrideType& a_stride = StrideType())
140  : Base(cast_to_pointer_type(dataPtr)), m_stride(a_stride)
141  {
142  PlainObjectType::Base::_check_template_params();
143  }
144 
151  inline Map(PointerArgType dataPtr, Index a_size, const StrideType& a_stride = StrideType())
152  : Base(cast_to_pointer_type(dataPtr), a_size), m_stride(a_stride)
153  {
154  PlainObjectType::Base::_check_template_params();
155  }
156 
164  inline Map(PointerArgType dataPtr, Index nbRows, Index nbCols, const StrideType& a_stride = StrideType())
165  : Base(cast_to_pointer_type(dataPtr), nbRows, nbCols), m_stride(a_stride)
166  {
167  PlainObjectType::Base::_check_template_params();
168  }
169 
171 
172  protected:
173  StrideType m_stride;
174 };
175 
176 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
178  ::Array(const Scalar *data)
179 {
180  this->_set_noalias(Eigen::Map<const Array>(data));
181 }
182 
183 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
185  ::Matrix(const Scalar *data)
186 {
187  this->_set_noalias(Eigen::Map<const Matrix>(data));
188 }
189 
190 } // end namespace Eigen
191 
192 #endif // EIGEN_MAP_H
Map(PointerArgType dataPtr, Index a_size, const StrideType &a_stride=StrideType())
Definition: Map.h:151
Base class for Map and Block expression with direct access.
MapBase< Map > Base
Definition: Map.h:109
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:104
const unsigned int LvalueBit
Definition: Constants.h:131
Definition: LDLT.h:16
Index outerStride() const
Definition: Map.h:126
Map(PointerArgType dataPtr, Index nbRows, Index nbCols, const StrideType &a_stride=StrideType())
Definition: Map.h:164
const unsigned int RowMajorBit
Definition: Constants.h:53
const unsigned int PacketAccessBit
Definition: Constants.h:81
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
const Scalar * PointerArgType
Definition: Map.h:114
const unsigned int AlignedBit
Definition: Constants.h:147
#define EIGEN_ALIGN
EIGEN_STRONG_INLINE Matrix()
Default constructor.
Definition: Matrix.h:203
Map(PointerArgType dataPtr, const StrideType &a_stride=StrideType())
Definition: Map.h:139
EIGEN_STRONG_INLINE Array()
Definition: Array.h:110
const unsigned int NestByRefBit
Definition: Constants.h:149
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
StrideType m_stride
Definition: Map.h:173
Base::PointerType PointerType
Definition: Map.h:112
const int Dynamic
Definition: Constants.h:21
const unsigned int LinearAccessBit
Definition: Constants.h:117
Index innerStride() const
Definition: Map.h:121
PointerType cast_to_pointer_type(PointerArgType ptr)
Definition: Map.h:115


tuw_aruco
Author(s): Lukas Pfeifhofer
autogenerated on Mon Jun 10 2019 15:40:53