Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ComplexSpace constructor from sector-degeneracy pairs similar to that of GradedSpace? #119

Closed
leburgel opened this issue Apr 30, 2024 · 1 comment

Comments

@leburgel
Copy link
Contributor

At some point I needed a routine to increase the degeneracies in a given space while preserving its sectors. The (seemingly) simplest way to do this fails for the ComplexSpace case, since this doesn't have a constructor which takes sector-degeneracy pairs as input.

using TensorKit

function expand_degeneracies(V::ElementarySpace; fact=1.5)
    return Vect[sectortype(V)](s => ceil(Int, dim(V, s) * fact) for s in sectors(V))
end
V1 = Z2Space(0 => 2, 1 => 2)
expand_degeneracies(V1)
Rep[ℤ₂](0=>3, 1=>3)
V2 =^4
expand_degeneracies(V2)
ERROR: MethodError: no method matching ComplexSpace(::Base.Generator{TensorKit.OneOrNoneIterator{Trivial}, var"#8#9"{Float64, ComplexSpace}})

Closest candidates are:
  ComplexSpace(::Any, ::Any)
   @ TensorKit ~/.julia/packages/TensorKit/j71BN/src/spaces/complexspace.jl:9
  ComplexSpace()
   @ TensorKit ~/.julia/packages/TensorKit/j71BN/src/spaces/complexspace.jl:12
  ComplexSpace(::AbstractDict; kwargs...)
   @ TensorKit ~/.julia/packages/TensorKit/j71BN/src/spaces/complexspace.jl:21
  ...

Would it make sense to add such a constructor for ComplexSpace, since it already behaves like a GradedSpace in most cases anyway?

Also, even then the CartesianSpace case is a bit tricky, since Vect[sectortype(::CartesianSpace)] == ComplexSpace.

@lkdvos
Copy link
Collaborator

lkdvos commented May 5, 2024

I think the following should work after #120 (before, you might have to unpack the generator for Cartesian/Complex spaces

function expand_degeneracies(V::GradedSpace; factor::Real=1.5)
       dual = isdual(V)
       return spacetype(V)((dual ? conj(s) : s) => ceil(Int, dim(V, s) * factor) for s in sectors(V); dual)
end

@lkdvos lkdvos closed this as completed May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants