Re: [eigen] pairwise multiply |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] pairwise multiply
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Sat, 20 Nov 2010 20:53:53 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=rvKRneTlqpL5W89uKGOSY12sEwHMUgcIh/4elX855Eo=; b=uJPcAllOyP4F2PtltdkzvyTgdCBiiiylr6m2U4XFvW0ZzJRIi64jQC7ikjbQJVzu7/ +FVU6xyCSlQGEnCvBm2JkSlJRWOx0cTuIjAHQP5xq73+/oG0cTbrvZhVSHrliJz93ZH1 jPQnlye2laqB4owXswYYPU8mkePi1iB+74a5E=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=SdlINMPK+K4ClwFQu3Ru36ibqBaNDgv0UORu2vXAWWeATU7fliObY6lI8cLDDntuSR 1ZOkpRgPymaaAHTugZXn4F/hd0zXTH9Y5wPTqNgFYZ3Xu7YZ29lQ4/eID0DQc2BC1ydz i41JfRcLPFXvGHQjvYiqXSnTZ+OfjPDRFAE5o=
to be more precise, you can:
1 - use Array from the beginning (in case you are not interested in
the linear algebra world):
a3 = a1 * a2;
2 - use the cwiseProduct() method:
m3 = m1.cwiseProduct(m2);
3 - use the .array() modifier:
m3 = m1.array() * m2.array();
gael
On Sat, Nov 20, 2010 at 8:36 PM, Jose Luis Blanco
<joseluisblancoc@xxxxxxxxx> wrote:
> It can be done with:
>
> RESULT.array() = A.array() * B.array();
>
> If you use it a lot, you could write something like:
>
> template <class A,class B,class RES>
> inline void dotProd(const A &a,const B& b, RES &res)
> {
> res.array() = a.array() * b.array();
> }
>
> dotProd(A,B,RES);
>
> JL
>
> On Sat, Nov 20, 2010 at 7:47 PM, Andy Somogyi <andy.somogyi@xxxxxxxxx> wrote:
>> Hello Eigen guys,
>>
>> Would it be possible to add a pairwise matrix matrix multiply i.e. the "..*" operator in matlab to the Eigen MatrixBase class. I use this operator a lot.
>>
>> thanks
>>
>
>
>