Skip to content

Commit c99d668

Browse files
committed
generic spacetype and sectortype
1 parent 0c73bd2 commit c99d668

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

src/fusiontrees/fusiontrees.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ FusionStyle(::Type{<:FusionTree{I}}) where {I<:Sector} = FusionStyle(I)
9898
BraidingStyle(::Type{<:FusionTree{I}}) where {I<:Sector} = BraidingStyle(I)
9999
Base.length(::Type{<:FusionTree{<:Sector,N}}) where {N} = N
100100

101-
sectortype(f::FusionTree) = sectortype(typeof(f))
102101
FusionStyle(f::FusionTree) = FusionStyle(typeof(f))
103102
BraidingStyle(f::FusionTree) = BraidingStyle(typeof(f))
104103
Base.length(f::FusionTree) = length(typeof(f))

src/spaces/homspace.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@ function Base.:(==)(W₁::HomSpace, W₂::HomSpace)
2727
return (W₁.codomain == W₂.codomain) && (W₁.domain == W₂.domain)
2828
end
2929

30-
spacetype(W::HomSpace) = spacetype(typeof(W))
31-
sectortype(W::HomSpace) = sectortype(typeof(W))
32-
field(W::HomSpace) = field(typeof(W))
33-
3430
spacetype(::Type{<:HomSpace{S}}) where {S} = S
35-
field(L::Type{<:HomSpace}) = field(spacetype(L))
36-
sectortype(L::Type{<:HomSpace}) = sectortype(spacetype(L))
3731

3832
numout(W::HomSpace) = length(codomain(W))
3933
numin(W::HomSpace) = length(domain(W))

src/spaces/vectorspaces.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ abstract type VectorSpace end
4747
Return the field type over which a vector space is defined.
4848
"""
4949
function field end
50-
field(V::VectorSpace) = field(typeof(V))
5150

5251
# Basic vector space methods
5352
#----------------------------
@@ -102,7 +101,6 @@ of a homogeneous tensor product of these spaces.
102101
abstract type ElementarySpace <: VectorSpace end
103102
const IndexSpace = ElementarySpace
104103

105-
field(V::ElementarySpace) = field(typeof(V))
106104
# field(::Type{<:ElementarySpace{𝕜}}) where {𝕜} = 𝕜
107105

108106
@doc """
@@ -274,13 +272,18 @@ abstract type CompositeSpace{S<:ElementarySpace} <: VectorSpace end
274272

275273
InnerProductStyle(::Type{<:CompositeSpace{S}}) where {S} = InnerProductStyle(S)
276274

275+
spacetype(x) = spacetype(typeof(x))
276+
function spacetype(::Type{T}) where {T}
277+
throw(MethodError(spacetype, ("spacetype not defined for type $T",)))
278+
end
277279
spacetype(S::Type{<:ElementarySpace}) = S
278-
spacetype(V::ElementarySpace) = typeof(V) # = spacetype(typeof(V))
279280
spacetype(::Type{<:CompositeSpace{S}}) where {S} = S
280-
spacetype(V::CompositeSpace) = spacetype(typeof(V)) # = spacetype(typeof(V))
281281

282-
field(P::Type{<:CompositeSpace}) = field(spacetype(P))
283-
sectortype(P::Type{<:CompositeSpace}) = sectortype(spacetype(P))
282+
sectortype(x) = sectortype(typeof(x))
283+
sectortype(::Type{T}) where {T} = sectortype(spacetype(T))
284+
285+
field(x) = field(typeof(x))
286+
field(::Type{T}) where {T} = field(spacetype(T))
284287

285288
# make ElementarySpace instances behave similar to ProductSpace instances
286289
blocksectors(V::ElementarySpace) = collect(sectors(V))

src/tensors/abstracttensor.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,7 @@ end
190190

191191
# tensor characteristics: work on instances and pass to type
192192
#------------------------------------------------------------
193-
spacetype(t::AbstractTensorMap) = spacetype(typeof(t))
194-
sectortype(t::AbstractTensorMap) = sectortype(typeof(t))
195193
InnerProductStyle(t::AbstractTensorMap) = InnerProductStyle(typeof(t))
196-
field(t::AbstractTensorMap) = field(typeof(t))
197194
storagetype(t::AbstractTensorMap) = storagetype(typeof(t))
198195
blocktype(t::AbstractTensorMap) = blocktype(typeof(t))
199196
similarstoragetype(t::AbstractTensorMap, T=scalartype(t)) = similarstoragetype(typeof(t), T)

0 commit comments

Comments
 (0)