File: vecgf2.h

package info (click to toggle)
gap 4r4p12-2
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 29,584 kB
  • ctags: 7,113
  • sloc: ansic: 98,786; sh: 3,299; perl: 2,263; makefile: 498; asm: 63; awk: 6
file content (253 lines) | stat: -rw-r--r-- 8,508 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/****************************************************************************
**
*W  vecgf2.h                    GAP source                       Frank Celler
**
*H  @(#)$Id: vecgf2.h,v 4.14 2003/04/30 11:27:14 sal Exp $
**
*Y  Copyright (C)  1997,  Lehrstuhl D fuer Mathematik,  RWTH Aachen,  Germany
*Y  (C) 1998 School Math and Comp. Sci., University of St.  Andrews, Scotland
*Y  Copyright (C) 2002 The GAP Group
*/
#ifdef  INCLUDE_DECLARATION_PART
const char * Revision_vecgf2_h =
   "@(#)$Id: vecgf2.h,v 4.14 2003/04/30 11:27:14 sal Exp $";
#endif


/****************************************************************************
**

*F  IS_GF2VEC_REP( <obj> )  . . . . . . check that <obj> is in GF2 vector rep
*/
#define IS_GF2VEC_REP(obj) \
  (TNUM_OBJ(obj)==T_DATOBJ && DoFilter(IsGF2VectorRep,obj) == True)


/****************************************************************************
**
*F  NEW_GF2VEC( <vec>, <type>, <len> )  . . . . . . . create a new GF2 vector
*/
#define NEW_GF2VEC( vec, type, len ) \
    do { \
        vec = NewBag( T_DATOBJ, SIZE_PLEN_GF2VEC(len) ); \
        TYPE_DATOBJ(vec) = type; \
    } while (0)


/****************************************************************************
**
*F  LEN_GF2VEC( <vec> ) . . . . . . . . . . . . . . . . length of a GF vector
**
**  'LEN_GF2VEC' returns the logical length of the GF2 vector <list>,  as a C
**  integer.
**
**  Note that 'LEN_GF2VEC' is a macro, so do not call it with  arguments that
**  have sideeffects.
*/
#define LEN_GF2VEC(list)         ((Int)(ADDR_OBJ(list)[1]))


/****************************************************************************
**
*F  NUMBER_BLOCKS_GF2VEC( <vec> ) . . . . . . . number of UInt blocks in list
*/
#define NUMBER_BLOCKS_GF2VEC(list)      ((LEN_GF2VEC((list))+ BIPEB-1)/BIPEB)


/****************************************************************************
**
*F  BLOCKS_GF2VEC( <list> ) . . . . . . . . . . . first block of a GF2 vector
**
**  returns a pointer to the start of the data of the GF2 vector
*/
#define BLOCKS_GF2VEC(list)             ((UInt*)(ADDR_OBJ(list)+2))


/****************************************************************************
**
*F  BLOCK_ELM_GF2VEC( <list>, <pos> ) . . . . . . . . . block of a GF2 vector
**
**  'BLOCK_ELM_GF2VEC' return the   block containing the <pos>-th  element of
**  the  GF2 vector <list> as  a UInt value, which is  also a valid left hand
**  side.  <pos> must be a positive integer less  than or equal to the length
**  of <list>.
**
**  Note that 'BLOCK_ELM_GF2VEC' is a macro, so do not call it with arguments
**  that have sideeffects.
*/
#define BLOCK_ELM_GF2VEC(list, pos)    (BLOCKS_GF2VEC(list)[((pos)-1)/BIPEB])


/****************************************************************************
**
*F  SET_LEN_GF2VEC( <list>, <len> ) .  set the logical length of a GF2 vector
**
**  'SET_LEN_GF2VEC' sets the length of the boolean list  <list> to the value
**  <len>, which must be a positive C integer.
**
**  Note that 'SET_LEN_GF2VEC' is a macro, so do  not  call it with arguments
**  that have sideeffects.
*/
#define SET_LEN_GF2VEC(list,len)        (ADDR_OBJ(list)[1] = (Obj)(len))


/****************************************************************************
**
*F  SIZE_PLEN_GF2VEC( <len> ) . . . . . . . . physical length of a GF2 vector
*/
#define SIZE_PLEN_GF2VEC(len) \
                           (2*sizeof(Obj)+((len)+BIPEB-1)/BIPEB*sizeof(UInt))


/****************************************************************************
**
*F  MASK_POS_GF2VEC( <pos> )  . . . . bit mask for position of a Boolean list
**
**  MASK_POS_GF2VEC(<pos>) returns a UInt with  a single set bit in  position
**  (pos-1) % BIPEB, useful for accessing the pos'th element of a blist
**
**  Note that 'MASK_POS_GF2VEC' is a  macro, so do not call it with arguments
**  that have sideeffects.
*/
#define MASK_POS_GF2VEC( pos ) (((UInt) 1)<<((pos)-1)%BIPEB)


