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)
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.
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:
Then the eigenvalues are all positive:
tensor([4.5855e-03, 1.8413e-01, 2.4693e+07], dtype=torch.float64)