Re: [eigen] Enabled muve support for Matrix and Array

[ Thread Index | Date Index | More Archives ]

On Sat, Apr 30, 2011 at 18:46, Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx> wrote:
Hi guys,

I have created a small patch which enables move support for Matrix and
Array - only if we enable C++0x.

I did not push it since I failed to do this correctly in the past but
I am confident that it is now working.

What is it all about!? Well, with move semantics enabled

MatrixXd m1( MatrixXd::Random(50,50).eval() );
MatrixXd m2( MatrixXd::Random(50,50) );

have identical performance. That means no additional copies are
triggered when assigning temporaries to lvalues (Matrix/Array).

I just recognized that I did not yet add operator=(Matrix/Array&&) but
that will be a trivial addition as soon as I get some confirmation
that the constructors work.

- Hauke

Hey, that's really cool!  Does this also improve return value scenarios? e.g.

MatrixXd m1(myfunc1()  + myfunc2());

or maybe

MatrixXd m1(std::move(myfunc1())  + std::move(myfunc2()));

For optimal performance, you'd want to return an _expression_ object, but commonly that's rather complex - a simpler, not quite as optimal solution would be great to have.

--eamon@xxxxxxxxxxxx - Tel#:+31-6-15142163

Mail converted by MHonArc 2.6.19+