Search code examples
c++eigeneigen3

Passing ArrayXd to const VectorXd& and const Ref<const VectorXd>&


Is my understanding correct about the efficiency of the two functions?

VectorXd v;

void Foo(const ArrayXd&);
void Boo(const Ref<const ArrayXd>&);

// a temporary is created?
Foo(v);
// no temporary is created?
Boo(v);

Also, I also see in eigen's doc some signature like Boo but without the &. Does it have any practical difference from Boo above?


Solution

  • Yes your understanding is correct.

    Regarding the signature of Boo see this answer.