Skip to content

Getting negative eigenvalues for PDS matrices #8

@zhesu1

Description

@zhesu1

Always getting negative eigenvalues for randomly generated PDS matrices when one eigenvalue is very small and close to 0 or very big. Any way to deal with this situation? The following is one specific example that gives a negative eigenvalue and the eigenvalue is not really close to 0.

T = torch.tensor([[ 1.3999e+00,  1.5765e+00, -5.5419e+03],
        [ 1.5765e+00,  2.1994e+00, -7.3147e+03],
        [-5.5419e+03, -7.3147e+03,  2.4693e+07]], dtype=torch.float64) 
vlinalg.vSymEig(T.reshape((1,9,1,1,1)), eigenvectors=False)[0]

The result is
tensor([[[[[-7.9096e-02]]], [[[ 2.6781e-01]]], [[[ 2.4693e+07]]]]], dtype=torch.float64)

But if we use the build-in function in Pytorch:

torch.symeig(T, eigenvectors=True)[0]

Then the eigenvalues are all positive:
tensor([4.5855e-03, 1.8413e-01, 2.4693e+07], dtype=torch.float64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions