Skip to content

Commit

Permalink
Merge pull request #30 from kalmarek/mk/update_PG_0_4
Browse files Browse the repository at this point in the history
update to PermutationGroups-0.4
  • Loading branch information
Marek Kaluba authored Aug 26, 2023
2 parents d385992 + 22cf629 commit 866e431
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Groups"
uuid = "5d8bd718-bd84-11e8-3b40-ad14f4a32557"
authors = ["Marek Kaluba <[email protected]>"]
version = "0.7.7"
version = "0.7.8"

[deps]
GroupsCore = "d5909c97-4eac-4ecc-a3dc-fdd0858a4120"
Expand All @@ -17,7 +17,7 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
GroupsCore = "0.4"
KnuthBendix = "0.4"
OrderedCollections = "1"
PermutationGroups = "0.3"
PermutationGroups = "0.4"
StaticArrays = "1"
julia = "1.6"

Expand Down
28 changes: 18 additions & 10 deletions src/constructions/wreath_product.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import PermutationGroups:
AbstractPermutationGroup, AbstractPerm, degree, SymmetricGroup
AbstractPermutationGroup,
AbstractPermutation,
degree

"""
WreathProduct(G::Group, P::AbstractPermutationGroup) <: Group
Expand Down Expand Up @@ -27,7 +29,7 @@ end

struct WreathProductElement{
DPEl<:DirectPowerElement,
PEl<:AbstractPerm,
PEl<:AbstractPermutation,
Wr<:WreathProduct,
} <: GroupsCore.GroupElement
n::DPEl
Expand All @@ -36,7 +38,7 @@ struct WreathProductElement{

function WreathProductElement(
n::DirectPowerElement,
p::AbstractPerm,
p::AbstractPermutation,
W::WreathProduct,
)
return new{typeof(n),typeof(p),typeof(W)}(n, p, W)
Expand All @@ -53,16 +55,19 @@ function Base.iterate(G::WreathProduct)
itr = Iterators.product(G.N, G.P)
res = iterate(itr)
@assert res !== nothing
elt = WreathProductElement(first(res)..., G)
return elt, (iterator = itr, state = last(res))
ab, st = res
(a, b) = ab
elt = WreathProductElement(a, b, G)
return elt, (itr, st)
end

function Base.iterate(G::WreathProduct, state)
itr, st = state.iterator, state.state
itr, st = state
res = iterate(itr, st)
res === nothing && return nothing
elt = WreathProductElement(first(res)..., G)
return elt, (iterator = itr, state = last(res))
(a::eltype(G.N), b::eltype(G.P)), st = res
elt = WreathProductElement(a, b, G)
return elt, (itr, st)
end

function Base.IteratorSize(::Type{<:WreathProduct{DP,PGr}}) where {DP,PGr}
Expand Down Expand Up @@ -118,8 +123,11 @@ function Base.deepcopy_internal(g::WreathProductElement, stackdict::IdDict)
)
end

function _act(p::AbstractPerm, n::DirectPowerElement)
return DirectPowerElement(n.elts^p, parent(n))
function _act(p::AbstractPermutation, n::DirectPowerElement)
return DirectPowerElement(
ntuple(i -> n.elts[i^p], length(n.elts)),
parent(n),
)
end

function Base.inv(g::WreathProductElement)
Expand Down
7 changes: 4 additions & 3 deletions test/AutSigma3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@test contains(sprint(print, π₁Σ), "surface")

Groups.PermRightAut(p::Perm) = Groups.PermRightAut(p.d)
Groups.PermRightAut(p::Perm) = Groups.PermRightAut([i^p for i in 1:2genus])
# Groups.PermLeftAut(p::Perm) = Groups.PermLeftAut(p.d)
autπ₁Σ = let autπ₁Σ = AutomorphismGroup(π₁Σ)
pauts = let p = perm"(1,3,5)(2,4,6)"
Expand Down Expand Up @@ -50,8 +50,9 @@
@test π₁Σ.(word.(z)) == Groups.domain(first(S))
d = Groups.domain(first(S))
p = perm"(1,3,5)(2,4,6)"
@test Groups.evaluate!(deepcopy(d), τ) == d^inv(p)
@test Groups.evaluate!(deepcopy(d), τ^2) == d^p
@test Groups.evaluate!(deepcopy(d), τ) ==
ntuple(i -> d[i^inv(p)], length(d))
@test Groups.evaluate!(deepcopy(d), τ^2) == ntuple(i -> d[i^p], length(d))

E, sizes = Groups.wlmetric_ball(S, radius=3)
@test sizes == [49, 1813, 62971]
Expand Down
10 changes: 5 additions & 5 deletions test/group_constructions.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
@testset "GroupConstructions" begin

symmetric_group(n) = PermGroup(perm"(1,2)", Perm([2:n; 1]))

@testset "DirectProduct" begin
GH =
let G = PermutationGroups.SymmetricGroup(3),
H = PermutationGroups.SymmetricGroup(4)
let G = symmetric_group(3), H = symmetric_group(4)

Groups.Constructions.DirectProduct(G, H)
end
Expand All @@ -17,7 +18,7 @@

@testset "DirectPower" begin
GGG = Groups.Constructions.DirectPower{3}(
PermutationGroups.SymmetricGroup(3),
symmetric_group(3),
)
test_Group_interface(GGG)
test_GroupElement_interface(rand(GGG, 2)...)
Expand All @@ -28,8 +29,7 @@
end
@testset "WreathProduct" begin
W =
let G = PermutationGroups.SymmetricGroup(2),
P = PermutationGroups.SymmetricGroup(4)
let G = symmetric_group(2), P = symmetric_group(4)

Groups.Constructions.WreathProduct(G, P)
end
Expand Down

2 comments on commit 866e431

@kalmarek
Copy link
Owner

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/90319

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.7.8 -m "<description of version>" 866e431c1aa184fd6a223431c69315aec91f6b7a
git push origin v0.7.8

Please sign in to comment.