| Re: [eigen] cwise question | 
[ Thread Index | 
Date Index
| More lists.tuxfamily.org/eigen Archives
] 
- To: eigen@xxxxxxxxxxxxxxxxxxx
 
- Subject: Re: [eigen] cwise question
 
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
 
- Date: Tue, 5 Jan 2010 21:02:37 -0500
 
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=gmail.com; s=gamma;        h=domainkey-signature:mime-version:received:in-reply-to:references         :date:message-id:subject:from:to:content-type         :content-transfer-encoding;        bh=BpUAdI8FmFvkymA+eRxf13E74Fcwy+TO7fDome3OUco=;        b=rV/2OclzDJrKq5AhzO0cIL+/bhXqxfnUm+CwMeNotNp/uYB5wTidV0UgJH9vBeyidf         yh7SsJWoNpxHwFkiYMoUGWokVaOyrCnZheHBB2dXbMuCO6ipUN7Lvxl2NSDNV0s3CrvE         JVj/0qw6b+jNN9BF9jTFPo4WMnkfYVWecPQ4k=
 
- Domainkey-signature: a=rsa-sha1; c=nofws;        d=gmail.com; s=gamma;        h=mime-version:in-reply-to:references:date:message-id:subject:from:to         :content-type:content-transfer-encoding;        b=bI4nCi14akiB/01sAdFkJQLTlWdfLcPrsypxwcpC0EDeRC1eW7I+Z05ZrGpq8hcYkL         kFoW/RBn+oHI4/lRPIIdHGLbQA+oeaMrdjX0FCdLOQ6pCcBWX7hGzR4ZnqNhJufGKrQn         Umz5gKyoSgQcv9KlqfXXAPFDvlNvif/g2IdTc=
 
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