Skip to content

Strategies for a matrix containing values very close to zero, when passing it to EigenDecompositionSymmetric()? #365

@mjw99

Description

@mjw99

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions