This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Wrong results with matrix multiplication

Tags: None
(comma "," separated)
Koda
Registered Member
Posts
3
Karma
0
Hi everybody,

I am using Eigen 3.0.3 and until now it has worked pretty well.

I have a strange problem with a multiplication between two matrices. The two matrices are initialized just before the multiplication. The result of the multiplication is wrong for a part. The beginning is okay but not the end and I don't know why. If I print these two matrices just before the multiplication they are okay but the result is not.

Here is the code not working well:

Code: Select all
int sizeStateVector = 6+3*state_.getNbLandmarks();
// typedef Matrix<double, 2, Dynamic> Matrix2Nd;
Matrix2Nd H(2, sizeStateVector);
H.setZero();
jacobianH(i, H);
MatrixXd P(sizeStateVector, sizeStateVector);
state_.cov(P);

// okay
cout << P << endl << endl;
cout << H.transpose() << endl << endl;
// not okay
cout << P*H.transpose() << endl;


I know there are some restrictions on how to use matrices as function parameters, and I have tried different ways, but as the matrices seem right, I don't see where the error could be.

Maybe I am missing something but if you could help me with that, It'd be nice.

Last edited by Koda on Tue Nov 29, 2011 12:57 pm, edited 1 time in total.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
well, maybe you could try to run your program under valgrind to detect possible memory errors.
Koda
Registered Member
Posts
3
Karma
0
Sorry, I forgot to mention that I already checked with valgrind and have no memory leaks.

Thanks for the help anyway.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Some tests:

What is the typical value of sizeStateVector ?

Do you get the same results with a MatrixXd instead of a Matrix2Nd ?

What if you disable vectorization by compiling with -DEIGEN_DONT_VECTORIZE ?

What if you try with P.lazyProduct(H.transpose()) ?
Koda
Registered Member
Posts
3
Karma
0
Typical value for sizeStateVector is between 6 and 12 here.

Yes, same results with MatrixXd.

Still the same results with -DEIGEN_DONT_VECTORIZE.

Once again, still the same results with the lazy product.

Not good, huh? Thank you for your time.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]