From 1c7c380bc83788aefc297d01b8b80bf247e01152 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Mon, 21 Jul 2025 17:51:00 -0400 Subject: [PATCH] Upgrade to BlockSparseArrays.jl v0.8 --- Project.toml | 14 ++--- .../KroneckerArraysBlockSparseArraysExt.jl | 52 +++++++++---------- test/Project.toml | 3 +- 3 files changed, 33 insertions(+), 36 deletions(-) diff --git a/Project.toml b/Project.toml index 46edc19..50fc329 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "KroneckerArrays" uuid = "05d0b138-81bc-4ff7-84be-08becefb1ccc" authors = ["ITensor developers and contributors"] -version = "0.1.23" +version = "0.1.24" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" @@ -21,14 +21,14 @@ BlockSparseArrays = "2c9a651f-6452-4ace-a6ac-809f4280fbb4" KroneckerArraysBlockSparseArraysExt = ["BlockArrays", "BlockSparseArrays"] [compat] -Adapt = "4.3.0" +Adapt = "4.3" BlockArrays = "1.6" -BlockSparseArrays = "0.7.22" -DerivableInterfaces = "0.5.0" +BlockSparseArrays = "0.8" +DerivableInterfaces = "0.5" DiagonalArrays = "0.3.5" -FillArrays = "1.13.0" -GPUArraysCore = "0.2.0" +FillArrays = "1.13" +GPUArraysCore = "0.2" LinearAlgebra = "1.10" MapBroadcast = "0.1.9" -MatrixAlgebraKit = "0.2.0" +MatrixAlgebraKit = "0.2" julia = "1.10" diff --git a/ext/KroneckerArraysBlockSparseArraysExt/KroneckerArraysBlockSparseArraysExt.jl b/ext/KroneckerArraysBlockSparseArraysExt/KroneckerArraysBlockSparseArraysExt.jl index b23c869..e67d3aa 100644 --- a/ext/KroneckerArraysBlockSparseArraysExt/KroneckerArraysBlockSparseArraysExt.jl +++ b/ext/KroneckerArraysBlockSparseArraysExt/KroneckerArraysBlockSparseArraysExt.jl @@ -24,7 +24,7 @@ function BlockSparseArrays.blockrange(bs::Vector{<:CartesianProduct}) end using BlockArrays: AbstractBlockedUnitRange -using BlockSparseArrays: Block, GetUnstoredBlock, eachblockaxis, mortar_axis +using BlockSparseArrays: Block, ZeroBlocks, eachblockaxis, mortar_axis using DerivableInterfaces: zero! using FillArrays: Eye using KroneckerArrays: @@ -56,45 +56,41 @@ function block_axes(ax::NTuple{N,AbstractUnitRange{<:Integer}}, I::Block{N}) whe return block_axes(ax, Tuple(I)...) end -function (f::GetUnstoredBlock)( - ::Type{<:AbstractMatrix{KroneckerMatrix{T,A,B}}}, I::Vararg{Int,2} +function Base.getindex( + a::ZeroBlocks{2,KroneckerMatrix{T,A,B}}, I::Vararg{Int,2} ) where {T,A<:AbstractMatrix{T},B<:AbstractMatrix{T}} - ax_a = arg1.(f.axes) - f_a = GetUnstoredBlock(ax_a) - a = f_a(AbstractMatrix{A}, I...) + ax_a1 = arg1.(a.parentaxes) + a1 = ZeroBlocks{2,A}(ax_a1)[I...] - ax_b = arg2.(f.axes) - f_b = GetUnstoredBlock(ax_b) - b = f_b(AbstractMatrix{B}, I...) + ax_a2 = arg2.(a.parentaxes) + a2 = ZeroBlocks{2,B}(ax_a2)[I...] - return a ⊗ b + return a1 ⊗ a2 end -function (f::GetUnstoredBlock)( - ::Type{<:AbstractMatrix{EyeKronecker{T,A,B}}}, I::Vararg{Int,2} +function Base.getindex( + a::ZeroBlocks{2,EyeKronecker{T,A,B}}, I::Vararg{Int,2} ) where {T,A<:Eye{T},B<:AbstractMatrix{T}} - block_ax_a = arg1.(block_axes(f.axes, Block(I))) - a = _similar(A, block_ax_a) + block_ax_a1 = arg1.(block_axes(a.parentaxes, Block(I))) + a1 = _similar(A, block_ax_a1) - ax_b = arg2.(f.axes) - f_b = GetUnstoredBlock(ax_b) - b = f_b(AbstractMatrix{B}, I...) + ax_a2 = arg2.(a.parentaxes) + a2 = ZeroBlocks{2,B}(ax_a2)[I...] - return a ⊗ b + return a1 ⊗ a2 end -function (f::GetUnstoredBlock)( - ::Type{<:AbstractMatrix{KroneckerEye{T,A,B}}}, I::Vararg{Int,2} +function Base.getindex( + a::ZeroBlocks{2,KroneckerEye{T,A,B}}, I::Vararg{Int,2} ) where {T,A<:AbstractMatrix{T},B<:Eye{T}} - ax_a = arg1.(f.axes) - f_a = GetUnstoredBlock(ax_a) - a = f_a(AbstractMatrix{A}, I...) + ax_a1 = arg1.(a.parentaxes) + a1 = ZeroBlocks{2,A}(ax_a1)[I...] - block_ax_b = arg2.(block_axes(f.axes, Block(I))) - b = _similar(B, block_ax_b) + block_ax_a2 = arg2.(block_axes(a.parentaxes, Block(I))) + a2 = _similar(B, block_ax_a2) - return a ⊗ b + return a1 ⊗ a2 end -function (f::GetUnstoredBlock)( - ::Type{<:AbstractMatrix{EyeEye{T,A,B}}}, I::Vararg{Int,2} +function Base.getindex( + a::ZeroBlocks{2,EyeEye{T,A,B}}, I::Vararg{Int,2} ) where {T,A<:Eye{T},B<:Eye{T}} return error("Not implemented.") end diff --git a/test/Project.toml b/test/Project.toml index 16b4265..81469e5 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -12,6 +12,7 @@ KroneckerArrays = "05d0b138-81bc-4ff7-84be-08becefb1ccc" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MatrixAlgebraKit = "6c742aac-3347-4629-af66-fc926824e5e4" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208" StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" @@ -21,7 +22,7 @@ TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a" Adapt = "4" Aqua = "0.8" BlockArrays = "1.6" -BlockSparseArrays = "0.7.21" +BlockSparseArrays = "0.8" DerivableInterfaces = "0.5" DiagonalArrays = "0.3.7" FillArrays = "1"