source:
git/factory/cf_char.cc
@
9f7665
Last change on this file since 9f7665 was 9f7665, checked in by , 10 years ago | |
---|---|
|
|
File size: 1.2 KB |
Rev | Line | |
---|---|---|
[493c477] | 1 | /* emacs edit mode for this file is -*- C++ -*- */ |
[2dd068] | 2 | |
[9f7665] | 3 | |
[e4fe2b] | 4 | #include "config.h" |
[9f7665] | 5 | |
[cc1367] | 6 | |
[650f2d8] | 7 | #include "cf_assert.h" |
[cc1367] | 8 | |
[2dd068] | 9 | #include "cf_defs.h" |
10 | #include "canonicalform.h" | |
11 | #include "imm.h" | |
[e82860] | 12 | #include "cf_primes.h" |
[a41f4b6] | 13 | #include "cf_util.h" |
[2dd068] | 14 | |
15 | static int theCharacteristic = 0; | |
16 | static int theDegree = 1; | |
17 | ||
18 | void setCharacteristic( int c ) | |
19 | { | |
[d09118] | 20 | if ( c == 0 ) |
21 | { | |
22 | theDegree = 0; | |
23 | CFFactory::settype( IntegerDomain ); | |
24 | theCharacteristic = 0; | |
[2dd068] | 25 | } |
[d09118] | 26 | else |
27 | { | |
28 | theDegree = 1; | |
29 | CFFactory::settype( FiniteFieldDomain ); | |
30 | theCharacteristic = c; | |
31 | ff_big = c > cf_getSmallPrime( cf_getNumSmallPrimes()-1 ); | |
[806c18] | 32 | if (c > 536870909) factoryError("characteristic is too large(max is 2^29)"); |
[d09118] | 33 | ff_setprime( c ); |
[2dd068] | 34 | } |
35 | } | |
36 | ||
37 | void setCharacteristic( int c, int n, char name ) | |
38 | { | |
39 | ASSERT( c != 0 && n > 1, "illegal GF(q)" ); | |
40 | setCharacteristic( c ); | |
41 | gf_setcharacteristic( c, n, name ); | |
42 | theDegree = n; | |
43 | CFFactory::settype( GaloisFieldDomain ); | |
44 | } | |
45 | ||
46 | int getCharacteristic() | |
47 | { | |
48 | return theCharacteristic; | |
49 | } | |
50 | ||
51 | int getGFDegree() | |
52 | { | |
[050d1b] | 53 | //ASSERT( theDegree > 0, "not in GF(q)" ); |
[2dd068] | 54 | return theDegree; |
55 | } | |
56 | ||
57 | CanonicalForm getGFGenerator() | |
58 | { | |
59 | ASSERT( theDegree > 1, "not in GF(q)" ); | |
60 | return int2imm_gf( 1 ); | |
61 | } |
Note: See TracBrowser
for help on using the repository browser.