Main MRPT website > C++ reference
MRPT logo
Public Types | Public Member Functions | Protected Attributes
Eigen::Map Class Reference

Detailed Description

A matrix or vector expression mapping an existing array of data.

Template Parameters:
PlainObjectTypethe equivalent matrix type of the mapped data
MapOptionsspecifies whether the pointer is Aligned, or Unaligned. The default is Unaligned.
StrideTypeoptionnally 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:

Output:

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.

Output:

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

Output:

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:

Output:

This class is the return type of Matrix::Map() but can also be used directly.

See also:
Matrix::Map(), TopicStorageOrders
Inheritance diagram for Eigen::Map:
Inheritance graph
[legend]

List of all members.

Public Types

typedef MapBase< MapBase
typedef Base::PointerType PointerType
typedef const Scalar * PointerArgType

Public Member Functions

PointerType cast_to_pointer_type (PointerArgType ptr)
Index innerStride () const
Index outerStride () const
 Map (PointerArgType data, const StrideType &stride=StrideType())
 Constructor in the fixed-size case.
 Map (PointerArgType data, Index size, const StrideType &stride=StrideType())
 Constructor in the dynamic-size vector case.
 Map (PointerArgType data, Index rows, Index cols, const StrideType &stride=StrideType())
 Constructor in the dynamic-size matrix case.

Protected Attributes

StrideType m_stride

Member Typedef Documentation

Definition at line 123 of file Core.

typedef const Scalar* Eigen::Map::PointerArgType

Definition at line 129 of file Core.

typedef Base::PointerType Eigen::Map::PointerType

Definition at line 127 of file Core.


Constructor & Destructor Documentation

Eigen::Map::Map ( PointerArgType  data,
const StrideType &  stride = StrideType() 
) [inline]

Constructor in the fixed-size case.

Parameters:
datapointer to the array to map
strideoptional Stride object, passing the strides.

Definition at line 154 of file Core.

Eigen::Map::Map ( PointerArgType  data,
Index  size,
const StrideType &  stride = StrideType() 
) [inline]

Constructor in the dynamic-size vector case.

Parameters:
datapointer to the array to map
sizethe size of the vector expression
strideoptional Stride object, passing the strides.

Definition at line 166 of file Core.

Eigen::Map::Map ( PointerArgType  data,
Index  rows,
Index  cols,
const StrideType &  stride = StrideType() 
) [inline]

Constructor in the dynamic-size matrix case.

Parameters:
datapointer to the array to map
rowsthe number of rows of the matrix expression
colsthe number of columns of the matrix expression
strideoptional Stride object, passing the strides.

Definition at line 179 of file Core.


Member Function Documentation

PointerType Eigen::Map::cast_to_pointer_type ( PointerArgType  ptr) [inline]

Definition at line 130 of file Core.

Index Eigen::Map::innerStride ( ) const [inline]

Definition at line 136 of file Core.

Index Eigen::Map::outerStride ( ) const [inline]

Definition at line 141 of file Core.


Member Data Documentation

StrideType Eigen::Map::m_stride [protected]

Definition at line 189 of file Core.




Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011