-
Notifications
You must be signed in to change notification settings - Fork 5
Add some tests for randomized SVD #159
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3b07931
Add some tests for randomized SVD
kshyatt 7401ab3
Don't run randomized SVD on empty arrays
42c448c
Fix again
5e1f782
One more fix
eb86e19
Another fix
86eeb48
And one more
f9cd6d5
Not sure about this
0da3837
Fix trunc arg whoops
bc586e5
Another typo
3afd7bc
Keyword args
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -398,29 +398,20 @@ function svd_trunc_no_error!(A::AbstractMatrix, USVᴴ, alg::TruncatedAlgorithm{ | |
| (Utr, Str, Vᴴtr), _ = truncate(svd_trunc!, (U, S, Vᴴ), alg.trunc) | ||
|
|
||
| do_gauge_fix = get(alg.alg.kwargs, :fixgauge, default_fixgauge())::Bool | ||
| # the output matrices here are the same size as for svd_full! | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am confused about the conclusion of the resolved comments, and just about the validity of this comment in the code, as well as why it is here in between those two code lines. The arguments to |
||
| do_gauge_fix && gaugefix!(svd_trunc!, Utr, Vᴴtr) | ||
|
|
||
| return Utr, Str, Vᴴtr | ||
| end | ||
|
|
||
| function svd_trunc!(A::AbstractMatrix, USVᴴ, alg::TruncatedAlgorithm{<:GPU_Randomized}) | ||
| U, S, Vᴴ = USVᴴ | ||
| check_input(svd_trunc!, A, (U, S, Vᴴ), alg.alg) | ||
| _gpu_Xgesvdr!(A, diagview(S), U, Vᴴ; alg.alg.kwargs...) | ||
|
|
||
| # TODO: make sure that truncation is based on maxrank, otherwise this might be wrong | ||
| (Utr, Str, Vᴴtr), _ = truncate(svd_trunc!, (U, S, Vᴴ), alg.trunc) | ||
|
|
||
| Utr, Str, Vᴴtr = svd_trunc_no_error!(A, USVᴴ, alg) | ||
| # normal `truncation_error!` does not work here since `S` is not the full singular value spectrum | ||
| normS = norm(diagview(Str)) | ||
| normA = norm(A) | ||
| # equivalent to sqrt(normA^2 - normS^2) | ||
| # but may be more accurate | ||
| ϵ = sqrt((normA + normS) * (normA - normS)) | ||
|
|
||
| do_gauge_fix = get(alg.alg.kwargs, :fixgauge, default_fixgauge())::Bool | ||
| do_gauge_fix && gaugefix!(svd_trunc!, Utr, Vᴴtr) | ||
|
|
||
| ϵ = sqrt((normA + normS) * abs(normA - normS)) | ||
| return Utr, Str, Vᴴtr, ϵ | ||
| end | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.