jengelh-datetimespielwiese
Last change
on this file since 050d1b was
050d1b,
checked in by Martin Lee <martinlee84@…>, 11 years ago
|
fix: wrong/unneccessary asserts
|
-
Property mode set to
100644
|
File size:
1.6 KB
|
Rev | Line | |
---|
[493c477] | 1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
[341696] | 2 | /* $Id$ */ |
---|
[2dd068] | 3 | |
---|
[e4fe2b] | 4 | #include "config.h" |
---|
[cc1367] | 5 | |
---|
[650f2d8] | 6 | #include "cf_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" |
---|
[a41f4b6] | 14 | #include "cf_util.h" |
---|
[2dd068] | 15 | |
---|
| 16 | static int theCharacteristic = 0; |
---|
| 17 | static int theDegree = 1; |
---|
| 18 | |
---|
| 19 | int initializeCharacteristic () |
---|
| 20 | { |
---|
| 21 | theCharacteristic = 0; |
---|
| 22 | theDegree = 1; |
---|
| 23 | return 1; |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | void setCharacteristic( int c ) |
---|
| 27 | { |
---|
[d09118] | 28 | if ( c == 0 ) |
---|
| 29 | { |
---|
| 30 | theDegree = 0; |
---|
| 31 | CFFactory::settype( IntegerDomain ); |
---|
| 32 | theCharacteristic = 0; |
---|
[2dd068] | 33 | } |
---|
[d09118] | 34 | else |
---|
| 35 | { |
---|
| 36 | theDegree = 1; |
---|
| 37 | CFFactory::settype( FiniteFieldDomain ); |
---|
| 38 | theCharacteristic = c; |
---|
| 39 | ff_big = c > cf_getSmallPrime( cf_getNumSmallPrimes()-1 ); |
---|
[806c18] | 40 | if (c > 536870909) factoryError("characteristic is too large(max is 2^29)"); |
---|
[d09118] | 41 | ff_setprime( c ); |
---|
| 42 | resetFPT(); |
---|
[2dd068] | 43 | } |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | void setCharacteristic( int c, int n ) |
---|
| 47 | { |
---|
| 48 | ASSERT( c > 1 && n > 0, "illegal characteristic" ); |
---|
| 49 | setCharacteristic( c ); |
---|
| 50 | InternalPrimePower::setPrimePower( c, n ); |
---|
| 51 | CFFactory::settype( PrimePowerDomain ); |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | void setCharacteristic( int c, int n, char name ) |
---|
| 55 | { |
---|
| 56 | ASSERT( c != 0 && n > 1, "illegal GF(q)" ); |
---|
| 57 | setCharacteristic( c ); |
---|
| 58 | gf_setcharacteristic( c, n, name ); |
---|
| 59 | theDegree = n; |
---|
| 60 | CFFactory::settype( GaloisFieldDomain ); |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | int getCharacteristic() |
---|
| 64 | { |
---|
| 65 | return theCharacteristic; |
---|
| 66 | } |
---|
| 67 | |
---|
[a99e31] | 68 | int getExp() |
---|
| 69 | { |
---|
| 70 | return InternalPrimePower::getk(); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | |
---|
[2dd068] | 74 | int getGFDegree() |
---|
| 75 | { |
---|
[050d1b] | 76 | //ASSERT( theDegree > 0, "not in GF(q)" ); |
---|
[2dd068] | 77 | return theDegree; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | CanonicalForm getGFGenerator() |
---|
| 81 | { |
---|
| 82 | ASSERT( theDegree > 1, "not in GF(q)" ); |
---|
| 83 | return int2imm_gf( 1 ); |
---|
| 84 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.