gap-packages / polycyclic

Computation with polycyclic groups
https://gap-packages.github.io/polycyclic/
Other
4 stars 9 forks source link

Random doesn't work on trivial PcpGroup #59

Closed stertooy closed 3 years ago

stertooy commented 3 years ago

For most of the common types of groups, calling Random on the trivial group works fine. Not so for PcpGroups:

gap> Random(TrivialGroup(IsPcGroup));
<identity> of ...
gap> Random(TrivialGroup(IsPermGroup));
()
gap> Random(TrivialGroup(IsFpGroup));
<identity ...>
gap> Random(TrivialGroup(IsPcpGroup));
Error, cannot compute this
 at /usr/lib/gap-4.11.1/pkg/polycyclic/gap/pcpgrp/general.gi:28 called from
MappedVector( g, pcp ) at /usr/lib/gap-4.11.1/pkg/polycyclic/gap/basic/pcpgrps.gi:111 called from
func( GlobalMersenneTwister, x ) at /usr/lib/gap-4.11.1/lib/random.gi:303 called from
<function "Random for a pcp group">( <arguments> )

The error happens because Random ends up calling MappedVector( [], Pcp [ ] with orders [ ] ), and MappedVector returns this error when the first argument has zero length. By contrast, the following does work, even though this is again the trivial group:

gap> H := AbelianPcpGroup( [ 1 ] );
Pcp-group with orders [ 1 ]
gap> Random( H );
id

Would adding the following code to Random in /basic/pcpgrps.gi (line 94) be an acceptable fix?

if Length(pcp) = 0 then
  Return One( G );
fi;