-
Notifications
You must be signed in to change notification settings - Fork 2
Implement left_orth/right_orth #122
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
784c469
[WIP] Implement left_orth/right_orth
mtfishman 1b918eb
Better implementation of left_orth/right_orth
mtfishman d4699b9
Add polar, add tests
mtfishman 969b49e
Improve polar a bit
mtfishman ce43787
More in-place
mtfishman 835c523
Merge branch 'main' into mf/orth
mtfishman 825c816
Simplify implementation
mtfishman bd696cd
Simplify test imports
mtfishman be112c8
Stricter checks, fix left_orth trunc, test trunc
mtfishman 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "BlockSparseArrays" | ||
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4" | ||
authors = ["ITensor developers <[email protected]> and contributors"] | ||
version = "0.6.4" | ||
version = "0.6.5" | ||
|
||
[deps] | ||
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
using MatrixAlgebraKit: | ||
MatrixAlgebraKit, | ||
left_orth!, | ||
left_polar!, | ||
lq_compact!, | ||
qr_compact!, | ||
right_orth!, | ||
right_polar!, | ||
select_algorithm, | ||
svd_compact! | ||
|
||
function MatrixAlgebraKit.initialize_output( | ||
::typeof(left_orth!), A::AbstractBlockSparseMatrix | ||
) | ||
return nothing | ||
end | ||
function MatrixAlgebraKit.check_input(::typeof(left_orth!), A::AbstractBlockSparseMatrix, F) | ||
!isnothing(F) && throw( | ||
ArgumentError( | ||
"`left_orth!` on block sparse matrices does not support specifying the output" | ||
), | ||
) | ||
return nothing | ||
end | ||
|
||
function MatrixAlgebraKit.left_orth_qr!(A::AbstractBlockSparseMatrix, F, alg) | ||
!isnothing(F) && throw( | ||
ArgumentError( | ||
"`left_orth!` on block sparse matrices does not support specifying the output" | ||
), | ||
) | ||
alg′ = select_algorithm(qr_compact!, A, alg) | ||
return qr_compact!(A, alg′) | ||
end | ||
function MatrixAlgebraKit.left_orth_polar!(A::AbstractBlockSparseMatrix, F, alg) | ||
!isnothing(F) && throw( | ||
ArgumentError( | ||
"`left_orth!` on block sparse matrices does not support specifying the output" | ||
), | ||
) | ||
alg′ = select_algorithm(left_polar!, A, alg) | ||
return left_polar!(A, alg′) | ||
end | ||
function MatrixAlgebraKit.left_orth_svd!( | ||
A::AbstractBlockSparseMatrix, F, alg, trunc::Nothing=nothing | ||
) | ||
!isnothing(F) && throw( | ||
ArgumentError( | ||
"`left_orth!` on block sparse matrices does not support specifying the output" | ||
), | ||
) | ||
alg′ = select_algorithm(svd_compact!, A, alg) | ||
U, S, Vᴴ = svd_compact!(A, alg′) | ||
return U, S * Vᴴ | ||
end | ||
function MatrixAlgebraKit.left_orth_svd!(A::AbstractBlockSparseMatrix, F, alg, trunc) | ||
!isnothing(F) && throw( | ||
ArgumentError( | ||
"`left_orth!` on block sparse matrices does not support specifying the output" | ||
), | ||
) | ||
alg′ = select_algorithm(svd_compact!, A, alg) | ||
alg_trunc = select_algorithm(svd_trunc!, A, alg′; trunc) | ||
U, S, Vᴴ = svd_trunc!(A, alg_trunc) | ||
return U, S * Vᴴ | ||
end | ||
|
||
function MatrixAlgebraKit.initialize_output( | ||
::typeof(right_orth!), A::AbstractBlockSparseMatrix | ||
) | ||
return nothing | ||
end | ||
function MatrixAlgebraKit.check_input( | ||
::typeof(right_orth!), A::AbstractBlockSparseMatrix, F::Nothing | ||
) | ||
!isnothing(F) && throw( | ||
ArgumentError( | ||
"`right_orth!` on block sparse matrices does not support specifying the output" | ||
), | ||
) | ||
return nothing | ||
end | ||
|
||
function MatrixAlgebraKit.right_orth_lq!(A::AbstractBlockSparseMatrix, F, alg) | ||
!isnothing(F) && throw( | ||
ArgumentError( | ||
"`right_orth!` on block sparse matrices does not support specifying the output" | ||
), | ||
) | ||
alg′ = select_algorithm(lq_compact!, A, alg) | ||
return lq_compact!(A, alg′) | ||
end | ||
function MatrixAlgebraKit.right_orth_polar!(A::AbstractBlockSparseMatrix, F, alg) | ||
!isnothing(F) && throw( | ||
ArgumentError( | ||
"`right_orth!` on block sparse matrices does not support specifying the output" | ||
), | ||
) | ||
alg′ = select_algorithm(right_polar!, A, alg) | ||
return right_polar!(A, alg′) | ||
end | ||
function MatrixAlgebraKit.right_orth_svd!( | ||
A::AbstractBlockSparseMatrix, F, alg, trunc::Nothing=nothing | ||
) | ||
!isnothing(F) && throw( | ||
ArgumentError( | ||
"`right_orth!` on block sparse matrices does not support specifying the output" | ||
), | ||
) | ||
alg′ = select_algorithm(svd_compact!, A, alg) | ||
U, S, Vᴴ = svd_compact!(A, alg′) | ||
return U * S, Vᴴ | ||
end | ||
function MatrixAlgebraKit.right_orth_svd!(A::AbstractBlockSparseMatrix, F, alg, trunc) | ||
!isnothing(F) && throw( | ||
ArgumentError( | ||
"`right_orth!` on block sparse matrices does not support specifying the output" | ||
), | ||
) | ||
alg′ = select_algorithm(svd_compact!, A, alg) | ||
alg_trunc = select_algorithm(svd_trunc!, A, alg′; trunc) | ||
U, S, Vᴴ = svd_trunc!(A, alg_trunc) | ||
return U * S, Vᴴ | ||
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
Oops, something went wrong.
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.