Re: [eigen] cwise question

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


Gael must be in bed so I'll reply:

2010/1/5 Trevor Irons <trevorirons@xxxxxxxxx>:
> Sorry to bother you all with a simple question, but I can't figure this out.
> Code like this used to compile: (2.0.10)
>
> #include "Eigen/Core"
> #include "Eigen/Array"
> #include "Eigen/Sparse"
>
> using namespace Eigen;
>
> int main() {
>
>     int size = 3;
>     VectorXd x;
>     x = VectorXd::Zero(size);

doesn't change

>
>     VectorXd y;
>     y = VectorXd::Ones(size);
>     y *= 2;

doesn't change


>
>     VectorXd z;
>     z = VectorXd::Ones(size);
>     z *=3;

doesn't change

>
>     Matrix3d Q;
>     Q.setIdentity();//Ones(size,size);
>     Q *= 2;

doesn't change

>
>     // Cwise operation
>     x +=  y.cwise() * (Q*z);

becomes:

x +=  y.cwiseProduct(Q*z);

or:

x +=  y.array() * (Q*z).array();



So the generic change is that

  x.cwise() OP y

becomes

  x.array() OP y.array()

and in some cases, such as OP=*, there may be a variant:

  x.cwiseOPNAME(y)

Where OPNAME is Product for OP=*, etc.

Benoit



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