Classes, representations and methods for manipulation of matrices.
- BLAS : fast, but awkward c library, often used as the backend for other c++ libraries. - BOOST : uses blas, main focus is c++ correctness and versatility of matrix types, not speed. - BLITZ++ : containers only, uses template tricks, but almost discontinued. - MKL : uses blas and focuses on multi-threading and multi-core performance specialised for intel chips. - TVMET : optimised for low-order matrices through heavy use of template tricks. The c++ libraries are all hobbled in one way or another. Most can't deal with aliasing intelligently, leaving it up to the user to handle that facet of matrix manipulation. They often use template expressions also, which is great for speeding up operations, but matrix multiplication regularly gets confused and bogged down - another thing that is left to the user to handle. Eigen is the new kid on the block and the one that is used here. It handles aliasing and nested matrix multiplication without a problem, includes important linear algebra modules (i.e. not just containers) and prioritises speed first, then c++ conveniences (but still manages to be more convenient than ublas!).
Using ros eigen now, but you can also opt to use the internal ecl_eigen.
Note that the namespace is simply an alias to the Eigen namespace. You can use either namespace, however the ecl namespace is preferred so its clear we're using our extended interface (via the eigen plugins).
Since eigen is a template class, no linking is required if you are only using eigen's classes.
The following are some important links for us back to the eigen documentation: - <a href="http://eigen.tuxfamily.org/dox-devel/">Documentation Frontend</a> - <a href="http://eigen.tuxfamily.org/dox-devel/TopicLazyEvaluation.html">Lazy Evaluation</a> - <a href="http://eigen.tuxfamily.org/dox-devel/TopicWritingEfficientProductExpression.html">Writing Optimised Expressions</a> - <a href="http://eigen.tuxfamily.org/dox-devel/TopicLinearAlgebraDecompositions.html">Decompositions Overview</a> - <a href="http://eigen.tuxfamily.org/dox-devel/TopicStructHavingEigenMembers.html">Modifications needed for Classes with Eigen Members</a> - <a href="http://eigen.tuxfamily.org/dox-devel/TopicStlContainers.html">Stl containers and eigen</a> Some important points to note (more detailed notes regarding some eigen specific issues further below): - Matrices/Vectors of all types are built from the one base class. - Typedefs exist for all common forms of matrices and vectors (important for vectors as there is no Vector class). The ecl supplements the eigen library with a few extras features.
The eigen matrixbase class provides a way to extend its api via a macro-based plugin. The trick is enabled by the following code in eigen's MatrixBase class:
Here we take advantage of it to add the following api:
This will be brought in if you do one of the following before you include any eigen headers:
Note that if you wish to customise the eigen plugin differently, simply define the macro, pointing it at your own customisation before including ecl/linear_algebra.hpp. The ecl plugin makes a check and won't override any existing definitions.
You have to be very careful with eigen to make sure alignment works properly. This is a bit of a pain in the bum, but will result in hardware speedups. If you see the following error message
its probably because you need to fix your storage mechanism for classes with eigen vectors inside them. See that web page for more detail and/or run gdb on your program to see where the compile time assert triggered.
Usual scenario - you have used an eigen type of fixed size as a storage container embeddded inside a class or struct, or inherited a class that does so.
In this situation, you need to add the following macro to the public section of the class as well as each class that inherits this class.
If always calling linear_algebra.hpp to access eigen, it will bring in Eigen's NewStdVector implementation. This will use it for eigen types and default to the original std vector for other types, but there's one caveat. For eigen to distinguish, you need to specify the vector allocator.
If you do not include it, you will see the usual compile time alignment warning that Eigen loves.
Formatters have been included in the plugin for float and double type matrices (may expand to integral types later if we need them). This is achieved by use of the ecl_formatters framework. There are several ways you can call these formatters, the most convenient methods are outlined below:
- <b>Mar 12</b> : depracated Eigen3. - <b>Dec 10</b> : switched the default to eigen3, also brought in unsupported modules for numerical differentiation and nonlinear optimisation. - <b>Sep 10</b> : added a formatter for float type matrices with precision and width control. - <b>Aug 10</b> : incorporated the new std vector implementation explicitly in linear_algebra.hpp. - <b>Jul 10</b> : embedded the eigen3 library in the ecl. - <b>May 10</b> : embedded the eigen2 library in the ecl. - <b>Oct 09</b> : conservative resizing functions added to the eigen plugin. - <b>May 09</b> : namespace alias to eigen set up.