Skip to content

Commit 1803c59

Browse files
committed
one -> unit + left/rightone -> left/rightunit + isone -> isunit when concerning sectors + some more unitspace
1 parent 8d2a356 commit 1803c59

File tree

12 files changed

+69
-69
lines changed

12 files changed

+69
-69
lines changed

src/fusiontrees/fusiontrees.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct FusionTree{I<:Sector,N,M,L}
3232
vertices::NTuple{L,Int}) where
3333
{I<:Sector,N,M,L}
3434
# if N == 0
35-
# @assert coupled == one(coupled)
35+
# @assert coupled == unit(coupled)
3636
# elseif N == 1
3737
# @assert coupled == uncoupled[1]
3838
# elseif N == 2
@@ -78,7 +78,7 @@ function FusionTree(uncoupled::NTuple{N,I}, coupled::I,
7878
end
7979
end
8080

81-
function FusionTree{I}(uncoupled::NTuple{N}, coupled=one(I),
81+
function FusionTree{I}(uncoupled::NTuple{N}, coupled=unit(I),
8282
isdual=ntuple(n -> false, N)) where {I<:Sector,N}
8383
FusionStyle(I) isa UniqueFusion ||
8484
error("fusion tree requires inner lines if `FusionStyle(I) <: MultipleFusion`")
@@ -90,7 +90,7 @@ function FusionTree(uncoupled::NTuple{N,I}, coupled::I,
9090
isdual=ntuple(n -> false, length(uncoupled))) where {N,I<:Sector}
9191
return FusionTree{I}(uncoupled, coupled, isdual)
9292
end
93-
FusionTree(uncoupled::Tuple{I,Vararg{I}}) where {I<:Sector} = FusionTree(uncoupled, one(I))
93+
FusionTree(uncoupled::Tuple{I,Vararg{I}}) where {I<:Sector} = FusionTree(uncoupled, unit(I))
9494

9595
# Properties
9696
sectortype(::Type{<:FusionTree{I}}) where {I<:Sector} = I
@@ -146,17 +146,17 @@ end
146146

147147
# converting to actual array
148148
function Base.convert(A::Type{<:AbstractArray}, f::FusionTree{I,0}) where {I}
149-
X = convert(A, fusiontensor(one(I), one(I), one(I)))[1, 1, :]
149+
X = convert(A, fusiontensor(unit(I), unit(I), unit(I)))[1, 1, :]
150150
return X
151151
end
152152
function Base.convert(A::Type{<:AbstractArray}, f::FusionTree{I,1}) where {I}
153153
c = f.coupled
154154
if f.isdual[1]
155-
sqrtdc = sqrtdim(c)
156-
Zcbartranspose = sqrtdc * convert(A, fusiontensor(conj(c), c, one(c)))[:, :, 1, 1]
155+
sqrtdc = sqrtdim(c) # TODO: change conj to dual
156+
Zcbartranspose = sqrtdc * convert(A, fusiontensor(conj(c), c, unit(c)))[:, :, 1, 1]
157157
X = conj!(Zcbartranspose) # we want Zcbar^†
158158
else
159-
X = convert(A, fusiontensor(c, one(c), c))[:, 1, :, 1, 1]
159+
X = convert(A, fusiontensor(c, unit(c), c))[:, 1, :, 1, 1]
160160
end
161161
return X
162162
end
@@ -234,13 +234,13 @@ include("iterator.jl")
234234
# _abelianinner: generate the inner indices for given outer indices in the abelian case
235235
_abelianinner(outer::Tuple{}) = ()
236236
function _abelianinner(outer::Tuple{I}) where {I<:Sector}
237-
return isone(outer[1]) ? () : throw(SectorMismatch())
237+
return isunit(outer[1]) ? () : throw(SectorMismatch())
238238
end
239239
function _abelianinner(outer::Tuple{I,I}) where {I<:Sector}
240240
return outer[1] == dual(outer[2]) ? () : throw(SectorMismatch())
241241
end
242242
function _abelianinner(outer::Tuple{I,I,I}) where {I<:Sector}
243-
return isone(first((outer...))) ? () : throw(SectorMismatch())
243+
return isunit(first((outer...))) ? () : throw(SectorMismatch())
244244
end
245245
function _abelianinner(outer::Tuple{I,I,I,I,Vararg{I}}) where {I<:Sector}
246246
c = first(outer[1] outer[2])

src/fusiontrees/iterator.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
fusiontrees(uncoupled::NTuple{N,I}[,
3-
coupled::I=one(I)[, isdual::NTuple{N,Bool}=ntuple(n -> false, length(uncoupled))]])
3+
coupled::I=unit(I)[, isdual::NTuple{N,Bool}=ntuple(n -> false, length(uncoupled))]])
44
where {N,I<:Sector} -> FusionTreeIterator{I,N,I}
55
66
Return an iterator over all fusion trees with a given coupled sector label `coupled` and
@@ -16,7 +16,7 @@ function fusiontrees(uncoupled::Tuple{Vararg{I}}, coupled::I) where {I<:Sector}
1616
return fusiontrees(uncoupled, coupled, isdual)
1717
end
1818
function fusiontrees(uncoupled::Tuple{I,Vararg{I}}) where {I<:Sector}
19-
coupled = one(I)
19+
coupled = unit(I)
2020
isdual = ntuple(n -> false, length(uncoupled))
2121
return fusiontrees(uncoupled, coupled, isdual)
2222
end
@@ -37,7 +37,7 @@ Base.IteratorEltype(::FusionTreeIterator) = Base.HasEltype()
3737
Base.eltype(::Type{<:FusionTreeIterator{I,N}}) where {I<:Sector,N} = fusiontreetype(I, N)
3838

