Re: [eigen] [FAQ] how to have an initialized static Matrix

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


Hi Helmut,

as of now, we do not really support C++11 features. A temporary solution might be

static const Eigen::Matrix<double,6,1> C = (Eigen::Matrix<double,6,1>() << 1.0 / 5, 3.0 / 10, 4.0 / 5, 8.0 / 9, 1.0, 1.0).finished();

Though one might argue about the "elegancy" of this solution.

Regards,
Hauke


On Thu, Mar 21, 2013 at 10:30 AM, Helmut Jarausch <jarausch@xxxxxxxxxxxxxxxxxxx> wrote:
Hi,

unfortunately, Eigen's elegant initialization is an _expression_.

Is there an "elegant" solution for this ugly code (within a function)


  static double _C[6] = { 1.0 / 5, 3.0 / 10, 4.0 / 5, 8.0 / 9, 1.0, 1.0 };
  static const Eigen::Map<Eigen::Matrix<double,6,1>,0> C((double*)_C);

What about Matrix with a constructor taking an initializer_list ?

Many thanks for a hint,
Helmut.





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