A matrix or vector expression mapping an existing array of data. More...
#include <Map.h>
Public Types | |
typedef MapBase< Map > | Base |
typedef const Scalar * | PointerArgType |
typedef Base::PointerType | PointerType |
Public Member Functions | |
PointerType | cast_to_pointer_type (PointerArgType ptr) |
Index | innerStride () const |
Map (PointerArgType dataPtr, const StrideType &a_stride=StrideType()) | |
Map (PointerArgType dataPtr, Index a_size, const StrideType &a_stride=StrideType()) | |
Map (PointerArgType dataPtr, Index nbRows, Index nbCols, const StrideType &a_stride=StrideType()) | |
Index | outerStride () const |
Protected Attributes | |
StrideType | m_stride |
A matrix or vector expression mapping an existing array of data.
PlainObjectType | the equivalent matrix type of the mapped data |
MapOptions | specifies whether the pointer is Aligned , or Unaligned . The default is Unaligned . |
StrideType | optionally specifies strides. By default, Map assumes the memory layout of an ordinary, contiguous array. This can be overridden by specifying strides. The type passed here must be a specialization of the Stride template, see examples below. |
This class represents a matrix or vector expression mapping an existing array of data. It can be used to let Eigen interface without any overhead with non-Eigen data structures, such as plain C arrays or structures from other libraries. By default, it assumes that the data is laid out contiguously in memory. You can however override this by explicitly specifying inner and outer strides.
Here's an example of simply mapping a contiguous array as a column-major matrix:
If you need to map non-contiguous arrays, you can do so by specifying strides:
Here's an example of mapping an array as a vector, specifying an inner stride, that is, the pointer increment between two consecutive coefficients. Here, we're specifying the inner stride as a compile-time fixed value.
Here's an example of mapping an array while specifying an outer stride. Here, since we're mapping as a column-major matrix, 'outer stride' means the pointer increment between two consecutive columns. Here, we're specifying the outer stride as a runtime parameter. Note that here OuterStride<>
is a short version of OuterStride<Dynamic>
because the default template parameter of OuterStride is Dynamic
For more details and for an example of specifying both an inner and an outer stride, see class Stride.
Tip: to change the array of data mapped by a Map object, you can use the C++ placement new syntax:
Example:
This class is the return type of PlainObjectBase::Map() but can also be used directly.
typedef MapBase<Map> Eigen::Map< PlainObjectType, MapOptions, StrideType >::Base |
typedef const Scalar* Eigen::Map< PlainObjectType, MapOptions, StrideType >::PointerArgType |
typedef Base::PointerType Eigen::Map< PlainObjectType, MapOptions, StrideType >::PointerType |
Eigen::Map< PlainObjectType, MapOptions, StrideType >::Map | ( | PointerArgType | dataPtr, |
const StrideType & | a_stride = StrideType() |
||
) | [inline] |
Eigen::Map< PlainObjectType, MapOptions, StrideType >::Map | ( | PointerArgType | dataPtr, |
Index | a_size, | ||
const StrideType & | a_stride = StrideType() |
||
) | [inline] |
Eigen::Map< PlainObjectType, MapOptions, StrideType >::Map | ( | PointerArgType | dataPtr, |
Index | nbRows, | ||
Index | nbCols, | ||
const StrideType & | a_stride = StrideType() |
||
) | [inline] |
PointerType Eigen::Map< PlainObjectType, MapOptions, StrideType >::cast_to_pointer_type | ( | PointerArgType | ptr | ) | [inline] |
Index Eigen::Map< PlainObjectType, MapOptions, StrideType >::innerStride | ( | ) | const [inline] |
Index Eigen::Map< PlainObjectType, MapOptions, StrideType >::outerStride | ( | ) | const [inline] |
StrideType Eigen::Map< PlainObjectType, MapOptions, StrideType >::m_stride [protected] |