|
|
namespace StormEigen {
/** \eigenManualPage QuickRefPage Quick reference guide
\eigenAutoToc
<hr>
<a href="#" class="top">top</a> \section QuickRef_Headers Modules and Header files
The Eigen library is divided in a Core module and several additional modules. Each module has a corresponding header file which has to be included in order to use the module. The \c %Dense and \c Eigen header files are provided to conveniently gain access to several modules at once.
<table class="manual"> <tr><th>Module</th><th>Header file</th><th>Contents</th></tr> <tr ><td>\link Core_Module Core \endlink</td><td>\code#include <StormEigen/Core>\endcode</td><td>Matrix and Array classes, basic linear algebra (including triangular and selfadjoint products), array manipulation</td></tr> <tr class="alt"><td>\link Geometry_Module Geometry \endlink</td><td>\code#include <StormEigen/Geometry>\endcode</td><td>Transform, Translation, Scaling, Rotation2D and 3D rotations (Quaternion, AngleAxis)</td></tr> <tr ><td>\link LU_Module LU \endlink</td><td>\code#include <StormEigen/LU>\endcode</td><td>Inverse, determinant, LU decompositions with solver (FullPivLU, PartialPivLU)</td></tr> <tr class="alt"><td>\link Cholesky_Module Cholesky \endlink</td><td>\code#include <StormEigen/Cholesky>\endcode</td><td>LLT and LDLT Cholesky factorization with solver</td></tr> <tr ><td>\link Householder_Module Householder \endlink</td><td>\code#include <StormEigen/Householder>\endcode</td><td>Householder transformations; this module is used by several linear algebra modules</td></tr> <tr class="alt"><td>\link SVD_Module SVD \endlink</td><td>\code#include <StormEigen/SVD>\endcode</td><td>SVD decompositions with least-squares solver (JacobiSVD, BDCSVD)</td></tr> <tr ><td>\link QR_Module QR \endlink</td><td>\code#include <StormEigen/QR>\endcode</td><td>QR decomposition with solver (HouseholderQR, ColPivHouseholderQR, FullPivHouseholderQR)</td></tr> <tr class="alt"><td>\link Eigenvalues_Module Eigenvalues \endlink</td><td>\code#include <StormEigen/Eigenvalues>\endcode</td><td>Eigenvalue, eigenvector decompositions (EigenSolver, SelfAdjointEigenSolver, ComplexEigenSolver)</td></tr> <tr ><td>\link Sparse_modules Sparse \endlink</td><td>\code#include <StormEigen/Sparse>\endcode</td><td>%Sparse matrix storage and related basic linear algebra (SparseMatrix, SparseVector) \n (see \ref SparseQuickRefPage for details on sparse modules)</td></tr> <tr class="alt"><td></td><td>\code#include <StormEigen/Dense>\endcode</td><td>Includes Core, Geometry, LU, Cholesky, SVD, QR, and Eigenvalues header files</td></tr> <tr ><td></td><td>\code#include <StormEigen/Eigen>\endcode</td><td>Includes %Dense and %Sparse header files (the whole Eigen library)</td></tr> </table>
<a href="#" class="top">top</a> \section QuickRef_Types Array, matrix and vector types
\b Recall: Eigen provides two kinds of dense objects: mathematical matrices and vectors which are both represented by the template class Matrix, and general 1D and 2D arrays represented by the template class Array: \code typedef Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, Options> MyMatrixType; typedef Array<Scalar, RowsAtCompileTime, ColsAtCompileTime, Options> MyArrayType; \endcode
\li \c Scalar is the scalar type of the coefficients (e.g., \c float, \c double, \c bool, \c int, etc.). \li \c RowsAtCompileTime and \c ColsAtCompileTime are the number of rows and columns of the matrix as known at compile-time or \c Dynamic. \li \c Options can be \c ColMajor or \c RowMajor, default is \c ColMajor. (see class Matrix for more options)
All combinations are allowed: you can have a matrix with a fixed number of rows and a dynamic number of columns, etc. The following are all valid: \code Matrix<double, 6, Dynamic> // Dynamic number of columns (heap allocation) Matrix<double, Dynamic, 2> // Dynamic number of rows (heap allocation) Matrix<double, Dynamic, Dynamic, RowMajor> // Fully dynamic, row major (heap allocation) Matrix<double, 13, 3> // Fully fixed (usually allocated on stack) \endcode
In most cases, you can simply use one of the convenience typedefs for \ref matrixtypedefs "matrices" and \ref arraytypedefs "arrays". Some examples: <table class="example"> <tr><th>Matrices</th><th>Arrays</th></tr> <tr><td>\code Matrix<float,Dynamic,Dynamic> <=> MatrixXf Matrix<double,Dynamic,1> <=> VectorXd Matrix<int,1,Dynamic> <=> RowVectorXi Matrix<float,3,3> <=> Matrix3f Matrix<float,4,1> <=> Vector4f \endcode</td><td>\code Array<float,Dynamic,Dynamic> <=> ArrayXXf Array<double,Dynamic,1> <=> ArrayXd Array<int,1,Dynamic> <=> RowArrayXi Array<float,3,3> <=> Array33f Array<float,4,1> <=> Array4f \endcode</td></tr> </table>
Conversion between the matrix and array worlds: \code Array44f a1, a1; Matrix4f m1, m2; m1 = a1 * a2; // coeffwise product, implicit conversion from array to matrix. a1 = m1 * m2; // matrix product, implicit conversion from matrix to array. a2 = a1 + m1.array(); // mixing array and matrix is forbidden m2 = a1.matrix() + m1; // and explicit conversion is required. ArrayWrapper<Matrix4f> m1a(m1); // m1a is an alias for m1.array(), they share the same coefficients MatrixWrapper<Array44f> a1m(a1); \endcode
In the rest of this document we will use the following symbols to emphasize the features which are specifics to a given kind of object: \li <a name="matrixonly"></a>\matrixworld linear algebra matrix and vector only \li <a name="arrayonly"></a>\arrayworld array objects only
\subsection QuickRef_Basics Basic matrix manipulation
<table class="manual"> <tr><th></th><th>1D objects</th><th>2D objects</th><th>Notes</th></tr> <tr><td>Constructors</td> <td>\code Vector4d v4; Vector2f v1(x, y); Array3i v2(x, y, z); Vector4d v3(x, y, z, w);
VectorXf v5; // empty object ArrayXf v6(size); \endcode</td><td>\code Matrix4f m1;
MatrixXf m5; // empty object MatrixXf m6(nb_rows, nb_columns); \endcode</td><td class="note"> By default, the coefficients \n are left uninitialized</td></tr> <tr class="alt"><td>Comma initializer</td> <td>\code Vector3f v1; v1 << x, y, z; ArrayXf v2(4); v2 << 1, 2, 3, 4;
\endcode</td><td>\code Matrix3f m1; m1 << 1, 2, 3, 4, 5, 6, 7, 8, 9; \endcode</td><td></td></tr>
<tr><td>Comma initializer (bis)</td> <td colspan="2"> \include Tutorial_commainit_02.cpp </td> <td> output: \verbinclude Tutorial_commainit_02.out </td> </tr>
<tr class="alt"><td>Runtime info</td> <td>\code vector.size();
vector.innerStride(); vector.data(); \endcode</td><td>\code matrix.rows(); matrix.cols(); matrix.innerSize(); matrix.outerSize(); matrix.innerStride(); matrix.outerStride(); matrix.data(); \endcode</td><td class="note">Inner/Outer* are storage order dependent</td></tr> <tr><td>Compile-time info</td> <td colspan="2">\code ObjectType::Scalar ObjectType::RowsAtCompileTime ObjectType::RealScalar ObjectType::ColsAtCompileTime ObjectType::Index ObjectType::SizeAtCompileTime \endcode</td><td></td></tr> <tr class="alt"><td>Resizing</td> <td>\code vector.resize(size);
vector.resizeLike(other_vector); vector.conservativeResize(size); \endcode</td><td>\code matrix.resize(nb_rows, nb_cols); matrix.resize(StormEigen::NoChange, nb_cols); matrix.resize(nb_rows, StormEigen::NoChange); matrix.resizeLike(other_matrix); matrix.conservativeResize(nb_rows, nb_cols); \endcode</td><td class="note">no-op if the new sizes match,<br/>otherwise data are lost<br/><br/>resizing with data preservation</td></tr>
<tr><td>Coeff access with \n range checking</td> <td>\code vector(i) vector.x() vector[i] vector.y() vector.z() vector.w() \endcode</td><td>\code matrix(i,j) \endcode</td><td class="note">Range checking is disabled if \n NDEBUG or STORMEIGEN_NO_DEBUG is defined</td></tr>
<tr class="alt"><td>Coeff access without \n range checking</td> <td>\code vector.coeff(i) vector.coeffRef(i) \endcode</td><td>\code matrix.coeff(i,j) matrix.coeffRef(i,j) \endcode</td><td></td></tr>
<tr><td>Assignment/copy</td> <td colspan="2">\code object = expression; object_of_float = expression_of_double.cast<float>(); \endcode</td><td class="note">the destination is automatically resized (if possible)</td></tr>
</table>
\subsection QuickRef_PredefMat Predefined Matrices
<table class="manual"> <tr> <th>Fixed-size matrix or vector</th> <th>Dynamic-size matrix</th> <th>Dynamic-size vector</th> </tr> <tr style="border-bottom-style: none;"> <td> \code typedef {Matrix3f|Array33f} FixedXD; FixedXD x;
x = FixedXD::Zero(); x = FixedXD::Ones(); x = FixedXD::Constant(value); x = FixedXD::Random(); x = FixedXD::LinSpaced(size, low, high);
x.setZero(); x.setOnes(); x.setConstant(value); x.setRandom(); x.setLinSpaced(size, low, high); \endcode </td> <td> \code typedef {MatrixXf|ArrayXXf} Dynamic2D; Dynamic2D x;
x = Dynamic2D::Zero(rows, cols); x = Dynamic2D::Ones(rows, cols); x = Dynamic2D::Constant(rows, cols, value);
|