3939
Base.length(iter::FusionTreeIterator) = _fusiondim(iter.uncouplediterators, iter.coupled)
40-
_fusiondim(::Tuple{}, c::I) where {I<:Sector} = Int(isone(c))
40+
_fusiondim(::Tuple{}, c::I) where {I<:Sector} = Int(isunit(c))
4141
_fusiondim(iters::NTuple{1}, c::I) where {I<:Sector} = Int(c iters[1])
4242
function _fusiondim(iters::NTuple{2}, c::I) where {I<:Sector}
4343
d = 0
@@ -60,7 +60,7 @@ end
6060
# * Iterator methods:
6161
# Start with special cases:
6262
function Base.iterate(it::FusionTreeIterator{I,0},
63-
state=!isone(it.coupled)) where {I<:Sector}
63+
state=!isunit(it.coupled)) where {I<:Sector}
6464
state && return nothing
6565
tree = FusionTree{I}((), it.coupled, (), (), ())
6666
return tree, true

src/fusiontrees/manipulations.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ operation is the inverse of `insertat` in the sense that if
165165
f₂ = FusionTree{I}(f.uncoupled, f.coupled, isdual2, f.innerlines, f.vertices)
166166
return f₁, f₂
167167
elseif M === 0
168-
u = leftone(f.uncoupled[1])
168+
u = leftunit(f.uncoupled[1])
169169
f₁ = FusionTree{I}((), u, (), ())
170170
uncoupled2 = (u, f.uncoupled...)
171171
coupled2 = f.coupled
@@ -290,7 +290,7 @@ function bendright(f₁::FusionTree{I,N₁}, f₂::FusionTree{I,N₂}) where {I<
290290
# map final splitting vertex (a, b)<-c to fusion vertex a<-(c, dual(b))
291291
@assert N₁ > 0
292292
c = f₁.coupled
293-
a = N₁ == 1 ? leftone(f₁.uncoupled[1]) :
293+
a = N₁ == 1 ? leftunit(f₁.uncoupled[1]) :
294294
(N₁ == 2 ? f₁.uncoupled[1] : f₁.innerlines[end])
295295
b = f₁.uncoupled[N₁]
296296

@@ -362,7 +362,7 @@ function foldright(f₁::FusionTree{I,N₁}, f₂::FusionTree{I,N₂}) where {I<
362362
hasmultiplicities = FusionStyle(a) isa GenericFusion
363363
local newtrees
364364
if N₁ == 1
365-
cset = (leftone(c1),) # or rightone(a)
365+
cset = (leftunit(c1),) # or rightunit(a)
366366
elseif N₁ == 2
367367
cset = (f₁.uncoupled[2],)
368368
else
@@ -373,7 +373,7 @@ function foldright(f₁::FusionTree{I,N₁}, f₂::FusionTree{I,N₂}) where {I<
373373
for μ in 1:Nsymbol(c1, c2, c)
374374
fc = FusionTree((c1, c2), c, (!isduala, false), (), (μ,))
375375
for (fl′, coeff1) in insertat(fc, 2, f₁)
376-
N₁ > 1 && !isone(fl′.innerlines[1]) && continue
376+
N₁ > 1 && !isunit(fl′.innerlines[1]) && continue
377377
coupled = fl′.coupled
378378
uncoupled = Base.tail(Base.tail(fl′.uncoupled))
379379
isdual = Base.tail(Base.tail(fl′.isdual))
@@ -718,7 +718,7 @@ corresponding coefficients.
718718
function elementary_trace(f::FusionTree{I,N}, i) where {I<:Sector,N}
719719
(N > 1 && 1 <= i <= N) ||
720720
throw(ArgumentError("Cannot trace outputs i=$i and i+1 out of only $N outputs"))
721-
i < N || isone(f.coupled) ||
721+
i < N || isunit(f.coupled) ||
722722
throw(ArgumentError("Cannot trace outputs i=$N and 1 of fusion tree that couples to non-trivial sector"))
723723

724724
T = sectorscalartype(I)
@@ -731,7 +731,7 @@ function elementary_trace(f::FusionTree{I,N}, i) where {I<:Sector,N}
731731
# if trace is zero, return empty dict
732732
(b == dual(b′) && f.isdual[i] != f.isdual[j]) || return newtrees
733733
if i < N
734-
inner_extended = (leftone(f.uncoupled[1]), f.uncoupled[1], f.innerlines...,
734+
inner_extended = (leftunit(f.uncoupled[1]), f.uncoupled[1], f.innerlines...,
735735
f.coupled)
736736
a = inner_extended[i]
737737
d = inner_extended[i + 2]
@@ -756,11 +756,11 @@ function elementary_trace(f::FusionTree{I,N}, i) where {I<:Sector,N}
756756
if i > 1
757757
c = f.innerlines[i - 1]
758758
if FusionStyle(I) isa MultiplicityFreeFusion
759-
coeff *= Fsymbol(a, b, dual(b), a, c, rightone(a))
759+
coeff *= Fsymbol(a, b, dual(b), a, c, rightunit(a))
760760
else
761761
μ = f.vertices[i - 1]
762762
ν = f.vertices[i]
763-
coeff *= Fsymbol(a, b, dual(b), a, c, rightone(a))[μ, ν, 1, 1]
763+
coeff *= Fsymbol(a, b, dual(b), a, c, rightunit(a))[μ, ν, 1, 1]
764764
end
765765
end
766766
if f.isdual[i]
@@ -769,7 +769,7 @@ function elementary_trace(f::FusionTree{I,N}, i) where {I<:Sector,N}
769769
push!(newtrees, f′ => coeff)
770770
return newtrees
771771
else # i == N
772-
unit = leftone(b)
772+
unit = leftunit(b)
773773
if N == 2
774774
f′ = FusionTree{I}((), unit, (), (), ())
775775
coeff = sqrtdim(b)
@@ -835,13 +835,13 @@ function artin_braid(f::FusionTree{I,N}, i; inv::Bool=false) where {I<:Sector,N}
835835
vertices = f.vertices
836836
oneT = one(sectorscalartype(I))
837837

838-
if isone(uncoupled[i]) || isone(uncoupled[i + 1])
838+
if isunit(a) || isunit(b)
839839
# braiding with trivial sector: simple and always possible
840840
inner′ = inner
841841
vertices′ = vertices
842842
if i > 1 # we also need to alter innerlines and vertices
843843
inner′ = TupleTools.setindex(inner,
844-
inner_extended[isone(a) ? (i + 1) : (i - 1)],
844+
inner_extended[isunit(a) ? (i + 1) : (i - 1)],
845845
i - 1)
846846
vertices′ = TupleTools.setindex(vertices′, vertices[i], i - 1)
847847
vertices′ = TupleTools.setindex(vertices′, vertices[i - 1], i)

src/spaces/deligne.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,28 @@ function ⊠(V::GradedSpace, P₀::ProductSpace{<:ElementarySpace,0})
2323
field(V) == field(P₀) || throw_incompatible_fields(V, P₀)
2424
I₁ = sectortype(V)
2525
I₂ = sectortype(P₀)
26-
return Vect[I₁ I₂](ifelse(isdual(V), dual(c), c) one(I₂) => dim(V, c)
26+
return Vect[I₁ I₂](ifelse(isdual(V), dual(c), c) unit(I₂) => dim(V, c)
2727
for c in sectors(V); dual=isdual(V))
2828
end
2929

3030
function (P₀::ProductSpace{<:ElementarySpace,0}, V::GradedSpace)
3131
field(P₀) == field(V) || throw_incompatible_fields(P₀, V)
3232
I₁ = sectortype(P₀)
3333
I₂ = sectortype(V)
34-
return Vect[I₁ I₂](one(I₁) ifelse(isdual(V), dual(c), c) => dim(V, c)
34+
return Vect[I₁ I₂](unit(I₁) ifelse(isdual(V), dual(c), c) => dim(V, c)
3535
for c in sectors(V); dual=isdual(V))
3636
end
3737

3838
function (V::ComplexSpace, P₀::ProductSpace{<:ElementarySpace,0})
3939
field(V) == field(P₀) || throw_incompatible_fields(V, P₀)
4040
I₂ = sectortype(P₀)
41-
return Vect[I₂](one(I₂) => dim(V); dual=isdual(V))
41+
return Vect[I₂](unit(I₂) => dim(V); dual=isdual(V))
4242
end
4343

4444
function (P₀::ProductSpace{<:ElementarySpace,0}, V::ComplexSpace)
4545
field(P₀) == field(V) || throw_incompatible_fields(P₀, V)
4646
I₁ = sectortype(P₀)
47-
return Vect[I₁](one(I₁) => dim(V); dual=isdual(V))
47+
return Vect[I₁](unit(I₁) => dim(V); dual=isdual(V))
4848
end
4949

5050
function (P::ProductSpace{<:ElementarySpace,0}, P₀::ProductSpace{<:ElementarySpace,0})

src/spaces/gradedspace.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ field(::Type{<:GradedSpace}) = ℂ
9292
InnerProductStyle(::Type{<:GradedSpace}) = EuclideanInnerProduct()
9393
function dim(V::GradedSpace)
9494
return reduce(+, dim(V, c) * dim(c) for c in sectors(V);
95-
init=zero(dim(one(sectortype(V)))))
95+
init=zero(dim(unit(sectortype(V)))))
9696
end
9797
function dim(V::GradedSpace{I,<:AbstractDict}, c::I) where {I<:Sector}
9898
return get(V.dims, isdual(V) ? dual(c) : c, 0)
@@ -130,9 +130,9 @@ function Base.axes(V::GradedSpace{I}, c::I) where {I<:Sector}
130130
end
131131
return (offset + 1):(offset + dim(c) * dim(V, c))
132132
end
133-
#TODO: one -> unit
134-
unitspace(S::Type{<:GradedSpace{I}}) where {I<:Sector} = S(one(I) => 1)
135-
Base.zero(S::Type{<:GradedSpace{I}}) where {I<:Sector} = S(one(I) => 0)
133+
134+
unitspace(S::Type{<:GradedSpace{I}}) where {I<:Sector} = S(unit(I) => 1)
135+
Base.zero(S::Type{<:GradedSpace{I}}) where {I<:Sector} = S(unit(I) => 0)
136136

137137
# TODO: the following methods can probably be implemented more efficiently for
138138
# `FiniteGradedSpace`, but we don't expect them to be used often in hot loops, so

src/spaces/productspace.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function blocksectors(P::ProductSpace{S,N}) where {S,N}
148148
end
149149
bs = Vector{I}()
150150
if N == 0
151-
push!(bs, one(I))
151+
push!(bs, unit(I))
152152
elseif N == 1
153153
for s in sectors(P)
154154
push!(bs, first(s))

src/tensors/braidingtensor.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ end
346346
# rmul!(C, β)
347347
# end
348348
# I = sectortype(B)
349-
# u = one(I)
349+
# u = unit(I)
350350
# f₀ = FusionTree{I}((), u, (), (), ())
351351
# braidingtensor_levels = A.adjoint ? (1, 2, 2, 1) : (2, 1, 1, 2)
352352
# inv_braid = braidingtensor_levels[cindA[2]] > braidingtensor_levels[cindA[3]]
@@ -414,7 +414,7 @@ end
414414
# rmul!(C, β)
415415
# end
416416
# I = sectortype(B)
417-
# u = one(I)
417+
# u = unit(I)
418418
# f₀ = FusionTree{I}((), u, (), (), ())
419419
# braidingtensor_levels = B.adjoint ? (1, 2, 2, 1) : (2, 1, 1, 2)
420420
# inv_braid = braidingtensor_levels[cindB[2]] > braidingtensor_levels[cindB[3]]
@@ -481,7 +481,7 @@ end
481481
# rmul!(C, β)
482482
# end
483483
# I = sectortype(B)
484-
# u = one(I)
484+
# u = unit(I)
485485
# braidingtensor_levels = A.adjoint ? (1, 2, 2, 1) : (2, 1, 1, 2)
486486
# inv_braid = braidingtensor_levels[cindA[2]] > braidingtensor_levels[cindA[3]]
487487
# for (f₁, f₂) in fusiontrees(B)
@@ -543,7 +543,7 @@ end
543543
# rmul!(C, β)
544544
# end
545545
# I = sectortype(B)
546-
# u = one(I)
546+
# u = unit(I)
547547
# braidingtensor_levels = B.adjoint ? (1, 2, 2, 1) : (2, 1, 1, 2)
548548
# inv_braid = braidingtensor_levels[cindB[2]] > braidingtensor_levels[cindB[3]]
549549
# for (f₁, f₂) in fusiontrees(A)

src/tensors/linalg.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,13 +597,13 @@ function ⊠(t1::AbstractTensorMap, t2::AbstractTensorMap)
597597
dom1 = domain(t1) one(S2)
598598
t1′ = similar(t1, codom1 dom1)
599599
for (c, b) in blocks(t1)
600-
copy!(block(t1′, c one(I2)), b)
600+
copy!(block(t1′, c unit(I2)), b)
601601
end
602602
codom2 = one(S1) codomain(t2)
603603
dom2 = one(S1) domain(t2)
604604
t2′ = similar(t2, codom2 dom2)
605605
for (c, b) in blocks(t2)
606-
copy!(block(t2′, one(I1) c), b)
606+
copy!(block(t2′, unit(I1) c), b)
607607
end
608608
return t1′ t2′
609609
end

src/tensors/tensor.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,9 @@ since it assumes a uniquely defined coupled charge.
538538
throw(ArgumentError("Number of sectors does not match."))
539539
s₁ = TupleTools.getindices(sectors, codomainind(t))
540540
s₂ = map(dual, TupleTools.getindices(sectors, domainind(t)))
541-
c1 = length(s₁) == 0 ? one(I) : (length(s₁) == 1 ? s₁[1] : first((s₁...)))
541+
c1 = length(s₁) == 0 ? unit(I) : (length(s₁) == 1 ? s₁[1] : first((s₁...)))
542542
@boundscheck begin
543-
c2 = length(s₂) == 0 ? one(I) : (length(s₂) == 1 ? s₂[1] : first((s₂...)))
543+
c2 = length(s₂) == 0 ? unit(I) : (length(s₂) == 1 ? s₂[1] : first((s₂...)))
544544
c2 == c1 || throw(SectorMismatch("Not a valid sector for this tensor"))
545545
hassector(codomain(t), s₁) && hassector(domain(t), s₂)
546546
end

test/fusiontrees.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ti = time()
2626
@test eval(Meta.parse(sprint(show, f))) == f
2727
end
2828
@testset "Fusion tree $Istr: constructor properties" begin
29-
u = one(I)
29+
u = unit(I)
3030
@constinferred FusionTree((), u, (), (), ())
3131
@constinferred FusionTree((u,), u, (false,), (), ())
3232
@constinferred FusionTree((u, u), u, (false, false), (), (1,))
@@ -125,7 +125,7 @@ ti = time()
125125
outgoing = (s, dual(s), s, dual(s), s, dual(s))
126126
for bool in (true, false)
127127
isdual = (bool, !bool, bool, !bool, bool, !bool)
128-
for f in fusiontrees(outgoing, one(s), isdual)
128+
for f in fusiontrees(outgoing, unit(s), isdual)
129129
af = convert(Array, f)
130130
T = eltype(af)
131131

@@ -548,7 +548,7 @@ ti = time()
548548
@testset "Double fusion tree $Istr: planar trace" begin
549549
d1 = transpose(f1, f1, (N + 1, 1:N..., ((2N):-1:(N + 3))...), (N + 2,))
550550
f1front, = TK.split(f1, N - 1)
551-
T = typeof(Fsymbol(one(I), one(I), one(I), one(I), one(I), one(I))[1, 1, 1, 1])
551+
T = typeof(Fsymbol(unit(I), unit(I), unit(I), unit(I), unit(I), unit(I))[1, 1, 1, 1]) #TODO: change to _fscalartype
552552
d2 = Dict{typeof((f1front, f1front)),T}()
553553
for ((f1′, f2′), coeff′) in d1
554554
for ((f1′′, f2′′), coeff′′) in

0 commit comments

Comments
 (0)