diff --git a/Project.toml b/Project.toml index ed2c089..53f4c4d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "NumericalRepresentationTheory" uuid = "6b7c1d51-ecee-4149-97a8-50646b514dce" authors = ["Sheehan Olver "] -version = "0.3.0" +version = "0.4.0" [deps] BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" diff --git a/README.md b/README.md index 861d489..500d3cf 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,9 @@ julia> plot(multiplicities(R)) # We can also plot In addition, one can find an orthogonal transformation that reduces a representation to irreducibles: ```julia -julia> ρ,Q = blockdiagonalize(R); # Q'R(g)*Q ≈ ρ(g) where ρ is a direct sum (block diagonal) of irreducibles. +julia> λ,Q = blockdiagonalize(R); # Q'R(g)*Q ≈ ρ(g) where ρ = Representation(λ) is a direct sum (block diagonal) of irreducibles encoded by the dictionary λ. + +julia> ρ = Representation(λ); julia> Q'R(g)*Q ≈ ρ(g) true diff --git a/src/NumericalRepresentationTheory.jl b/src/NumericalRepresentationTheory.jl index d97c96a..3c6c285 100644 --- a/src/NumericalRepresentationTheory.jl +++ b/src/NumericalRepresentationTheory.jl @@ -278,15 +278,46 @@ end irrepgenerators(σ::Partition) = [irrepgenerator(σ, i) for i=1:Int(σ)-1] +""" + Representation([τ₁,…,τₙ]) +is a representation of the symmetric group generated by τ₁,…,τₙ. +""" struct Representation{MT} generators::Vector{MT} end + +""" + Representation(λ₁::Int, …, λₙ::Int) + Representation(Partition(λ₁, …, λₙ)) + +both generate the irreducible representation associated with the given partition. +""" Representation(σ::Int...) = Representation(Partition(σ...)) Representation(σ::Partition) = Representation(irrepgenerators(σ)) Representation{MT}(ρ::Representation) where MT = Representation(convert.(MT, ρ.generators)) + +""" + Representation(::Dict{Partition,Int}) + +makes a representation corresponding to a direct sum of the irreducible representations encoded in +by the partitions. The partitions are sorted for a consistent ordering. +""" +function Representation(d::Dict{Partition,Int}) + kys = sort(collect(keys(d))) + + reps = Representation{SparseMatrixCSC{Float64,Int}}[] + for k in kys + irrep = Representation(k) + for j in 1:d[k] + push!(reps, irrep) + end + end + blockdiag(reps...) +end + kron(A::Representation, B::Representation) = Representation(kron.(A.generators, B.generators)) _blockdiag(A::AbstractSparseMatrixCSC...) = blockdiag(A...) @@ -513,9 +544,7 @@ function blockdiagonalize(ρ::Representation) n = length(ρ.generators)+1 Q̃ = similar(Q) - # diagonalised generators - ρd = float.(zero.(ρ.generators)) - + # diagonalised generators c = contents2partition(Λ) k = 0 @@ -526,13 +555,10 @@ function blockdiagonalize(ρ::Representation) Q̃ⱼ = singlemultreduce_blockdiag(ρⱼ, Representation(pⱼ)) m = length(j) Q̃[:,k+1:k+m] = Qⱼ * Q̃ⱼ - irrep = Representation(pⱼ) - for ℓ = 1:n-1 - ρd[ℓ][k+1:k+m,k+1:k+m] = blockdiag(fill(irrep.generators[ℓ], m÷size(irrep,1))...) - end k += m end - Representation(ρd), Q̃ + + multiplicities(c), Q̃ end function contents2partition(part::Vector) diff --git a/test/runtests.jl b/test/runtests.jl index b351564..10017ba 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -20,9 +20,9 @@ import NumericalRepresentationTheory: gelfandbasis, canonicalprojection, singlem ρ = Representation(Partition([3,2])) ⊗ Representation(Partition([2,2,1])) ⊗ Representation(Partition([3,1,1])) λ,Q = blockdiagonalize(ρ) - - for k = 1:length(λ.generators) - @test Q' * ρ.generators[k] * Q ≈ λ.generators[k] + irreps = Representation(λ) + for k = 1:length(ρ.generators) + @test Q' * ρ.generators[k] * Q ≈ irreps.generators[k] end @testset "Rotate irrep" begin