Skip to content

Numerical issues with svd #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
olof3 opened this issue Jul 18, 2019 · 1 comment · Fixed by #65
Closed

Numerical issues with svd #54

olof3 opened this issue Jul 18, 2019 · 1 comment · Fixed by #65

Comments

@olof3
Copy link

olof3 commented Jul 18, 2019

I've been running into some problems with svd when multiple singular values have the same magnitude. Consider for example the following.

import GenericLinearAlgebra

# Construct a matrix with singular values [1; 1; 1; 0]
U0, _, V0 = svd(big.(reshape(0:15,4,4)))
A = U0[:, 1:3] * V0[:, 1:3]'

U, S, V = svd(A)

norm(A - U*Diagonal(S)*V')

This gives an error of 2.07 (!). With GenericSVD the same error is 5.6e-77. Casting A to Float64 gives an error of 1.9e-16.

Note that the singular values themselves seem to be computed alright.

@andreasnoack
Copy link
Member

andreasnoack commented May 6, 2020

Sorry for the slow response here. I've identified the issue but I'm still working on the fix. I think the issue is that a shift is causing catastrophic cancellation which introduces an inaccurate Givens rotation. I'll probably have to adjust the convergence criterion a bit.

andreasnoack added a commit that referenced this issue May 7, 2020
zero-shift algorithm and the algorithm with shifts. The algorhtm
now follows the criterion of LAWN for switching between the two
algorithms.

Fixes #54
andreasnoack added a commit that referenced this issue May 7, 2020
zero-shift algorithm and the algorithm with shifts. The algorhtm
now follows the criterion of LAWN for switching between the two
algorithms.

Fixes #54
andreasnoack added a commit that referenced this issue May 7, 2020
)

* Fix SVD convergence criteria and criteria for switching between the
zero-shift algorithm and the algorithm with shifts. The algorhtm
now follows the criterion of LAWN for switching between the two
algorithms.

Fixes #54

* Include some unrelated cleanup in the general eigensolver

* Test on latest release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants