fix Matrix::Map/MapAligned documentation, and rephrase the tutorial on Map

This commit is contained in:
Benoit Jacob 2009-10-31 14:45:50 -04:00
parent c64ca6870e
commit e158cdd61d
2 changed files with 19 additions and 11 deletions

View File

@ -402,9 +402,10 @@ class Matrix
void swap(const MatrixBase<OtherDerived>& other); void swap(const MatrixBase<OtherDerived>& other);
/** \name Map /** \name Map
* These are convenience functions returning Map objects. The Map() static functions return unaligned Map objects, * These are convenience functions returning Map objects.
* while the AlignedMap() functions return aligned Map objects and thus should be called only with 16-byte-aligned *
* \a data pointers. * \warning Do not use MapAligned in the Eigen 2.0. Mapping aligned arrays will be fully
* supported in Eigen 3.0 (already implemented in the development branch)
* *
* \see class Map * \see class Map
*/ */

View File

@ -229,17 +229,24 @@ Of course, fixed-size matrices can't be resized.
\subsection TutorialMap Map \subsection TutorialMap Map
Any memory buffer can be mapped as an Eigen expression: Any memory buffer can be mapped as an Eigen expression using the Map() static method:
<table class="tutorial_code"><tr><td>
\code \code
std::vector<float> stlarray(10); std::vector<float> stlarray(10);
Map<VectorXf>(&stlarray[0], stlarray.size()).setOnes(); VectorXf::Map(&stlarray[0], stlarray.size()).squaredNorm();
int data[4] = 1, 2, 3, 4; \endcode
Matrix2i mat2x2(data); Here VectorXf::Map returns an object of class Map<VectorXf>, which behaves like a VectorXf except that it uses the existing array. You can write to this object, that will write to the existing array. You can also construct a named obtect to reuse it:
MatrixXi mat2x2 = Map<Matrix2i>(data); \code
MatrixXi mat2x2 = Map<MatrixXi>(data,2,2); float array[rows*cols];
Map<MatrixXf> m(array,rows,cols);
m = othermatrix1 * othermatrix2;
m.eigenvalues();
\endcode
In the fixed-size case, no need to pass sizes:
\code
float array[9];
Map<Matrix3d> m(array);
Matrix3d::Map(array).setIdentity();
\endcode \endcode
</td></tr></table>