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 hash(g) != hash(h) && return false
end end
length(word(g)) > 8 && normalform!(g) normalform!(g)
length(word(h)) > 8 && normalform!(h) normalform!(h)
word(g) == word(h) && return true word(g) == word(h) && return true

View File

@ -2,8 +2,10 @@
normalform!(g::FPGroupElement) normalform!(g::FPGroupElement)
Compute the normal form of `g`, possibly modifying `g` in-place. Compute the normal form of `g`, possibly modifying `g` in-place.
""" """
@inline function normalform!(g::AbstractFPGroupElement) @inline function normalform!(g::AbstractFPGroupElement; force = false)
isnormalform(g) && return g if !force
isnormalform(g) && return g
end
let w = one(word(g)) let w = one(word(g))
w = normalform!(w, g) w = normalform!(w, g)
@ -36,9 +38,9 @@ end
""" """
normalform!(res::AbstractWord, g::FPGroupElement) 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) @inline function normalform!(res::AbstractWord, g::AbstractFPGroupElement)
isone(res) && isnormalform(g) && return append!(res, word(g)) isone(res) && isnormalform(g) && return append!(res, word(g))