Skip to content

Commit f3f6b96

Browse files
committed
non-abelian interface in tensor_product
1 parent 6cc612f commit f3f6b96

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

NDTensors/src/lib/GradedAxes/src/fusion.jl

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using BlockArrays: AbstractBlockedUnitRange
1+
using BlockArrays: AbstractBlockedUnitRange, blocklengths
22

33
# Represents the range `1:1` or `Base.OneTo(1)`.
44
struct OneToOne{T} <: AbstractUnitRange{T} end
@@ -48,24 +48,23 @@ function fuse_labels(x, y)
4848
end
4949

5050
function fuse_blocklengths(x::Integer, y::Integer)
51-
return x * y
51+
# return blocked unit range to keep non-abelian interface
52+
return blockedrange([x * y])
5253
end
5354

5455
using ..LabelledNumbers: LabelledInteger, label, labelled, unlabel
5556
function fuse_blocklengths(x::LabelledInteger, y::LabelledInteger)
56-
return labelled(unlabel(x) * unlabel(y), fuse_labels(label(x), label(y)))
57+
# return blocked unit range to keep non-abelian interface
58+
return blockedrange([labelled(x * y, fuse_labels(label(x), label(y)))])
5759
end
5860

59-
flatten_maybe_nested(v::Vector{<:Integer}) = v
60-
flatten_maybe_nested(v::Vector{<:AbstractGradedUnitRange}) = reduce(vcat, blocklengths.(v))
61-
6261
using BlockArrays: blockedrange, blocks
6362
function tensor_product(a1::AbstractBlockedUnitRange, a2::AbstractBlockedUnitRange)
64-
maybe_nested = map(Iterators.flatten((Iterators.product(blocks(a1), blocks(a2)),))) do it
63+
nested = map(Iterators.flatten((Iterators.product(blocks(a1), blocks(a2)),))) do it
6564
return mapreduce(length, fuse_blocklengths, it)
6665
end
67-
blocklengths = flatten_maybe_nested(maybe_nested)
68-
return blockedrange(blocklengths)
66+
new_blocklengths = reduce(vcat, blocklengths.(nested))
67+
return blockedrange(new_blocklengths)
6968
end
7069

7170
# convention: sort UnitRangeDual according to nondual blocks

NDTensors/src/lib/Sectors/src/abstractcategory.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function GradedAxes.fuse_blocklengths(
8989
::AbelianStyle, l1::LabelledInteger, l2::LabelledInteger
9090
)
9191
fused = label(l1) label(l2)
92-
return labelled(l1 * l2, fused)
92+
return gradedrange([labelled(l1 * l2, fused)])
9393
end
9494

9595
# cast to range

0 commit comments

Comments
 (0)