Registered Member
|
Hi,
I'm curious if there are plans to support uniform initialization in future versions of Eigen? For example, in C++11 one can initialize a std::vector with the code:
It would be very convenient if one could do the same for a dynamic sized Eigen variable, for example:
Are there plans for such a feature, does uniform initialization somehow conflict with Eigen's internal design, or is this simply a feature that is not in high demand? Cheers! |
Moderator
|
Generally, we want to keep Eigen C++03 compatible as much as possible, so C++11 initializer lists is not a priority. Moreover, we support more powerful initialization mechanisms, e.g.:
|
Registered Member
|
Right, that makes sense, thank you! The current initialization mechanisms do not support sparse matrices, though, no? While not essential at all, it would be convenient to be able to set the triplets from an initializer list.
|
Registered Member
|
EDIT 2: Made a more expression template-friendly version, using NumPy's hstack / vstack style. Added a new topic:
viewtopic.php?f=74&t=140012#p375247 EDIT 1: Made a very sheepish attempt at expression templates, but ultimately failed. Attempt may be found here: https://github.com/EricCousineau-TRI/re ... xpr_tpl.cc ORIGINAL: Reviving an old thread, but I was tinkering around with initializer_list stuff. I saw there were some other examples here: https://github.com/hauptmech/eigen-initializer_list (has a fork with a plugin for Arrays) These work well with scalars, and I wanted to see if something really rough could be done for initializer_lists. Tinkered around, and tried out a quick proof of concept using composed initializer_lists, and it works; probably not performant in this case, but mayhaps it could leverage expression template wizardry that the present initializer expressions use? I do see that Eigen has some CXX11 guards, and I'd be interested if this could be incorporated as an optional interface. AFAIK, the present initializer mechanisms may not permit ragged initialization across rows, without the need to use either block accessors or using pre-concatenated temporary matrices. This may provide a little more expressiveness, if it turns out to be viable. Code overview, from https://github.com/EricCousineau-TRI/repro/blob/29fe69e/eigen_scratch/matrix_stack.cc
Output, from https://github.com/EricCousineau-TRI/repro/blob/29fe69e/eigen_scratch/matrix_stack.output.txt
|
Registered users: Bing [Bot], claydoh, gfielding, Google [Bot], markhm, rblackwell, sethaaaa, Sogou [Bot], Yahoo [Bot]