Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
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 <support@itensor.org> and contributors"]
version = "0.6.7"
version = "0.6.8"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
53 changes: 53 additions & 0 deletions src/factorizations/orthnull.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
using MatrixAlgebraKit:
MatrixAlgebraKit,
default_svd_algorithm,
left_null!,
left_null_svd!,
left_orth!,
left_polar!,
lq_compact!,
null_truncation_strategy,
qr_compact!,
right_null!,
right_null_svd!,
right_orth!,
right_polar!,
select_algorithm,
Expand Down Expand Up @@ -122,3 +128,50 @@ function MatrixAlgebraKit.right_orth_svd!(A::AbstractBlockSparseMatrix, F, alg,
U, S, Vᴴ = svd_trunc!(A, alg_trunc)
return U * S, Vᴴ
end

function MatrixAlgebraKit.initialize_output(
::typeof(left_null!), A::AbstractBlockSparseMatrix
)
return nothing
end
function MatrixAlgebraKit.check_input(
::typeof(left_null!), A::AbstractBlockSparseMatrix, N::Nothing
)
return nothing
end
function MatrixAlgebraKit.left_null_qr!(A::AbstractBlockSparseMatrix, N, alg)
return left_null_svd!(A, N, default_svd_algorithm(A))
end
function MatrixAlgebraKit.left_null_svd!(
A::AbstractBlockSparseMatrix, N, alg, trunc::Nothing
)
return left_null_svd!(A, N, alg, null_truncation_strategy(; atol=0, rtol=0))
end
function MatrixAlgebraKit.truncate!(
::typeof(left_null!),
(U, S)::Tuple{AbstractBlockSparseMatrix,AbstractBlockSparseMatrix},
strategy::TruncationStrategy,
)
return error("Not implemented.")
end

function MatrixAlgebraKit.initialize_output(
::typeof(right_null!), A::AbstractBlockSparseMatrix
)
return nothing
end
function MatrixAlgebraKit.check_input(
::typeof(right_null!), A::AbstractBlockSparseMatrix, N::Nothing
)
return nothing
end
function MatrixAlgebraKit.right_null_lq!(A::AbstractBlockSparseMatrix, N, alg)
return error("Not implement.")
end
function MatrixAlgebraKit.truncate!(
::typeof(right_null!),
(S, Vᴴ)::Tuple{AbstractBlockSparseMatrix,AbstractBlockSparseMatrix},
strategy::TruncationStrategy,
)
return error("Not implemented.")
end
9 changes: 5 additions & 4 deletions src/factorizations/qr.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using MatrixAlgebraKit: MatrixAlgebraKit, lq_compact!, lq_full!, qr_compact!, qr_full!
using MatrixAlgebraKit:
MatrixAlgebraKit, default_qr_algorithm, lq_compact!, lq_full!, qr_compact!, qr_full!

# TODO: this is a hardcoded for now to get around this function not being defined in the
# type domain
function default_blocksparse_qr_algorithm(A::AbstractMatrix; kwargs...)
function MatrixAlgebraKit.default_qr_algorithm(A::AbstractBlockSparseMatrix; kwargs...)
blocktype(A) <: StridedMatrix{<:LinearAlgebra.BLAS.BlasFloat} ||
error("unsupported type: $(blocktype(A))")
alg = MatrixAlgebraKit.LAPACK_HouseholderQR(; kwargs...)
Expand All @@ -11,12 +12,12 @@ end
function MatrixAlgebraKit.default_algorithm(
::typeof(qr_compact!), A::AbstractBlockSparseMatrix; kwargs...
)
return default_blocksparse_qr_algorithm(A; kwargs...)
return default_qr_algorithm(A; kwargs...)
end
function MatrixAlgebraKit.default_algorithm(
::typeof(qr_full!), A::AbstractBlockSparseMatrix; kwargs...
)
return default_blocksparse_qr_algorithm(A; kwargs...)
return default_qr_algorithm(A; kwargs...)
end

function similar_output(
Expand Down
8 changes: 4 additions & 4 deletions src/factorizations/svd.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MatrixAlgebraKit: MatrixAlgebraKit, svd_compact!, svd_full!
using MatrixAlgebraKit: MatrixAlgebraKit, default_svd_algorithm, svd_compact!, svd_full!

"""
BlockPermutedDiagonalAlgorithm(A::MatrixAlgebraKit.AbstractAlgorithm)
Expand All @@ -12,7 +12,7 @@ struct BlockPermutedDiagonalAlgorithm{A<:MatrixAlgebraKit.AbstractAlgorithm} <:
alg::A
end

function default_blocksparse_svd_algorithm(f, A; kwargs...)
function MatrixAlgebraKit.default_svd_algorithm(A; kwargs...)
blocktype(A) <: StridedMatrix{<:LinearAlgebra.BLAS.BlasFloat} ||
error("unsupported type: $(blocktype(A))")
# TODO: this is a hardcoded for now to get around this function not being defined in the
Expand All @@ -25,12 +25,12 @@ end
function MatrixAlgebraKit.default_algorithm(
f::typeof(svd_compact!), A::AbstractBlockSparseMatrix; kwargs...
)
return default_blocksparse_svd_algorithm(f, A; kwargs...)
return default_svd_algorithm(A; kwargs...)
end
function MatrixAlgebraKit.default_algorithm(
f::typeof(svd_full!), A::AbstractBlockSparseMatrix; kwargs...
)
return default_blocksparse_svd_algorithm(f, A; kwargs...)
return default_svd_algorithm(A; kwargs...)
end

function similar_output(
Expand Down
Loading