diff --git a/Project.toml b/Project.toml index 732b82d69..860a1b3f0 100644 --- a/Project.toml +++ b/Project.toml @@ -51,7 +51,7 @@ Printf = "1" Random = "1" ScopedValues = "1.3.0" Strided = "2" -TensorKitSectors = "0.3.6" +TensorKitSectors = "0.3.7" TensorOperations = "5.1" TupleTools = "1.5" VectorInterface = "0.4.8, 0.5" diff --git a/src/TensorKit.jl b/src/TensorKit.jl index 032db36c0..d8361ac79 100644 --- a/src/TensorKit.jl +++ b/src/TensorKit.jl @@ -8,11 +8,12 @@ module TensorKit # Exports #--------- # Reexport common sector types: -export Sector, AbstractIrrep, Irrep +export Sector, AbstractIrrep, Irrep, GroupElement export FusionStyle, UniqueFusion, MultipleFusion, MultiplicityFreeFusion, SimpleFusion, GenericFusion export UnitStyle, SimpleUnit, GenericUnit export BraidingStyle, SymmetricBraiding, Bosonic, Fermionic, Anyonic, NoBraiding, HasBraiding -export Trivial, Z2Irrep, Z3Irrep, Z4Irrep, ZNIrrep, U1Irrep, SU2Irrep, CU1Irrep +export Trivial, Z2Irrep, Z3Irrep, Z4Irrep, ZNIrrep, LargeZNIrrep +export ZNElement, Z2Element, Z3Element, Z4Element, DNIrrep, A4Irrep, U1Irrep, SU2Irrep, CU1Irrep export ProductSector, TimeReversed export FermionParity, FermionNumber, FermionSpin export FibonacciAnyon, IsingAnyon, IsingBimodule @@ -41,8 +42,9 @@ export infimum, supremum, isisomorphic, ismonomorphic, isepimorphic # 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 unit, rightunit, leftunit, allunits, isunit, otimes, deligneproduct, timereversed +export Nsymbol, Fsymbol, Rsymbol, Bsymbol, frobenius_schur_phase, frobenius_schur_indicator, twist, fusiontensor +export sectorscalartype, fusionscalartype, braidingscalartype # Export methods for fusion trees export fusiontrees, braid, permute, transpose @@ -52,7 +54,7 @@ export fusiontrees, braid, permute, transpose # some unicode export ⊕, ⊗, ⊖, ×, ⊠, ℂ, ℝ, ℤ, ←, →, ≾, ≿, ≅, ≺, ≻ -export ℤ₂, ℤ₃, ℤ₄, U₁, SU, SU₂, CU₁ +export ℤ₂, ℤ₃, ℤ₄, D₃, D₄, A₄, U₁, SU, SU₂, CU₁ export fℤ₂, fU₁, fSU₂ export ℤ₂Space, ℤ₃Space, ℤ₄Space, U₁Space, CU₁Space, SU₂Space diff --git a/src/auxiliary/dicts.jl b/src/auxiliary/dicts.jl index 8c6b47217..626599c01 100644 --- a/src/auxiliary/dicts.jl +++ b/src/auxiliary/dicts.jl @@ -21,84 +21,6 @@ Base.get(d::SingletonDict, key, default) = isequal(d.key, key) ? d.value : defau Base.iterate(d::SingletonDict, s = true) = s ? ((d.key => d.value), false) : nothing -struct VectorDict{K, V} <: AbstractDict{K, V} - keys::Vector{K} - values::Vector{V} -end -VectorDict{K, V}() where {K, V} = VectorDict{K, V}(Vector{K}(), Vector{V}()) -VectorDict() = VectorDict{Any, Any}() - -function VectorDict{K, V}(kvs) where {K, V} - keys = Vector{K}() - values = Vector{V}() - if Base.IteratorSize(kv) !== SizeUnknown() - sizehint!(keys, length(kvs)) - sizehint!(values, length(kvs)) - end - for (k, v) in kvs - push!(keys, k) - push!(values, v) - end - return VectorDict{K, V}(keys, values) -end -VectorDict(kv1::Pair{K, V}, kvs::Pair{K, V}...) where {K, V} = VectorDict{K, V}((kv1, kvs...)) -VectorDict(g::Base.Generator) = VectorDict(g...) - -Base.length(d::VectorDict) = length(d.keys) -function Base.sizehint!(d::VectorDict, newsz) - (sizehint!(d.keys, newsz); sizehint!(d.values, newsz); return d) -end - -@propagate_inbounds getpair(d::VectorDict, i::Integer) = d.keys[i] => d.values[i] - -Base.copy(d::VectorDict) = VectorDict(copy(d.keys), copy(d.values)) -Base.empty(::VectorDict, ::Type{K}, ::Type{V}) where {K, V} = VectorDict{K, V}() -Base.empty!(d::VectorDict) = (empty!(d.keys); empty!(d.values); return d) - -function Base.delete!(d::VectorDict, key) - i = findfirst(isequal(key), d.keys) - if !(i === nothing || i == 0) - deleteat!(d.keys, i) - deleteat!(d.values, i) - end - return d -end - -Base.keys(d::VectorDict) = d.keys -Base.values(d::VectorDict) = d.values -Base.haskey(d::VectorDict, key) = key in d.keys -function Base.getindex(d::VectorDict, key) - i = findfirst(isequal(key), d.keys) - @inbounds begin - return i !== nothing ? d.values[i] : throw(KeyError(key)) - end -end -function Base.setindex!(d::VectorDict, v, key) - i = findfirst(isequal(key), d.keys) - if i === nothing - push!(d.keys, key) - push!(d.values, v) - else - d.values[i] = v - end - return d -end - -function Base.get(d::VectorDict, key, default) - i = findfirst(isequal(key), d.keys) - @inbounds begin - return i !== nothing ? d.values[i] : default - end -end - -function Base.iterate(d::VectorDict, s = 1) - @inbounds if s > length(d) - return nothing - else - return (d.keys[s] => d.values[s]), s + 1 - end -end - struct SortedVectorDict{K, V} <: AbstractDict{K, V} keys::Vector{K} values::Vector{V} diff --git a/src/tensors/abstracttensor.jl b/src/tensors/abstracttensor.jl index 46e7b96d6..21955d44e 100644 --- a/src/tensors/abstracttensor.jl +++ b/src/tensors/abstracttensor.jl @@ -212,7 +212,6 @@ See also [`domain`](@ref) and [`space`](@ref). codomain(t::AbstractTensorMap) = codomain(space(t)) codomain(t::AbstractTensorMap, i) = codomain(t)[i] -target(t::AbstractTensorMap) = codomain(t) # categorical terminology @doc """ domain(t::AbstractTensorMap{T,S,N₁,N₂}) -> ProductSpace{S,N₂} @@ -226,7 +225,6 @@ See also [`codomain`](@ref) and [`space`](@ref). domain(t::AbstractTensorMap) = domain(space(t)) domain(t::AbstractTensorMap, i) = domain(t)[i] -source(t::AbstractTensorMap) = domain(t) # categorical terminology @doc """ numout(x) -> Int diff --git a/test/setup.jl b/test/setup.jl index 944ea5b59..37c682d62 100644 --- a/test/setup.jl +++ b/test/setup.jl @@ -87,9 +87,9 @@ function randsector(::Type{I}) where {I <: Sector} return a end function hasfusiontensor(I::Type{<:Sector}) - isa(UnitStyle(I), GenericUnit) && return false try - TensorKit.fusiontensor(unit(I), unit(I), unit(I)) + u = first(allunits(I)) + fusiontensor(u, u, u) return true catch e if e isa MethodError diff --git a/test/tensors/diagonal.jl b/test/tensors/diagonal.jl index 3da1fd78f..8a4c46161 100644 --- a/test/tensors/diagonal.jl +++ b/test/tensors/diagonal.jl @@ -4,9 +4,13 @@ using TensorKit diagspacelist = ( (ℂ^4)', Vect[Z2Irrep](0 => 2, 1 => 3), + Vect[Z3Element{1}](0 => 2, 1 => 3, 2 => 1), + Vect[A4Irrep](0 => 1, 1 => 2, 2 => 2, 3 => 2), Vect[FermionNumber](0 => 2, 1 => 2, -1 => 1), Vect[SU2Irrep](0 => 2, 1 => 1)', Vect[FibonacciAnyon](:I => 2, :τ => 2), + Vect[Z3Element{1}](0 => 2, 1 => 2, 2 => 1), + Vect[IsingBimodule]((1, 1, 0) => 2, (1, 1, 1) => 3), ) @testset "DiagonalTensor with domain $V" for V in diagspacelist