From 5993cb328febeecad5e360aa1746d438ca4abf16 Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Mon, 12 Feb 2024 11:35:40 +0100 Subject: [PATCH] normalform! should be a no-op for normalized words --- src/autgroups.jl | 4 ++-- src/normalform.jl | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/autgroups.jl b/src/autgroups.jl index e96f4d1..f361b37 100644 --- a/src/autgroups.jl +++ b/src/autgroups.jl @@ -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 diff --git a/src/normalform.jl b/src/normalform.jl index 7b7742c..613e51a 100644 --- a/src/normalform.jl +++ b/src/normalform.jl @@ -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))