1 #include <NTL/GF2EX.h>
2 #include <NTL/GF2XFactoring.h>
3
4 namespace NTL {
5
6 void BuildPlain(GF2EXModulus& F, const GF2EX& f, bool plain);
7
8 }
9
10 NTL_CLIENT
11
12
13 #define TIME_IT(t, action) \
14 do { \
15 double _t0, _t1; \
16 long _iter = 1; \
17 long _cnt = 0; \
18 do { \
19 _t0 = GetTime(); \
20 for (long _i = 0; _i < _iter; _i++) { action; _cnt++; } \
21 _t1 = GetTime(); \
22 } while ( _t1 - _t0 < 2 && (_iter *= 2)); \
23 t = (_t1 - _t0)/_iter; \
24 } while(0)
25
26
test(long k)27 long test(long k)
28 {
29 GF2X P;
30
31 BuildIrred(P, k);
32 GF2EPush push(P);
33
34 for (long n = 5; ; n+=5) {
35 cerr << ",";
36 GF2EX a, r, f;
37 random(a, 2*n-1);
38 random(f, n);
39 SetCoeff(f, n);
40 GF2EXModulus F1, F2;
41 BuildPlain(F1, f, false);
42 BuildPlain(F2, f, true);
43 double t1, t2;
44 TIME_IT(t1, rem(r, a, F1));
45 TIME_IT(t2, rem(r, a, F2));
46 double t = t1/t2;
47 if (t <= 0.95) return n;
48 }
49 }
50
main()51 int main()
52 {
53 cerr << "0.5 " << test(32) << "\n";
54 for (long i = 1; i <= 40 ; i++) {
55 cerr << i << " " << test(64*i) << "\n";
56 }
57 }
58
59
60