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
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "GradedArrays"
uuid = "bc96ca6e-b7c8-4bb6-888e-c93f838762c2"
version = "0.13.1"
version = "0.13.2"
authors = ["ITensor developers <support@itensor.org> and contributors"]

[workspace]
Expand All @@ -18,6 +18,7 @@ MatrixAlgebraKit = "6c742aac-3347-4629-af66-fc926824e5e4"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
SplitApplyCombine = "03a91e81-4c3e-53e1-a0a4-9c0c8f19dd66"
StridedViews = "4db3bf67-4bd7-4b4e-b153-31dc3fb37143"
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
TensorKitSectors = "13a9c161-d5da-41f0-bcbd-e1a08ae0647f"

Expand All @@ -40,6 +41,7 @@ Random = "1.10"
SUNRepresentations = "0.3, 0.4"
SparseArraysBase = "0.10"
SplitApplyCombine = "1.2.3"
TensorAlgebra = "0.12.4, 0.13"
StridedViews = "0.5"
TensorAlgebra = "0.14"
TensorKitSectors = "0.3"
julia = "1.10"
6 changes: 4 additions & 2 deletions src/fusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ function TensorAlgebra.unmatricize(
if isempty(codomain_axes) && isempty(domain_axes)
# Scalar (rank-0) result: only the trivial-sector block contributes, and
# `cod ∩ dom = {trivial}` for a fused scalar means `m.blocks` is at most
# one 1×1 entry. Return a 0-D `Array` matching the eltype.
a = fill(zero(eltype(m)))
# one 1×1 entry. Return a graded rank-0 array, like the result at every other
# rank, so the permute-add back into the destination dispatches to the graded
# `bipermutedimsopadd!` overload rather than the generic strided path.
a = zero!(similar(m, ()))
triv = trivial(sectortype(m))
haskey(m.blocks, triv) && (a[] = m.blocks[triv][1, 1])
return a
Expand Down
7 changes: 7 additions & 0 deletions src/tensoralgebra.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using SplitApplyCombine: groupcount
using StridedViews: StridedViews

function tensor_product(r1, r2, r3, rs...)
return tensor_product(tensor_product(r1, r2), r3, rs...)
Expand Down Expand Up @@ -173,6 +174,12 @@ function TensorAlgebra.bipermutedimsopadd!(
return y
end

# An abelian sector array's dense form is its data block (each abelian sector is
# one-dimensional, so the structural sector-delta factor is an identity selection).
# Wrapping it as a `StridedView` of its data lets it flow through the generic strided
# permute-add path when the other operand is a plain dense array.
StridedViews.StridedView(a::AbelianSectorArray) = StridedViews.StridedView(data(a))

function TensorAlgebra.bipermutedimsopadd!(
y::AbstractGradedArray{<:Any, <:Any, N}, op, x::AbstractGradedArray{<:Any, <:Any, N},
perm_codomain, perm_domain,
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SUNRepresentations = "0.3, 0.4"
SafeTestsets = "0.1"
SparseArraysBase = "0.10"
Suppressor = "0.2.8"
TensorAlgebra = "0.12.4, 0.13"
TensorAlgebra = "0.14"
TensorKitSectors = "0.3"
Test = "1.10"
TestExtras = "0.3.1"
4 changes: 2 additions & 2 deletions test/test_tensoralgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ end
@test isdual(col)

# A rank-0 graded array matricizes to a 1×1 trivial-sector `FusedGradedMatrix`,
# and unmatricizing back recovers the scalar.
# and unmatricizing back recovers the scalar as a rank-0 graded array.
a = AbelianGradedArray{Float64, U1, 0, Array{Float64, 0}}(undef, ())
a[] = 4.0
m = matricize(GradedArrays.SectorFusion(), a, Val(0))
Expand All @@ -347,7 +347,7 @@ end
@test data(m[Block(1, 1)]) == fill(4.0, 1, 1)

back = unmatricize(GradedArrays.SectorFusion(), m, (), ())
@test back isa Array{Float64, 0}
@test back isa AbelianGradedArray{Float64, <:Any, 0}
@test back[] == 4.0
end

Expand Down
Loading