Skip to content

Commit 8c89827

Browse files
authored
Upgrade to TensorAlgebra v0.5 (#187)
1 parent c9fe25e commit 8c89827

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "BlockSparseArrays"
22
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
3-
version = "0.10.11"
3+
version = "0.10.12"
44
authors = ["ITensor developers <[email protected]> and contributors"]
55

66
[deps]
@@ -44,7 +44,7 @@ MapBroadcast = "0.1.5"
4444
MatrixAlgebraKit = "0.6"
4545
SparseArraysBase = "0.7.1"
4646
SplitApplyCombine = "1.2.3"
47-
TensorAlgebra = "0.3, 0.4"
47+
TensorAlgebra = "0.5"
4848
TensorProducts = "0.1.7"
4949
Test = "1.10"
5050
TypeParameterAccessors = "0.4.1"

ext/BlockSparseArraysTensorAlgebraExt/BlockSparseArraysTensorAlgebraExt.jl

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
module BlockSparseArraysTensorAlgebraExt
22

33
using BlockSparseArrays: AbstractBlockSparseArray, blockreshape
4-
using TensorAlgebra:
5-
TensorAlgebra,
6-
BlockedTrivialPermutation,
7-
BlockedTuple,
8-
FusionStyle,
9-
ReshapeFusion,
10-
fuseaxes
4+
using TensorAlgebra: TensorAlgebra, BlockedTuple, FusionStyle, fuseaxes
115

126
struct BlockReshapeFusion <: FusionStyle end
137

@@ -20,12 +14,12 @@ using BlockSparseArrays: blocksparse
2014
using SparseArraysBase: eachstoredindex
2115
using TensorAlgebra: TensorAlgebra, matricize, unmatricize
2216
function TensorAlgebra.matricize(
23-
::BlockReshapeFusion, a::AbstractArray, biperm::BlockedTrivialPermutation{2}
17+
::BlockReshapeFusion, a::AbstractArray, length1::Val, length2::Val
2418
)
25-
ax = fuseaxes(axes(a), biperm)
19+
ax = fuseaxes(axes(a), length1, length2)
2620
reshaped_blocks_a = reshape(blocks(a), map(blocklength, ax))
2721
key(I) = Block(Tuple(I))
28-
value(I) = matricize(reshaped_blocks_a[I], biperm)
22+
value(I) = matricize(reshaped_blocks_a[I], length1, length2)
2923
Is = eachstoredindex(reshaped_blocks_a)
3024
bs = if isempty(Is)
3125
# Catch empty case and make sure the type is constrained properly.
@@ -45,16 +39,17 @@ using BlockArrays: blocklengths
4539
function TensorAlgebra.unmatricize(
4640
::BlockReshapeFusion,
4741
m::AbstractMatrix,
48-
blocked_ax::BlockedTuple{2, <:Any, <:Tuple{Vararg{AbstractUnitRange}}},
42+
codomain_axes::Tuple{Vararg{AbstractUnitRange}},
43+
domain_axes::Tuple{Vararg{AbstractUnitRange}},
4944
)
50-
ax = Tuple(blocked_ax)
45+
ax = (codomain_axes..., domain_axes...)
5146
reshaped_blocks_m = reshape(blocks(m), map(blocklength, ax))
5247
function f(I)
5348
block_axes_I = BlockedTuple(
5449
map(ntuple(identity, length(ax))) do i
5550
return Base.axes1(ax[i][Block(I[i])])
5651
end,
57-
blocklengths(blocked_ax),
52+
(length(codomain_axes), length(domain_axes)),
5853
)
5954
return unmatricize(reshaped_blocks_m[I], block_axes_I)
6055
end

test/Project.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2020
TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a"
2121
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"
2222

23+
[sources]
24+
BlockSparseArrays = {path = ".."}
25+
2326
[compat]
2427
Adapt = "4"
2528
Aqua = "0.8"
@@ -37,7 +40,7 @@ SafeTestsets = "0.1"
3740
SparseArraysBase = "0.7"
3841
StableRNGs = "1"
3942
Suppressor = "0.2"
40-
TensorAlgebra = "0.3, 0.4"
43+
TensorAlgebra = "0.5"
4144
Test = "1"
4245
TestExtras = "0.3"
4346
TypeParameterAccessors = "0.4"

0 commit comments

Comments
 (0)