Re: [eigen] C++11 Style Initialisation

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


Hello,

I think a static method taking an std::initializer_list and returning a Matrix
_expression_ would be more suitable than a constructor. For your personal use you
can easily create an add-on that provides the desired functionality and include
it using Eigen's plugin mechanism (https://eigen.tuxfamily.org/dox/TopicCustomizing_Plugins.html). 

In the attachment you find a file addon.h that provides a minimal implementation
of such a static method that can be used as a plugin for MatrixBase. It then can
be used like this:

Eigen::Matrix<int, 4, 4> mat = Eigen::Matrix<int, 4, 4>::initByList({
  {1, 2, 3, 4}, // 1. row
  {5, 6, 7, 8}, // 2. row
  {9, 10, 11, 12},
  {13, 14, 15, 16}
});

Taking not a list of lists, but a single list should be easy to implement if thats what 
you want.

Cheers,
David

Attachment: addon.h
Description: Binary data




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