Re: [eigen] Array, Matrix, PlainObjectBase and DenseStorage are now move enabled

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


Hi Tobias,

I would start by adding std::initializer_list support to internal::plain_array and DenseStorage. Both are located in src/Core/DenseStorage.h. There are several specializations for heap and stack objects and you have to add support to all of them.

For details regarding the class hierarchy, take a look at this site http://eigen.tuxfamily.org/dox/TopicClassHierarchy.html.

Once you have support in DenseStorage, you need to add the constructors to Array, Matrix and PlainObjectBase. PlainObjectBase is the class which owns the DenseStorage. I think only the constructors in DenseStorage, Array and Matrix need to be public. The others should probably be protected since they are not intended for public use. (I just recognized that I made the move constructor/assignment public, I probably should change that too).

Then there is one issue left which is discussed here: http://stackoverflow.com/questions/17803475/why-is-stdinitializer-list-often-passed-by-value. Passing by value relies on the compiler performing copy elision and the original article (Want Speed? Pass by Value..) states that if no elision is performed you are loosing nothing. As I see it, this is true if the class hierarchy is flat and makes sense if the type T being stored in the Matrix/Array is movable. In our case, we are passing the std::initializer_list from Matrix to PlainObjectBase to DenseStorage and maybe even further to internal::plain_array. That means if no copy elision is performed we are copying up to 3 times. Therefore, I would suggest to actually pass by const reference in our case.

If any of the specialists on the list object to what I have written in the last paragraph, please let us know.

Regards,
Hauke


On Sat, Aug 10, 2013 at 12:40 PM, Wood, Tobias <tobias.wood@xxxxxxxxx> wrote:
Hi Hauke,
I'd like to work on this, but I'm struggling to work out where to start. Which class or classes should this be added to? I thought it would be DenseBase, but I can't work out how the constructors for it work - they seem to be declared private which I don't understand. The level of template programming in Eigen is a bit beyond my normal level!
Thanks,
Toby

On 9 Aug 2013, at 10:26, Hauke Heibel wrote:

> Hi Tobias,
>
> On Mon, Aug 5, 2013 at 1:08 PM, Wood, Tobias <tobias.wood@xxxxxxxxx> wrote:
> On the subject of C++11, the other nice feature that I would like to see in Eigen is the {} initialisation/construction syntax. Is there any chance of Eigen supporting this as an alternative to the << initialiser?
>
> Support for std::initializer_list should be possible. I cannot do it right now since VC11 does not support std::initializer_list but as always, patches are welcome.
>
> Regards,
> Hauke







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