Skip to content

Commit

Permalink
Only return multiplicities from blockdiag (#11)
Browse files Browse the repository at this point in the history
* Only return multiplicities from blockdiag

* Update README.md
  • Loading branch information
dlfivefifty authored Oct 20, 2024
1 parent b129d05 commit fa8840d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NumericalRepresentationTheory"
uuid = "6b7c1d51-ecee-4149-97a8-50646b514dce"
authors = ["Sheehan Olver <[email protected]>"]
version = "0.3.0"
version = "0.4.0"

[deps]
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 34 additions & 8 deletions src/NumericalRepresentationTheory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down Expand Up @@ -513,9 +544,7 @@ function blockdiagonalize(ρ::Representation)
n = length.generators)+1

= similar(Q)
# diagonalised generators
ρd = float.(zero.(ρ.generators))

# diagonalised generators
c = contents2partition(Λ)

k = 0
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

2 comments on commit fa8840d

@dlfivefifty
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/119102

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.0 -m "<description of version>" fa8840d405f262186bd4049fa5517a84ece8e0fa
git push origin v0.4.0

Please sign in to comment.