1 /****************************************************************************
2 **
3 **  This file is part of GAP, a system for computational discrete algebra.
4 **
5 **  Copyright of GAP belongs to its developers, whose names are too numerous
6 **  to list here. Please refer to the COPYRIGHT file for details.
7 **
8 **  SPDX-License-Identifier: GPL-2.0-or-later
9 */
10 
11 #ifndef GAP_TRANS_H
12 #define GAP_TRANS_H
13 
14 #include "objects.h"
15 
IS_TRANS(Obj f)16 EXPORT_INLINE int IS_TRANS(Obj f)
17 {
18     return (TNUM_OBJ(f) == T_TRANS2 || TNUM_OBJ(f) == T_TRANS4);
19 }
20 
NEW_TRANS2(UInt deg)21 EXPORT_INLINE Obj NEW_TRANS2(UInt deg)
22 {
23     GAP_ASSERT(deg <= 65536);
24     return NewBag(T_TRANS2, deg * sizeof(UInt2) + 3 * sizeof(Obj));
25 }
26 
ADDR_TRANS2(Obj f)27 EXPORT_INLINE UInt2 * ADDR_TRANS2(Obj f)
28 {
29     GAP_ASSERT(TNUM_OBJ(f) == T_TRANS2);
30     return (UInt2 *)(ADDR_OBJ(f) + 3);
31 }
32 
CONST_ADDR_TRANS2(Obj f)33 EXPORT_INLINE const UInt2 * CONST_ADDR_TRANS2(Obj f)
34 {
35     GAP_ASSERT(TNUM_OBJ(f) == T_TRANS2);
36     return (const UInt2 *)(CONST_ADDR_OBJ(f) + 3);
37 }
38 
DEG_TRANS2(Obj f)39 EXPORT_INLINE UInt DEG_TRANS2(Obj f)
40 {
41     GAP_ASSERT(TNUM_OBJ(f) == T_TRANS2);
42     return ((UInt)(SIZE_OBJ(f) - 3 * sizeof(Obj)) / sizeof(UInt2));
43 }
44 
45 UInt RANK_TRANS2(Obj f);
46 
NEW_TRANS4(UInt deg)47 EXPORT_INLINE Obj NEW_TRANS4(UInt deg)
48 {
49     // No assert here since we allow creating new T_TRANS4's when the degree
50     // is low enough to fit in a T_TRANS2.
51     return NewBag(T_TRANS4, deg * sizeof(UInt4) + 3 * sizeof(Obj));
52 }
53 
ADDR_TRANS4(Obj f)54 EXPORT_INLINE UInt4 * ADDR_TRANS4(Obj f)
55 {
56     GAP_ASSERT(TNUM_OBJ(f) == T_TRANS4);
57     return (UInt4 *)(ADDR_OBJ(f) + 3);
58 }
59 
CONST_ADDR_TRANS4(Obj f)60 EXPORT_INLINE const UInt4 * CONST_ADDR_TRANS4(Obj f)
61 {
62     GAP_ASSERT(TNUM_OBJ(f) == T_TRANS4);
63     return (const UInt4 *)(CONST_ADDR_OBJ(f) + 3);
64 }
65 
DEG_TRANS4(Obj f)66 EXPORT_INLINE UInt DEG_TRANS4(Obj f)
67 {
68     GAP_ASSERT(TNUM_OBJ(f) == T_TRANS4);
69     return ((UInt)(SIZE_OBJ(f) - 3 * sizeof(Obj)) / sizeof(UInt4));
70 }
71 
72 UInt RANK_TRANS4(Obj f);
73 
NEW_TRANS(UInt deg)74 EXPORT_INLINE Obj NEW_TRANS(UInt deg)
75 {
76     if (deg < 65536) {
77         return NEW_TRANS2(deg);
78     }
79     else {
80         return NEW_TRANS4(deg);
81     }
82 }
83 
DEG_TRANS(Obj f)84 EXPORT_INLINE UInt DEG_TRANS(Obj f)
85 {
86     GAP_ASSERT(IS_TRANS(f));
87     return (TNUM_OBJ(f) == T_TRANS2 ? DEG_TRANS2(f) : DEG_TRANS4(f));
88 }
89 
RANK_TRANS(Obj f)90 EXPORT_INLINE UInt RANK_TRANS(Obj f)
91 {
92     GAP_ASSERT(IS_TRANS(f));
93     return (TNUM_OBJ(f) == T_TRANS2 ? RANK_TRANS2(f) : RANK_TRANS4(f));
94 }
95 
96 /****************************************************************************
97 **
98 *F  OnTuplesTrans( <tup>, <f> )  . . . .  operations on tuples of points
99 **
100 **  'OnTuplesTrans'  returns  the  image  of  the  tuple  <tup>   under  the
101 **  transformation <f>.
102 */
103 Obj OnTuplesTrans(Obj tup, Obj f);
104 
105 /****************************************************************************
106 **
107 *F  OnSetsTrans( <set>, <f> ) . . . . . . . .  operations on sets of points
108 **
109 **  'OnSetsTrans' returns the  image of the  tuple <set> under the
110 **  transformation <f>.
111 */
112 Obj OnSetsTrans(Obj set, Obj f);
113 
114 
115 /****************************************************************************
116 **
117 *F  HashFuncForTrans( <f> ) . . . hash transformation
118 **
119 **  Returns a hash value for a transformation
120 */
121 Int HashFuncForTrans(Obj f);
122 
123 
124 /****************************************************************************
125 **
126 *F * * * * * * * * * * * * * initialize module * * * * * * * * * * * * * * *
127 */
128 
129 /****************************************************************************
130 **
131 *F  InitInfoTrans() . . . . . . . . . . . . . . . . . table of init functions
132 */
133 StructInitInfo * InitInfoTrans(void);
134 
135 #endif    // GAP_TRANS_H
136