I am trying to return a block of a matrix as an lvalue of a function. Let's say my function looks like this:
Block<Derived> getBlock(MatrixXd & m, int i, int j, int row, int column)
{
return m.block(i,j,row,column);
}
As it turns out, it seems that C++ compiler understands that block() operator gives only temporary value and so returning it as an lvalue is prohibited by the compiler. However, in Eigen documentation there is some example that we can use Eigen as an lvalue (http://eigen.tuxfamily.org/dox/TutorialBlockOperations.html#TutorialBlockOperationsUsing) so I am wondering how we couldn't do the same with function return.
a.block(0,0,2,3) = a.block(2,1,2,3);
Thank you!