1#
2# Tests for functions defined in src/permutat.cc
3#
4gap> START_TEST("kernel/permutat.tst");
5
6# Reduce the amount printed by CYCLE_STRUCT_PERM by skipping unbound values
7gap> CycleStructPermShort := function(p)
8>  local ret, i, l;
9>  l := CYCLE_STRUCT_PERM(p);
10>  ret := [];
11>  for i in [1..Length(l)] do
12>    if IsBound(l[i]) then
13>      Add(ret, [i,l[i]]);
14>    fi;
15> od;
16> return ret;
17> end;;
18gap> permprops := function(p)
19>  local name;
20>  for name in ["LARGEST_MOVED_POINT_PERM",
21>               "ORDER_PERM", "SIGN_PERM"] do
22>      PrintFormatted("{}:{}\n", name, ValueGlobal(name)(p));
23>  od;
24>  PrintFormatted("CYCLE_SHORT_PERM (short output): {}\n", CycleStructPermShort(p));
25> end;;
26gap> permprops(());
27LARGEST_MOVED_POINT_PERM:0
28ORDER_PERM:1
29SIGN_PERM:1
30CYCLE_SHORT_PERM (short output): [  ]
31gap> permprops((1,2));
32LARGEST_MOVED_POINT_PERM:2
33ORDER_PERM:2
34SIGN_PERM:-1
35CYCLE_SHORT_PERM (short output): [ [ 1, 1 ] ]
36gap> permprops((1,2)(3,4));
37LARGEST_MOVED_POINT_PERM:4
38ORDER_PERM:2
39SIGN_PERM:1
40CYCLE_SHORT_PERM (short output): [ [ 1, 2 ] ]
41gap> permprops((1,5,4,3,2));
42LARGEST_MOVED_POINT_PERM:5
43ORDER_PERM:5
44SIGN_PERM:1
45CYCLE_SHORT_PERM (short output): [ [ 4, 1 ] ]
46gap> permprops((1,2)(3,4)(5,6));
47LARGEST_MOVED_POINT_PERM:6
48ORDER_PERM:2
49SIGN_PERM:-1
50CYCLE_SHORT_PERM (short output): [ [ 1, 3 ] ]
51gap> permprops((1,2^20));
52LARGEST_MOVED_POINT_PERM:1048576
53ORDER_PERM:2
54SIGN_PERM:-1
55CYCLE_SHORT_PERM (short output): [ [ 1, 1 ] ]
56gap> permprops((1,2,3,4,5)^5);
57LARGEST_MOVED_POINT_PERM:0
58ORDER_PERM:1
59SIGN_PERM:1
60CYCLE_SHORT_PERM (short output): [  ]
61gap> permprops(PermList(Concatenation([2^17], [1..2^17-1])));
62LARGEST_MOVED_POINT_PERM:131072
63ORDER_PERM:131072
64SIGN_PERM:-1
65CYCLE_SHORT_PERM (short output): [ [ 131071, 1 ] ]
66
67# Test the boundary between PERM2 and PERM4
68gap> permprops((2^16-1, 2^16));
69LARGEST_MOVED_POINT_PERM:65536
70ORDER_PERM:2
71SIGN_PERM:-1
72CYCLE_SHORT_PERM (short output): [ [ 1, 1 ] ]
73gap> permprops((2^16-2, 2^16-1));
74LARGEST_MOVED_POINT_PERM:65535
75ORDER_PERM:2
76SIGN_PERM:-1
77CYCLE_SHORT_PERM (short output): [ [ 1, 1 ] ]
78gap> permprops((2^16-2, 2^16-3));
79LARGEST_MOVED_POINT_PERM:65534
80ORDER_PERM:2
81SIGN_PERM:-1
82CYCLE_SHORT_PERM (short output): [ [ 1, 1 ] ]
83gap> permprops(PermList(Concatenation([2^16+1], [1..2^16])));
84LARGEST_MOVED_POINT_PERM:65537
85ORDER_PERM:65537
86SIGN_PERM:1
87CYCLE_SHORT_PERM (short output): [ [ 65536, 1 ] ]
88gap> permprops(PermList(Concatenation([2^16], [1..2^16-1])));
89LARGEST_MOVED_POINT_PERM:65536
90ORDER_PERM:65536
91SIGN_PERM:-1
92CYCLE_SHORT_PERM (short output): [ [ 65535, 1 ] ]
93gap> permprops(PermList(Concatenation([2^16-1], [1..2^16-2])));
94LARGEST_MOVED_POINT_PERM:65535
95ORDER_PERM:65535
96SIGN_PERM:1
97CYCLE_SHORT_PERM (short output): [ [ 65534, 1 ] ]
98gap> permprops(PermList(Concatenation([2^16-2], [1..2^16-3])));
99LARGEST_MOVED_POINT_PERM:65534
100ORDER_PERM:65534
101SIGN_PERM:-1
102CYCLE_SHORT_PERM (short output): [ [ 65533, 1 ] ]
103gap> permprops(PermList(Concatenation([2,1,2^16], [3..2^16-1])));
104LARGEST_MOVED_POINT_PERM:65536
105ORDER_PERM:65534
106SIGN_PERM:1
107CYCLE_SHORT_PERM (short output): [ [ 1, 1 ], [ 65533, 1 ] ]
108gap> permprops(PermList(Concatenation(List([1,3..2^16-1], x -> [x+1,x]))));
109LARGEST_MOVED_POINT_PERM:65536
110ORDER_PERM:2
111SIGN_PERM:1
112CYCLE_SHORT_PERM (short output): [ [ 1, 32768 ] ]
113gap> STOP_TEST("kernel/permutat.tst", 1);
114