Skip to content

Commit

Permalink
Merge pull request #72 from kalmarek/mk/add_characters_to_DirectSummands
Browse files Browse the repository at this point in the history
add characters to direct summands
  • Loading branch information
Marek Kaluba authored Nov 29, 2023
2 parents 38d35ee + 274f971 commit 38f6c70
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
34 changes: 19 additions & 15 deletions src/direct_summands.jl
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
struct DirectSummand{T,M<:AbstractMatrix{T}} <: AbstractMatrix{T}
struct DirectSummand{T,M<:AbstractMatrix{T},Ch} <: AbstractMatrix{T}
basis::M
multiplicity::Int
degree::Int
character::Ch

function DirectSummand(
basis::M,
multiplicity::Integer,
degree::Integer,
character::Characters.Character,
) where {M<:AbstractMatrix}
@assert size(basis, 1) < size(basis, 2)
# @assert 1 ≤ degree ≤ size(basis, 1)
let (pr_rank, r) = divrem(size(basis, 1), multiplicity)
@assert 1 pr_rank degree
@assert 1 pr_rank Characters.degree(character)
@assert r == 0
end
return new{eltype(M),M}(basis, multiplicity, degree)
return new{eltype(M),M,typeof(character)}(
basis,
multiplicity,
character,
)
end
end

image_basis(ds::DirectSummand) = ds.basis
PermutationGroups.degree(ds::DirectSummand) = ds.degree
multiplicity(ds::DirectSummand) = ds.multiplicity
pr_rank(ds::DirectSummand) = div(size(image_basis(ds), 1), multiplicity(ds))
issimple(ds::DirectSummand) = isone(pr_rank(ds))

# AbstractArray API
Base.size(ds::DirectSummand) = size(ds.basis)
Base.@propagate_inbounds function Base.getindex(ds::DirectSummand, i...)
return image_basis(ds)[i...]
end

function SparseArrays.sparse(ds::DirectSummand)
sp = sparse(image_basis(ds))
return DirectSummand(sp, multiplicity(ds), degree(ds), issimple(ds))
# Accessors
image_basis(ds::DirectSummand) = ds.basis
character(ds::DirectSummand) = ds.character
multiplicity(ds::DirectSummand) = ds.multiplicity

PermutationGroups.degree(ds::DirectSummand) = Characters.degree(character(ds))
function projection_rank(ds::DirectSummand)
return div(size(image_basis(ds), 1), multiplicity(ds))
end
issimple(ds::DirectSummand) = isone(projection_rank(ds))

function SparseArrays.droptol!(
ds::DirectSummand{T,<:AbstractSparseArray},
Expand Down
18 changes: 8 additions & 10 deletions src/sa_basis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function _constituents_decomposition(ψ::Character, tbl::CharacterTable)
"Something went wrong: characters do not constitute a complete basis for action:
$(dot(multips, degrees))$(degree(ψ))"

present_irreps = [i for (i, m) in enumerate(multips) if m 0]
present_irreps = [i for (i, m) in pairs(multips) if m 0]
return irr[present_irreps], multips[present_irreps]
end

Expand All @@ -218,16 +218,15 @@ function _symmetry_adapted_basis(
multiplicities::AbstractVector{<:Integer},
hom = nothing,
)
res = map(zip(irr, multiplicities)) do (µ, m)
res = map(zip(irr, multiplicities)) do (χ, m)
Threads.@spawn begin
µT = eltype(µ) == T ? µ : Character{T}(µ)
deg = degree(µ)
χT = eltype(χ) == T ? χ : Character{T}(χ)
# here we use algebra to compute the dimension of image;
# direct summand is simple only if rk == m, i.e. deg == 1
rk = m * deg
rk = m * degree(χ)
image =
isnothing(hom) ? image_basis(µT, rk) : image_basis(hom, µT, rk)
DirectSummand(image, m, deg)
isnothing(hom) ? image_basis(χT, rk) : image_basis(hom, χT, rk)
DirectSummand(image, m, χ)
end
end
return fetch.(res)
Expand All @@ -241,17 +240,16 @@ function _symmetry_adapted_basis(
hom = nothing,
)
mps, ranks = minimal_projection_system(irr, RG)
degrees = degree.(irr)
@debug "ranks of projections obtained by mps:" degrees
res = map(zip(mps, multips, degrees, ranks)) do (µ, m, deg, r)
res = map(zip(mps, irr, multips, ranks)) do (µ, χ, m, r)
Threads.@spawn begin
µT = eltype(µ) == T ? µ : AlgebraElement{T}(µ)
# here we use algebra to compute the dimension of image;
# direct summand is simple only if rk == m, i.e. r == 1
rk = m * r
image =
isnothing(hom) ? image_basis(µT, rk) : image_basis(hom, µT, rk)
return DirectSummand(image, m, deg)
return DirectSummand(image, m, χ)
end
end
direct_summands = fetch.(res)
Expand Down

0 comments on commit 38f6c70

Please sign in to comment.