Re: [eigen] Array cwise multiplication |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] Array cwise multiplication*From*: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>*Date*: Wed, 29 Sep 2010 10:49:12 -0700*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=xS8iBxTchDO3CLDxiiGkvhH8hXfJBuDghNIzzDJVQYs=; b=KBkn3QarLFiCXz26XulIuwMYI5JTbuFk6wGHgLF1r3tYUHqs7valgFdzev0VLVLO9j uzshvoHxHoH/54hTbei9UVd1Cp08jd3JerZ6DLe4eBbB3wYSjaSR+MxkEJLYTWoORhZh R1ow89Q2jD7rm2DHPTlDE5FmQtZMTjiwKU/Q0=*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=hMWXp9kjESMu2Ln6Lt2b/RMzZM+mnHGovTc+6ltQwNqgjttdG3D0YITPXtdkrK0f0v 65T/nzEgGeFEVsZlzUE0tEI0LStvsnVqhG2bMYxd9/s67OhmM2n/LJJ3wnrVIta+TvS3 yTch9v9ehIGS+nF9TBTBd2E4eIWMPVIXLtNtA=

Does a.array().colwise() * b.array() work ? We're a bit pedantic if we require putting array() here since the colwise() makes it clear what you want to do... Benoit 2010/9/29 Carlos Becker <carlosbecker@xxxxxxxxx>: > Hi Benoit. No, it doesn't work and it makes sense, since it would be like > multiplying a vector by a vector algebraically, which has no sense for a > Matrix type (has it?) > I wanted to do element-wise multiplication, and I thought that > .array().colwise() would cope with that. Just to clarify, I want to do: > if A = [1 2; > 3 4] > and B = [a;b] (matlab notation) > then I want to get something like: > result = [ 1*a, 2*a; > 3*b 4*b ] > Should I do this another way? I thought that .array().colwise() was defined > to apply the element-wise operation for every column vector in A. > Thanks > > On Wed, Sep 29, 2010 at 7:41 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> > wrote: >> >> 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 >> >> > >

**Follow-Ups**:**Re: [eigen] Array cwise multiplication***From:*Carlos Becker

**References**:**[eigen] Array cwise multiplication***From:*Carlos Becker

**Re: [eigen] Array cwise multiplication***From:*Benoit Jacob

**Re: [eigen] Array cwise multiplication***From:*Carlos Becker

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] Array cwise multiplication** - Next by Date:
**Re: [eigen] Array cwise multiplication** - Previous by thread:
**Re: [eigen] Array cwise multiplication** - Next by thread:
**Re: [eigen] Array cwise multiplication**

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