Skip to content

Commit

Permalink
import AbstractPermutations as AP, PermutationGroups as PG
Browse files Browse the repository at this point in the history
  • Loading branch information
kalmarek committed Feb 8, 2024
1 parent cab89df commit 56e117a
Show file tree
Hide file tree
Showing 19 changed files with 65 additions and 61 deletions.
5 changes: 3 additions & 2 deletions src/Characters/Characters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ using Primes
using GroupsCore
using Cyclotomics

import PermutationGroups: AbstractOrbit, degree
import PermutationGroups
import AbstractPermutations as AP
import AbstractPermutations: degree
import PermutationGroups as PG

export AbstractClassFunction, Character, CharacterTable

Expand Down
2 changes: 1 addition & 1 deletion src/Characters/character_tables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function complex_character_table(
)
end

function _inv_of(cc::AbstractVector{<:AbstractOrbit})
function _inv_of(cc::AbstractVector{<:PG.AbstractOrbit})
inv_of = zeros(Int, size(cc))
for (i, c) in enumerate(cc)
g = inv(first(c))
Expand Down
6 changes: 3 additions & 3 deletions src/Characters/chars.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ Base.:^(χ::Character, n::Integer) = Base.power_by_squaring(χ, n)

## Group-theoretic functions:

PermutationGroups.degree::Character) = Int(χ(one(parent(χ))))
function PermutationGroups.degree(
AP.degree::Character) = Int(χ(one(parent(χ))))
function AP.degree(
χ::Character{T,CCl},
) where {T,CCl<:AbstractOrbit{<:AbstractMatrix}}
) where {T,CCl<:PG.AbstractOrbit{<:AbstractMatrix}}
return Int(χ[1])
end

Expand Down
4 changes: 2 additions & 2 deletions src/Characters/cmmatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ function conjugacy_classes_orbit(G::GroupsCore.Group)
S = gens(G)
ordG = order(Int, G)

cclasses = [PermutationGroups.Orbit([id])]
cclasses = [PG.Orbit([id])]
elts_counted = 1

for g in G
any(ccl -> g ccl, cclasses) && continue
ccl_g = PermutationGroups.Orbit(g, S, conj)
ccl_g = PG.Orbit(g, S, conj)
elts_counted += length(ccl_g)
push!(cclasses, ccl_g)
elts_counted == ordG && break
Expand Down
4 changes: 2 additions & 2 deletions src/Characters/powermap.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
struct PowerMap{T<:AbstractOrbit} <: AbstractMatrix{Int}
struct PowerMap{T<:PG.AbstractOrbit} <: AbstractMatrix{Int}
cc::Vector{T}
cache::Matrix{Int}

function PowerMap(
ccG::AbstractVector{T},
exp = exponent(ccG),
) where {T<:AbstractOrbit}
) where {T<:PG.AbstractOrbit}
cache = zeros(Int, length(ccG), exp)
id = one(first(first(ccG)))
idx = findfirst(cc -> id cc, ccG)
Expand Down
4 changes: 3 additions & 1 deletion src/SymbolicWedderburn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ using Primes

using Cyclotomics
using GroupsCore
using PermutationGroups
import AbstractPermutations as AP
import AbstractPermutations: degree
import PermutationGroups as PG
using StarAlgebras

export symmetry_adapted_basis, WedderburnDecomposition
Expand Down
8 changes: 4 additions & 4 deletions src/action_characters.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## characters defined by actions/homomorphisms
function nfixedpoints(p::PermutationGroups.AbstractPermutation, deg = degree(p))
function nfixedpoints(p::AP.AbstractPermutation, deg = degree(p))
return count(i -> i^p == i, Base.OneTo(deg))
end

function _action_class_fun(
conjugacy_cls::AbstractVector{CCl},
) where {CCl<:AbstractOrbit{<:PermutationGroups.AbstractPermutation}}
) where {CCl<:PG.AbstractOrbit{<:AP.AbstractPermutation}}
deg = mapreduce(cc -> maximum(degree, cc), max, conjugacy_cls)
vals = map(conjugacy_cls) do cc
repr = first(cc)
Expand All @@ -18,7 +18,7 @@ end

function _action_class_fun(
conjugacy_cls::AbstractVector{CCl},
) where {CCl<:AbstractOrbit{<:AbstractMatrix}}
) where {CCl<:PG.AbstractOrbit{<:AbstractMatrix}}
vals = [tr(first(cc)) for cc in conjugacy_cls]
return Characters.ClassFunction(vals, conjugacy_cls)
end
Expand All @@ -27,7 +27,7 @@ function _action_class_fun(
hom::InducedActionHomomorphism{<:ByPermutations},
conjugacy_cls,
)
deg = degree(hom)
deg = AP.degree(hom)
vals = map(conjugacy_cls) do cc
repr = induce(hom, first(cc))
return nfixedpoints(repr, deg)
Expand Down
6 changes: 4 additions & 2 deletions src/actions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract type ByPermutations <: Action end

function action(
::ByPermutations,
g::PermutationGroups.AbstractPermutation,
g::AP.AbstractPermutation,
v::AbstractVector,
)
return [v[i^g] for i in eachindex(v)]
Expand All @@ -40,7 +40,9 @@ coeff_type(::ByPermutations) = Int

function induce(::ByPermutations, hom::ExtensionHomomorphism, g::GroupElement)
I = _int_type(hom)
return Perm{I}(vec(I[hom[action(action(hom), g, f)] for f in basis(hom)]))
return PG.Perm{I}(
vec(I[hom[action(action(hom), g, f)] for f in basis(hom)]),
)
end

"""
Expand Down
4 changes: 2 additions & 2 deletions src/direct_summands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct DirectSummand{T,M<:AbstractMatrix{T},Ch} <: AbstractMatrix{T}
) where {M<:AbstractMatrix}
@assert size(basis, 1) < size(basis, 2)
let (pr_rank, r) = divrem(size(basis, 1), multiplicity)
@assert 1 pr_rank Characters.degree(character)
@assert 1 pr_rank AP.degree(character)
@assert r == 0
end
return new{eltype(M),M,typeof(character)}(
Expand All @@ -32,7 +32,7 @@ image_basis(ds::DirectSummand) = ds.basis
character(ds::DirectSummand) = ds.character
multiplicity(ds::DirectSummand) = ds.multiplicity

PermutationGroups.degree(ds::DirectSummand) = Characters.degree(character(ds))
AP.degree(ds::DirectSummand) = AP.degree(character(ds))
function projection_rank(ds::DirectSummand)
return div(size(image_basis(ds), 1), multiplicity(ds))
end
Expand Down
2 changes: 1 addition & 1 deletion src/ext_homomorphisms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function Base.getindex(hom::InducedActionHomomorphism{A,T}, f::T) where {A,T}
return basis(hom)[f]
end

PermutationGroups.degree(hom::InducedActionHomomorphism) = length(basis(hom))
AP.degree(hom::InducedActionHomomorphism) = length(basis(hom))

coeff_type(hom::InducedActionHomomorphism) = coeff_type(action(hom))
_int_type(::Type{<:StarAlgebras.AbstractBasis{T,I}}) where {T,I} = I
Expand Down
12 changes: 5 additions & 7 deletions src/matrix_projections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,7 @@ end
function matrix_projection_irr_acc!(
result::AbstractMatrix,
vals,
ccls::AbstractVector{
<:AbstractOrbit{<:PermutationGroups.AbstractPermutation},
},
ccls::AbstractVector{<:PG.AbstractOrbit{<:AP.AbstractPermutation}},
weight,
)
iszero(weight) && return result
Expand All @@ -189,7 +187,7 @@ end
function matrix_projection_irr_acc!(
res::AbstractMatrix,
vals,
ccls::AbstractVector{<:AbstractOrbit{<:AbstractMatrix}},
ccls::AbstractVector{<:PG.AbstractOrbit{<:AbstractMatrix}},
weight,
)
# TODO: call to inv(Matrix(g)) is a dirty hack, since if `g`
Expand Down Expand Up @@ -234,7 +232,7 @@ function matrix_projection_irr_acc!(
w = weight * val
for g in ccl
h = induce(hom, g)
@assert h isa PermutationGroups.Perm
@assert h isa PG.Perm
for i in 1:size(result, 1)
push!(I, i)
push!(J, i^h)
Expand Down Expand Up @@ -294,7 +292,7 @@ end
function matrix_representation_acc!(
result::AbstractMatrix,
α::AlgebraElement{
<:StarAlgebra{<:PermutationGroups.AbstractPermutationGroup},
<:StarAlgebra{<:PG.AbstractPermutationGroup},
},
)
b = basis(parent(α))
Expand Down Expand Up @@ -326,7 +324,7 @@ function matrix_representation_acc!(
for (idx, val) in StarAlgebras._nzpairs(StarAlgebras.coeffs(α))
iszero(val) && continue
g = induce(hom, b[idx])
@assert g isa PermutationGroups.Perm
@assert g isa PG.Perm
for i in 1:size(result, 1)
push!(I, i)
push!(J, i^g)
Expand Down
4 changes: 2 additions & 2 deletions src/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ PrecompileTools.@setup_workload begin
end

struct OnLetters <: ByPermutations end
function action(::OnLetters, p::PermutationGroups.AbstractPermutation, w::Word)
function action(::OnLetters, p::AP.AbstractPermutation, w::Word)
return Word(w.alphabet, [w.letters[i]^p for i in eachindex(w.letters)])
end

Expand All @@ -46,7 +46,7 @@ PrecompileTools.@setup_workload begin
act = OnLetters()

PrecompileTools.@compile_workload begin
G = PermGroup(perm"(1,2,3)", perm"(1,2)")
G = PG.PermGroup(PG.perm"(1,2,3)", PG.perm"(1,2)")
wd = WedderburnDecomposition(Rational{Int}, G, act, words, words)
wdfl = WedderburnDecomposition(Float64, G, act, words, words)
end
Expand Down
4 changes: 2 additions & 2 deletions src/sa_basis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function affordable_real(
end

function symmetry_adapted_basis(
G::PermutationGroups.AbstractPermutationGroup,
G::PG.AbstractPermutationGroup,
S::Type = Rational{Int};
semisimple::Bool = false,
)
Expand Down Expand Up @@ -79,7 +79,7 @@ overflow occurs during the computation of characters) specifying
"""
function symmetry_adapted_basis(
T::Type,
G::PermutationGroups.AbstractPermutationGroup,
G::PG.AbstractPermutationGroup,
S::Type = Rational{Int};
semisimple::Bool = false,
)
Expand Down
12 changes: 6 additions & 6 deletions test/action_permutation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ end
struct OnLetters <: SymbolicWedderburn.ByPermutations end
function SymbolicWedderburn.action(
::OnLetters,
p::PermutationGroups.AbstractPermutation,
p::AP.AbstractPermutation,
w::Word,
)
return Word(w.alphabet, [w.letters[i]^p for i in eachindex(w.letters)])
Expand All @@ -29,7 +29,7 @@ end
struct OnLettersSigned <: SymbolicWedderburn.BySignedPermutations end
function SymbolicWedderburn.action(
::OnLettersSigned,
p::PermutationGroups.AbstractPermutation,
p::AP.AbstractPermutation,
w::Word,
)
return (Word(w.alphabet, [w.letters[i]^p for i in eachindex(w.letters)]), 1)
Expand All @@ -54,13 +54,13 @@ end
w = Word(A, [1, 2, 3, 2, 1])

# (a·b·c·b·a)^(2,3) == a·c·b·c·a
@test SymbolicWedderburn.action(OnLetters(), perm"(2,3)", w) ==
@test SymbolicWedderburn.action(OnLetters(), PG.perm"(2,3)", w) ==
Word(A, [1, 3, 2, 3, 1])

words = allwords(A, radius)
end

G = PermGroup(perm"(1,2,3)", perm"(1,2)") # G acts on words permuting letters
G = PG.PermGroup(PG.perm"(1,2,3)", PG.perm"(1,2)") # G acts on words permuting letters

@test SymbolicWedderburn.check_group_action(G, OnLetters(), words)
@test SymbolicWedderburn.check_group_action(G, OnLettersSigned(), words)
Expand All @@ -75,7 +75,7 @@ end
precompute = true,
)
@test all(g keys(ehom.cache) for g in G) # we actually cached
@test typeof(SymbolicWedderburn.induce(ehom, one(G))) == Perm{Int32}
@test typeof(SymbolicWedderburn.induce(ehom, one(G))) == PG.Perm{Int32}

ehom = SymbolicWedderburn.CachedExtensionHomomorphism(
G,
Expand All @@ -84,7 +84,7 @@ end
precompute = true,
)
@test all(g keys(ehom.cache) for g in G) # we actually cached
@test typeof(SymbolicWedderburn.induce(ehom, one(G))) == Perm{UInt32} # the default
@test typeof(SymbolicWedderburn.induce(ehom, one(G))) == PG.Perm{UInt32} # the default

ψ = SymbolicWedderburn.action_character(ehom, tbl)
@test SymbolicWedderburn.multiplicities(ψ) == [22, 18, 40]
Expand Down
2 changes: 1 addition & 1 deletion test/ccmatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ end
AbstractVector{<:AbstractOrbit}

for cc in Characters.conjugacy_classes(G)
@test all(permtype(g) == permtype(first(cc)) for g in cc)
@test all(AP.permtype(g) == AP.permtype(first(cc)) for g in cc)
end

C = Characters.conjugacy_classes(G)
Expand Down
2 changes: 1 addition & 1 deletion test/characters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@test 2ψ / 2 == χ
@test 2ψ != χ

@test PermutationGroups.degree(χ) == 2
@test AP.degree(χ) == 2

# @test size(SymbolicWedderburn.image_basis(χ), 1) == 4

Expand Down
10 changes: 5 additions & 5 deletions test/projections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ end
end
@test test_orthogonality(chars)
@test sum(first size, SymbolicWedderburn.image_basis.(chars)) ==
PermutationGroups.degree(G)
AP.degree(G)

G = PermGroup([perm"(1,2,3,4)", perm"(1,2)"])
chars = SymbolicWedderburn.irreducible_characters(G)
@test test_orthogonality(chars)
@test sum(first size, SymbolicWedderburn.image_basis.(chars)) ==
PermutationGroups.degree(G)
AP.degree(G)

G = PermGroup([perm"(1,2,3)", perm"(2,3,4)"])
chars = SymbolicWedderburn.irreducible_characters(G)
@test test_orthogonality(chars)
@test sum(first size, SymbolicWedderburn.image_basis.(chars)) ==
PermutationGroups.degree(G)
AP.degree(G)

@time for ord in 2:16
# @testset "SmallGroup($ord, $n)"
Expand All @@ -49,14 +49,14 @@ end
@test test_orthogonality(chars)

@test sum(first size SymbolicWedderburn.image_basis, chars) ==
PermutationGroups.degree(G)
AP.degree(G)

mps, _ = SymbolicWedderburn.minimal_projection_system(
chars,
SymbolicWedderburn._group_algebra(G),
)
@test sum(first size SymbolicWedderburn.image_basis, mps)
PermutationGroups.degree(G)
AP.degree(G)
end
end
end
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ using LinearAlgebra
using SparseArrays

using GroupsCore
using PermutationGroups
import AbstractPermutations as AP
import PermutationGroups as PG
using Cyclotomics

using SymbolicWedderburn
Expand Down
Loading

0 comments on commit 56e117a

Please sign in to comment.