Skip to content

add tolerance to is_hermitian() for sparse "double" matrices #33031

@orlitzky

Description

@orlitzky

Discovered in #33023, the implementation of is_hermitian() for sparse double matrices is the generic one that tests equality of entries, and can fail due to numerical imprecision.

We already have an is_hermitian() for DENSE double matrices, but it is not used for the sparse class, which is its sibling and not a child. A quick way to fix this is to implement the "naive" version from the sense class in the sparse class. But a better solution might be to move the "naive" algorithm for dense matrices up into the superclass, and just allow the generic method to take a tolerance. If that's stable, it would allow us to avoid reimplementing is_hermitian() three times.

When this has been fixed, the # known bug tags need to be removed from the following tests in src/sage/matrix/matrix_double_sparse.pyx:

sage: L = A.cholesky()                    # known bug, 33031        
sage: (A - L*L.T).norm(1) < 1e-10         # known bug, 33031        
True                                                                
sage: B = A.change_ring(RR)               # known bug, 33031        
sage: (B.cholesky() - L).norm(1) < 1e-10  # known bug, 33031
sage: L = A.cholesky()                    # known bug, 33031        
sage: (A - L*L.H).norm(1) < 1e-10         # known bug, 33031        
True                                                                
sage: B = A.change_ring(CC)               # known bug, 33031        
sage: (B.cholesky() - L).norm(1) < 1e-10  # known bug, 33031

Depends on #33023

CC: @collares @kliem

Component: linear algebra

Author: Michael Orlitzky

Branch/Commit: 4c14a9e

Reviewer: Dima Pasechnik

Issue created by migration from https://trac.sagemath.org/ticket/33031

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions