Skip to content

Commit

Permalink
Make GroupWithMemory behave more like Group
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fingolfin committed Aug 18, 2023
1 parent 6e7846d commit 6a8cd88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions lib/memory.gi
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 128 in lib/memory.gi

View check run for this annotation

Codecov / codecov/patch

lib/memory.gi#L128

Added line #L128 was not covered by tests
# trick: ensure all transformations that GroupWithGenerators applies
# to the generators are applied here, too
gens := GroupWithGenerators(gens);

Check warning on line 131 in lib/memory.gi

View check run for this annotation

Codecov / codecov/patch

lib/memory.gi#L131

Added line #L131 was not covered by tests
fi;
memgens := GeneratorsWithMemory(GeneratorsOfGroup(gens));

Check warning on line 133 in lib/memory.gi

View check run for this annotation

Codecov / codecov/patch

lib/memory.gi#L133

Added line #L133 was not covered by tests
g := GroupWithGenerators(memgens);
return g;
end);
Expand Down
2 changes: 1 addition & 1 deletion tst/testinstall/memory.tst
Original file line number Diff line number Diff line change
@@ -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);
Expand Down

0 comments on commit 6a8cd88

Please sign in to comment.