From ab9ce394b61656c786088b14c3a3f92ec0efeec7 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Thu, 22 May 2025 15:45:09 -0400 Subject: [PATCH] Bump to MatrixAlgebraKit v0.2 --- Project.toml | 4 ++-- src/factorizations/svd.jl | 18 +++++++++++++++--- test/Project.toml | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index 4cf9329..5f9e404 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "BlockSparseArrays" uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4" authors = ["ITensor developers and contributors"] -version = "0.5.4" +version = "0.5.5" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" @@ -39,7 +39,7 @@ GPUArraysCore = "0.1.0, 0.2" LinearAlgebra = "1.10" MacroTools = "0.5.13" MapBroadcast = "0.1.5" -MatrixAlgebraKit = "0.1.2" +MatrixAlgebraKit = "0.2" SparseArraysBase = "0.5" SplitApplyCombine = "1.2.3" TensorAlgebra = "0.3.2" diff --git a/src/factorizations/svd.jl b/src/factorizations/svd.jl index 04d187b..d1a37b6 100644 --- a/src/factorizations/svd.jl +++ b/src/factorizations/svd.jl @@ -12,15 +12,27 @@ struct BlockPermutedDiagonalAlgorithm{A<:MatrixAlgebraKit.AbstractAlgorithm} <: alg::A end -# TODO: this is a hardcoded for now to get around this function not being defined in the -# type domain -function MatrixAlgebraKit.default_svd_algorithm(A::AbstractBlockSparseMatrix; kwargs...) +function default_blocksparse_svd_algorithm(f, 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 + # type domain + # alg = MatrixAlgebraKit.default_algorithm(f, blocktype(A); kwargs...) alg = MatrixAlgebraKit.LAPACK_DivideAndConquer(; kwargs...) return BlockPermutedDiagonalAlgorithm(alg) end +function MatrixAlgebraKit.default_algorithm( + f::typeof(svd_compact!), A::AbstractBlockSparseMatrix; kwargs... +) + return default_blocksparse_svd_algorithm(f, A; kwargs...) +end +function MatrixAlgebraKit.default_algorithm( + f::typeof(svd_full!), A::AbstractBlockSparseMatrix; kwargs... +) + return default_blocksparse_svd_algorithm(f, A; kwargs...) +end + function similar_output( ::typeof(svd_compact!), A, diff --git a/test/Project.toml b/test/Project.toml index 7d8eb2e..d59a1a1 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -28,7 +28,7 @@ DiagonalArrays = "0.3" GPUArraysCore = "0.2" JLArrays = "0.2" LinearAlgebra = "1" -MatrixAlgebraKit = "0.1" +MatrixAlgebraKit = "0.2" Random = "1" SafeTestsets = "0.1" SparseArraysBase = "0.5"