Medial Code Documentation
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
67namespace internal {
68template<typename PlainObjectType, int MapOptions, typename StrideType>
69struct traits<Map<PlainObjectType, MapOptions, StrideType> >
70 : public traits<PlainObjectType>
71{
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 };
84private:
85 enum { Options }; // Expressions don't have Options
86};
87}
88
89template<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;
100 inline PointerType cast_to_pointer_type(PointerArgType ptr) { return ptr; }
101
103 inline Index innerStride() const
104 {
105 return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1;
106 }
107
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
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
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
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:91
EIGEN_DEVICE_FUNC Map(PointerArgType dataPtr, Index size, const StrideType &stride=StrideType())
Constructor in the dynamic-size vector case.
Definition Map.h:136
EIGEN_DEVICE_FUNC Map(PointerArgType dataPtr, Index rows, Index cols, const StrideType &stride=StrideType())
Constructor in the dynamic-size matrix case.
Definition Map.h:150
EIGEN_DEVICE_FUNC Map(PointerArgType dataPtr, const StrideType &stride=StrideType())
Constructor in the fixed-size case.
Definition Map.h:123
Pseudo expression representing a solving operation.
Definition Solve.h:63
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:61
Definition XprHelper.h:628
Definition ForwardDeclarations.h:17