Skip to content
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

Custom svd function #55

Open
NicolaLorenzoni opened this issue Feb 3, 2021 · 3 comments
Open

Custom svd function #55

NicolaLorenzoni opened this issue Feb 3, 2021 · 3 comments

Comments

@NicolaLorenzoni
Copy link

Hi everyone,
I've just noticed that, in mparray.py, and specifically in compress_svd_l and compress_svd_r, with relerr we use svd instead of svdfunc, which does not enable to use a different svd function respect numpy.linalg.svd.

Screenshot from 2021-02-03 12-40-42

@dsuess
Copy link
Owner

dsuess commented Feb 3, 2021

The idea behind svdfunc was to provide different implementations for the truncated SVD. The most naive implementation just computes the full SVD and truncates at given rank. However, you can do much better using e.g. this implementation or randomized algorithms.

However, for relerr=True, we need to compute all singular values. Do you need to change the implementation of the SVD in this case as well?

@NicolaLorenzoni
Copy link
Author

I see, many thanks for the answer.
I stumbled in this because in my case the SVD was not reaching convergence. Searching more in the library, this is due the fact that in the relerr = True case we use numpy.linalg.svd, while in the relerr = None one scipy.linalg.svd. When the numpy doesn't convergence, using the lapack driver 'gsvd' within the scipy one gives no problem, since it is more stable and precise.
So, the error I was stumbling into is not directly related to the truncated or the randomized method, but with the different svd we use in the relerr = None or relerr = True case.

@dsuess
Copy link
Owner

dsuess commented Feb 7, 2021

Ahh, interesting. I thought the implementations in scipy and numpy would be the same. I'll need to benchmark whether gsvd is slower than the current implementation and, if not, just change it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants