This page explains how to work with ‘raw’ C/C++ arrays. This can be useful in a variety of contexts, particularly when ‘importing’ vectors and matrices from other libraries into Eigen. Occasionally you may have a pre-defined array of numbers that you want to use within Eigen as a vector or matrix. While one option is to make a copy of the data, most commonly you probably want to re-use this memory as an Eigen type. Fortunately, this is very easy with the Map class. To construct a Map variable, you need two other pieces of information: a pointer to the region of memory defining the array of coefficients, and the desired shape of the matrix or vector. For example, to define a matrix of float with sizes determined at compile time, you might do the following: where pf is a float * pointing to the array of memory. A fixed-size read-only vector of integers might be declared as where pi is an int *. In this case the size does not have to be passed to the constructor, because it is already specified by the Matrix/Array type. Note that Map does not have a default constructor, you must pass a pointer to intialize the object. However, you can work around this requirement (see Changing the mapped array). Map is flexible enough to accomodate a variety of different data representations. There are two other (optional) template parameters: All Eigen functions are written to accept Map objects just like other Eigen types. However, when writing your own functions taking Eigen types, this does not happen automatically: a Map type is not identical to its Dense equivalent. See Writing Functions Taking Eigen Types as Parameters for details. It is possible to change the array of a Map object after declaration, using the C++ ‘placement new’ syntax: Despite appearances, this does not invoke the memory allocator, because the syntax specifies the location for storing the result. This syntax makes it possible to declare a Map object without first knowing the mapped array’s location in memory: Source.