spielwiese
Last change
on this file since b666c7 was
f4365f,
checked in by Martin Lee <martinlee84@…>, 9 years ago
|
fix: compilation without NTL
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
2 | |
---|
3 | |
---|
4 | #include "config.h" |
---|
5 | |
---|
6 | |
---|
7 | #include "cf_assert.h" |
---|
8 | |
---|
9 | #include "cf_defs.h" |
---|
10 | #include "canonicalform.h" |
---|
11 | #include "cf_algorithm.h" |
---|
12 | #include "cf_random.h" |
---|
13 | |
---|
14 | #ifdef HAVE_NTL |
---|
15 | #include "NTLconvert.h" |
---|
16 | #endif |
---|
17 | |
---|
18 | static bool |
---|
19 | is_irreducible ( const CanonicalForm & f ) |
---|
20 | { |
---|
21 | CFFList F = factorize( f ); |
---|
22 | return F.length() == 1 && F.getFirst().exp() == 1; |
---|
23 | } |
---|
24 | |
---|
25 | CanonicalForm |
---|
26 | find_irreducible ( int deg, CFRandom & gen, const Variable & x ) |
---|
27 | { |
---|
28 | CanonicalForm result; |
---|
29 | int i; |
---|
30 | do { |
---|
31 | result = power( x, deg ); |
---|
32 | for ( i = deg-1; i >= 0; i-- ) |
---|
33 | result += gen.generate() * power( x, i ); |
---|
34 | } while ( ! is_irreducible( result ) ); |
---|
35 | return result; |
---|
36 | } |
---|
37 | |
---|
38 | #ifdef HAVE_NTL |
---|
39 | /// computes a random monic irreducible univariate polynomial in x over Fp of |
---|
40 | /// degree i via NTL |
---|
41 | CanonicalForm |
---|
42 | randomIrredpoly (int i, const Variable & x) |
---|
43 | { |
---|
44 | int p= getCharacteristic(); |
---|
45 | if (fac_NTL_char != p) |
---|
46 | { |
---|
47 | fac_NTL_char= p; |
---|
48 | zz_p::init (p); |
---|
49 | } |
---|
50 | zz_pX NTLirredpoly; |
---|
51 | CanonicalForm CFirredpoly; |
---|
52 | BuildIrred (NTLirredpoly, i); |
---|
53 | CFirredpoly= convertNTLzzpX2CF (NTLirredpoly, x); |
---|
54 | return CFirredpoly; |
---|
55 | } |
---|
56 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.