--
Date: Thu, 9 May 2013 14:38:32
+0100 (BST)
From: gsermaid <
linuxfever@yahoo.gr>
To: "
ublas@lists.boost.org" <
ublas@lists.boost.org>
Subject: [ublas] Initializing from an initializer_list
Message-ID:
<
1368106712.65540.YahooMailNeo@web172102.mail.ir2.yahoo.com>
Content-Type: text/plain; charset="iso-8859-1"
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
-------------- next part --------------
HTML attachment scrubbed and removed
------------------------------
Message: 2
Date: Thu, 9 May 2013 11:47:34 -0400
From: Nasos Iliopoulos <
nasos_i@hotmail.com>
To:
ublas@lists.boost.orgSubject: Re: [ublas] Initializing from an initializer_list
Message-ID: <
BLU0-SMTP164BA137EB50FAEFD1C00A099A40@phx.gbl>
Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"
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.cppThe unit tests cover some additional items:
http://svn.boost.org/svn/boost/trunk/libs/numeric/ublas/test/test_assignment.cppSome 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-------------- next part --------------
HTML attachment scrubbed and removed
------------------------------
Subject: Digest Footer
_______________________________________________
ublas mailing list
ublas@lists.boost.orghttp://lists.boost.org/mailman/listinfo.cgi/ublas------------------------------
End of ublas Digest, Vol 102, Issue 4
*************************************