Shapeworks Studio  2.1
Shape analysis software suite
List of all members | Public Types | Public Member Functions | Protected Attributes
Eigen::Map< PlainObjectType, MapOptions, StrideType > Class Template Reference

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

#include <Map.h>

+ Inheritance diagram for Eigen::Map< PlainObjectType, MapOptions, StrideType >:
+ Collaboration diagram for Eigen::Map< PlainObjectType, MapOptions, StrideType >:

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 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())
 

Protected Attributes

StrideType m_stride
 

Detailed Description

template<typename PlainObjectType, int MapOptions, typename StrideType>
class Eigen::Map< PlainObjectType, MapOptions, StrideType >

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.
StrideTypeoptionally 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 PlainObjectBase::Map() but can also be used directly.

See also
PlainObjectBase::Map(), TopicStorageOrders

Definition at line 104 of file Map.h.

Constructor & Destructor Documentation

template<typename PlainObjectType, int MapOptions, typename StrideType>
Eigen::Map< PlainObjectType, MapOptions, StrideType >::Map ( PointerArgType  dataPtr,
const StrideType &  a_stride = StrideType() 
)
inline

Constructor in the fixed-size case.

Parameters
dataPtrpointer to the array to map
a_strideoptional Stride object, passing the strides.

Definition at line 139 of file Map.h.

140  : Base(cast_to_pointer_type(dataPtr)), m_stride(a_stride)
141  {
142  PlainObjectType::Base::_check_template_params();
143  }
template<typename PlainObjectType, int MapOptions, typename StrideType>
Eigen::Map< PlainObjectType, MapOptions, StrideType >::Map ( PointerArgType  dataPtr,
Index  a_size,
const StrideType &  a_stride = StrideType() 
)
inline

Constructor in the dynamic-size vector case.

Parameters
dataPtrpointer to the array to map
a_sizethe size of the vector expression
a_strideoptional Stride object, passing the strides.

Definition at line 151 of file Map.h.

152  : Base(cast_to_pointer_type(dataPtr), a_size), m_stride(a_stride)
153  {
154  PlainObjectType::Base::_check_template_params();
155  }
template<typename PlainObjectType, int MapOptions, typename StrideType>
Eigen::Map< PlainObjectType, MapOptions, StrideType >::Map ( PointerArgType  dataPtr,
Index  nbRows,
Index  nbCols,
const StrideType &  a_stride = StrideType() 
)
inline

Constructor in the dynamic-size matrix case.

Parameters
dataPtrpointer to the array to map
nbRowsthe number of rows of the matrix expression
nbColsthe number of columns of the matrix expression
a_strideoptional Stride object, passing the strides.

Definition at line 164 of file Map.h.

165  : Base(cast_to_pointer_type(dataPtr), nbRows, nbCols), m_stride(a_stride)
166  {
167  PlainObjectType::Base::_check_template_params();
168  }

The documentation for this class was generated from the following file: