Skip to content

Commit

Permalink
Refactor deligne field test in a function
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Sep 29, 2023
1 parent f7f37cb commit b84f8f0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
33 changes: 18 additions & 15 deletions src/spaces/deligne.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,52 +12,51 @@ The Deligne tensor product also works in the type domain and for sectors and ten
group representations, we have `Rep[G₁] ⊠ Rep[G₂] == Rep[G₁ × G₂]`, i.e. these are the
natural representation spaces of the direct product of two groups.
"""
(V₁::VectorSpace, V₂::VectorSpace) = (V₁ one(V₂)) (one(V₁) V₂)
function (V₁::VectorSpace, V₂::VectorSpace)
check_fields_deligne(V₁, V₂)
return (V₁ one(V₂)) (one(V₁) V₂)
end

# define deligne products with empty tensor product: just add a trivial sector of the type of the empty space to each of the sectors in the non-empty space
# define deligne products with empty tensor product: just add a trivial sector of the type
# of the empty space to each of the sectors in the non-empty space
function (V::GradedSpace, P₀::ProductSpace{<:ElementarySpace,0})
field(V) == field(P₀) || throw(ArgumentError("Deligne products require spaces over the same field"))
check_fields_deligne(V, P₀)
I₁ = sectortype(V)
I₂ = sectortype(P₀)
return Vect[I₁ I₂](ifelse(isdual(V), dual(c), c) one(I₂) => dim(V, c)
for c in sectors(V); dual=isdual(V))
end

function (P₀::ProductSpace{<:ElementarySpace,0}, V::GradedSpace)
field(V) == field(P₀) ||
throw(ArgumentError("Deligne products require spaces over the same field"))
check_fields_deligne(V, P₀)
I₁ = sectortype(P₀)
I₂ = sectortype(V)
return Vect[I₁ I₂](one(I₁) ifelse(isdual(V), dual(c), c) => dim(V, c)
for c in sectors(V); dual=isdual(V))
end

function (V::ComplexSpace, P₀::ProductSpace{<:ElementarySpace,0})
field(V) == field(P₀) ||
throw(ArgumentError("Deligne products require spaces over the same field"))
check_fields_deligne(V, P₀)
I₂ = sectortype(P₀)
return Vect[I₂](one(I₂) => dim(V); dual=isdual(V))
end

function (P₀::ProductSpace{<:ElementarySpace,0}, V::ComplexSpace)
field(V) == field(P₀) ||
throw(ArgumentError("Deligne products require spaces over the same field"))
check_fields_deligne(V, P₀)
I₁ = sectortype(P₀)
return Vect[I₁](one(I₁) => dim(V); dual=isdual(V))
end

function (P::ProductSpace{<:ElementarySpace,0},
P₀::ProductSpace{<:ElementarySpace,0})
field(P) == field(P₀) ||
throw(ArgumentError("Deligne products require spaces over the same field"))
check_fields_deligne(P, P₀)
I₁ = sectortype(P)
I₂ = sectortype(P₀)
return one(Vect[I₁ I₂])
end

function (P::ProductSpace{<:ElementarySpace}, P₀::ProductSpace{<:ElementarySpace,0})
field(P) == field(P₀) ||
throw(ArgumentError("Deligne products require spaces over the same field"))
check_fields_deligne(P, P₀)
I₁ = sectortype(P)
I₂ = sectortype(P₀)
S = Vect[I₁ I₂]
Expand All @@ -66,11 +65,15 @@ function ⊠(P::ProductSpace{<:ElementarySpace}, P₀::ProductSpace{<:Elementary
end

function (P₀::ProductSpace{<:ElementarySpace,0}, P::ProductSpace{<:ElementarySpace})
field(P) == field(P₀) ||
throw(ArgumentError("Deligne products require spaces over the same field"))
check_fields_deligne(P, P₀)
I₁ = sectortype(P₀)
I₂ = sectortype(P)
S = Vect[I₁ I₂]
N = length(P)
return ProductSpace{S,N}(map(V -> P₀ V, tuple(P...)))
end

@noinline function check_fields_deligne(P₁, P₂)
return field(P₁) == field(P₂) ||
throw(ArgumentError("Deligne products require spaces over the same field"))
end
2 changes: 1 addition & 1 deletion src/spaces/productspace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,4 @@ Base.convert(::Type{S}, P::ProductSpace{S,0}) where {S<:ElementarySpace} = oneun
Base.convert(::Type{S}, P::ProductSpace{S}) where {S<:ElementarySpace} = fuse(P.spaces...)

# ElementarySpace to ProductSpace
Base.convert(::Type{<:ProductSpace}, V::S) where {S<:ElementarySpace} = (V)
Base.convert(::Type{<:ProductSpace}, V::S) where {S<:ElementarySpace} = (V)

0 comments on commit b84f8f0

Please sign in to comment.