[Next] [Prev] [_____] [Left] [Up] [Index] [Root]
Optimizing Magma Code

Optimizing Magma Code

Subsections

PowerGroup

If the user is working with enumerated sets of polycyclic groups that are all subgroups of a common over-group G, then the following optimization is strongly recommended. Define the set to have the universe PowerGroup(G). For any subgroup H of G, we can find a canonical form for the generators of H. This allows us to have a very good hashing function for the subgroups.


Example GrpPC_PowerGroupTwo (H19E12)

The following example illustrates the optimization.

> G := ExtraSpecialGroup( GrpPC, 3, 3 );
> P := PowerGroup(G);
> time s1 := {  P | sub< G | Random(G), Random(G) > : x in { 1..500 }  };
Time: 1.140
> time s2 := { Parent(G) | sub< G | Random(G), Random(G) > : x in { 1..500 }  }; 
Time: 9.769

CompactPresentation

When the Magma parser reads in large group presentations of the form

S4 := PolycyclicGroup< a, b, c, d | a^2 = 1, b^3 = 1, c^2 = 1,
       d^2 = 1, b^a = b^2, c^a = c * d, c^b = c * d, d^b = c >;
a large amount of memory and time is used to build all of the expressions involved in the statement. This time is most noticeable when loading in large libraries of Magma code containing many large presentations. The following intrinsics provide a way to avoid this overhead.
CompactPresentation(G) : GrpPC -> [RngIntElt]
Given a polycyclic group G, return a sequence of integers that contains the information needed to define the group's presentation.
PCGroup(Q : parameters ) : [RngIntElt] -> GrpPC
    Check: BoolElt                      Default: true
    ExponentLimit: RngIntElt            Default: 20
Return a polycyclic group G whose presentation is provided by the integer sequence Q. Constructing the group from the integer sequence has very low overhead in the parser.

The parameter Check indicates whether or not the presentation is checked for consistency. ExponentLimit determines the amount of space that will be used by the group to speed calculations. Given ExponentLimit := e, the group will store the products a^i * b^j where a and b are generators and i and j are in the range 1 to e.


Example GrpPC_CompactPresentation (H19E13)

If the user wants to store the definition of a group in a library, the following may be done.

> S4 := PolycyclicGroup< a, b, c, d | a^2 = 1, b^3 = 1, c^2 = 1, d^2 = 1,
>              b^a = b^2, c^a = c * d, c^b = c * d, d^b = c >;
> Q := CompactPresentation( S4 );
> Q;
[ 4, 2, 3, 2, 2, 33, 218, 114, 55 ]

The library code would then be

> Make:=func< | PCGroup(\[4, 2, 3, 2, 2, 33, 218, 114, 55] : Check := false) >;
Note the use of a literal sequence here --- see Chapter number chapSeq.
[Next] [Prev] [_____] [Left] [Up] [Index] [Root]