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  InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0
24  ? int(PlainObjectType::InnerStrideAtCompileTime)
25  : int(StrideType::InnerStrideAtCompileTime),
26  OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0
27  ? int(PlainObjectType::OuterStrideAtCompileTime)
28  : int(StrideType::OuterStrideAtCompileTime),
29  Alignment = int(MapOptions)&int(AlignedMask),
30  Flags0 = TraitsBase::Flags & (~NestByRefBit),
31  Flags = is_lvalue<PlainObjectType>::value ? int(Flags0) : (int(Flags0) & ~LvalueBit)
32  };
33 private:
34  enum { Options }; // Expressions don't have Options
35 };
36 }
37 
88 template<typename PlainObjectType, int MapOptions, typename StrideType> class Map
89  : public MapBase<Map<PlainObjectType, MapOptions, StrideType> >
90 {
91  public:
92 
93  typedef MapBase<Map> Base;
95 
96  typedef typename Base::PointerType PointerType;
97  typedef PointerType PointerArgType;
98  EIGEN_DEVICE_FUNC
99  inline PointerType cast_to_pointer_type(PointerArgType ptr) { return ptr; }
100 
101  EIGEN_DEVICE_FUNC
102  inline Index innerStride() const
103  {
104  return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1;
105  }
106 
107  EIGEN_DEVICE_FUNC
108  inline Index outerStride() const
109  {
110  return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer()
111  : IsVectorAtCompileTime ? this->size()
112  : int(Flags)&RowMajorBit ? this->cols()
113  : this->rows();
114  }
115 
121  EIGEN_DEVICE_FUNC
122  explicit inline Map(PointerArgType dataPtr, const StrideType& stride = StrideType())
123  : Base(cast_to_pointer_type(dataPtr)), m_stride(stride)
124  {
125  PlainObjectType::Base::_check_template_params();
126  }
127 
134  EIGEN_DEVICE_FUNC
135  inline Map(PointerArgType dataPtr, Index size, const StrideType& stride = StrideType())
136  : Base(cast_to_pointer_type(dataPtr), size), m_stride(stride)
137  {
138  PlainObjectType::Base::_check_template_params();
139  }
140 
148  EIGEN_DEVICE_FUNC
149  inline Map(PointerArgType dataPtr, Index rows, Index cols, const StrideType& stride = StrideType())
150  : Base(cast_to_pointer_type(dataPtr), rows, cols), m_stride(stride)
151  {
152  PlainObjectType::Base::_check_template_params();
153  }
154 
156 
157  protected:
158  StrideType m_stride;
159 };
160 
161 
162 } // end namespace Eigen
163 
164 #endif // EIGEN_MAP_H
MapBase< Map > Base
Definition: Map.h:93
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:88
const unsigned int LvalueBit
Definition: Constants.h:139
Definition: LDLT.h:16
static constexpr size_t size(Tuple< Args... > &)
Provides access to the number of elements in a tuple as a compile-time constant expression.
const unsigned int RowMajorBit
Definition: Constants.h:61
EIGEN_DEVICE_FUNC Index innerStride() const
Definition: Map.h:102
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
EIGEN_DEVICE_FUNC Map(PointerArgType dataPtr, Index rows, Index cols, const StrideType &stride=StrideType())
Definition: Map.h:149
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
Definition: Macros.h:839
EIGEN_DEVICE_FUNC Index outerStride() const
Definition: Map.h:108
const unsigned int NestByRefBit
Definition: Constants.h:164
EIGEN_DEVICE_FUNC Map(PointerArgType dataPtr, const StrideType &stride=StrideType())
Definition: Map.h:122
EIGEN_DEVICE_FUNC Map(PointerArgType dataPtr, Index size, const StrideType &stride=StrideType())
Definition: Map.h:135
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:867
StrideType m_stride
Definition: Map.h:158


hebiros
Author(s): Xavier Artache , Matthew Tesch
autogenerated on Thu Sep 3 2020 04:08:21