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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ PackageExtensionCompat = "1"
Random = "1"
ScopedValues = "1.3.0"
Strided = "2"
TensorKitSectors = "0.1.4, 0.2"
TensorKitSectors = "0.3"
TensorOperations = "5.1"
Test = "1"
TestExtras = "0.2,0.3"
Expand Down
6 changes: 3 additions & 3 deletions docs/src/lib/sectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ Irrep

## Methods for defining and characterizing `Sector` subtypes
```@docs
Base.one(::Sector)
dual(::Sector)
unit(::Sector)
dual
Nsymbol
Fsymbol
Rsymbol
Bsymbol
dim(::Sector)
frobeniusschur
frobenius_schur_phase
twist(::Sector)
Base.isreal(::Type{<:Sector})
TensorKitSectors.sectorscalartype
Expand Down
6 changes: 3 additions & 3 deletions docs/src/lib/spaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ The following methods act specifically on `ElementarySpace` spaces:

```@docs
isdual
dual
dual(::VectorSpace)
conj
flip
zero(::ElementarySpace)
oneunit
zerospace
unitspace
supremum
infimum
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/man/sectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ For practical reasons, we also require some additional methods to be defined:

Further information, such as the quantum dimensions ``d_a`` and Frobenius-Schur indicator
``χ_a`` (only if ``a == \overline{a}``) are encoded in the F-symbol. They are obtained as
[`dim(a)`](@ref) and [`frobeniusschur(a)`](@ref). These functions have default definitions
[`dim(a)`](@ref) and [`frobenius_schur_phase(a)`](@ref). These functions have default definitions
which extract the requested data from `Fsymbol(a, conj(a), a, a, one(a), one(a))`, but they
can be overloaded in case the value can be computed more efficiently.

