Search code examples
c++eigen

What do the initialized Array constructors do?


In the Eigen documentation I see a lot of these:

Array (const Scalar &val0, const Scalar &val1)
Array (const Scalar &val0, const Scalar &val1, const Scalar &val2)
Array (const Scalar &val0, const Scalar &val1, const Scalar &val2, const Scalar &val3)

According to the documentation (http://eigen.tuxfamily.org/dox/classEigen_1_1Array.html) these constructors "constructs an initialized ND vector with given coefficients".

What does that mean? If I do Array(1,2,3), what is the result?

Specifically, what coefficients does it place in each dimension, and how large is the array in each of those respective dimensions? The constructor Array(1,2,3), according to the docs, should construct an 3D array, and initialise its contents with "the given coefficients". How should the result look?


Solution

  • The constructors are for fixed sized Arrays. Assuming the declaration is Eigen::Array3i then the constructor you mentioned initializes a 1D int array with three elements initialized to the stated values.