From 56e117a53d0564070f9d9346501e8d0f856a113d Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Thu, 8 Feb 2024 01:00:07 +0100 Subject: [PATCH] import AbstractPermutations as AP, PermutationGroups as PG --- src/Characters/Characters.jl | 5 +++-- src/Characters/character_tables.jl | 2 +- src/Characters/chars.jl | 6 +++--- src/Characters/cmmatrix.jl | 4 ++-- src/Characters/powermap.jl | 4 ++-- src/SymbolicWedderburn.jl | 4 +++- src/action_characters.jl | 8 ++++---- src/actions.jl | 6 ++++-- src/direct_summands.jl | 4 ++-- src/ext_homomorphisms.jl | 2 +- src/matrix_projections.jl | 12 +++++------ src/precompile.jl | 4 ++-- src/sa_basis.jl | 4 ++-- test/action_permutation.jl | 12 +++++------ test/ccmatrix.jl | 2 +- test/characters.jl | 2 +- test/projections.jl | 10 +++++----- test/runtests.jl | 3 ++- test/sa_basis.jl | 32 +++++++++++++++--------------- 19 files changed, 65 insertions(+), 61 deletions(-) diff --git a/src/Characters/Characters.jl b/src/Characters/Characters.jl index 41a0cc8..8fecbd2 100644 --- a/src/Characters/Characters.jl +++ b/src/Characters/Characters.jl @@ -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 diff --git a/src/Characters/character_tables.jl b/src/Characters/character_tables.jl index f84e894..b49aa8f 100644 --- a/src/Characters/character_tables.jl +++ b/src/Characters/character_tables.jl @@ -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)) diff --git a/src/Characters/chars.jl b/src/Characters/chars.jl index 90fac44..65f6146 100644 --- a/src/Characters/chars.jl +++ b/src/Characters/chars.jl @@ -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 diff --git a/src/Characters/cmmatrix.jl b/src/Characters/cmmatrix.jl index deefe2f..8f991e5 100644 --- a/src/Characters/cmmatrix.jl +++ b/src/Characters/cmmatrix.jl @@ -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 diff --git a/src/Characters/powermap.jl b/src/Characters/powermap.jl index 702fa66..eb80f17 100644 --- a/src/Characters/powermap.jl +++ b/src/Characters/powermap.jl @@ -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) diff --git a/src/SymbolicWedderburn.jl b/src/SymbolicWedderburn.jl index 4c4f913..2bf05c2 100644 --- a/src/SymbolicWedderburn.jl +++ b/src/SymbolicWedderburn.jl @@ -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 diff --git a/src/action_characters.jl b/src/action_characters.jl index 21fb840..7bbca58 100644 --- a/src/action_characters.jl +++ b/src/action_characters.jl @@ -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) @@ -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 @@ -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) diff --git a/src/actions.jl b/src/actions.jl index e8b80a4..95b7bad 100644 --- a/src/actions.jl +++ b/src/actions.jl @@ -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)] @@ -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 """ diff --git a/src/direct_summands.jl b/src/direct_summands.jl index 9c60c0e..fcf19e9 100644 --- a/src/direct_summands.jl +++ b/src/direct_summands.jl @@ -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)}( @@ -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 diff --git a/src/ext_homomorphisms.jl b/src/ext_homomorphisms.jl index a3f6170..186baa0 100644 --- a/src/ext_homomorphisms.jl +++ b/src/ext_homomorphisms.jl @@ -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 diff --git a/src/matrix_projections.jl b/src/matrix_projections.jl index 42afb33..b79fb94 100644 --- a/src/matrix_projections.jl +++ b/src/matrix_projections.jl @@ -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 @@ -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` @@ -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) @@ -294,7 +292,7 @@ end function matrix_representation_acc!( result::AbstractMatrix, α::AlgebraElement{ - <:StarAlgebra{<:PermutationGroups.AbstractPermutationGroup}, + <:StarAlgebra{<:PG.AbstractPermutationGroup}, }, ) b = basis(parent(α)) @@ -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) diff --git a/src/precompile.jl b/src/precompile.jl index 1f6c774..2b17e88 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -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 @@ -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 diff --git a/src/sa_basis.jl b/src/sa_basis.jl index a490f80..e14792a 100644 --- a/src/sa_basis.jl +++ b/src/sa_basis.jl @@ -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, ) @@ -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, ) diff --git a/test/action_permutation.jl b/test/action_permutation.jl index accd24a..862c3c6 100644 --- a/test/action_permutation.jl +++ b/test/action_permutation.jl @@ -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)]) @@ -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) @@ -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) @@ -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, @@ -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] diff --git a/test/ccmatrix.jl b/test/ccmatrix.jl index 401750a..e267888 100644 --- a/test/ccmatrix.jl +++ b/test/ccmatrix.jl @@ -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) diff --git a/test/characters.jl b/test/characters.jl index 36f5977..d02e065 100644 --- a/test/characters.jl +++ b/test/characters.jl @@ -32,7 +32,7 @@ @test 2ψ / 2 == χ @test 2ψ != χ - @test PermutationGroups.degree(χ) == 2 + @test AP.degree(χ) == 2 # @test size(SymbolicWedderburn.image_basis(χ), 1) == 4 diff --git a/test/projections.jl b/test/projections.jl index dd1a85a..5c3b716 100644 --- a/test/projections.jl +++ b/test/projections.jl @@ -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)" @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index 34f316f..6c16ad8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,7 +4,8 @@ using LinearAlgebra using SparseArrays using GroupsCore -using PermutationGroups +import AbstractPermutations as AP +import PermutationGroups as PG using Cyclotomics using SymbolicWedderburn diff --git a/test/sa_basis.jl b/test/sa_basis.jl index ee9101c..46d8414 100644 --- a/test/sa_basis.jl +++ b/test/sa_basis.jl @@ -64,7 +64,7 @@ end @test dot( multiplicity.(sa_basis_ssimple), SymbolicWedderburn.degree.(sa_basis_ssimple), - ) == PermutationGroups.degree(G) + ) == AP.degree(G) sa_basis = symmetry_adapted_basis( Rational{Int}, @@ -81,25 +81,25 @@ end S₄ = PermGroup([perm"(1,2,3,4)", perm"(1,2)"]) sa_basis = symmetry_adapted_basis(C₄; semisimple = true) - @test sum(first ∘ size, sa_basis) == PermutationGroups.degree(C₄) + @test sum(first ∘ size, sa_basis) == AP.degree(C₄) sa_basis = symmetry_adapted_basis(A₄; semisimple = true) - @test sum(first ∘ size, sa_basis) == PermutationGroups.degree(A₄) + @test sum(first ∘ size, sa_basis) == AP.degree(A₄) sa_basis = symmetry_adapted_basis(S₄; semisimple = true) - @test sum(first ∘ size, sa_basis) == PermutationGroups.degree(S₄) + @test sum(first ∘ size, sa_basis) == AP.degree(S₄) sa_basis = symmetry_adapted_basis(ComplexF64, C₄; semisimple = true) - @test sum(first ∘ size, sa_basis) == PermutationGroups.degree(C₄) + @test sum(first ∘ size, sa_basis) == AP.degree(C₄) sa_basis = symmetry_adapted_basis(ComplexF64, A₄; semisimple = true) - @test sum(first ∘ size, sa_basis) == PermutationGroups.degree(A₄) + @test sum(first ∘ size, sa_basis) == AP.degree(A₄) sa_basis = symmetry_adapted_basis(ComplexF64, S₄; semisimple = true) - @test sum(first ∘ size, sa_basis) == PermutationGroups.degree(S₄) + @test sum(first ∘ size, sa_basis) == AP.degree(S₄) sa_basis = symmetry_adapted_basis(Float64, C₄; semisimple = true) - @test sum(first ∘ size, sa_basis) == PermutationGroups.degree(C₄) + @test sum(first ∘ size, sa_basis) == AP.degree(C₄) sa_basis = symmetry_adapted_basis(Float64, A₄; semisimple = true) - @test sum(first ∘ size, sa_basis) == PermutationGroups.degree(A₄) + @test sum(first ∘ size, sa_basis) == AP.degree(A₄) sa_basis = symmetry_adapted_basis(Float64, S₄; semisimple = true) - @test sum(first ∘ size, sa_basis) == PermutationGroups.degree(S₄) + @test sum(first ∘ size, sa_basis) == AP.degree(S₄) end @testset "Symmetry adapted basis: small groups" begin @@ -115,10 +115,10 @@ end @test dot( SymbolicWedderburn.degree.(sa_basis), multiplicity.(sa_basis), - ) == PermutationGroups.degree(G) + ) == AP.degree(G) @test sum(first ∘ size, sa_basis) == - PermutationGroups.degree(G) + AP.degree(G) S = if (ord, n) in ((26, 1),) Rational{BigInt} @@ -145,9 +145,9 @@ end @test dot( SymbolicWedderburn.degree.(sa_basisR), multiplicity.(sa_basisR), - ) == PermutationGroups.degree(G) + ) == AP.degree(G) @test sum(first ∘ size, sa_basisR) == - PermutationGroups.degree(G) + AP.degree(G) sa_basisR = symmetry_adapted_basis( Float64, @@ -183,11 +183,11 @@ end return rank(b) == size(b, 1) end - @test sum(first ∘ size, sa_basis) == PermutationGroups.degree(G) + @test sum(first ∘ size, sa_basis) == AP.degree(G) basisC = symmetry_adapted_basis(Complex{T}, G; semisimple = true) - @test sum(first ∘ size, basisC) == PermutationGroups.degree(G) + @test sum(first ∘ size, basisC) == AP.degree(G) end end end