source: git/ntl/doc/GF2X.txt @ 2cfffe

spielwiese
Last change on this file since 2cfffe was 2cfffe, checked in by Hans Schönemann <hannes@…>, 21 years ago
This commit was generated by cvs2svn to compensate for changes in r6316, which included commits to RCS files with non-trunk default branches. git-svn-id: file:///usr/local/Singular/svn/trunk@6317 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 21.9 KB
Line 
1
2/**************************************************************************\
3
4MODULE: GF2X
5
6SUMMARY:
7
8The class GF2X implements polynomial arithmetic modulo 2.
9
10Polynomial arithmetic is implemented using a combination of classical
11routines and Karatsuba.
12
13\**************************************************************************/
14
15#include <NTL/GF2.h>
16#include <NTL/vec_GF2.h>
17
18class GF2X {
19public:
20
21   GF2X(); // initial value 0
22
23   GF2X(const GF2X& a); // copy
24
25   GF2X& operator=(const GF2X& a); // assignment
26   GF2X& operator=(GF2 a);
27   GF2X& operator=(long a);
28
29   ~GF2X(); // destructor
30
31   GF2X(long i, GF2 c); // initialize to X^i*c
32   GF2X(long i, long c);
33   
34};
35
36
37// SIZE INVARIANT: for any f in GF2X, def(f)+1 < 2^(NTL_BITS_PER_LONG-4).
38
39
40
41/**************************************************************************\
42
43                                  Comparison
44
45\**************************************************************************/
46
47
48long operator==(const GF2X& a, const GF2X& b);
49long operator!=(const GF2X& a, const GF2X& b);
50
51long IsZero(const GF2X& a); // test for 0
52long IsOne(const GF2X& a); // test for 1
53
54// PROMOTIONS: operators ==, != promote {long, GF2} to GF2X on (a, b)
55
56
57/**************************************************************************\
58
59                                   Addition
60
61\**************************************************************************/
62
63// operator notation:
64
65GF2X operator+(const GF2X& a, const GF2X& b);
66GF2X operator-(const GF2X& a, const GF2X& b);
67
68GF2X operator-(const GF2X& a); // unary -
69
70GF2X& operator+=(GF2X& x, const GF2X& a);
71GF2X& operator+=(GF2X& x, GF2 a);
72GF2X& operator+=(GF2X& x, long a);
73
74GF2X& operator-=(GF2X& x, const GF2X& a);
75GF2X& operator-=(GF2X& x, GF2 a);
76GF2X& operator-=(GF2X& x, long a);
77
78GF2X& operator++(GF2X& x);  // prefix
79void operator++(GF2X& x, int);  // postfix
80
81GF2X& operator--(GF2X& x);  // prefix
82void operator--(GF2X& x, int);  // postfix
83
84// procedural versions:
85
86
87void add(GF2X& x, const GF2X& a, const GF2X& b); // x = a + b
88void sub(GF2X& x, const GF2X& a, const GF2X& b); // x = a - b
89void negate(GF2X& x, const GF2X& a); // x = -a
90
91// PROMOTIONS: binary +, - and procedures add, sub promote {long, GF2}
92// to GF2X on (a, b).
93
94
95/**************************************************************************\
96
97                               Multiplication
98
99\**************************************************************************/
100
101// operator notation:
102
103GF2X operator*(const GF2X& a, const GF2X& b);
104
105GF2X& operator*=(GF2X& x, const GF2X& a);
106GF2X& operator*=(GF2X& x, GF2 a);
107GF2X& operator*=(GF2X& x, long a);
108
109// procedural versions:
110
111void mul(GF2X& x, const GF2X& a, const GF2X& b); // x = a * b
112
113void sqr(GF2X& x, const GF2X& a); // x = a^2
114GF2X sqr(const GF2X& a);
115
116// PROMOTIONS: operator * and procedure mul promote {long, GF2} to GF2X
117// on (a, b).
118
119
120/**************************************************************************\
121
122                               Shift Operations
123
124LeftShift by n means multiplication by X^n
125RightShift by n means division by X^n
126
127A negative shift amount reverses the direction of the shift.
128
129\**************************************************************************/
130
131// operator notation:
132
133GF2X operator<<(const GF2X& a, long n);
134GF2X operator>>(const GF2X& a, long n);
135
136GF2X& operator<<=(GF2X& x, long n);
137GF2X& operator>>=(GF2X& x, long n);
138
139// procedural versions:
140
141void LeftShift(GF2X& x, const GF2X& a, long n);
142GF2X LeftShift(const GF2X& a, long n);
143
144void RightShift(GF2X& x, const GF2X& a, long n);
145GF2X RightShift(const GF2X& a, long n);
146
147void MulByX(GF2X& x, const GF2X& a);
148GF2X MulByX(const GF2X& a);
149
150
151/**************************************************************************\
152
153                                  Division
154
155\**************************************************************************/
156
157// operator notation:
158
159GF2X operator/(const GF2X& a, const GF2X& b);
160GF2X operator%(const GF2X& a, const GF2X& b);
161
162GF2X& operator/=(GF2X& x, const GF2X& a);
163GF2X& operator/=(GF2X& x, GF2 a);
164GF2X& operator/=(GF2X& x, long a);
165
166GF2X& operator%=(GF2X& x, const GF2X& b);
167
168
169// procedural versions:
170
171
172void DivRem(GF2X& q, GF2X& r, const GF2X& a, const GF2X& b);
173// q = a/b, r = a%b
174
175void div(GF2X& q, const GF2X& a, const GF2X& b);
176// q = a/b
177
178void rem(GF2X& r, const GF2X& a, const GF2X& b);
179// r = a%b
180
181long divide(GF2X& q, const GF2X& a, const GF2X& b);
182// if b | a, sets q = a/b and returns 1; otherwise returns 0
183
184long divide(const GF2X& a, const GF2X& b);
185// if b | a, sets q = a/b and returns 1; otherwise returns 0
186
187// PROMOTIONS: operator / and procedure div promote {long, GF2} to GF2X
188// on (a, b).
189
190
191/**************************************************************************\
192
193                                   GCD's
194
195\**************************************************************************/
196
197
198void GCD(GF2X& x, const GF2X& a, const GF2X& b);
199GF2X GCD(const GF2X& a, const GF2X& b);
200// x = GCD(a, b) (zero if a==b==0).
201
202
203void XGCD(GF2X& d, GF2X& s, GF2X& t, const GF2X& a, const GF2X& b);
204// d = gcd(a,b), a s + b t = d
205
206
207/**************************************************************************\
208
209                                  Input/Output
210
211I/O format:
212
213   [a_0 a_1 ... a_n],
214
215represents the polynomial a_0 + a_1*X + ... + a_n*X^n.
216
217On output, all coefficients will be 0 or 1, and
218a_n not zero (the zero polynomial is [ ]).  On input, the coefficients
219may be arbitrary integers which are reduced modulo 2, and leading zeros
220stripped.
221
222There is also a more compact hex I/O format.  To output in this
223format, set GF2X::HexOutput to a nonzero value.  On input, if the first
224non-blank character read is 'x' or 'X', then a hex format is assumed.
225
226
227\**************************************************************************/
228
229istream& operator>>(istream& s, GF2X& x);
230ostream& operator<<(ostream& s, const GF2X& a);
231
232
233/**************************************************************************\
234
235                              Some utility routines
236
237\**************************************************************************/
238
239long deg(const GF2X& a);  // return deg(a); deg(0) == -1.
240
241GF2 coeff(const GF2X& a, long i);
242// returns the coefficient of X^i, or zero if i not in range
243
244GF2 LeadCoeff(const GF2X& a);
245// returns leading term of a, or zero if a == 0
246
247GF2 ConstTerm(const GF2X& a);
248// returns constant term of a, or zero if a == 0
249
250void SetCoeff(GF2X& x, long i, GF2 a);
251void SetCoeff(GF2X& x, long i, long a);
252// makes coefficient of X^i equal to a; error is raised if i < 0
253
254void SetCoeff(GF2X& x, long i);
255// makes coefficient of X^i equal to 1;  error is raised if i < 0
256
257void SetX(GF2X& x); // x is set to the monomial X
258
259long IsX(const GF2X& a); // test if x = X
260
261void diff(GF2X& x, const GF2X& a);
262GF2X diff(const GF2X& a);
263// x = derivative of a
264
265
266void reverse(GF2X& x, const GF2X& a, long hi);
267GF2X reverse(const GF2X& a, long hi);
268
269void reverse(GF2X& x, const GF2X& a);
270GF2X reverse(const GF2X& a);
271
272// x = reverse of a[0]..a[hi] (hi >= -1);
273// hi defaults to deg(a) in second version
274
275
276void VectorCopy(vec_GF2& x, const GF2X& a, long n);
277vec_GF2 VectorCopy(const GF2X& a, long n);
278// x = copy of coefficient vector of a of length exactly n.
279// input is truncated or padded with zeroes as appropriate.
280
281// Note that there is also a conversion routine from GF2X to vec_GF2
282// that makes the length of the vector match the number of coefficients
283// of the polynomial.
284
285long weight(const GF2X& a);
286// returns the # of nonzero coefficients in a
287
288void GF2XFromBytes(GF2X& x, const unsigned char *p, long n);
289GF2X GF2XFromBytes(const unsigned char *p, long n);
290// conversion from byte vector to polynomial.
291// x = sum(p[i]*X^(8*i), i = 0..n-1), where the bits of p[i] are interpretted
292// as a polynomial in the natural way (i.e., p[i] = 1 is interpretted as 1,
293// p[i] = 2 is interpretted as X, p[i] = 3 is interpretted as X+1, etc.).
294// In the unusual event that characters are wider than 8 bits,
295// only the low-order 8 bits of p[i] are used.
296
297void BytesFromGF2X(unsigned char *p, const GF2X& a, long n);
298// conversion from polynomial to byte vector.
299// p[0..n-1] are computed so that
300//     a = sum(p[i]*X^(8*i), i = 0..n-1) mod X^(8*n),
301// where the values p[i] are interpretted as polynomials as in GF2XFromBytes
302// above.
303
304long NumBits(const GF2X& a);
305// returns number of bits of a, i.e., deg(a) + 1.
306
307long NumBytes(const GF2X& a);
308// returns number of bytes of a, i.e., floor((NumBits(a)+7)/8)
309
310
311
312
313/**************************************************************************\
314
315                             Random Polynomials
316
317\**************************************************************************/
318
319void random(GF2X& x, long n);
320GF2X random_GF2X(long n);
321// x = random polynomial of degree < n
322
323
324
325/**************************************************************************\
326
327                       Arithmetic mod X^n
328
329Required: n >= 0; otherwise, an error is raised.
330
331\**************************************************************************/
332
333void trunc(GF2X& x, const GF2X& a, long n); // x = a % X^n
334GF2X trunc(const GF2X& a, long n);
335
336void MulTrunc(GF2X& x, const GF2X& a, const GF2X& b, long n);
337GF2X MulTrunc(const GF2X& a, const GF2X& b, long n);
338// x = a * b % X^n
339
340void SqrTrunc(GF2X& x, const GF2X& a, long n);
341GF2X SqrTrunc(const GF2X& a, long n);
342// x = a^2 % X^n
343
344void InvTrunc(GF2X& x, const GF2X& a, long n);
345GF2X InvTrunc(const GF2X& a, long n);
346// computes x = a^{-1} % X^n.  Must have ConstTerm(a) invertible.
347
348/**************************************************************************\
349
350                Modular Arithmetic (without pre-conditioning)
351
352Arithmetic mod f.
353
354All inputs and outputs are polynomials of degree less than deg(f), and
355deg(f) > 0.
356
357NOTE: if you want to do many computations with a fixed f, use the
358GF2XModulus data structure and associated routines below for better
359performance.
360
361\**************************************************************************/
362
363void MulMod(GF2X& x, const GF2X& a, const GF2X& b, const GF2X& f);
364GF2X MulMod(const GF2X& a, const GF2X& b, const GF2X& f);
365// x = (a * b) % f
366
367void SqrMod(GF2X& x, const GF2X& a, const GF2X& f);
368GF2X SqrMod(const GF2X& a, const GF2X& f);
369// x = a^2 % f
370
371void MulByXMod(GF2X& x, const GF2X& a, const GF2X& f);
372GF2X MulByXMod(const GF2X& a, const GF2X& f);
373// x = (a * X) mod f
374
375void InvMod(GF2X& x, const GF2X& a, const GF2X& f);
376GF2X InvMod(const GF2X& a, const GF2X& f);
377// x = a^{-1} % f, error is a is not invertible
378
379long InvModStatus(GF2X& x, const GF2X& a, const GF2X& f);
380// if (a, f) = 1, returns 0 and sets x = a^{-1} % f; otherwise,
381// returns 1 and sets x = (a, f)
382
383
384// for modular exponentiation, see below
385
386
387
388/**************************************************************************\
389
390                     Modular Arithmetic with Pre-Conditioning
391
392If you need to do a lot of arithmetic modulo a fixed f, build
393GF2XModulus F for f.  This pre-computes information about f that
394speeds up subsequent computations.
395
396As an example, the following routine computes the product modulo f of a vector
397of polynomials.
398
399#include <NTL/GF2X.h>
400
401void product(GF2X& x, const vec_GF2X& v, const GF2X& f)
402{
403   GF2XModulus F(f);
404   GF2X res;
405   res = 1;
406   long i;
407   for (i = 0; i < v.length(); i++)
408      MulMod(res, res, v[i], F);
409   x = res;
410}
411
412
413Note that automatic conversions are provided so that a GF2X can
414be used wherever a GF2XModulus is required, and a GF2XModulus
415can be used wherever a GF2X is required.
416
417The GF2XModulus routines optimize several important special cases:
418
419  - f = X^n + X^k + 1, where k <= min((n+1)/2, n-NTL_BITS_PER_LONG)
420
421  - f = X^n + X^{k_3} + X^{k_2} + X^{k_1} + 1,
422      where k_3 <= min((n+1)/2, n-NTL_BITS_PER_LONG)
423
424  - f = X^n + g, where deg(g) is small
425
426
427\**************************************************************************/
428
429class GF2XModulus {
430public:
431   GF2XModulus(); // initially in an unusable state
432   ~GF2XModulus();
433
434   GF2XModulus(const GF2XModulus&);  // copy
435
436   GF2XModulus& operator=(const GF2XModulus&);   // assignment
437
438   GF2XModulus(const GF2X& f); // initialize with f, deg(f) > 0
439
440   operator const GF2X& () const;
441   // read-only access to f, implicit conversion operator
442
443   const GF2X& val() const;
444   // read-only access to f, explicit notation
445
446   long WordLength() const;
447   // returns word-length of resisues
448};
449
450void build(GF2XModulus& F, const GF2X& f);
451// pre-computes information about f and stores it in F; deg(f) > 0.
452// Note that the declaration GF2XModulus F(f) is equivalent to
453// GF2XModulus F; build(F, f).
454
455// In the following, f refers to the polynomial f supplied to the
456// build routine, and n = deg(f).
457
458long deg(const GF2XModulus& F);  // return deg(f)
459
460void MulMod(GF2X& x, const GF2X& a, const GF2X& b, const GF2XModulus& F);
461GF2X MulMod(const GF2X& a, const GF2X& b, const GF2XModulus& F);
462// x = (a * b) % f; deg(a), deg(b) < n
463
464void SqrMod(GF2X& x, const GF2X& a, const GF2XModulus& F);
465GF2X SqrMod(const GF2X& a, const GF2XModulus& F);
466// x = a^2 % f; deg(a) < n
467
468void MulByXMod(GF2X& x, const GF2X& a, const GF2XModulus& F);
469GF2X MulByXMod(const GF2X& a, const GF2XModulus& F);
470// x = (a * X) mod F
471
472void PowerMod(GF2X& x, const GF2X& a, const ZZ& e, const GF2XModulus& F);
473GF2X PowerMod(const GF2X& a, const ZZ& e, const GF2XModulus& F);
474
475void PowerMod(GF2X& x, const GF2X& a, long e, const GF2XModulus& F);
476GF2X PowerMod(const GF2X& a, long e, const GF2XModulus& F);
477
478// x = a^e % f; deg(a) < n (e may be negative)
479
480void PowerXMod(GF2X& x, const ZZ& e, const GF2XModulus& F);
481GF2X PowerXMod(const ZZ& e, const GF2XModulus& F);
482
483void PowerXMod(GF2X& x, long e, const GF2XModulus& F);
484GF2X PowerXMod(long e, const GF2XModulus& F);
485
486// x = X^e % f (e may be negative)
487
488
489void rem(GF2X& x, const GF2X& a, const GF2XModulus& F);
490// x = a % f
491
492void DivRem(GF2X& q, GF2X& r, const GF2X& a, const GF2XModulus& F);
493// q = a/f, r = a%f
494
495void div(GF2X& q, const GF2X& a, const GF2XModulus& F);
496// q = a/f
497
498// operator notation:
499
500GF2X operator/(const GF2X& a, const GF2XModulus& F);
501GF2X operator%(const GF2X& a, const GF2XModulus& F);
502
503GF2X& operator/=(GF2X& x, const GF2XModulus& F);
504GF2X& operator%=(GF2X& x, const GF2XModulus& F);
505
506
507/**************************************************************************\
508
509                             vectors of GF2X's
510
511\**************************************************************************/
512
513NTL_vector_decl(GF2X,vec_GF2X)
514// vec_GF2X
515
516NTL_eq_vector_decl(GF2X,vec_GF2X)
517// == and !=
518
519NTL_io_vector_decl(GF2X,vec_GF2X)
520// I/O operators
521
522
523/**************************************************************************\
524
525                              Modular Composition
526
527Modular composition is the problem of computing g(h) mod f for
528polynomials f, g, and h.
529
530The algorithm employed is that of Brent & Kung (Fast algorithms for
531manipulating formal power series, JACM 25:581-595, 1978), which uses
532O(n^{1/2}) modular polynomial multiplications, and O(n^2) scalar
533operations.
534
535
536
537\**************************************************************************/
538
539void CompMod(GF2X& x, const GF2X& g, const GF2X& h, const GF2XModulus& F);
540GF2X CompMod(const GF2X& g, const GF2X& h, const GF2XModulus& F);
541// x = g(h) mod f; deg(h) < n
542
543void Comp2Mod(GF2X& x1, GF2X& x2, const GF2X& g1, const GF2X& g2,
544              const GF2X& h, const GF2XModulus& F);
545// xi = gi(h) mod f (i=1,2), deg(h) < n.
546
547void CompMod3(GF2X& x1, GF2X& x2, GF2X& x3,
548              const GF2X& g1, const GF2X& g2, const GF2X& g3,
549              const GF2X& h, const GF2XModulus& F);
550// xi = gi(h) mod f (i=1..3), deg(h) < n
551
552
553/**************************************************************************\
554
555                     Composition with Pre-Conditioning
556
557If a single h is going to be used with many g's then you should build
558a GF2XArgument for h, and then use the compose routine below.  The
559routine build computes and stores h, h^2, ..., h^m mod f.  After this
560pre-computation, composing a polynomial of degree roughly n with h
561takes n/m multiplies mod f, plus n^2 scalar multiplies.  Thus,
562increasing m increases the space requirement and the pre-computation
563time, but reduces the composition time.
564
565\**************************************************************************/
566
567
568struct GF2XArgument {
569   vec_GF2X H;
570};
571
572void build(GF2XArgument& H, const GF2X& h, const GF2XModulus& F, long m);
573// Pre-Computes information about h.  m > 0, deg(h) < n
574
575void CompMod(GF2X& x, const GF2X& g, const GF2XArgument& H,
576             const GF2XModulus& F);
577
578GF2X CompMod(const GF2X& g, const GF2XArgument& H,
579             const GF2XModulus& F);
580
581
582extern long GF2XArgBound;
583
584// Initially 0.  If this is set to a value greater than zero, then
585// composition routines will allocate a table of no than about
586// GF2XArgBound KB.  Setting this value affects all compose routines
587// and the power projection and minimal polynomial routines below,
588// and indirectly affects many routines in GF2XFactoring.
589
590/**************************************************************************\
591
592                     Power Projection routines
593
594\**************************************************************************/
595
596void project(GF2& x, const vec_GF2& a, const GF2X& b);
597GF2 project(const vec_GF2& a, const GF2X& b);
598// x = inner product of a with coefficient vector of b
599
600
601void ProjectPowers(vec_GF2& x, const vec_GF2& a, long k,
602                   const GF2X& h, const GF2XModulus& F);
603
604vec_GF2 ProjectPowers(const vec_GF2& a, long k,
605                   const GF2X& h, const GF2XModulus& F);
606
607// Computes the vector
608
609//   (project(a, 1), project(a, h), ..., project(a, h^{k-1} % f). 
610
611// Restriction: must have a.length <= deg(F) and deg(h) < deg(F).
612// This operation is really the "transpose" of the modular composition
613// operation.
614
615void ProjectPowers(vec_GF2& x, const vec_GF2& a, long k,
616                   const GF2XArgument& H, const GF2XModulus& F);
617
618vec_GF2 ProjectPowers(const vec_GF2& a, long k,
619                   const GF2XArgument& H, const GF2XModulus& F);
620
621// same as above, but uses a pre-computed GF2XArgument
622
623
624// lower-level routines for transposed modular multiplication:
625
626class GF2XTransMultiplier { /* ... */ };
627
628void build(GF2XTransMultiplier& B, const GF2X& b, const GF2XModulus& F);
629
630// build a GF2XTransMultiplier to use in the following routine:
631
632void UpdateMap(vec_GF2& x, const vec_GF2& a, const GF2XTransMultiplier& B,
633         const GF2XModulus& F);
634
635vec_GF2 UpdateMap(const vec_GF2& a, const GF2XTransMultiplier& B,
636         const GF2XModulus& F);
637
638// Computes the vector
639
640//   project(a, b), project(a, (b*X)%f), ..., project(a, (b*X^{n-1})%f)
641
642// Restriction: must have a.length() <= deg(F) and deg(b) < deg(F).
643// This is really the transpose of modular multiplication.
644// Input may have "high order" zeroes stripped.
645// Output always has high order zeroes stripped.
646
647
648/**************************************************************************\
649
650                              Minimum Polynomials
651
652All of these routines implement the algorithm from [Shoup, J. Symbolic
653Comp. 17:371-391, 1994] and [Shoup, J. Symbolic Comp. 20:363-397,
6541995], based on transposed modular composition and the
655Berlekamp/Massey algorithm.
656
657\**************************************************************************/
658
659
660void MinPolySeq(GF2X& h, const vec_GF2& a, long m);
661// computes the minimum polynomial of a linealy generated sequence; m
662// is a bound on the degree of the polynomial; required: a.length() >=
663// 2*m
664
665void ProbMinPolyMod(GF2X& h, const GF2X& g, const GF2XModulus& F, long m);
666GF2X ProbMinPolyMod(const GF2X& g, const GF2XModulus& F, long m);
667
668void ProbMinPolyMod(GF2X& h, const GF2X& g, const GF2XModulus& F);
669GF2X ProbMinPolyMod(const GF2X& g, const GF2XModulus& F);
670
671// computes the monic minimal polynomial if (g mod f).  m = a bound on
672// the degree of the minimal polynomial; in the second version, this
673// argument defaults to n.  The algorithm is probabilistic; it always
674// returns a divisor of the minimal polynomial, possibly a proper divisor.
675
676void MinPolyMod(GF2X& h, const GF2X& g, const GF2XModulus& F, long m);
677GF2X MinPolyMod(const GF2X& g, const GF2XModulus& F, long m);
678
679void MinPolyMod(GF2X& h, const GF2X& g, const GF2XModulus& F);
680GF2X MinPolyMod(const GF2X& g, const GF2XModulus& F);
681
682// same as above, but guarantees that result is correct
683
684void IrredPolyMod(GF2X& h, const GF2X& g, const GF2XModulus& F, long m);
685GF2X IrredPolyMod(const GF2X& g, const GF2XModulus& F, long m);
686
687void IrredPolyMod(GF2X& h, const GF2X& g, const GF2XModulus& F);
688GF2X IrredPolyMod(const GF2X& g, const GF2XModulus& F);
689
690// same as above, but assumes that F is irreducible, or at least that
691// the minimal poly of g is itself irreducible.  The algorithm is
692// deterministic (and is always correct).
693
694
695/**************************************************************************\
696
697                                Traces
698
699\**************************************************************************/
700
701
702void TraceMod(GF2& x, const GF2X& a, const GF2XModulus& F);
703GF2 TraceMod(const GF2X& a, const GF2XModulus& F);
704
705void TraceMod(GF2& x, const GF2X& a, const GF2X& f);
706GF2 TraceMod(const GF2X& a, const GF2X& f);
707// x = Trace(a mod f); deg(a) < deg(f)
708
709
710void TraceVec(vec_GF2& S, const GF2X& f);
711vec_GF2 TraceVec(const GF2X& f);
712// S[i] = Trace(X^i mod f), i = 0..deg(f)-1; 0 < deg(f)
713
714// The above routines implement the asymptotically fast trace
715// algorithm from [von zur Gathen and Shoup, Computational Complexity,
716// 1992].
717
718
719/**************************************************************************\
720
721                           Miscellany
722
723\**************************************************************************/
724
725
726void clear(GF2X& x) // x = 0
727void set(GF2X& x); // x = 1
728
729void GF2X::normalize(); 
730// f.normalize() strips leading zeros from f.rep.
731
732void GF2X::SetMaxLength(long n);
733// f.SetMaxLength(n) pre-allocate spaces for n coefficients.  The
734// polynomial that f represents is unchanged.
735
736void GF2X::kill();
737// f.kill() sets f to 0 and frees all memory held by f.  Equivalent to
738// f.rep.kill().
739
740GF2X::GF2X(INIT_SIZE_TYPE, long n);
741// GF2X(INIT_SIZE, n) initializes to zero, but space is pre-allocated
742// for n coefficients
743
744static const GF2X& zero();
745// GF2X::zero() is a read-only reference to 0
746
747void swap(GF2X& x, GF2X& y);
748// swap x and y (via "pointer swapping")
749
Note: See TracBrowser for help on using the repository browser.