Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is_left and is_right for SubgroupTransversal #4298

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions src/Groups/cosets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
end

function Base.show(io::IO, ::MIME"text/plain", x::GroupCoset)
side = x.side === :left ? "Left" : "Right"
side = is_left(x) ? "Left" : "Right"
io = pretty(io)
println(io, "$side coset of ", Lowercase(), x.H)
print(io, Indent())
Expand All @@ -57,7 +57,7 @@
end

function Base.show(io::IO, x::GroupCoset)
side = x.side === :left ? "Left" : "Right"
side = is_left(x) ? "Left" : "Right"
if is_terse(io)
print(io, "$side coset of a group")
else
Expand Down Expand Up @@ -146,7 +146,7 @@

function Base.:*(c::GroupCoset, y::GAPGroupElem)
@assert y in c.G "element not in the group"
if c.side == :right
if is_right(c)
return right_coset(c.H, representative(c)*y)
else
return left_coset(c.H^y, representative(c)*y)
Expand All @@ -155,15 +155,15 @@

function Base.:*(y::GAPGroupElem, c::GroupCoset)
@assert y in c.G "element not in the group"
if c.side == :left
if is_left(c)
return left_coset(c.H, y*representative(c))
else
return right_coset(c.H^(y^-1), y*representative(c))
end
end

function Base.:*(c::GroupCoset, d::GroupCoset)
@req (c.side == :right && d.side == :left) "Wrong input"
@req (is_right(c) && is_left(d)) "Wrong input"
return double_coset(c.H, representative(c)*representative(d), d.H)
end

Expand Down Expand Up @@ -325,11 +325,14 @@
SubgroupTransversal{T<: GAPGroup, S<: GAPGroup, E<: GAPGroupElem}

Type of left/right transversals of subgroups in groups.
The elements are encoded via a right transversal object in GAP.
(Note that GAP does not support left transversals.)

Objects of this type are created by [`right_transversal`](@ref) and
[`left_transversal`](@ref).

# Note for developers

The elements are encoded via a right transversal object in GAP.
(Note that GAP does not support left transversals.)
"""
struct SubgroupTransversal{T<: GAPGroup, S<: GAPGroup, E<: GAPGroupElem} <: AbstractVector{E}
G::T # big group containing the subgroup
Expand All @@ -341,7 +344,7 @@
GAP.@install GapObj(T::SubgroupTransversal) = T.X

function Base.show(io::IO, ::MIME"text/plain", x::SubgroupTransversal)
side = x.side === :left ? "Left" : "Right"
side = is_left(x) ? "Left" : "Right"
println(io, "$side transversal of length $(length(x)) of")
io = pretty(io)
print(io, Indent())
Expand All @@ -351,7 +354,7 @@
end

function Base.show(io::IO, x::SubgroupTransversal)
side = x.side === :left ? "Left" : "Right"
side = is_left(x) ? "Left" : "Right"
if is_terse(io)
print(io, "$side transversal of groups")
else
Expand All @@ -361,13 +364,17 @@
end
end

is_left(x::SubgroupTransversal) = x.side == :left

is_right(x::SubgroupTransversal) = x.side == :right

Check warning on line 369 in src/Groups/cosets.jl

View check run for this annotation

Codecov / codecov/patch

src/Groups/cosets.jl#L369

Added line #L369 was not covered by tests

Base.hash(x::SubgroupTransversal, h::UInt) = h # FIXME

Base.length(T::SubgroupTransversal) = index(Int, T.G, T.H)

function Base.getindex(T::SubgroupTransversal, i::Int)
res = group_element(T.G, GapObj(T)[i])
if T.side === :left
if is_left(T)
res = inv(res)
end
return res
Expand Down
Loading