Re: [eigen] Array cwise multiplication
• To: eigen@xxxxxxxxxxxxxxxxxxx
• Subject: Re: [eigen] Array cwise multiplication
• From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
• Date: Wed, 29 Sep 2010 10:41:10 -0700
• 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; b=mz9ygrKFxMjGve6w9/hsO7S0a5gSEO6cO6RNyZkKnAGxMYSIrRH0n68zWMe0j/irJM FPU1tI/fYh0v+N9AuzPT0cqJl9mXoFsjSHzmrDPKpUXb1h4950+hgxwoIGFY9AArMZxf 8oS5kP2W1SjoZxkJGwCuWAGNjPFVHk8+MpMIg=

```2010/9/29 Carlos Becker <carlosbecker@xxxxxxxxx>:
> Hi all, I was trying to code something like this:
> #include <Eigen/Dense>
> using namespace Eigen;
> using namespace std;
> int main()
> {
> MatrixXf a;
> VectorXf b;
> a.resize(2,4);
> b.resize(2);
> a << 1,2,
> 3,4,
> 5,6,
> 7,8;
> b << 1,2;
> a = a.array().colwise() * b;

Here you're multiplying an array by a matrix.

Doesn't a.colwise() * b work?

Benoit

> return 0;
> }
> Should this compile correctly? I want to multiply every column in matrix a,
> element-wise, with vector b, but I cannot make it work
> I hope I am not forgetting about something important here.
> Cheers,
> Carlos

```

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