[493c477] | 1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
[341696] | 2 | /* $Id$ */ |
---|
[2dd068] | 3 | |
---|
[cc1367] | 4 | #include <config.h> |
---|
| 5 | |
---|
[2dd068] | 6 | #include "assert.h" |
---|
[cc1367] | 7 | |
---|
[2dd068] | 8 | #include "cf_defs.h" |
---|
| 9 | #include "canonicalform.h" |
---|
| 10 | #include "imm.h" |
---|
| 11 | #include "int_pp.h" |
---|
[e82860] | 12 | #include "cf_primes.h" |
---|
[88e0d34] | 13 | #include "cf_binom.h" |
---|
[da2fc8] | 14 | #ifdef SINGULAR |
---|
| 15 | #include "singext.h" |
---|
| 16 | #endif |
---|
[2dd068] | 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 | { |
---|
[d09118] | 30 | if ( c == 0 ) |
---|
| 31 | { |
---|
| 32 | theDegree = 0; |
---|
| 33 | CFFactory::settype( IntegerDomain ); |
---|
| 34 | theCharacteristic = 0; |
---|
[2dd068] | 35 | } |
---|
[d09118] | 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 |
---|
[c6c86b] | 43 | if (!errorreported && (c > 536870909)) Werror("characteristic %d is too large(max is 2^29)",c); |
---|
[d09118] | 44 | #endif |
---|
| 45 | ff_setprime( c ); |
---|
| 46 | resetFPT(); |
---|
[2dd068] | 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 | |
---|
[a99e31] | 72 | int getExp() |
---|
| 73 | { |
---|
| 74 | return InternalPrimePower::getk(); |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | |
---|
[2dd068] | 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 | } |
---|