From 6a8cd88535bc687cb2ac4a445f33795ea453c176 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 18 Aug 2023 09:20:57 +0200 Subject: [PATCH] Make GroupWithMemory behave more like Group In particular, ensure that the wrapped generators are made immutable, and in the case of matrices, possibly converted to a better representation. This is achieved by calling `GroupWithGenerators` on the given generators, and then wrapping the generators of the resulting group. This avoids a surprising mismatch in behavior between ordinary groups and groups with memory in some situations. And of course making the generators immutable prevents further pitfalls. Also make sure we have at least one test for GroupWithMemory where the input is not a group. --- lib/memory.gi | 11 ++++++----- tst/testinstall/memory.tst | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/memory.gi b/lib/memory.gi index d8e85b5367..31f267f516 100644 --- a/lib/memory.gi +++ b/lib/memory.gi @@ -123,13 +123,14 @@ InstallGlobalFunction( CopyMemory, InstallGlobalFunction( GroupWithMemory, function(gens) - # gens a list of generators + # gens a list of generators or a group local g,memgens; - if IsGroup(gens) then - memgens := GeneratorsWithMemory(GeneratorsOfGroup(gens)); - else - memgens := GeneratorsWithMemory(gens); + if not IsGroup(gens) then + # trick: ensure all transformations that GroupWithGenerators applies + # to the generators are applied here, too + gens := GroupWithGenerators(gens); fi; + memgens := GeneratorsWithMemory(GeneratorsOfGroup(gens)); g := GroupWithGenerators(memgens); return g; end); diff --git a/tst/testinstall/memory.tst b/tst/testinstall/memory.tst index dea81b2c32..dfa6a1116f 100644 --- a/tst/testinstall/memory.tst +++ b/tst/testinstall/memory.tst @@ -1,5 +1,5 @@ #@local G, H, g, h, tmp, stabChain, s1, s2 -gap> G := GroupWithMemory(GroupByGenerators([ (1,2,3,4,5), (1,2) ]));; +gap> G := GroupWithMemory([ (1,2,3,4,5), (1,2) ]);; gap> H := GroupWithMemory(GL(IsMatrixGroup, 3, 3));; gap> g := H.1 ^ 2;; h := H.2 ^ 2;; gap> StripMemory(g);