Hipparchus-Math / hipparchus

An efficient, general-purpose mathematics components library in the Java programming language
Apache License 2.0
142 stars 41 forks source link

Error with non-symmetric test in SequentialGaussNewtonOptimizer #205

Closed robincourson1 closed 2 years ago

robincourson1 commented 2 years ago

Sending a symmetric matrix as a Array2DRowRealMatrix using SequentialGaussNewtonOptimizer.WithAPrioriData(...) triggers this warning :

org.hipparchus.exception.MathIllegalArgumentException: matrice non symmétrique: la différence entre les éléments (0,1) et (1,0) est supérieure à 0

The issue is triggered by CholeskyDecomposition (line 134) which does its own symmetry test. It appears not to be possible to change the tolerance margin with the call of SequentialGaussNewtonOptimizer.WithAPrioriData(...) since it does call CholeskyDecomposition without extra arguments.

Surprisingly, the identity matrix is not rejected, identity + 1e-9 is not rejected also, but identity +1e-8 is considered not symmetric (as well as others symmetric matrices...)

I'm using Hipparchus as part of the python wrapper for orekit but I'm not sure if it does make a difference. Testing the matrices using MatrixUtils.isSymmetric(matrix, 1.0e-15) does return the correct test (why is CholeskyDecomposition not using this util function ?)

BryanCazabonne commented 2 years ago

Hi @robincourson1

I had the same issue using Orekit. I generated an OPM file with an orbit determination and initialized a sequential least square estimation based on this OPM.

I'll fix the issue by adding a new signature for the method withAPrioriData(...) allowing to initialize the Cholesky decomposition threshold.