1
2
3 #ifndef NTL_GF2EX__H
4 #define NTL_GF2EX__H
5
6 #include <NTL/vector.h>
7 #include <NTL/GF2E.h>
8 #include <NTL/vec_GF2E.h>
9 #include <NTL/vec_long.h>
10 #include <NTL/GF2XVec.h>
11 #include <NTL/Lazy.h>
12
13
14 NTL_OPEN_NNS
15
16 class GF2EXModulus; // forward declaration
17
18 class GF2EX {
19 public:
20 typedef GF2E coeff_type;
21 typedef GF2EXModulus modulus_type;
22
23
24 vec_GF2E rep;
25
26
27 /***************************************************************
28
29 Constructors, Destructors, and Assignment
30
31 ****************************************************************/
32
33
GF2EX()34 GF2EX() { }
35
GF2EX(long a)36 explicit GF2EX(long a) { *this = a; }
GF2EX(GF2 a)37 explicit GF2EX(GF2 a) { *this = a; }
GF2EX(const GF2 & a)38 explicit GF2EX(const GF2& a) { *this = a; }
39
40
GF2EX(INIT_SIZE_TYPE,long n)41 GF2EX(INIT_SIZE_TYPE, long n) { rep.SetMaxLength(n); }
42
43 // default copy constructor and assignment
44 // default destructor
45
46 void normalize();
47 // strip leading zeros
48
SetMaxLength(long n)49 void SetMaxLength(long n)
50 // pre-allocate space for n coefficients.
51 // Value is unchanged
52
53 { rep.SetMaxLength(n); }
54
55
kill()56 void kill()
57 // free space held by this polynomial. Value becomes 0.
58
59 { rep.kill(); }
60
61
62
SetLength(long n)63 void SetLength(long n) { rep.SetLength(n); }
64 GF2E& operator[](long i) { return rep[i]; }
65 const GF2E& operator[](long i) const { return rep[i]; }
66
67
68
69
70 static const GF2EX& zero();
71
72
73
74 inline GF2EX& operator=(long a);
75 inline GF2EX& operator=(GF2 a);
76 inline GF2EX& operator=(const GF2E& a);
77
78 inline GF2EX(long i, long a);
79 inline GF2EX(long i, GF2 a);
80 inline GF2EX(long i, const GF2E& a);
81
82
83 inline GF2EX(INIT_MONO_TYPE, long i, long a);
84 inline GF2EX(INIT_MONO_TYPE, long i, GF2 a);
85 inline GF2EX(INIT_MONO_TYPE, long i, const GF2E& a);
86 inline GF2EX(INIT_MONO_TYPE, long i);
87
88
GF2EX(GF2EX & x,INIT_TRANS_TYPE)89 GF2EX(GF2EX& x, INIT_TRANS_TYPE) : rep(x.rep, INIT_TRANS) { }
90
swap(GF2EX & x)91 void swap(GF2EX& x) { rep.swap(x.rep); }
92
93
94 };
95
96
97
98 NTL_DECLARE_RELOCATABLE((GF2EX*))
99
100
101
102
103 /********************************************************************
104
105 input and output
106
107 *********************************************************************/
108
109
110 NTL_SNS istream& operator>>(NTL_SNS istream& s, GF2EX& x);
111 NTL_SNS ostream& operator<<(NTL_SNS ostream& s, const GF2EX& a);
112
113
114
115
116 /**********************************************************
117
118 Some utility routines
119
120 ***********************************************************/
121
122
deg(const GF2EX & a)123 inline long deg(const GF2EX& a) { return a.rep.length() - 1; }
124
125 const GF2E& coeff(const GF2EX& a, long i);
126 // zero if i not in range
127
128 void GetCoeff(GF2E& x, const GF2EX& a, long i);
129 // x = a[i], or zero if i not in range
130
131 const GF2E& LeadCoeff(const GF2EX& a);
132 // zero if a == 0
133
134 const GF2E& ConstTerm(const GF2EX& a);
135 // zero if a == 0
136
137 void SetCoeff(GF2EX& x, long i, const GF2E& a);
138 void SetCoeff(GF2EX& x, long i, GF2 a);
139 void SetCoeff(GF2EX& x, long i, long a);
140 // x[i] = a, error is raised if i < 0
141
142 void SetCoeff(GF2EX& x, long i);
143 // x[i] = 1, error is raised if i < 0
144
GF2EX(long i,const GF2E & a)145 inline GF2EX::GF2EX(long i, const GF2E& a) { SetCoeff(*this, i, a); }
GF2EX(long i,GF2 a)146 inline GF2EX::GF2EX(long i, GF2 a) { SetCoeff(*this, i, a); }
GF2EX(long i,long a)147 inline GF2EX::GF2EX(long i, long a) { SetCoeff(*this, i, a); }
148
149
GF2EX(INIT_MONO_TYPE,long i,const GF2E & a)150 inline GF2EX::GF2EX(INIT_MONO_TYPE, long i, const GF2E& a) { SetCoeff(*this, i, a); }
GF2EX(INIT_MONO_TYPE,long i,GF2 a)151 inline GF2EX::GF2EX(INIT_MONO_TYPE, long i, GF2 a) { SetCoeff(*this, i, a); }
GF2EX(INIT_MONO_TYPE,long i,long a)152 inline GF2EX::GF2EX(INIT_MONO_TYPE, long i, long a) { SetCoeff(*this, i, a); }
GF2EX(INIT_MONO_TYPE,long i)153 inline GF2EX::GF2EX(INIT_MONO_TYPE, long i) { SetCoeff(*this, i); }
154
155
156 void SetX(GF2EX& x);
157 // x is set to the monomial X
158
159 long IsX(const GF2EX& a);
160 // test if x = X
161
clear(GF2EX & x)162 inline void clear(GF2EX& x)
163 // x = 0
164
165 { x.rep.SetLength(0); }
166
set(GF2EX & x)167 inline void set(GF2EX& x)
168 // x = 1
169
170 { x.rep.SetLength(1); set(x.rep[0]); }
171
swap(GF2EX & x,GF2EX & y)172 inline void swap(GF2EX& x, GF2EX& y)
173 // swap x & y (only pointers are swapped)
174
175 { x.swap(y); }
176
177 void random(GF2EX& x, long n);
random_GF2EX(long n)178 inline GF2EX random_GF2EX(long n)
179 { GF2EX x; random(x, n); NTL_OPT_RETURN(GF2EX, x); }
180 // generate a random polynomial of degree < n
181
182 void trunc(GF2EX& x, const GF2EX& a, long m);
trunc(const GF2EX & a,long m)183 inline GF2EX trunc(const GF2EX& a, long m)
184 { GF2EX x; trunc(x, a, m); NTL_OPT_RETURN(GF2EX, x); }
185 // x = a % X^m
186
187 void RightShift(GF2EX& x, const GF2EX& a, long n);
RightShift(const GF2EX & a,long n)188 inline GF2EX RightShift(const GF2EX& a, long n)
189 { GF2EX x; RightShift(x, a, n); NTL_OPT_RETURN(GF2EX, x); }
190 // x = a/X^n
191
192 void LeftShift(GF2EX& x, const GF2EX& a, long n);
LeftShift(const GF2EX & a,long n)193 inline GF2EX LeftShift(const GF2EX& a, long n)
194 { GF2EX x; LeftShift(x, a, n); NTL_OPT_RETURN(GF2EX, x); }
195 // x = a*X^n
196
197 #ifndef NTL_TRANSITION
198
199 inline GF2EX operator>>(const GF2EX& a, long n)
200 { GF2EX x; RightShift(x, a, n); NTL_OPT_RETURN(GF2EX, x); }
201
202 inline GF2EX operator<<(const GF2EX& a, long n)
203 { GF2EX x; LeftShift(x, a, n); NTL_OPT_RETURN(GF2EX, x); }
204
205 inline GF2EX& operator<<=(GF2EX& x, long n)
206 { LeftShift(x, x, n); return x; }
207
208 inline GF2EX& operator>>=(GF2EX& x, long n)
209 { RightShift(x, x, n); return x; }
210
211 #endif
212
213
214
215 void diff(GF2EX& x, const GF2EX& a);
diff(const GF2EX & a)216 inline GF2EX diff(const GF2EX& a)
217 { GF2EX x; diff(x, a); NTL_OPT_RETURN(GF2EX, x); }
218 // x = derivative of a
219
220
221
222 void MakeMonic(GF2EX& x);
223
224 void reverse(GF2EX& c, const GF2EX& a, long hi);
225
reverse(const GF2EX & a,long hi)226 inline GF2EX reverse(const GF2EX& a, long hi)
227 { GF2EX x; reverse(x, a, hi); NTL_OPT_RETURN(GF2EX, x); }
228
reverse(GF2EX & c,const GF2EX & a)229 inline void reverse(GF2EX& c, const GF2EX& a)
230 { reverse(c, a, deg(a)); }
231
reverse(const GF2EX & a)232 inline GF2EX reverse(const GF2EX& a)
233 { GF2EX x; reverse(x, a); NTL_OPT_RETURN(GF2EX, x); }
234
VectorCopy(vec_GF2E & x,const GF2EX & a,long n)235 inline void VectorCopy(vec_GF2E& x, const GF2EX& a, long n)
236 { VectorCopy(x, a.rep, n); }
237
VectorCopy(const GF2EX & a,long n)238 inline vec_GF2E VectorCopy(const GF2EX& a, long n)
239 { return VectorCopy(a.rep, n); }
240
241
242
243
244 /*******************************************************************
245
246 conversion routines
247
248 ********************************************************************/
249
250
251
252 void conv(GF2EX& x, long a);
253 void conv(GF2EX& x, GF2 a);
254 void conv(GF2EX& x, const GF2E& a);
255 void conv(GF2EX& x, const ZZ& a);
256
257 #ifndef NTL_TRANSITION
258 void conv(GF2EX& x, const GF2X& a);
259 #endif
260
261 void conv(GF2EX& x, const vec_GF2E& a);
262
to_GF2EX(long a)263 inline GF2EX to_GF2EX(long a)
264 { GF2EX x; conv(x, a); NTL_OPT_RETURN(GF2EX, x); }
265
to_GF2EX(GF2 a)266 inline GF2EX to_GF2EX(GF2 a)
267 { GF2EX x; conv(x, a); NTL_OPT_RETURN(GF2EX, x); }
268
to_GF2EX(const GF2E & a)269 inline GF2EX to_GF2EX(const GF2E& a)
270 { GF2EX x; conv(x, a); NTL_OPT_RETURN(GF2EX, x); }
271
to_GF2EX(const ZZ & a)272 inline GF2EX to_GF2EX(const ZZ& a)
273 { GF2EX x; conv(x, a); NTL_OPT_RETURN(GF2EX, x); }
274
275 #ifndef NTL_TRANSITION
to_GF2EX(const GF2X & a)276 inline GF2EX to_GF2EX(const GF2X& a)
277 { GF2EX x; conv(x, a); NTL_OPT_RETURN(GF2EX, x); }
278 #endif
279
to_GF2EX(const vec_GF2E & a)280 inline GF2EX to_GF2EX(const vec_GF2E& a)
281 { GF2EX x; conv(x, a); NTL_OPT_RETURN(GF2EX, x); }
282
283 inline GF2EX& GF2EX::operator=(const GF2E& a) { conv(*this, a); return *this; }
284 inline GF2EX& GF2EX::operator=(GF2 a) { conv(*this, a); return *this; }
285 inline GF2EX& GF2EX::operator=(long a) { conv(*this, a); return *this; }
286
287
288
289
290 /* additional legacy conversions for v6 conversion regime */
291
conv(GF2EX & x,const GF2EX & a)292 inline void conv(GF2EX& x, const GF2EX& a)
293 { x = a; }
294
conv(vec_GF2E & x,const GF2EX & a)295 inline void conv(vec_GF2E& x, const GF2EX& a)
296 { x = a.rep; }
297
298 class ZZX;
299 void conv(GF2EX& x, const ZZX& a);
300
301
302 /* ------------------------------------- */
303
304
305
306
307
308 /*************************************************************
309
310 Comparison
311
312 **************************************************************/
313
314 long IsZero(const GF2EX& a);
315
316 long IsOne(const GF2EX& a);
317
318 inline long operator==(const GF2EX& a, const GF2EX& b)
319 { return a.rep == b.rep; }
320
321 long operator==(const GF2EX& a, const GF2E& b);
322 long operator==(const GF2EX& a, GF2 b);
323 long operator==(const GF2EX& a, long b);
324
325 inline long operator==(const GF2E& a, const GF2EX& b) { return b == a; }
326 inline long operator==(GF2 a, const GF2EX& b) { return b == a; }
327 inline long operator==(long a, const GF2EX& b) { return b == a; }
328
329 inline long operator!=(const GF2EX& a, const GF2EX& b) { return !(a == b); }
330
331 inline long operator!=(const GF2EX& a, const GF2E& b) { return !(a == b); }
332 inline long operator!=(const GF2EX& a, GF2 b) { return !(a == b); }
333 inline long operator!=(const GF2EX& a, long b) { return !(a == b); }
334
335 inline long operator!=(const GF2E& a, const GF2EX& b) { return !(a == b); }
336 inline long operator!=(GF2 a, const GF2EX& b) { return !(a == b); }
337 inline long operator!=(long a, const GF2EX& b) { return !(a == b); }
338
339
340 /***************************************************************
341
342 Addition
343
344 ****************************************************************/
345
346 void add(GF2EX& x, const GF2EX& a, const GF2EX& b);
347 // x = a + b
348
349 void add(GF2EX& x, const GF2EX& a, const GF2E& b);
350 void add(GF2EX& x, const GF2EX& a, GF2 b);
351 void add(GF2EX& x, const GF2EX& a, long);
352
add(GF2EX & x,const GF2E & a,const GF2EX & b)353 inline void add(GF2EX& x, const GF2E& a, const GF2EX& b) { add(x, b, a); }
add(GF2EX & x,GF2 a,const GF2EX & b)354 inline void add(GF2EX& x, GF2 a, const GF2EX& b) { add(x, b, a); }
add(GF2EX & x,long a,const GF2EX & b)355 inline void add(GF2EX& x, long a, const GF2EX& b) { add(x, b, a); }
356
sub(GF2EX & x,const GF2EX & a,const GF2EX & b)357 inline void sub(GF2EX& x, const GF2EX& a, const GF2EX& b) { add(x, a, b); }
358
sub(GF2EX & x,const GF2EX & a,const GF2E & b)359 inline void sub(GF2EX& x, const GF2EX& a, const GF2E& b) { add(x, a, b); }
sub(GF2EX & x,const GF2EX & a,GF2 b)360 inline void sub(GF2EX& x, const GF2EX& a, GF2 b) { add(x, a, b); }
sub(GF2EX & x,const GF2EX & a,long b)361 inline void sub(GF2EX& x, const GF2EX& a, long b) { add(x, a, b); }
362
sub(GF2EX & x,const GF2E & a,const GF2EX & b)363 inline void sub(GF2EX& x, const GF2E& a, const GF2EX& b) { add(x, a, b); }
sub(GF2EX & x,GF2 a,const GF2EX & b)364 inline void sub(GF2EX& x, GF2 a, const GF2EX& b) { add(x, a, b); }
sub(GF2EX & x,long a,const GF2EX & b)365 inline void sub(GF2EX& x, long a, const GF2EX& b) { add(x, a, b); }
366
negate(GF2EX & x,const GF2EX & a)367 inline void negate(GF2EX& x, const GF2EX& a) { x = a; }
368
369
370
371
372 inline GF2EX operator+(const GF2EX& a, const GF2EX& b)
373 { GF2EX x; add(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
374
375 inline GF2EX operator+(const GF2EX& a, const GF2E& b)
376 { GF2EX x; add(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
377
378 inline GF2EX operator+(const GF2EX& a, GF2 b)
379 { GF2EX x; add(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
380
381 inline GF2EX operator+(const GF2EX& a, long b)
382 { GF2EX x; add(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
383
384 inline GF2EX operator+(const GF2E& a, const GF2EX& b)
385 { GF2EX x; add(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
386
387 inline GF2EX operator+(GF2 a, const GF2EX& b)
388 { GF2EX x; add(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
389
390 inline GF2EX operator+(long a, const GF2EX& b)
391 { GF2EX x; add(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
392
393
394 inline GF2EX operator-(const GF2EX& a, const GF2EX& b)
395 { GF2EX x; sub(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
396
397 inline GF2EX operator-(const GF2EX& a, const GF2E& b)
398 { GF2EX x; sub(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
399
400 inline GF2EX operator-(const GF2EX& a, GF2 b)
401 { GF2EX x; sub(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
402
403 inline GF2EX operator-(const GF2EX& a, long b)
404 { GF2EX x; sub(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
405
406 inline GF2EX operator-(const GF2E& a, const GF2EX& b)
407 { GF2EX x; sub(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
408
409 inline GF2EX operator-(GF2 a, const GF2EX& b)
410 { GF2EX x; sub(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
411
412 inline GF2EX operator-(long a, const GF2EX& b)
413 { GF2EX x; sub(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
414
415
416 inline GF2EX& operator+=(GF2EX& x, const GF2EX& b)
417 { add(x, x, b); return x; }
418
419 inline GF2EX& operator+=(GF2EX& x, const GF2E& b)
420 { add(x, x, b); return x; }
421
422 inline GF2EX& operator+=(GF2EX& x, GF2 b)
423 { add(x, x, b); return x; }
424
425 inline GF2EX& operator+=(GF2EX& x, long b)
426 { add(x, x, b); return x; }
427
428 inline GF2EX& operator-=(GF2EX& x, const GF2EX& b)
429 { sub(x, x, b); return x; }
430
431 inline GF2EX& operator-=(GF2EX& x, const GF2E& b)
432 { sub(x, x, b); return x; }
433
434 inline GF2EX& operator-=(GF2EX& x, GF2 b)
435 { sub(x, x, b); return x; }
436
437 inline GF2EX& operator-=(GF2EX& x, long b)
438 { sub(x, x, b); return x; }
439
440
441 inline GF2EX operator-(const GF2EX& a)
442 { GF2EX x; negate(x, a); NTL_OPT_RETURN(GF2EX, x); }
443
444 inline GF2EX& operator++(GF2EX& x) { add(x, x, 1); return x; }
445 inline void operator++(GF2EX& x, int) { add(x, x, 1); }
446 inline GF2EX& operator--(GF2EX& x) { sub(x, x, 1); return x; }
447 inline void operator--(GF2EX& x, int) { sub(x, x, 1); }
448
449
450 /*****************************************************************
451
452 Multiplication
453
454 ******************************************************************/
455
456
457 void mul(GF2EX& x, const GF2EX& a, const GF2EX& b);
458 // x = a * b
459
460 void sqr(GF2EX& x, const GF2EX& a);
sqr(const GF2EX & a)461 inline GF2EX sqr(const GF2EX& a)
462 { GF2EX x; sqr(x, a); NTL_OPT_RETURN(GF2EX, x); }
463 // x = a^2
464
465 void mul(GF2EX & x, const GF2EX& a, const GF2E& b);
466 void mul(GF2EX & x, const GF2EX& a, GF2 b);
467 void mul(GF2EX & x, const GF2EX& a, long b);
468
mul(GF2EX & x,const GF2E & a,const GF2EX & b)469 inline void mul(GF2EX& x, const GF2E& a, const GF2EX& b) { mul(x, b, a); }
mul(GF2EX & x,GF2 a,const GF2EX & b)470 inline void mul(GF2EX& x, GF2 a, const GF2EX& b) { mul(x, b, a); }
mul(GF2EX & x,long a,const GF2EX & b)471 inline void mul(GF2EX& x, long a, const GF2EX& b) { mul(x, b, a); }
472
473 void MulTrunc(GF2EX& x, const GF2EX& a, const GF2EX& b, long n);
MulTrunc(const GF2EX & a,const GF2EX & b,long n)474 inline GF2EX MulTrunc(const GF2EX& a, const GF2EX& b, long n)
475 { GF2EX x; MulTrunc(x, a, b, n); NTL_OPT_RETURN(GF2EX, x); }
476 // x = a * b % X^n
477
478 void SqrTrunc(GF2EX& x, const GF2EX& a, long n);
SqrTrunc(const GF2EX & a,long n)479 inline GF2EX SqrTrunc(const GF2EX& a, long n)
480 { GF2EX x; SqrTrunc(x, a, n); NTL_OPT_RETURN(GF2EX, x); }
481 // x = a*a % X^n
482
483
484 inline GF2EX operator*(const GF2EX& a, const GF2EX& b)
485 { GF2EX x; mul(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
486
487 inline GF2EX operator*(const GF2EX& a, const GF2E& b)
488 { GF2EX x; mul(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
489
490 inline GF2EX operator*(const GF2EX& a, GF2 b)
491 { GF2EX x; mul(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
492
493 inline GF2EX operator*(const GF2EX& a, long b)
494 { GF2EX x; mul(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
495
496 inline GF2EX operator*(const GF2E& a, const GF2EX& b)
497 { GF2EX x; mul(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
498
499 inline GF2EX operator*(GF2 a, const GF2EX& b)
500 { GF2EX x; mul(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
501
502 inline GF2EX operator*(long a, const GF2EX& b)
503 { GF2EX x; mul(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
504
505 inline GF2EX& operator*=(GF2EX& x, const GF2EX& b)
506 { mul(x, x, b); return x; }
507
508 inline GF2EX& operator*=(GF2EX& x, const GF2E& b)
509 { mul(x, x, b); return x; }
510
511 inline GF2EX& operator*=(GF2EX& x, GF2 b)
512 { mul(x, x, b); return x; }
513
514 inline GF2EX& operator*=(GF2EX& x, long b)
515 { mul(x, x, b); return x; }
516
517
518 void power(GF2EX& x, const GF2EX& a, long e);
power(const GF2EX & a,long e)519 inline GF2EX power(const GF2EX& a, long e)
520 { GF2EX x; power(x, a, e); NTL_OPT_RETURN(GF2EX, x); }
521
522
523
524
525 /*************************************************************
526
527 Division
528
529 **************************************************************/
530
531 void DivRem(GF2EX& q, GF2EX& r, const GF2EX& a, const GF2EX& b);
532 // q = a/b, r = a%b
533
534 void div(GF2EX& q, const GF2EX& a, const GF2EX& b);
535 void div(GF2EX& q, const GF2EX& a, const GF2E& b);
536 void div(GF2EX& q, const GF2EX& a, GF2 b);
537 void div(GF2EX& q, const GF2EX& a, long b);
538 // q = a/b
539
540 void rem(GF2EX& r, const GF2EX& a, const GF2EX& b);
541 // r = a%b
542
543 long divide(GF2EX& q, const GF2EX& a, const GF2EX& b);
544 // if b | a, sets q = a/b and returns 1; otherwise returns 0
545
546 long divide(const GF2EX& a, const GF2EX& b);
547 // if b | a, sets q = a/b and returns 1; otherwise returns 0
548
549 void InvTrunc(GF2EX& x, const GF2EX& a, long m);
InvTrunc(const GF2EX & a,long m)550 inline GF2EX InvTrunc(const GF2EX& a, long m)
551 { GF2EX x; InvTrunc(x, a, m); NTL_OPT_RETURN(GF2EX, x); }
552
553 // computes x = a^{-1} % X^m
554 // constant term must be non-zero
555
556
557
558 inline GF2EX operator/(const GF2EX& a, const GF2EX& b)
559 { GF2EX x; div(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
560
561 inline GF2EX operator/(const GF2EX& a, const GF2E& b)
562 { GF2EX x; div(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
563
564 inline GF2EX operator/(const GF2EX& a, GF2 b)
565 { GF2EX x; div(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
566
567 inline GF2EX operator/(const GF2EX& a, long b)
568 { GF2EX x; div(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
569
570 inline GF2EX& operator/=(GF2EX& x, const GF2EX& b)
571 { div(x, x, b); return x; }
572
573 inline GF2EX& operator/=(GF2EX& x, const GF2E& b)
574 { div(x, x, b); return x; }
575
576 inline GF2EX& operator/=(GF2EX& x, GF2 b)
577 { div(x, x, b); return x; }
578
579 inline GF2EX& operator/=(GF2EX& x, long b)
580 { div(x, x, b); return x; }
581
582
583 inline GF2EX operator%(const GF2EX& a, const GF2EX& b)
584 { GF2EX x; rem(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
585
586 inline GF2EX& operator%=(GF2EX& x, const GF2EX& b)
587 { rem(x, x, b); return x; }
588
589
590
591
592 /***********************************************************
593
594 GCD's
595
596 ************************************************************/
597
598
599 void GCD(GF2EX& x, const GF2EX& a, const GF2EX& b);
GCD(const GF2EX & a,const GF2EX & b)600 inline GF2EX GCD(const GF2EX& a, const GF2EX& b)
601 { GF2EX x; GCD(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
602
603 // x = GCD(a, b), x is always monic (or zero if a==b==0).
604
605 void XGCD(GF2EX& d, GF2EX& s, GF2EX& t, const GF2EX& a, const GF2EX& b);
606 // d = gcd(a,b), a s + b t = d
607
608
609 /*************************************************************
610
611 Modular Arithmetic without pre-conditioning
612
613 **************************************************************/
614
615 // arithmetic mod f.
616 // all inputs and outputs are polynomials of degree less than deg(f).
617 // ASSUMPTION: f is assumed monic, and deg(f) > 0.
618 // NOTE: if you want to do many computations with a fixed f,
619 // use the GF2EXModulus data structure and associated routines below.
620
621
622
623 void MulMod(GF2EX& x, const GF2EX& a, const GF2EX& b, const GF2EX& f);
MulMod(const GF2EX & a,const GF2EX & b,const GF2EX & f)624 inline GF2EX MulMod(const GF2EX& a, const GF2EX& b, const GF2EX& f)
625 { GF2EX x; MulMod(x, a, b, f); NTL_OPT_RETURN(GF2EX, x); }
626 // x = (a * b) % f
627
628 void SqrMod(GF2EX& x, const GF2EX& a, const GF2EX& f);
SqrMod(const GF2EX & a,const GF2EX & f)629 inline GF2EX SqrMod(const GF2EX& a, const GF2EX& f)
630 { GF2EX x; SqrMod(x, a, f); NTL_OPT_RETURN(GF2EX, x); }
631 // x = a^2 % f
632
633 void MulByXMod(GF2EX& x, const GF2EX& a, const GF2EX& f);
MulByXMod(const GF2EX & a,const GF2EX & f)634 inline GF2EX MulByXMod(const GF2EX& a, const GF2EX& f)
635 { GF2EX x; MulByXMod(x, a, f); NTL_OPT_RETURN(GF2EX, x); }
636 // x = (a * X) mod f
637
638 void InvMod(GF2EX& x, const GF2EX& a, const GF2EX& f);
InvMod(const GF2EX & a,const GF2EX & f)639 inline GF2EX InvMod(const GF2EX& a, const GF2EX& f)
640 { GF2EX x; InvMod(x, a, f); NTL_OPT_RETURN(GF2EX, x); }
641 // x = a^{-1} % f, error is a is not invertible
642
643 long InvModStatus(GF2EX& x, const GF2EX& a, const GF2EX& f);
644 // if (a, f) = 1, returns 0 and sets x = a^{-1} % f
645 // otherwise, returns 1 and sets x = (a, f)
646
647
648
649
650
651 /******************************************************************
652
653 Modular Arithmetic with Pre-conditioning
654
655 *******************************************************************/
656
657
658 // If you need to do a lot of arithmetic modulo a fixed f,
659 // build GF2EXModulus F for f. This pre-computes information about f
660 // that speeds up the computation a great deal.
661
662 class GF2EXModulus {
663 public:
664 GF2EXModulus();
665
666 GF2EXModulus(const GF2EX& ff);
667
668 GF2EX f; // the modulus
669
670 operator const GF2EX& () const { return f; }
val()671 const GF2EX& val() const { return f; }
672
673 long n; // deg(f)
674
675 long method; // GF2EX_MOD_PLAIN or GF2EX_MOD_MUL
676
677 GF2EX h0;
678 GF2E hlc;
679 GF2EX f0;
680
681 OptionalVal< Lazy<vec_GF2E> > tracevec;
682 // extra level of indirection to ensure class is relocatable
683
684 };
685
686
687 NTL_DECLARE_RELOCATABLE((GF2EXModulus*))
deg(const GF2EXModulus & F)688 inline long deg(const GF2EXModulus& F) { return F.n; }
689
690 void build(GF2EXModulus& F, const GF2EX& f);
691
692
693
694 void rem(GF2EX& r, const GF2EX& a, const GF2EXModulus& F);
695
696 void DivRem(GF2EX& q, GF2EX& r, const GF2EX& a, const GF2EXModulus& F);
697
698 void div(GF2EX& q, const GF2EX& a, const GF2EXModulus& F);
699
700 void MulMod(GF2EX& c, const GF2EX& a, const GF2EX& b, const GF2EXModulus& F);
MulMod(const GF2EX & a,const GF2EX & b,const GF2EXModulus & F)701 inline GF2EX MulMod(const GF2EX& a, const GF2EX& b, const GF2EXModulus& F)
702 { GF2EX x; MulMod(x, a, b, F); NTL_OPT_RETURN(GF2EX, x); }
703
704 void SqrMod(GF2EX& c, const GF2EX& a, const GF2EXModulus& F);
SqrMod(const GF2EX & a,const GF2EXModulus & F)705 inline GF2EX SqrMod(const GF2EX& a, const GF2EXModulus& F)
706 { GF2EX x; SqrMod(x, a, F); NTL_OPT_RETURN(GF2EX, x); }
707
708
709 void PowerMod(GF2EX& h, const GF2EX& g, const ZZ& e, const GF2EXModulus& F);
710
PowerMod(GF2EX & h,const GF2EX & g,long e,const GF2EXModulus & F)711 inline void PowerMod(GF2EX& h, const GF2EX& g, long e, const GF2EXModulus& F)
712 { PowerMod(h, g, ZZ_expo(e), F); }
713
PowerMod(const GF2EX & g,const ZZ & e,const GF2EXModulus & F)714 inline GF2EX PowerMod(const GF2EX& g, const ZZ& e, const GF2EXModulus& F)
715 { GF2EX x; PowerMod(x, g, e, F); NTL_OPT_RETURN(GF2EX, x); }
716
PowerMod(const GF2EX & g,long e,const GF2EXModulus & F)717 inline GF2EX PowerMod(const GF2EX& g, long e, const GF2EXModulus& F)
718 { GF2EX x; PowerMod(x, g, e, F); NTL_OPT_RETURN(GF2EX, x); }
719
720 void PowerXMod(GF2EX& hh, const ZZ& e, const GF2EXModulus& F);
721
PowerXMod(GF2EX & h,long e,const GF2EXModulus & F)722 inline void PowerXMod(GF2EX& h, long e, const GF2EXModulus& F)
723 { PowerXMod(h, ZZ_expo(e), F); }
724
725
PowerXMod(const ZZ & e,const GF2EXModulus & F)726 inline GF2EX PowerXMod(const ZZ& e, const GF2EXModulus& F)
727 { GF2EX x; PowerXMod(x, e, F); NTL_OPT_RETURN(GF2EX, x); }
728
PowerXMod(long e,const GF2EXModulus & F)729 inline GF2EX PowerXMod(long e, const GF2EXModulus& F)
730 { GF2EX x; PowerXMod(x, e, F); NTL_OPT_RETURN(GF2EX, x); }
731
732 inline GF2EX operator%(const GF2EX& a, const GF2EXModulus& F)
733 { GF2EX x; rem(x, a, F); NTL_OPT_RETURN(GF2EX, x); }
734
735 inline GF2EX& operator%=(GF2EX& x, const GF2EXModulus& F)
736 { rem(x, x, F); return x; }
737
738 inline GF2EX operator/(const GF2EX& a, const GF2EXModulus& F)
739 { GF2EX x; div(x, a, F); NTL_OPT_RETURN(GF2EX, x); }
740
741 inline GF2EX& operator/=(GF2EX& x, const GF2EXModulus& F)
742 { div(x, x, F); return x; }
743
744
745
746 /*****************************************************************
747
748 vectors of GF2EX's
749
750 *****************************************************************/
751
752
753
754 typedef Vec<GF2EX> vec_GF2EX;
755
756
757
758 /*******************************************************
759
760 Evaluation and related problems
761
762 ********************************************************/
763
764
765 void BuildFromRoots(GF2EX& x, const vec_GF2E& a);
BuildFromRoots(const vec_GF2E & a)766 inline GF2EX BuildFromRoots(const vec_GF2E& a)
767 { GF2EX x; BuildFromRoots(x, a); NTL_OPT_RETURN(GF2EX, x); }
768 // computes the polynomial (X-a[0]) ... (X-a[n-1]), where n = a.length()
769
770
771 void eval(GF2E& b, const GF2EX& f, const GF2E& a);
eval(const GF2EX & f,const GF2E & a)772 inline GF2E eval(const GF2EX& f, const GF2E& a)
773 { GF2E x; eval(x, f, a); NTL_OPT_RETURN(GF2E, x); }
774 // b = f(a)
775
776 void eval(vec_GF2E& b, const GF2EX& f, const vec_GF2E& a);
eval(const GF2EX & f,const vec_GF2E & a)777 inline vec_GF2E eval(const GF2EX& f, const vec_GF2E& a)
778 { vec_GF2E x; eval(x, f, a); NTL_OPT_RETURN(vec_GF2E, x); }
779 // b[i] = f(a[i])
780
eval(GF2E & b,const GF2X & f,const GF2E & a)781 inline void eval(GF2E& b, const GF2X& f, const GF2E& a)
782 { conv(b, CompMod(f, rep(a), GF2E::modulus())); }
783
eval(const GF2X & f,const GF2E & a)784 inline GF2E eval(const GF2X& f, const GF2E& a)
785 { GF2E x; eval(x, f, a); NTL_OPT_RETURN(GF2E, x); }
786 // b = f(a)
787
788
789 void interpolate(GF2EX& f, const vec_GF2E& a, const vec_GF2E& b);
interpolate(const vec_GF2E & a,const vec_GF2E & b)790 inline GF2EX interpolate(const vec_GF2E& a, const vec_GF2E& b)
791 { GF2EX x; interpolate(x, a, b); NTL_OPT_RETURN(GF2EX, x); }
792 // computes f such that f(a[i]) = b[i]
793
794
795
796
797 /**********************************************************
798
799 Modular Composition and Minimal Polynomials
800
801 ***********************************************************/
802
803
804 // algorithms for computing g(h) mod f
805
806
807
808
809 void CompMod(GF2EX& x, const GF2EX& g, const GF2EX& h, const GF2EXModulus& F);
810 inline GF2EX
CompMod(const GF2EX & g,const GF2EX & h,const GF2EXModulus & F)811 CompMod(const GF2EX& g, const GF2EX& h, const GF2EXModulus& F)
812 { GF2EX x; CompMod(x, g, h, F); NTL_OPT_RETURN(GF2EX, x); }
813 // x = g(h) mod f
814
815 void Comp2Mod(GF2EX& x1, GF2EX& x2, const GF2EX& g1, const GF2EX& g2,
816 const GF2EX& h, const GF2EXModulus& F);
817 // xi = gi(h) mod f (i=1,2)
818
819 void Comp3Mod(GF2EX& x1, GF2EX& x2, GF2EX& x3,
820 const GF2EX& g1, const GF2EX& g2, const GF2EX& g3,
821 const GF2EX& h, const GF2EXModulus& F);
822 // xi = gi(h) mod f (i=1..3)
823
824
825
826 // The routine build (see below) which is implicitly called
827 // by the various compose and UpdateMap routines builds a table
828 // of polynomials.
829 // If GF2EXArgBound > 0, then the table is limited in
830 // size to approximamtely that many KB.
831 // If GF2EXArgBound <= 0, then it is ignored, and space is allocated
832 // so as to maximize speed.
833 // Initially, GF2EXArgBound = 0.
834
835
836 // If a single h is going to be used with many g's
837 // then you should build a GF2EXArgument for h,
838 // and then use the compose routine below.
839 // build computes and stores h, h^2, ..., h^m mod f.
840 // After this pre-computation, composing a polynomial of degree
841 // roughly n with h takes n/m multiplies mod f, plus n^2
842 // scalar multiplies.
843 // Thus, increasing m increases the space requirement and the pre-computation
844 // time, but reduces the composition time.
845 // If GF2EXArgBound > 0, a table of size less than m may be built.
846
847 struct GF2EXArgument {
848 vec_GF2EX H;
849 };
850
851 extern
852 NTL_CHEAP_THREAD_LOCAL
853 long GF2EXArgBound;
854
855
856 void build(GF2EXArgument& H, const GF2EX& h, const GF2EXModulus& F, long m);
857
858 // m must be > 0, otherwise an error is raised
859
860 void CompMod(GF2EX& x, const GF2EX& g, const GF2EXArgument& H,
861 const GF2EXModulus& F);
862
863 inline GF2EX
CompMod(const GF2EX & g,const GF2EXArgument & H,const GF2EXModulus & F)864 CompMod(const GF2EX& g, const GF2EXArgument& H, const GF2EXModulus& F)
865 { GF2EX x; CompMod(x, g, H, F); NTL_OPT_RETURN(GF2EX, x); }
866
867
868
869
870 void MinPolySeq(GF2EX& h, const vec_GF2E& a, long m);
MinPolySeq(const vec_GF2E & a,long m)871 inline GF2EX MinPolySeq(const vec_GF2E& a, long m)
872 { GF2EX x; MinPolySeq(x, a, m); NTL_OPT_RETURN(GF2EX, x); }
873
874
875 void MinPolyMod(GF2EX& hh, const GF2EX& g, const GF2EXModulus& F);
MinPolyMod(const GF2EX & g,const GF2EXModulus & F)876 inline GF2EX MinPolyMod(const GF2EX& g, const GF2EXModulus& F)
877 { GF2EX x; MinPolyMod(x, g, F); NTL_OPT_RETURN(GF2EX, x); }
878
879
880 void MinPolyMod(GF2EX& hh, const GF2EX& g, const GF2EXModulus& F, long m);
MinPolyMod(const GF2EX & g,const GF2EXModulus & F,long m)881 inline GF2EX MinPolyMod(const GF2EX& g, const GF2EXModulus& F, long m)
882 { GF2EX x; MinPolyMod(x, g, F, m); NTL_OPT_RETURN(GF2EX, x); }
883
884 void ProbMinPolyMod(GF2EX& hh, const GF2EX& g, const GF2EXModulus& F);
ProbMinPolyMod(const GF2EX & g,const GF2EXModulus & F)885 inline GF2EX ProbMinPolyMod(const GF2EX& g, const GF2EXModulus& F)
886 { GF2EX x; ProbMinPolyMod(x, g, F); NTL_OPT_RETURN(GF2EX, x); }
887
888 void ProbMinPolyMod(GF2EX& hh, const GF2EX& g, const GF2EXModulus& F, long m);
ProbMinPolyMod(const GF2EX & g,const GF2EXModulus & F,long m)889 inline GF2EX ProbMinPolyMod(const GF2EX& g, const GF2EXModulus& F, long m)
890 { GF2EX x; ProbMinPolyMod(x, g, F, m); NTL_OPT_RETURN(GF2EX, x); }
891
892 void IrredPolyMod(GF2EX& h, const GF2EX& g, const GF2EXModulus& F);
IrredPolyMod(const GF2EX & g,const GF2EXModulus & F)893 inline GF2EX IrredPolyMod(const GF2EX& g, const GF2EXModulus& F)
894 { GF2EX x; IrredPolyMod(x, g, F); NTL_OPT_RETURN(GF2EX, x); }
895
896 void IrredPolyMod(GF2EX& h, const GF2EX& g, const GF2EXModulus& F, long m);
IrredPolyMod(const GF2EX & g,const GF2EXModulus & F,long m)897 inline GF2EX IrredPolyMod(const GF2EX& g, const GF2EXModulus& F, long m)
898 { GF2EX x; IrredPolyMod(x, g, F, m); NTL_OPT_RETURN(GF2EX, x); }
899
900
901 struct GF2EXTransMultiplier {
902 GF2EX f0, fbi, b;
903 long shamt, shamt_fbi, shamt_b;
904 };
905
906 void build(GF2EXTransMultiplier& B, const GF2EX& b, const GF2EXModulus& F);
907
908 void TransMulMod(GF2EX& x, const GF2EX& a, const GF2EXTransMultiplier& B,
909 const GF2EXModulus& F);
910
911 void UpdateMap(vec_GF2E& x, const vec_GF2E& a,
912 const GF2EXTransMultiplier& B, const GF2EXModulus& F);
913
UpdateMap(const vec_GF2E & a,const GF2EXTransMultiplier & B,const GF2EXModulus & F)914 inline vec_GF2E UpdateMap(const vec_GF2E& a,
915 const GF2EXTransMultiplier& B, const GF2EXModulus& F)
916 { vec_GF2E x; UpdateMap(x, a, B, F); NTL_OPT_RETURN(vec_GF2E, x); }
917
918 void ProjectPowers(vec_GF2E& x, const vec_GF2E& a, long k,
919 const GF2EXArgument& H, const GF2EXModulus& F);
ProjectPowers(const vec_GF2E & a,long k,const GF2EXArgument & H,const GF2EXModulus & F)920 inline vec_GF2E ProjectPowers(const vec_GF2E& a, long k,
921 const GF2EXArgument& H, const GF2EXModulus& F)
922 { vec_GF2E x; ProjectPowers(x, a, k, H, F); NTL_OPT_RETURN(vec_GF2E, x); }
923
924 void ProjectPowers(vec_GF2E& x, const vec_GF2E& a, long k, const GF2EX& h,
925 const GF2EXModulus& F);
ProjectPowers(const vec_GF2E & a,long k,const GF2EX & H,const GF2EXModulus & F)926 inline vec_GF2E ProjectPowers(const vec_GF2E& a, long k,
927 const GF2EX& H, const GF2EXModulus& F)
928 { vec_GF2E x; ProjectPowers(x, a, k, H, F); NTL_OPT_RETURN(vec_GF2E, x); }
929
project(GF2E & x,const vec_GF2E & a,const GF2EX & b)930 inline void project(GF2E& x, const vec_GF2E& a, const GF2EX& b)
931 { InnerProduct(x, a, b.rep); }
932
project(const vec_GF2E & a,const GF2EX & b)933 inline GF2E project(const vec_GF2E& a, const GF2EX& b)
934 { GF2E x; InnerProduct(x, a, b.rep); NTL_OPT_RETURN(GF2E, x); }
935
936 /**********************************************************
937
938 Modular Composition and Minimal Polynomials
939 in towers
940
941 ***********************************************************/
942
943 // composition
944
945 void CompTower(GF2EX& x, const GF2X& g, const GF2EXArgument& A,
946 const GF2EXModulus& F);
947
CompTower(const GF2X & g,const GF2EXArgument & A,const GF2EXModulus & F)948 inline GF2EX CompTower(const GF2X& g, const GF2EXArgument& A,
949 const GF2EXModulus& F)
950 { GF2EX x; CompTower(x, g, A, F); NTL_OPT_RETURN(GF2EX, x); }
951
952 void CompTower(GF2EX& x, const GF2X& g, const GF2EX& h,
953 const GF2EXModulus& F);
954
CompTower(const GF2X & g,const GF2EX & h,const GF2EXModulus & F)955 inline GF2EX CompTower(const GF2X& g, const GF2EX& h,
956 const GF2EXModulus& F)
957 { GF2EX x; CompTower(x, g, h, F); NTL_OPT_RETURN(GF2EX, x); }
958
959 // prob min poly
960
961 void ProbMinPolyTower(GF2X& h, const GF2EX& g, const GF2EXModulus& F,
962 long m);
963
ProbMinPolyTower(const GF2EX & g,const GF2EXModulus & F,long m)964 inline GF2X ProbMinPolyTower(const GF2EX& g, const GF2EXModulus& F,
965 long m)
966 { GF2X x; ProbMinPolyTower(x, g, F, m); NTL_OPT_RETURN(GF2X, x); }
967
ProbMinPolyTower(GF2X & h,const GF2EX & g,const GF2EXModulus & F)968 inline void ProbMinPolyTower(GF2X& h, const GF2EX& g,
969 const GF2EXModulus& F)
970 { ProbMinPolyTower(h, g, F, deg(F)*GF2E::degree()); }
971
ProbMinPolyTower(const GF2EX & g,const GF2EXModulus & F)972 inline GF2X ProbMinPolyTower(const GF2EX& g, const GF2EXModulus& F)
973 { GF2X x; ProbMinPolyTower(x, g, F); NTL_OPT_RETURN(GF2X, x); }
974
975
976 // min poly
977
978
979 void MinPolyTower(GF2X& h, const GF2EX& g, const GF2EXModulus& F,
980 long m);
981
MinPolyTower(const GF2EX & g,const GF2EXModulus & F,long m)982 inline GF2X MinPolyTower(const GF2EX& g, const GF2EXModulus& F,
983 long m)
984 { GF2X x; MinPolyTower(x, g, F, m); NTL_OPT_RETURN(GF2X, x); }
985
MinPolyTower(GF2X & h,const GF2EX & g,const GF2EXModulus & F)986 inline void MinPolyTower(GF2X& h, const GF2EX& g,
987 const GF2EXModulus& F)
988 { MinPolyTower(h, g, F, deg(F)*GF2E::degree()); }
989
MinPolyTower(const GF2EX & g,const GF2EXModulus & F)990 inline GF2X MinPolyTower(const GF2EX& g, const GF2EXModulus& F)
991 { GF2X x; MinPolyTower(x, g, F); NTL_OPT_RETURN(GF2X, x); }
992
993 // irred poly
994
995
996 void IrredPolyTower(GF2X& h, const GF2EX& g, const GF2EXModulus& F,
997 long m);
998
IrredPolyTower(const GF2EX & g,const GF2EXModulus & F,long m)999 inline GF2X IrredPolyTower(const GF2EX& g, const GF2EXModulus& F,
1000 long m)
1001 { GF2X x; IrredPolyTower(x, g, F, m); NTL_OPT_RETURN(GF2X, x); }
1002
IrredPolyTower(GF2X & h,const GF2EX & g,const GF2EXModulus & F)1003 inline void IrredPolyTower(GF2X& h, const GF2EX& g,
1004 const GF2EXModulus& F)
1005 { IrredPolyTower(h, g, F, deg(F)*GF2E::degree()); }
1006
IrredPolyTower(const GF2EX & g,const GF2EXModulus & F)1007 inline GF2X IrredPolyTower(const GF2EX& g, const GF2EXModulus& F)
1008 { GF2X x; IrredPolyTower(x, g, F); NTL_OPT_RETURN(GF2X, x); }
1009
1010
1011
1012 /*****************************************************************
1013
1014 Traces, norms, resultants
1015
1016 ******************************************************************/
1017
1018 void TraceVec(vec_GF2E& S, const GF2EX& f);
1019
TraceVec(const GF2EX & f)1020 inline vec_GF2E TraceVec(const GF2EX& f)
1021 { vec_GF2E x; TraceVec(x, f); NTL_OPT_RETURN(vec_GF2E, x); }
1022
1023
1024 void TraceMod(GF2E& x, const GF2EX& a, const GF2EXModulus& F);
1025
TraceMod(const GF2EX & a,const GF2EXModulus & F)1026 inline GF2E TraceMod(const GF2EX& a, const GF2EXModulus& F)
1027 { GF2E x; TraceMod(x, a, F); NTL_OPT_RETURN(GF2E, x); }
1028
1029 void TraceMod(GF2E& x, const GF2EX& a, const GF2EX& f);
1030
TraceMod(const GF2EX & a,const GF2EX & f)1031 inline GF2E TraceMod(const GF2EX& a, const GF2EX& f)
1032 { GF2E x; TraceMod(x, a, f); NTL_OPT_RETURN(GF2E, x); }
1033
1034
1035
1036
1037
1038 void NormMod(GF2E& x, const GF2EX& a, const GF2EX& f);
1039
NormMod(const GF2EX & a,const GF2EX & f)1040 inline GF2E NormMod(const GF2EX& a, const GF2EX& f)
1041 { GF2E x; NormMod(x, a, f); NTL_OPT_RETURN(GF2E, x); }
1042
1043 void resultant(GF2E& rres, const GF2EX& a, const GF2EX& b);
1044
resultant(const GF2EX & a,const GF2EX & b)1045 inline GF2E resultant(const GF2EX& a, const GF2EX& b)
1046 { GF2E x; resultant(x, a, b); NTL_OPT_RETURN(GF2E, x); }
1047
1048
1049 NTL_CLOSE_NNS
1050
1051 #endif
1052