Skip to content

Commit 58f834e

Browse files
authored
Upgrade to BlockSparseArrays.jl v0.8 (#30)
1 parent 9636477 commit 58f834e

File tree

3 files changed

+33
-36
lines changed

3 files changed

+33
-36
lines changed

Project.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "KroneckerArrays"
22
uuid = "05d0b138-81bc-4ff7-84be-08becefb1ccc"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.1.23"
4+
version = "0.1.24"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
@@ -21,14 +21,14 @@ BlockSparseArrays = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
2121
KroneckerArraysBlockSparseArraysExt = ["BlockArrays", "BlockSparseArrays"]
2222

2323
[compat]
24-
Adapt = "4.3.0"
24+
Adapt = "4.3"
2525
BlockArrays = "1.6"
26-
BlockSparseArrays = "0.7.22"
27-
DerivableInterfaces = "0.5.0"
26+
BlockSparseArrays = "0.8"
27+
DerivableInterfaces = "0.5"
2828
DiagonalArrays = "0.3.5"
29-
FillArrays = "1.13.0"
30-
GPUArraysCore = "0.2.0"
29+
FillArrays = "1.13"
30+
GPUArraysCore = "0.2"
3131
LinearAlgebra = "1.10"
3232
MapBroadcast = "0.1.9"
33-
MatrixAlgebraKit = "0.2.0"
33+
MatrixAlgebraKit = "0.2"
3434
julia = "1.10"

ext/KroneckerArraysBlockSparseArraysExt/KroneckerArraysBlockSparseArraysExt.jl

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function BlockSparseArrays.blockrange(bs::Vector{<:CartesianProduct})
2424
end
2525

2626
using BlockArrays: AbstractBlockedUnitRange
27-
using BlockSparseArrays: Block, GetUnstoredBlock, eachblockaxis, mortar_axis
27+
using BlockSparseArrays: Block, ZeroBlocks, eachblockaxis, mortar_axis
2828
using DerivableInterfaces: zero!
2929
using FillArrays: Eye
3030
using KroneckerArrays:
@@ -56,45 +56,41 @@ function block_axes(ax::NTuple{N,AbstractUnitRange{<:Integer}}, I::Block{N}) whe
5656
return block_axes(ax, Tuple(I)...)
5757
end
5858

59-
function (f::GetUnstoredBlock)(
60-
::Type{<:AbstractMatrix{KroneckerMatrix{T,A,B}}}, I::Vararg{Int,2}
59+
function Base.getindex(
60+
a::ZeroBlocks{2,KroneckerMatrix{T,A,B}}, I::Vararg{Int,2}
6161
) where {T,A<:AbstractMatrix{T},B<:AbstractMatrix{T}}
62-
ax_a = arg1.(f.axes)
63-
f_a = GetUnstoredBlock(ax_a)
64-
a = f_a(AbstractMatrix{A}, I...)
62+
ax_a1 = arg1.(a.parentaxes)
63+
a1 = ZeroBlocks{2,A}(ax_a1)[I...]
6564

66-
ax_b = arg2.(f.axes)
67-
f_b = GetUnstoredBlock(ax_b)
68-
b = f_b(AbstractMatrix{B}, I...)
65+
ax_a2 = arg2.(a.parentaxes)
66+
a2 = ZeroBlocks{2,B}(ax_a2)[I...]
6967

70-
return a b
68+
return a1 a2
7169
end
72-
function (f::GetUnstoredBlock)(
73-
::Type{<:AbstractMatrix{EyeKronecker{T,A,B}}}, I::Vararg{Int,2}
70+
function Base.getindex(
71+
a::ZeroBlocks{2,EyeKronecker{T,A,B}}, I::Vararg{Int,2}
7472
) where {T,A<:Eye{T},B<:AbstractMatrix{T}}
75-
block_ax_a = arg1.(block_axes(f.axes, Block(I)))
76-
a = _similar(A, block_ax_a)
73+
block_ax_a1 = arg1.(block_axes(a.parentaxes, Block(I)))
74+
a1 = _similar(A, block_ax_a1)
7775

78-
ax_b = arg2.(f.axes)
79-
f_b = GetUnstoredBlock(ax_b)
80-
b = f_b(AbstractMatrix{B}, I...)
76+
ax_a2 = arg2.(a.parentaxes)
77+
a2 = ZeroBlocks{2,B}(ax_a2)[I...]
8178

82-
return a b
79+
return a1 a2
8380
end
84-
function (f::GetUnstoredBlock)(
85-
::Type{<:AbstractMatrix{KroneckerEye{T,A,B}}}, I::Vararg{Int,2}
81+
function Base.getindex(
82+
a::ZeroBlocks{2,KroneckerEye{T,A,B}}, I::Vararg{Int,2}
8683
) where {T,A<:AbstractMatrix{T},B<:Eye{T}}
87-
ax_a = arg1.(f.axes)
88-
f_a = GetUnstoredBlock(ax_a)
89-
a = f_a(AbstractMatrix{A}, I...)
84+
ax_a1 = arg1.(a.parentaxes)
85+
a1 = ZeroBlocks{2,A}(ax_a1)[I...]
9086

91-
block_ax_b = arg2.(block_axes(f.axes, Block(I)))
92-
b = _similar(B, block_ax_b)
87+
block_ax_a2 = arg2.(block_axes(a.parentaxes, Block(I)))
88+
a2 = _similar(B, block_ax_a2)
9389

94-
return a b
90+
return a1 a2
9591
end
96-
function (f::GetUnstoredBlock)(
97-
::Type{<:AbstractMatrix{EyeEye{T,A,B}}}, I::Vararg{Int,2}
92+
function Base.getindex(
93+
a::ZeroBlocks{2,EyeEye{T,A,B}}, I::Vararg{Int,2}
9894
) where {T,A<:Eye{T},B<:Eye{T}}
9995
return error("Not implemented.")
10096
end

test/Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ KroneckerArrays = "05d0b138-81bc-4ff7-84be-08becefb1ccc"
1212
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1313
MatrixAlgebraKit = "6c742aac-3347-4629-af66-fc926824e5e4"
1414
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
15+
SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
1516
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
1617
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
1718
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
@@ -21,7 +22,7 @@ TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a"
2122
Adapt = "4"
2223
Aqua = "0.8"
2324
BlockArrays = "1.6"
24-
BlockSparseArrays = "0.7.21"
25+
BlockSparseArrays = "0.8"
2526
DerivableInterfaces = "0.5"
2627
DiagonalArrays = "0.3.7"
2728
FillArrays = "1"

0 commit comments

Comments
 (0)