Re: [eigen] Eigen C++11 alias templates

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]



Hi,

I agree such generic typedefs are be very useful. They also involve few lines of code. However, with respect to our recent discussion on C++11 features, this is for me a borderline one because when you're using e.g.:

VectorX<float>

there is nothing that make it clear you are using a C++11 feature. Actually similar declarations would be possible in C++03 with a more complex class hierarchy, much more code boilerplate and some other drawbacks... So, in my opinion such an addition should go in a separate C++11 module.

gael



On Thu, Feb 13, 2014 at 12:03 AM, Jim Garrison <jim@xxxxxxxxxxx> wrote:
Hi all,

Another C++11 feature I'd like to see available to users is alias
templates for commonly used types.

Currently, users can create e.g. an arbitrary sized matrix of doubles
using the Eigen::MatrixXd typedef, defined in Eigen/src/Core/Matrix.h.
However, if one wants to do this with a templated type, it is necessary
to write out in full each time:

    Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> mat;

The attached header defines alias templates similar to MatrixXd, etc.,
which allow for the same functionality with less verbosity.  With this,
the above type definition can be written as:

    Eigen::MatrixX<T> mat;

I've been using this now for several months and it makes my code much
clearer.  Please feel free to adapt it and include it in Eigen.

Regards,
Jim



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/