2 # gap -b -q < /dev/null group.gap | perl -pe 's/\\\n//s' | indent -kr
4 Print("/* ----- data generated by group.gap begins ----- */\n\n");
5 Print("struct group {\n unsigned long autosize;\n");
6 Print(" int order, ngens;\n const char *gens;\n};\n");
7 Print("struct groups {\n int ngroups;\n");
8 Print(" const struct group *groups;\n};\n\n");
9 Print("static const struct group groupdata[] = {\n");
13 Print(" /* order ", n, " */\n");
14 for G in AllSmallGroups(n) do
16 # Construct a representation of the group G as a subgroup
17 # of a permutation group, and find its generators in that
20 # GAP has the 'IsomorphismPermGroup' function, but I don't want
21 # to use it because it doesn't guarantee that the permutation
22 # representation of the group forms a Cayley table. For example,
23 # C_4 could be represented as a subgroup of S_4 in many ways,
24 # and not all of them work: the group generated by (12) and (34)
25 # is clearly isomorphic to C_4 but its four elements do not form
26 # a Cayley table. The group generated by (12)(34) and (13)(24)
29 # Hence I construct the permutation representation _as_ the
30 # Cayley table, and then pick generators of that. This
31 # guarantees that when we rebuild the full group by BFS in
32 # group.c, we will end up with the right thing.
46 Add(gi, PermList(gr));
49 # GAP has the 'GeneratorsOfGroup' function, but we don't want to
50 # use it because it's bad at picking generators - it thinks the
51 # generators of C_4 are [ (1,2)(3,4), (1,3,2,4) ] and that those
52 # of C_6 are [ (1,2,3)(4,5,6), (1,4)(2,5)(3,6) ] !
54 gl := ShallowCopy(Elements(gi));
55 Sort(gl, function(v,w) return Order(v) > Order(w); end);
59 if gens = [] or not (x in gp) then
61 gp := GroupWithGenerators(gens);
65 # Construct the C representation of the group generators.
74 for i in ListPerm(x) do
75 chars := "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
79 s := JoinStringsWithSeparator([" {", String(Size(AutomorphismGroup(G))),
80 "L, ", String(Size(G)),
81 ", ", String(Size(gens)),
82 ", \"", s, "\"},\n"],"");
88 Print("};\n\nstatic const struct groups groups[] = {\n");
89 Print(" {0, NULL}, /* trivial case: 0 */\n");
90 Print(" {0, NULL}, /* trivial case: 1 */\n");
92 for i in [1..Size(offsets)-1] do
93 Print(" {", offsets[i+1] - offsets[i], ", groupdata+",
94 offsets[i], "}, /* ", i+1, " */\n");
96 Print("};\n\n/* ----- data generated by group.gap ends ----- */\n");