Eigen  3.3.0
 
Loading...
Searching...
No Matches
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
14namespace Eigen {
15
16namespace internal {
17template<typename PlainObjectType, int MapOptions, typename StrideType>
18struct traits<Map<PlainObjectType, MapOptions, StrideType> >
19 : public traits<PlainObjectType>
20{
21 typedef traits<PlainObjectType> TraitsBase;
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 };
33private:
34 enum { Options }; // Expressions don't have Options
35};
36}
37
88template<typename PlainObjectType, int MapOptions, typename StrideType> class Map
89 : public MapBase<Map<PlainObjectType, MapOptions, StrideType> >
90{
91 public:
92
93 typedef MapBase<Map> Base;
94 EIGEN_DENSE_PUBLIC_INTERFACE(Map)
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
155 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
156
157 protected:
158 StrideType m_stride;
159};
160
161
162} // end namespace Eigen
163
164#endif // EIGEN_MAP_H
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:90
Map(PointerArgType dataPtr, Index rows, Index cols, const StrideType &stride=StrideType())
Definition: Map.h:149
Map(PointerArgType dataPtr, const StrideType &stride=StrideType())
Definition: Map.h:122
Map(PointerArgType dataPtr, Index size, const StrideType &stride=StrideType())
Definition: Map.h:135
const unsigned int LvalueBit
Definition: Constants.h:139
const unsigned int RowMajorBit
Definition: Constants.h:61
Namespace containing all symbols from the Eigen library.
Definition: Core:287
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33