Skip to content

Commit 6bee699

Browse files
authored
Begin implementation of null (#128)
1 parent 2578245 commit 6bee699

File tree

4 files changed

+63
-9
lines changed

4 files changed

+63
-9
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BlockSparseArrays"
22
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.6.7"
4+
version = "0.6.8"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

src/factorizations/orthnull.jl

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
using MatrixAlgebraKit:
22
MatrixAlgebraKit,
3+
default_svd_algorithm,
4+
left_null!,
5+
left_null_svd!,
36
left_orth!,
47
left_polar!,
58
lq_compact!,
9+
null_truncation_strategy,
610
qr_compact!,
11+
right_null!,
12+
right_null_svd!,
713
right_orth!,
814
right_polar!,
915
select_algorithm,
@@ -122,3 +128,50 @@ function MatrixAlgebraKit.right_orth_svd!(A::AbstractBlockSparseMatrix, F, alg,
122128
U, S, Vᴴ = svd_trunc!(A, alg_trunc)
123129
return U * S, Vᴴ
124130
end
131+
132+
function MatrixAlgebraKit.initialize_output(
133+
::typeof(left_null!), A::AbstractBlockSparseMatrix
134+
)
135+
return nothing
136+
end
137+
function MatrixAlgebraKit.check_input(
138+
::typeof(left_null!), A::AbstractBlockSparseMatrix, N::Nothing
139+
)
140+
return nothing
141+
end
142+
function MatrixAlgebraKit.left_null_qr!(A::AbstractBlockSparseMatrix, N, alg)
143+
return left_null_svd!(A, N, default_svd_algorithm(A))
144+
end
145+
function MatrixAlgebraKit.left_null_svd!(
146+
A::AbstractBlockSparseMatrix, N, alg, trunc::Nothing
147+
)
148+
return left_null_svd!(A, N, alg, null_truncation_strategy(; atol=0, rtol=0))
149+
end
150+
function MatrixAlgebraKit.truncate!(
151+
::typeof(left_null!),
152+
(U, S)::Tuple{AbstractBlockSparseMatrix,AbstractBlockSparseMatrix},
153+
strategy::TruncationStrategy,
154+
)
155+
return error("Not implemented.")
156+
end
157+
158+
function MatrixAlgebraKit.initialize_output(
159+
::typeof(right_null!), A::AbstractBlockSparseMatrix
160+
)
161+
return nothing
162+
end
163+
function MatrixAlgebraKit.check_input(
164+
::typeof(right_null!), A::AbstractBlockSparseMatrix, N::Nothing
165+
)
166+
return nothing
167+
end
168+
function MatrixAlgebraKit.right_null_lq!(A::AbstractBlockSparseMatrix, N, alg)
169+
return error("Not implement.")
170+
end
171+
function MatrixAlgebraKit.truncate!(
172+
::typeof(right_null!),
173+
(S, Vᴴ)::Tuple{AbstractBlockSparseMatrix,AbstractBlockSparseMatrix},
174+
strategy::TruncationStrategy,
175+
)
176+
return error("Not implemented.")
177+
end

src/factorizations/qr.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
using MatrixAlgebraKit: MatrixAlgebraKit, lq_compact!, lq_full!, qr_compact!, qr_full!
1+
using MatrixAlgebraKit:
2+
MatrixAlgebraKit, default_qr_algorithm, lq_compact!, lq_full!, qr_compact!, qr_full!
23

34
# TODO: this is a hardcoded for now to get around this function not being defined in the
45
# type domain
5-
function default_blocksparse_qr_algorithm(A::AbstractMatrix; kwargs...)
6+
function MatrixAlgebraKit.default_qr_algorithm(A::AbstractBlockSparseMatrix; kwargs...)
67
blocktype(A) <: StridedMatrix{<:LinearAlgebra.BLAS.BlasFloat} ||
78
error("unsupported type: $(blocktype(A))")
89
alg = MatrixAlgebraKit.LAPACK_HouseholderQR(; kwargs...)
@@ -11,12 +12,12 @@ end
1112
function MatrixAlgebraKit.default_algorithm(
1213
::typeof(qr_compact!), A::AbstractBlockSparseMatrix; kwargs...
1314
)
14-
return default_blocksparse_qr_algorithm(A; kwargs...)
15+
return default_qr_algorithm(A; kwargs...)
1516
end
1617
function MatrixAlgebraKit.default_algorithm(
1718
::typeof(qr_full!), A::AbstractBlockSparseMatrix; kwargs...
1819
)
19-
return default_blocksparse_qr_algorithm(A; kwargs...)
20+
return default_qr_algorithm(A; kwargs...)
2021
end
2122

2223
function similar_output(

src/factorizations/svd.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using MatrixAlgebraKit: MatrixAlgebraKit, svd_compact!, svd_full!
1+
using MatrixAlgebraKit: MatrixAlgebraKit, default_svd_algorithm, svd_compact!, svd_full!
22

33
"""
44
BlockPermutedDiagonalAlgorithm(A::MatrixAlgebraKit.AbstractAlgorithm)
@@ -12,7 +12,7 @@ struct BlockPermutedDiagonalAlgorithm{A<:MatrixAlgebraKit.AbstractAlgorithm} <:
1212
alg::A
1313
end
1414

15-
function default_blocksparse_svd_algorithm(f, A; kwargs...)
15+
function MatrixAlgebraKit.default_svd_algorithm(A; kwargs...)
1616
blocktype(A) <: StridedMatrix{<:LinearAlgebra.BLAS.BlasFloat} ||
1717
error("unsupported type: $(blocktype(A))")
1818
# TODO: this is a hardcoded for now to get around this function not being defined in the
@@ -25,12 +25,12 @@ end
2525
function MatrixAlgebraKit.default_algorithm(
2626
f::typeof(svd_compact!), A::AbstractBlockSparseMatrix; kwargs...
2727
)
28-
return default_blocksparse_svd_algorithm(f, A; kwargs...)
28+
return default_svd_algorithm(A; kwargs...)
2929
end
3030
function MatrixAlgebraKit.default_algorithm(
3131
f::typeof(svd_full!), A::AbstractBlockSparseMatrix; kwargs...
3232
)
33-
return default_blocksparse_svd_algorithm(f, A; kwargs...)
33+
return default_svd_algorithm(A; kwargs...)
3434
end
3535

3636
function similar_output(

0 commit comments

Comments
 (0)