Re: [eigen] Pass column by reference

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


Thanks, I will try them. I am thinking that it would be good to put this information in the tutorial since it seems to be happening to everyone I am coding with that is using Eigen, since it would seem as if VectorXf should succeed, but does not.

Do you think there would be a way to include such a change in the future so that columns could be taken as vectors? I am not aware of the internals for this in Eigen, maybe it is a complete rewrite or has important disadvantages.

Thanks.
Carlos


On Fri, May 21, 2010 at 12:04 PM, Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx> wrote:
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/