I am in the process of refactoring a codebase that made use of EigenDecomposition() in Hipparchus version 2.3 to use EigenDecompositionSymmetric() in Hipparchus 3.1.
However, it is now failing some of its unittests due to there being double values very close to zero in a matrix that I pass to the EigenDecompositionSymmetric() constructor; resulting in a "MathIllegalArgumentException: non symmetric matrix..." being thrown. This is being generated by MatrixUtils.checkSymmetric() and the following example can reproduce something very similar to what I am seeing:
@Test
void testIsSymmetricToleranceMjw() {
// Default
final double eps = 1e-12;
final double[][] dataSym1 = {
{ 1, 1, 1.0E-16 },
{ 1, 1, 1 },
{1.0E-17, 1, 1 },
};
RealMatrix matrix = MatrixUtils.createRealMatrix(dataSym1);
System.out.println(MatrixUtils.isSymmetric(matrix, eps));
new EigenDecompositionSymmetric(matrix,eps,true);
}
The above will trigger this condition here
Are there any utility methods that can actually zero double values close to zero or any other hints/tips for this situation?
Thank you.