/****************************************************************************
**
*F  ELM_GF2VEC( <list>, <pos> ) . . . . . . . . . . element of a a GF2 vector
**
**  'ELM_GF2VEC' return the <pos>-th element of  the GF2 vector <list>, which
**  is either 'Z(2)' or '0*Z(2)'.  <pos> must be a positive integer less than
**  or equal to the length of <list>.
**
**  Note that 'ELM_GF2VEC' is a macro, so do  not call it with arguments that
**  have sideeffects.
*/
#define ELM_GF2VEC(list,pos) \
  ((BLOCK_ELM_GF2VEC(list,pos) & MASK_POS_GF2VEC(pos)) ?  GF2One : GF2Zero)


/****************************************************************************
**
*F  LEN_GF2MAT( <list> )  . . . . . . . . . . . . . . . length of a GF matrix
**
**  'LEN_GF2MAT' returns the logical length of the GF2 matrix <list>,  as a C
**  integer.
**
**  Note that 'LEN_GF2MAT' is a macro, so do not call it with  arguments that
**  have sideeffects.
*/
#define LEN_GF2MAT(list)         (INT_INTOBJ(ADDR_OBJ(list)[1]))


/****************************************************************************
**
*F  SET_LEN_GF2MAT( <list>, <len> ) . . . . . . set the length of a GF matrix
**
**  'SET_LEN_GF2MAT' sets the logical length of the GF2 matrix <list>, as a C
**  integer.
**
**  Note that 'SET_LEN_GF2MAT' is a  macro, so do not  call it with arguments
**  that have sideeffects.
*/
#define SET_LEN_GF2MAT(list,len)    (ADDR_OBJ(list)[1]=INTOBJ_INT(len))


/****************************************************************************
**
*F  ELM_GF2MAT( <list>, <pos> ) . . . . . . . . . . element of a a GF2 matrix
**
**  'ELM_GF2MAT' returns the <pos>-th element of the GF2 matrix <list>, which
**  is a GF2 vector.  <pos> must be a positive  integer less than or equal to
**  the length of <list>.
**
**  Note that 'ELM_GF2MAT' is a macro, so do  not call it with arguments that
**  have sideeffects.
*/
#define ELM_GF2MAT(list,pos)    (ADDR_OBJ(list)[pos+1])


/****************************************************************************
**
*F  SET_ELM_GF2MAT( <list>, <pos>, <elm> )  . . set element of a a GF2 matrix
**
**  'SET_ELM_GF2MAT'  sets the <pos>-th element   of  the GF2 matrix  <list>,
**  which must be a  GF2 vector.  <pos> must  be a positive integer less than
**  or equal to the length of <list>.
**
**  Note that 'ELM_GF2MAT' is a macro, so do  not call it with arguments that
**  have sideeffects.
*/
#define SET_ELM_GF2MAT(list,pos,elm)    (ADDR_OBJ(list)[pos+1]=elm)


/****************************************************************************
**
*F  SIZE_PLEN_GF2MAT( <len> ) . . . . . . . . physical length of a GF2 matrix
*/
#define SIZE_PLEN_GF2MAT(len)   (((len)+2)*sizeof(Obj))

/****************************************************************************
**
*V  TYPE_LIST_GF2VEC  . . . . . . . . . . . . . . type of a GF2 vector object
*/
extern Obj TYPE_LIST_GF2VEC;


/****************************************************************************
**
*V  TYPE_LIST_GF2VEC_IMM  . . . . . .  type of an immutable GF2 vector object
*/
extern Obj TYPE_LIST_GF2VEC_IMM;

/****************************************************************************
**
*V  TYPE_LIST_GF2VEC_IMM_LOCKED. . . .  type of an immutable GF2 vector object
**                                          with locked representation
*/
extern Obj TYPE_LIST_GF2VEC_IMM_LOCKED;

/****************************************************************************
**
*V  TYPE_LIST_GF2VEC_LOCKED. . . .  type of a GF2 vector object
**                                          with locked representation
*/
extern Obj TYPE_LIST_GF2VEC_LOCKED;


/****************************************************************************
**
*V  TYPE_LIST_GF2MAT  . . . . . . . . . . . . . . type of a GF2 matrix object
*/
extern Obj TYPE_LIST_GF2MAT;


/****************************************************************************
**
*V  TYPE_LIST_GF2MAT_IMM  . . . . . .  type of an immutable GF2 matrix object
*/
extern Obj TYPE_LIST_GF2MAT_IMM;


extern Obj IsGF2VectorRep;

/****************************************************************************
**

*F * * * * * * * * * * * * * initialize package * * * * * * * * * * * * * * *
*/


/****************************************************************************
**

*F  InitInfoGF2Vec()  . . . . . . . . . . . . . . . . table of init functions
*/
StructInitInfo * InitInfoGF2Vec ( void );


/****************************************************************************
**

*E  vecgf2.h  . . . . . . . . . . . . . . . . . . . . . . . . . . . ends here
*/