Hello,
I think we should add intializer_lists in the future, since it will help with containers that need to be created (and initialized) plenty of times.

For other cases uBlas has an advanced facility that can be used to fill a container using a similar format with initializer lists. It is an assigner though  rather than initialization facility. The good thing is that it can be used to fill the container with either scalars, vectors or matrices,  navigate while inserting them or define insertion traversal policies like by row or by column (features that an initiliazer list cannot have). It also covers special operations for sparse containers so that the insertion is fast in those cases as well.

You can do this: (A a matrix)
A <<= 0, 1, 2,
         3, 4, 5,
         6, 7, 8;

But also this:
  A <<= 0, 1, 2,
         a,
         3, 4, 5; // a is a 3-vector here

or even:
    B <<= A, A,
         A, A;
    std::cout << B << std::endl;
    // [ A A ]
    // [ A A ]
 
I am still to write the  documentation for  ublas:assignment but I think the examples pretty much cover most of the functionality:
http://svn.boost.org/svn/boost/trunk/libs/numeric/ublas/doc/samples/assignment_examples.cpp

The unit tests cover some additional items:
http://svn.boost.org/svn/boost/trunk/libs/numeric/ublas/test/test_assignment.cpp

Some benchmarks are here:
http://svn.boost.org/svn/boost/trunk/libs/numeric/ublas/bench5/

Regards,
-Nasos



On 05/09/2013 09:38 AM, gsermaid wrote:
Hi all,

One feature I would really like to see for ublas vectors is the ability to initialize them from a std::initializer_list, in a similar way to the std::vector. 
This would allow filling in a vector much more easily and help creating test cases more quickly. Are there any plans for such a functionality in a future ublas release?

Best regards


_______________________________________________
ublas mailing list
ublas@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: athanasios.iliopoulos.ctr.gr@nrl.navy.mil