Re: [eigen] Pass column by reference

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


You have two options:

a) declare a template function (that will take vectors as well as
col/row expressions)

template <typename Derived>
void putSomethingInVector(MatrixBase<Derived>& data {}

b) explicitly allows this for MatrixXf columns only by utilizing
Matrix typedefs for special expressions (here ColXpr)

void putSomethingInVector( MatrixXf::ColXpr& data) {}

I hope I did not make any mistake since I did not test, but that's how
it should be working.

- Hauke

On Fri, May 21, 2010 at 11:57 AM, Carlos Becker <carlosbecker@xxxxxxxxx> wrote:
> Hi everyone, I was wondering if it is possible to do something like this:
> void  putSomethingInVector( VectorXf &data ) { work with data and modify it;
> }
> ---------------------------------------------------------------------
> MatrixXf  myMatrix(100,100);
> putSomethingInVector( myMatrix.col(4) );
> ---------------------------------------------------------------------
> I know it is not possible like that, but is there any way? or .col() returns
> a read-only reference? I was looking for something like colRef() but no luck
> Thanks!
> Carlos



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