GAP Most efficient way to check multiple properties of a group in the small group library

371 Views Asked by At

In GAP I would like to search the small groups library looking for groups with specific properties (I suppose this is the most common usage).

  • If I have a list of properties I want to test, what is the most efficient and elegant way to do this?

  • In some languages there is a 'Switch' statement, I couldn't find such a thing in GAP. Is there anything similar?

  • If I want to check several properties, is it better to iterate over a list checking all properties for each element in the list, or is it better to filter out of the list everything that doesn't have the first property, and then go back over the filtered list removing everything that doesn't have the second property, etc.

  • If I was iterating over the small groups by

        for g in AllSmallGroups(n) do
            check some property
            check another property
            check some attributes
        od;
    

    GAP would have to calculate some information about the group g, in the process perhaps learning some attributes about g.

  • For how long would GAP 'remember' these, and what is the best way to search keeping this in mind?

1

There are 1 best solutions below

4
On BEST ANSWER

As long as g is the same group, GAP will (in the same session) remember all its properties (and use up memory for it). If you create the group anew (e.g. by SmallGroup(n,index), or by another call to AllSmallGroups), all but the properties it is given from the start will be lost. So running group by group is the better way. However the way you use the loop you first create all groups and then remember them all with all their properties and attributes, which can be hard on the memory. Assuming you're looking for a few groups in a large set (or only want to store the identification numbers of the groups anyhow) running by index numbers will be much better:

for i in [1..NrSmallGroups(n)] do
  g:=SmallGroup(n,i);
  Now Do Your Tests for g, if they are satisfied remember index i in a list.
od;

(There is no switch statement, but an elif which will allow the same construct.)


Added by AK: Also, SmallGroupsInformation is very useful: it may tell you how the groups of a given order are sorted, and which properties and attributes are precomputed for very fast use in selection functions like AllSmallGroups. For example:

gap> SmallGroupsInformation(256);

  There are 56092 groups of order 256.
  They are sorted by their ranks. 
     1 is cyclic. 
     2 - 541 have rank 2.
     542 - 6731 have rank 3.
     6732 - 26972 have rank 4.
     26973 - 55625 have rank 5.
     55626 - 56081 have rank 6.
     56082 - 56091 have rank 7.
     56092 is elementary abelian. 

  For the selection functions the values of the following attributes 
  are precomputed and stored:
     IsAbelian, PClassPGroup, RankPGroup, FrattinifactorSize and 
     FrattinifactorId. 

  This size belongs to layer 2 of the SmallGroups library. 
  IdSmallGroup is available for this size. 

You can use this knowledge to speed up the search and narrow the search space.