Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary/Motivation:
Presently, the
SVDToolbox
isn't widely utilized, in part because of the limited options for calculating the SVD. Scipy's dense SVD is time-consuming on problems larger than 1000x1000, while its sparse SVD does not work well to find the singular values of the smallest magnitude.Therefore, I've implemented a custom version of the SVD that uses simultaneous inverse iteration. Due to limited options for sparse matrix factorization available in Scipy, we must explicitly form a normal matrix
A.T @ A
orA @ A.T
in order to invert it, which reduces numerical precision of the results from ~1e-16
to ~1e-8
. Therefore a second refinement step is used, in order to projectA
into its near-null space computed through the inverse iteration and then computes a dense SVD of that matrix, reduces an n by n matrix calculation to an n by n_vec matrix computation, which can be computed rapidly.In order to try out the new method, check out this branch, optionally merge it into your working branch, then set the svd callback:
I'd appreciate testers for this method before we merge it.
Legal Acknowledgement
By contributing to this software project, I agree to the following terms and conditions for my contribution: