Re: [eigen] C++0x initializer lists

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



Hi Ben,

well, first of all we want to support compilers which does not provide any support for C++0x, so any feature based on C++0x has to be optional and not the default.

C++0x's initializer lists are not as general than our comma initializer. Here are the differences:

* C++0x's initializer lists are limited to the initialization of a matrix or vector object by enumerating each coefficient individually. All elements of an initialization list have to be of the same type.

* in addition our comma initializer allows to:

- set the coeffs of any object at any time:

Matrix mat;
mat = foo(...);
mat << a, b, c, d, e, f;
mat.col(i) << a, b, c;

- the elements of the right hand side list can be any _expression_ (heterogeneous):
int rows=5, cols=5;
MatrixXf m(rows,cols);
m << (Matrix3f() << 1, 2, 3, 4, 5, 6, 7, 8, 9).finished(),
MatrixXf::Zero(3,cols-3),
MatrixXf::Zero(rows-3,3),
MatrixXf::Identity(rows-3,cols-3);
cout << m;
output:
1 2 3 0 0
4 5 6 0 0
7 8 9 0 0
0 0 0 1 0
0 0 0 0 1

So definitely, initialization lists cannot be a replacement for our comma initializer. At the very least it could be an additional feature enabled only when C++0x is detected...

gael

On Wed, Jun 2, 2010 at 7:09 AM, Ben Gamari <bgamari.foss@xxxxxxxxx> wrote:
Hey all,

Has any work been done to implement C++0x's initializer lists in
Eigen? It seems like this would be an excellent cleanup for Eigen 3 and
G++ has supported initializer lists for quite a while now. Comma
initializers have always bothered me, so I for one would be very glad to
see their need disappear. Perhaps later this week I'll take a look at
the source myself if no one else is already looking into the matter.

Cheers,

- Ben





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