Eigen  3.2.91
Map.h
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 {
72  typedef traits<PlainObjectType> TraitsBase;
73  enum {
74  InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0
75  ? int(PlainObjectType::InnerStrideAtCompileTime)
76  : int(StrideType::InnerStrideAtCompileTime),
77  OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0
78  ? int(PlainObjectType::OuterStrideAtCompileTime)
79  : int(StrideType::OuterStrideAtCompileTime),
80  Alignment = int(MapOptions)&int(AlignedMask),
81  Flags0 = TraitsBase::Flags & (~NestByRefBit),
82  Flags = is_lvalue<PlainObjectType>::value ? int(Flags0) : (int(Flags0) & ~LvalueBit)
83  };
84 private:
85  enum { Options }; // Expressions don't have Options
86 };
87 }
88 
89 template<typename PlainObjectType, int MapOptions, typename StrideType> class Map
90  : public MapBase<Map<PlainObjectType, MapOptions, StrideType> >
91 {
92  public:
93 
94  typedef MapBase<Map> Base;
95  EIGEN_DENSE_PUBLIC_INTERFACE(Map)
96 
97  typedef typename Base::PointerType PointerType;
98  typedef PointerType PointerArgType;
99  EIGEN_DEVICE_FUNC
100  inline PointerType cast_to_pointer_type(PointerArgType ptr) { return ptr; }
101 
102  EIGEN_DEVICE_FUNC
103  inline Index innerStride() const
104  {
105  return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1;
106  }
107 
108  EIGEN_DEVICE_FUNC
109  inline Index outerStride() const
110  {
111  return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer()
112  : IsVectorAtCompileTime ? this->size()
113  : int(Flags)&RowMajorBit ? this->cols()
114  : this->rows();
115  }
116 
122  EIGEN_DEVICE_FUNC
123  explicit inline Map(PointerArgType dataPtr, const StrideType& stride = StrideType())
124  : Base(cast_to_pointer_type(dataPtr)), m_stride(stride)
125  {
126  PlainObjectType::Base::_check_template_params();
127  }
128 
135  EIGEN_DEVICE_FUNC
136  inline Map(PointerArgType dataPtr, Index size, const StrideType& stride = StrideType())
137  : Base(cast_to_pointer_type(dataPtr), size), m_stride(stride)
138  {
139  PlainObjectType::Base::_check_template_params();
140  }
141 
149  EIGEN_DEVICE_FUNC
150  inline Map(PointerArgType dataPtr, Index rows, Index cols, const StrideType& stride = StrideType())
151  : Base(cast_to_pointer_type(dataPtr), rows, cols), m_stride(stride)
152  {
153  PlainObjectType::Base::_check_template_params();
154  }
155 
156  EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
157 
158  protected:
159  StrideType m_stride;
160 };
161 
162 
163 } // end namespace Eigen
164 
165 #endif // EIGEN_MAP_H
Base class for Map and Block expression with direct access.
Definition: ForwardDeclarations.h:117
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:89
const unsigned int LvalueBit
Definition: Constants.h:130
Definition: LDLT.h:16
const unsigned int RowMajorBit
Definition: Constants.h:53
Map(PointerArgType dataPtr, const StrideType &stride=StrideType())
Definition: Map.h:123
Map(PointerArgType dataPtr, Index size, const StrideType &stride=StrideType())
Definition: Map.h:136
Definition: Eigen_Colamd.h:54
Map(PointerArgType dataPtr, Index rows, Index cols, const StrideType &stride=StrideType())
Definition: Map.h:150