orocos / orocos-bayesian-filtering

The orocos Bayesian Filtering Library
148 stars 59 forks source link

SymmetricMatrix boost wrapper returns incorrect value #35

Closed jamesgunnfiveai closed 6 years ago

jamesgunnfiveai commented 6 years ago

When calculating the determinant of a 3x3 SymmetricMatrix using the boost wrapper, the value returned is incorrect. For example, 2.33 is returned for the symmetric matrix ((3,2,0),(2,2,0),(0,0,0.5)) which has unit determinant.

I suspect this is because matrix_BOOST.cpp assumes the result of LU decomposition will be a symmetric matrix in the implementation of SymmetricMatrix.determinant(), but this is not true. Similarly for the .inverse function. This does not show up in testing because line 542 of matrixwrapper_test.cpp uses a Matrix (rather than a SymmetricMatrix) when attempting to test the determinant of a SymmetricMatrix.

toeklk commented 6 years ago

Thanks for submitting! Bug confirmed, and added a test in commit 6c6a306 . Patch that fixes the issue is also welcome ;-)

jamesgunnfiveai commented 6 years ago

Fair point! I didn't have time midweek but I've opened a pull request with a patch and fixed up the tests.

toeklk commented 6 years ago

Thanks, seems to work flawless!

MattC11 commented 6 years ago

Thank you for finding this, it was causing havoc with me getting negative determinants my symetric matrices and thus Guassiona::ProbabilityGet not working.