Expand Down
17 changes: 8 additions & 9 deletions docs/src/man/spaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,19 +316,18 @@ flip(ℂ^4) == ℂ^4
```

We also define the direct sum `V1` and `V2` as `V1 ⊕ V2`, where `⊕` is obtained by typing
`\oplus`+TAB. This is possible only if `isdual(V1) == isdual(V2)`. With a little pun on
Julia Base, `oneunit` applied to an elementary space (in the value or type domain) returns
the one-dimensional space, which is isomorphic to the scalar field of the space itself. Some
examples illustrate this better
`\oplus`+TAB. This is possible only if `isdual(V1) == isdual(V2)`. `unitspace` applied to an elementary space
(in the value or type domain) returns the one-dimensional space, which is isomorphic to the
scalar field of the space itself. Some examples illustrate this better.
```@repl tensorkit
ℝ^5 ⊕ ℝ^3
ℂ^5 ⊕ ℂ^3
ℂ^5 ⊕ (ℂ^3)'
oneunit(ℝ^3)
ℂ^5 ⊕ oneunit(ComplexSpace)
oneunit((ℂ^3)')
(ℂ^5) ⊕ oneunit((ℂ^5))
(ℂ^5)' ⊕ oneunit((ℂ^5)')
unitspace(ℝ^3)
ℂ^5 ⊕ unitspace(ComplexSpace)
unitspace((ℂ^3)')
(ℂ^5) ⊕ unitspace((ℂ^5))
(ℂ^5)' ⊕ unitspace((ℂ^5)')
```

Finally, while spaces have a partial order, there is no unique infimum or supremum of a two
Expand Down
30 changes: 16 additions & 14 deletions src/TensorKit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ module TensorKit

# Exports
#---------
# Types:
# Reexport common sector types:
export Sector, AbstractIrrep, Irrep
export FusionStyle, UniqueFusion, MultipleFusion, MultiplicityFreeFusion,
SimpleFusion, GenericFusion
export FusionStyle, UniqueFusion, MultipleFusion, MultiplicityFreeFusion, SimpleFusion, GenericFusion
export UnitStyle, SimpleUnit, GenericUnit
export BraidingStyle, SymmetricBraiding, Bosonic, Fermionic, Anyonic, NoBraiding
export Trivial, Z2Irrep, Z3Irrep, Z4Irrep, ZNIrrep, U1Irrep, SU2Irrep, CU1Irrep
export ProductSector
export FermionParity, FermionNumber, FermionSpin
export FibonacciAnyon, IsingAnyon

# Export common vector space, fusion tree and tensor types
export VectorSpace, Field, ElementarySpace # abstract vector spaces
export InnerProductStyle, NoInnerProduct, HasInnerProduct, EuclideanInnerProduct
export ComplexSpace, CartesianSpace, GeneralSpace, GradedSpace # concrete spaces
Expand All @@ -30,18 +31,19 @@ export DiagonalTensorMap, BraidingTensor
export TruncationScheme
export SpaceMismatch, SectorMismatch, IndexError # error types

# general vector space methods
export space, field, dual, dim, reduceddim, dims, fuse, flip, isdual, oplus, ominus,
insertleftunit, insertrightunit, removeunit

# partial order for vector spaces
# Export general vector space methods
export space, field, dual, dim, reduceddim, dims, fuse, flip, isdual
export unitspace, zerospace, oplus, ominus
export insertleftunit, insertrightunit, removeunit
export infimum, supremum, isisomorphic, ismonomorphic, isepimorphic

# methods for sectors and properties thereof
export sectortype, sectors, hassector, Nsymbol, Fsymbol, Rsymbol, Bsymbol,
frobeniusschur, twist, otimes, sectorscalartype, deligneproduct
# Reexport methods for sectors and properties thereof
export sectortype, sectors, hassector
export unit, rightunit, leftunit, allunits, isunit, otimes
export Nsymbol, Fsymbol, Rsymbol, Bsymbol, frobenius_schur_phase, frobenius_schur_indicator, twist, sectorscalartype, deligneproduct

# Export methods for fusion trees
export fusiontrees, braid, permute, transpose
export ZNSpace, SU2Irrep, U1Irrep, CU1Irrep
# other fusion tree manipulations, should not be exported:
# export insertat, split, merge, repartition, artin_braid,
# bendleft, bendright, foldleft, foldright, cycleclockwise, cycleanticlockwise
Expand All @@ -52,9 +54,9 @@ export ℤ₂, ℤ₃, ℤ₄, U₁, SU, SU₂, CU₁
export fℤ₂, fU₁, fSU₂
export ℤ₂Space, ℤ₃Space, ℤ₄Space, U₁Space, CU₁Space, SU₂Space

# tensor maps
# Export tensor map methods
export domain, codomain, numind, numout, numin, domainind, codomainind, allind
export spacetype, sectortype, storagetype, scalartype, tensormaptype
export spacetype, storagetype, scalartype, tensormaptype
export blocksectors, blockdim, block, blocks

# random methods for constructor
Expand Down
16 changes: 8 additions & 8 deletions src/fusiontrees/fusiontrees.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct FusionTree{I <: Sector, N, M, L}
) where
{I <: Sector, N, M, L}
# if N == 0
# @assert coupled == one(coupled)
# @assert coupled == unit(coupled)
# elseif N == 1
# @assert coupled == uncoupled[1]
# elseif N == 2
Expand Down Expand Up @@ -89,7 +89,7 @@ function FusionTree(
end

function FusionTree{I}(
uncoupled::NTuple{N}, coupled = one(I), isdual = ntuple(n -> false, N)
uncoupled::NTuple{N}, coupled = unit(I), isdual = ntuple(Returns(false), N)
) where {I <: Sector, N}
FusionStyle(I) isa UniqueFusion ||
error("fusion tree requires inner lines if `FusionStyle(I) <: MultipleFusion`")
Expand All @@ -103,7 +103,7 @@ function FusionTree(
) where {N, I <: Sector}
return FusionTree{I}(uncoupled, coupled, isdual)
end
FusionTree(uncoupled::Tuple{I, Vararg{I}}) where {I <: Sector} = FusionTree(uncoupled, one(I))
FusionTree(uncoupled::Tuple{I, Vararg{I}}) where {I <: Sector} = FusionTree(uncoupled, unit(I))

# Properties
sectortype(::Type{<:FusionTree{I}}) where {I <: Sector} = I
Expand Down Expand Up @@ -159,17 +159,17 @@ end

# converting to actual array
function Base.convert(A::Type{<:AbstractArray}, f::FusionTree{I, 0}) where {I}
X = convert(A, fusiontensor(one(I), one(I), one(I)))[1, 1, :]
X = convert(A, fusiontensor(unit(I), unit(I), unit(I)))[1, 1, :]
return X
end
function Base.convert(A::Type{<:AbstractArray}, f::FusionTree{I, 1}) where {I}
c = f.coupled
if f.isdual[1]
sqrtdc = sqrtdim(c)
Zcbartranspose = sqrtdc * convert(A, fusiontensor(conj(c), c, one(c)))[:, :, 1, 1]
Zcbartranspose = sqrtdc * convert(A, fusiontensor(dual(c), c, unit(c)))[:, :, 1, 1]
X = conj!(Zcbartranspose) # we want Zcbar^†
else
X = convert(A, fusiontensor(c, one(c), c))[:, 1, :, 1, 1]
X = convert(A, fusiontensor(c, unit(c), c))[:, 1, :, 1, 1]
end
return X
end
Expand Down Expand Up @@ -257,13 +257,13 @@ include("iterator.jl")
# _abelianinner: generate the inner indices for given outer indices in the abelian case
_abelianinner(outer::Tuple{}) = ()
function _abelianinner(outer::Tuple{I}) where {I <: Sector}
return isone(outer[1]) ? () : throw(SectorMismatch())
return isunit(outer[1]) ? () : throw(SectorMismatch())
end
function _abelianinner(outer::Tuple{I, I}) where {I <: Sector}
return outer[1] == dual(outer[2]) ? () : throw(SectorMismatch())
end
function _abelianinner(outer::Tuple{I, I, I}) where {I <: Sector}
return isone(first(⊗(outer...))) ? () : throw(SectorMismatch())
return isunit(first(⊗(outer...))) ? () : throw(SectorMismatch())
end
function _abelianinner(outer::Tuple{I, I, I, I, Vararg{I}}) where {I <: Sector}
c = first(outer[1] ⊗ outer[2])
Expand Down
8 changes: 4 additions & 4 deletions src/fusiontrees/iterator.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
fusiontrees(uncoupled::NTuple{N,I}[,
coupled::I=one(I)[, isdual::NTuple{N,Bool}=ntuple(n -> false, length(uncoupled))]])
coupled::I=unit(I)[, isdual::NTuple{N,Bool}=ntuple(n -> false, length(uncoupled))]])
where {N,I<:Sector} -> FusionTreeIterator{I,N,I}

Return an iterator over all fusion trees with a given coupled sector label `coupled` and
Expand All @@ -17,7 +17,7 @@ function fusiontrees(uncoupled::Tuple{Vararg{I}}, coupled::I) where {I <: Sector
return fusiontrees(uncoupled, coupled, isdual)
end
function fusiontrees(uncoupled::Tuple{I, Vararg{I}}) where {I <: Sector}
coupled = one(I)
coupled = unit(I)
isdual = ntuple(n -> false, length(uncoupled))
return fusiontrees(uncoupled, coupled, isdual)
end
Expand All @@ -38,7 +38,7 @@ Base.IteratorEltype(::FusionTreeIterator) = Base.HasEltype()
Base.eltype(::Type{<:FusionTreeIterator{I, N}}) where {I <: Sector, N} = fusiontreetype(I, N)

Base.length(iter::FusionTreeIterator) = _fusiondim(iter.uncouplediterators, iter.coupled)
_fusiondim(::Tuple{}, c::I) where {I <: Sector} = Int(isone(c))
_fusiondim(::Tuple{}, c::I) where {I <: Sector} = Int(isunit(c))
_fusiondim(iters::NTuple{1}, c::I) where {I <: Sector} = Int(c ∈ iters[1])
function _fusiondim(iters::NTuple{2}, c::I) where {I <: Sector}
d = 0
Expand All @@ -60,7 +60,7 @@ end

# * Iterator methods:
# Start with special cases:
function Base.iterate(it::FusionTreeIterator{I, 0}, state = !isone(it.coupled)) where {I <: Sector}
function Base.iterate(it::FusionTreeIterator{I, 0}, state = !isunit(it.coupled)) where {I <: Sector}
state && return nothing
tree = FusionTree{I}((), it.coupled, (), (), ())
return tree, true
Expand Down
Loading
Loading