Re: [eigen] vector-cwise operator +=/-= |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] vector-cwise operator +=/-=*From*: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>*Date*: Wed, 16 Dec 2009 10:07:56 +0100*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; bh=0M52A4zF1jOcZn3FRK9txEt6KK7fpU62yF9JuOZQrA8=; b=U/oAG2Nz9AOgf8duOnfd5dKSgPZ8bm9m90WMrfToOprOYtX/E3H64LNNEj0PkftW5n UFU4lBOAMoaOnEg1KffhOEImN0jgkO2qfffTe1FC4QpdEWk5hzl9xSLXcc9C+g3HwPKv OrLjiO47v+e2VJrst4FV6a++0NgXjNVB0q/UI=*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=No95/2inwxdI1pUHMVBl9UZxp22HzjChIqHWpo6aJjeN3U0QRgypAgsj5DN8UWUqkD 4pWSNmiggN2t3ABJBzwOR03yQxzE5RlKBp4JMLL59mRolAf8qJXPwvCwfARxXPmuVvDR mP2JCxQCCY6IMUoRiGukP/CHZuASmTqVhpWGQ=

note that the static assert is to catch errors at compile time, and so it only works for fixed size objects. Therefore the ei_assert is still needed for dynamic size objects.

gael.

On Wed, Dec 16, 2009 at 9:58 AM, Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx> wrote:

Here is the patch I have in mind.On Wed, Dec 16, 2009 at 9:39 AM, Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx> wrote:

Hi guys,

I think it would be cool, if the following code worked:

#include <Eigen/Core>

#include <Eigen/Array>

using namespace Eigen;

void main ()

{

Matrix<double,3,1> v3;

Matrix<double,2,1> v2;

Matrix<double,2,3> m;

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

EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Lhs, Rhs)

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?

- Hauke

**References**:**[eigen] vector-cwise operator +=/-=***From:*Hauke Heibel

**Re: [eigen] vector-cwise operator +=/-=***From:*Hauke Heibel

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] vector-cwise operator +=/-=** - Next by Date:
**Re: [eigen] vector-cwise operator +=/-=** - Previous by thread:
**Re: [eigen] vector-cwise operator +=/-=** - Next by thread:
**Re: [eigen] vector-cwise operator +=/-=**

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