1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
2 | /* $Id$ */ |
---|
3 | |
---|
4 | #include <config.h> |
---|
5 | |
---|
6 | #include "assert.h" |
---|
7 | |
---|
8 | #include "cf_defs.h" |
---|
9 | #include "canonicalform.h" |
---|
10 | #include "imm.h" |
---|
11 | #include "int_pp.h" |
---|
12 | #include "cf_primes.h" |
---|
13 | #include "cf_binom.h" |
---|
14 | #ifdef SINGULAR |
---|
15 | #include "singext.h" |
---|
16 | #endif |
---|
17 | |
---|
18 | static int theCharacteristic = 0; |
---|
19 | static int theDegree = 1; |
---|
20 | |
---|
21 | int initializeCharacteristic () |
---|
22 | { |
---|
23 | theCharacteristic = 0; |
---|
24 | theDegree = 1; |
---|
25 | return 1; |
---|
26 | } |
---|
27 | |
---|
28 | void setCharacteristic( int c ) |
---|
29 | { |
---|
30 | if ( c == 0 ) |
---|
31 | { |
---|
32 | theDegree = 0; |
---|
33 | CFFactory::settype( IntegerDomain ); |
---|
34 | theCharacteristic = 0; |
---|
35 | } |
---|
36 | else |
---|
37 | { |
---|
38 | theDegree = 1; |
---|
39 | CFFactory::settype( FiniteFieldDomain ); |
---|
40 | theCharacteristic = c; |
---|
41 | ff_big = c > cf_getSmallPrime( cf_getNumSmallPrimes()-1 ); |
---|
42 | #ifdef SINGULAR |
---|
43 | if (!errorreported && (c > 536870909)) Werror("characteristic %d is too large(max is 2^29)",c); |
---|
44 | #endif |
---|
45 | ff_setprime( c ); |
---|
46 | resetFPT(); |
---|
47 | } |
---|
48 | } |
---|
49 | |
---|
50 | void setCharacteristic( int c, int n ) |
---|
51 | { |
---|
52 | ASSERT( c > 1 && n > 0, "illegal characteristic" ); |
---|
53 | setCharacteristic( c ); |
---|
54 | InternalPrimePower::setPrimePower( c, n ); |
---|
55 | CFFactory::settype( PrimePowerDomain ); |
---|
56 | } |
---|
57 | |
---|
58 | void setCharacteristic( int c, int n, char name ) |
---|
59 | { |
---|
60 | ASSERT( c != 0 && n > 1, "illegal GF(q)" ); |
---|
61 | setCharacteristic( c ); |
---|
62 | gf_setcharacteristic( c, n, name ); |
---|
63 | theDegree = n; |
---|
64 | CFFactory::settype( GaloisFieldDomain ); |
---|
65 | } |
---|
66 | |
---|
67 | int getCharacteristic() |
---|
68 | { |
---|
69 | return theCharacteristic; |
---|
70 | } |
---|
71 | |
---|
72 | int getExp() |
---|
73 | { |
---|
74 | return InternalPrimePower::getk(); |
---|
75 | } |
---|
76 | |
---|
77 | |
---|
78 | int getGFDegree() |
---|
79 | { |
---|
80 | ASSERT( theDegree > 0, "not in GF(q)" ); |
---|
81 | return theDegree; |
---|
82 | } |
---|
83 | |
---|
84 | CanonicalForm getGFGenerator() |
---|
85 | { |
---|
86 | ASSERT( theDegree > 1, "not in GF(q)" ); |
---|
87 | return int2imm_gf( 1 ); |
---|
88 | } |
---|