|Re: [eigen] vector-cwise operator +=/-=|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] vector-cwise operator +=/-=
- From: Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
- Date: Wed, 16 Dec 2009 10:24:38 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=uj9scgnJZhFANn9qVorKOp/wWH8+FlUDfz5ebo9SJCs=; b=v9Lx1IfSbx+98QCCC5OnF8FEFpq3OYZ3/bSsvWkLHP9Y1+NAGq4a8h6p6UNiDON2VQ x1frz1Kc1sgPQYPhXrrha6tA7qn3D+GWI2uph+INN7EljagGomlsJiOmBpdeSwZdG6Es 9uUJ0EKE+7W+kNDWqHnFYQD3LgpYosVjwoPQA=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=jV8mSqzyAce53U0kJiuasT9hmgpCM482fLFdguxL+q505d66LBrarEOYcDLObUZsZq gWwWH9IBClyBcxDdr2AYcoUwtv34M4fyjDdNcfCplZr00OUx4KUntzP4WUpllcr1VDGK nGsf4VItjpk/pH+DYP7jqiOjstrspZU7+a2Dg=
Geez, its complaining about 'aliasing' in lazyAssign (line 309, Transpose.h).
On Wed, Dec 16, 2009 at 10:17 AM, Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
And another thing - I know that it's again not the nicest use case but this code yields a run-time error complaining about slicing...
v3.transpose() += v2.transpose() * m;
Can we create a compile time error here? Or should we also try to make it work?
On Wed, Dec 16, 2009 at 10:14 AM, Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
So the transposition is really not (!) taking place - it's optimized away? Is there a general rule of thumb to infer, when and if transposition is a nullary op?
Regarding the convenience I would say 'yes, it's more convenient'. In particular in presence of my previous question - it is (*cough* at least for me) not intuitively clear to the user that the multiplication as proposed by you is equally efficient.
Finally, in the patch I am guarding against vectors of different size. I can not guarantee, that I am overseeing a use case where this might fail. I can run the unit tests against the modifications and true, I see the need for the ei_assert...
On Wed, Dec 16, 2009 at 10:05 AM, Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
indeed we already allow col_vector = row_vector, but I'm not sure we should allow coeff-wise binary operators to work between column and row vectors... is it always safe ? is it really more convenient ?
About the last question, e.g., your example is better written like this:
v3 += m.transpose() * v2;
I think it would be cool, if the following code worked:
using namespace Eigen;
void main ()
m << 1,2,3,4,5,6;
v2 << 7,8;
v3 << 4,5,6;
v3 += v2.transpose() * m; // expected 43, 59, 57
std::cout << v3 << std::endl;
The simple assignment
v3 = v2.transpose() * m;
is already working and if I am not totally wrong, the only thing which keeps this current example from working is the ctor of CwiseBinaryOp. In particular the lines
ei_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
(these are redundant, right?). I think, if we simply make this check less restrictive in the sense that we allow the assignment of vectors and their transposed counterparts (having the same size...) we would be done. Any objections or comments against such a change?