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
1 change: 0 additions & 1 deletion src/fusiontrees/fusiontrees.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ FusionStyle(::Type{<:FusionTree{I}}) where {I<:Sector} = FusionStyle(I)
BraidingStyle(::Type{<:FusionTree{I}}) where {I<:Sector} = BraidingStyle(I)
Base.length(::Type{<:FusionTree{<:Sector,N}}) where {N} = N

sectortype(f::FusionTree) = sectortype(typeof(f))
FusionStyle(f::FusionTree) = FusionStyle(typeof(f))
BraidingStyle(f::FusionTree) = BraidingStyle(typeof(f))
Base.length(f::FusionTree) = length(typeof(f))
Expand Down
6 changes: 0 additions & 6 deletions src/spaces/homspace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@ function Base.:(==)(W₁::HomSpace, W₂::HomSpace)
return (W₁.codomain == W₂.codomain) && (W₁.domain == W₂.domain)
end

spacetype(W::HomSpace) = spacetype(typeof(W))
sectortype(W::HomSpace) = sectortype(typeof(W))
field(W::HomSpace) = field(typeof(W))

spacetype(::Type{<:HomSpace{S}}) where {S} = S
field(L::Type{<:HomSpace}) = field(spacetype(L))
sectortype(L::Type{<:HomSpace}) = sectortype(spacetype(L))

numout(W::HomSpace) = length(codomain(W))
numin(W::HomSpace) = length(domain(W))
Expand Down
34 changes: 22 additions & 12 deletions src/spaces/vectorspaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@
abstract type VectorSpace end

"""
field(V::VectorSpace) -> Field
field(a) -> Type{𝔽<:Field}
field(::Type{T}) -> Type{𝔽<:Field}

Return the field type over which a vector space is defined.
Return the type of field over which object `a` (e.g. a vector space or a tensor) is defined.
Also works in type domain.
"""
function field end
field(V::VectorSpace) = field(typeof(V))
field(x) = field(typeof(x))
field(::Type{T}) where {T} = field(spacetype(T))

# Basic vector space methods
#----------------------------
Expand Down Expand Up @@ -102,7 +104,6 @@
abstract type ElementarySpace <: VectorSpace end
const IndexSpace = ElementarySpace

field(V::ElementarySpace) = field(typeof(V))
# field(::Type{<:ElementarySpace{𝕜}}) where {𝕜} = 𝕜

@doc """
Expand Down Expand Up @@ -241,11 +242,14 @@

"""
sectortype(a) -> Type{<:Sector}
sectortype(::Type) -> Type{<:Sector}

Return the type of sector over which object `a` (e.g. a representation space or a tensor) is
defined. Also works in type domain.
"""
sectortype(V::VectorSpace) = sectortype(typeof(V))
sectortype(x) = sectortype(typeof(x))
sectortype(::Type{T}) where {T} = sectortype(spacetype(T))
sectortype(::Type{S}) where {S<:Sector} = S

Check warning on line 252 in src/spaces/vectorspaces.jl

View check run for this annotation

Codecov / codecov/patch

src/spaces/vectorspaces.jl#L252

Added line #L252 was not covered by tests

"""
hassector(V::VectorSpace, a::Sector) -> Bool
Expand Down Expand Up @@ -274,13 +278,19 @@

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

spacetype(S::Type{<:ElementarySpace}) = S
spacetype(V::ElementarySpace) = typeof(V) # = spacetype(typeof(V))
spacetype(::Type{<:CompositeSpace{S}}) where {S} = S
spacetype(V::CompositeSpace) = spacetype(typeof(V)) # = spacetype(typeof(V))
"""
spacetype(a) -> Type{S<:IndexSpace}
spacetype(::Type) -> Type{S<:IndexSpace}

field(P::Type{<:CompositeSpace}) = field(spacetype(P))
sectortype(P::Type{<:CompositeSpace}) = sectortype(spacetype(P))
Return the type of the elementary space `S` of object `a` (e.g. a tensor). Also works in
type domain.
"""
spacetype(x) = spacetype(typeof(x))
function spacetype(::Type{T}) where {T}
throw(MethodError(spacetype, (T,)))

Check warning on line 290 in src/spaces/vectorspaces.jl

View check run for this annotation

Codecov / codecov/patch

src/spaces/vectorspaces.jl#L289-L290

Added lines #L289 - L290 were not covered by tests
end
spacetype(::Type{E}) where {E<:ElementarySpace} = E
spacetype(::Type{S}) where {E,S<:CompositeSpace{E}} = E

# make ElementarySpace instances behave similar to ProductSpace instances
blocksectors(V::ElementarySpace) = collect(sectors(V))
Expand Down
25 changes: 0 additions & 25 deletions src/tensors/abstracttensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,12 @@ Return the scalar or element type `T` of a tensor.
"""
Base.eltype(::Type{<:AbstractTensorMap{T}}) where {T} = T

"""
spacetype(::AbstractTensorMap) -> Type{S<:IndexSpace}
spacetype(::Type{<:AbstractTensorMap}) -> Type{S<:IndexSpace}

Return the type of the elementary space `S` of a tensor.
"""
spacetype(::Type{<:AbstractTensorMap{<:Any,S}}) where {S} = S

"""
sectortype(::AbstractTensorMap) -> Type{I<:Sector}
sectortype(::Type{<:AbstractTensorMap}) -> Type{I<:Sector}

Return the type of sector `I` of a tensor.
"""
sectortype(::Type{TT}) where {TT<:AbstractTensorMap} = sectortype(spacetype(TT))

function InnerProductStyle(::Type{TT}) where {TT<:AbstractTensorMap}
return InnerProductStyle(spacetype(TT))
end

"""
field(::AbstractTensorMap) -> Type{𝔽<:Field}
field(::Type{<:AbstractTensorMap}) -> Type{𝔽<:Field}

Return the type of field `𝔽` of a tensor.
"""
field(::Type{TT}) where {TT<:AbstractTensorMap} = field(spacetype(TT))

@doc """
storagetype(t::AbstractTensorMap) -> Type{A<:AbstractVector}
storagetype(T::Type{<:AbstractTensorMap}) -> Type{A<:AbstractVector}
Expand Down Expand Up @@ -190,10 +168,7 @@ end

# tensor characteristics: work on instances and pass to type
#------------------------------------------------------------
spacetype(t::AbstractTensorMap) = spacetype(typeof(t))
sectortype(t::AbstractTensorMap) = sectortype(typeof(t))
InnerProductStyle(t::AbstractTensorMap) = InnerProductStyle(typeof(t))
field(t::AbstractTensorMap) = field(typeof(t))
storagetype(t::AbstractTensorMap) = storagetype(typeof(t))
blocktype(t::AbstractTensorMap) = blocktype(typeof(t))
similarstoragetype(t::AbstractTensorMap, T=scalartype(t)) = similarstoragetype(typeof(t), T)
Expand Down
Loading