normalform! should be a no-op for normalized words

This commit is contained in:
Marek Kaluba 2024-02-12 11:35:40 +01:00
parent 8137e40998
commit 5993cb328f
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
2 changed files with 8 additions and 6 deletions

View File

@ -36,8 +36,8 @@ function Base.:(==)(
hash(g) != hash(h) && return false
end
length(word(g)) > 8 && normalform!(g)
length(word(h)) > 8 && normalform!(h)
normalform!(g)
normalform!(h)
word(g) == word(h) && return true

View File

@ -2,8 +2,10 @@
normalform!(g::FPGroupElement)
Compute the normal form of `g`, possibly modifying `g` in-place.
"""
@inline function normalform!(g::AbstractFPGroupElement)
isnormalform(g) && return g
@inline function normalform!(g::AbstractFPGroupElement; force = false)
if !force
isnormalform(g) && return g
end
let w = one(word(g))
w = normalform!(w, g)
@ -36,9 +38,9 @@ end
"""
normalform!(res::AbstractWord, g::FPGroupElement)
Append the normal form of `g` to word `res`, modifying `res` in place.
Write the normal form of `g` to word `res`, modifying `res` in place.
Defaults to the rewriting in the free group.
The particular implementation of the normal form depends on `parent(g)`.
"""
@inline function normalform!(res::AbstractWord, g::AbstractFPGroupElement)
isone(res) && isnormalform(g) && return append!(res, word(g))