Re: [eigen] bug in data() on col/row |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] bug in data() on col/row
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Sat, 29 Aug 2009 20:09:46 -0400
- 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 :content-transfer-encoding; bh=GJwn6hSpTMug6TxlwgdLrVx6YGdllwvF4JZ34Mpj/j0=; b=mmQ3837dOmi/gA2P+68B4jqX9ZgYRDh2zIjcoQEMpCsqCD2WXiTkTNCl4ljw5SV0WR XZ0ZfSHKl0vHjwpRWopUq3Whjg9zljEGDRfEY0h740ie8DYDKc9M5BzcSrxdas5ma7Ac 3yTq+X2WcHhK3wK374WRuzGEfMIKWh1V+rZA0=
- 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=P04xY83IfHSF7fGgLCRR0UfuW0kHu1zKmBSFxEqHQ0TOoqzhFC4tT7bWIVyPQWSQ1Z H/AYeXhFS1SeeMAk1u0LpKkKQC7bEJuoosjMbeCLbFwkdyLfP7srHRxzLGk99mNQcQkR +Ot/Pbgb3XEa8DPJZQdD1gNebwkBrF3xKRwgY=
Hi,
Matrices can be stored in either row-major or column-major order.
Eigen defaults to column-major and you were apparently expecting it to
be row-major, that's all :)
If you want row-major, do:
typedef Matrix<float,3,3,RowMajor> RowMajorMatrix3f;
and henceforth use this typedef instead of Matrix3f.
Cheers,
Benoit
2009/8/27 Benjamin Schindler <bschindler@xxxxxxxxxxx>:
> Hi
>
> I just discovered a nasty "bug" - depending on how you look at it - in
> Eigen, see the following program:
>
> #include <eigen2/Eigen/Core>
>
> using namespace Eigen;
> using namespace std;
>
> void copy(const float *from, float *to)
> {
> for(int i=0;i<3;i++)
> to[i] = from[i];
> }
>
> int main(int argc, char** argv)
> {
> Matrix3f m;
> m << 1,2,3,4,5,6,7,8,9;
> cout << m << endl << endl;
> float var[3];
> copy(m.row(0).data(), var);
> Map<Vector3f> map(var);
> cout << map.transpose() << endl;
> }
>
> bschindl@hundertwasser ~ $ ./test
> 1 2 3
> 4 5 6
> 7 8 9
>
> 1 4 7
>
> When I save m.row(0) in a Vector3f and output it, I of course get this:
>
>
> bschindl@hundertwasser ~ $ ./test
> 1 2 3
> 4 5 6
> 7 8 9
>
> 1 2 3
>
> That's a nasty thing - and can cause lots of pain...
> Is there something we can do about it?
>
> Cheers
> Benjamin
>
>
>
>
>