1 | // emacs edit mode for this file is -*- C++ -*- |
---|
2 | // $Id: cf_char.cc,v 1.4 1996-07-08 08:12:23 stobbe Exp $ |
---|
3 | |
---|
4 | /* |
---|
5 | $Log: not supported by cvs2svn $ |
---|
6 | Revision 1.3 1996/06/24 11:25:45 stobbe |
---|
7 | "setCharacteristic: minor bug fix, index correction |
---|
8 | " |
---|
9 | |
---|
10 | Revision 1.2 1996/06/18 12:09:43 stobbe |
---|
11 | "setCharacteristic: changed the setting of ff_big. |
---|
12 | " |
---|
13 | |
---|
14 | Revision 1.1 1996/06/18 06:52:45 stobbe |
---|
15 | "setCharacteristic: now sets the flag ff_big |
---|
16 | " |
---|
17 | |
---|
18 | Revision 1.0 1996/05/17 10:59:43 stobbe |
---|
19 | Initial revision |
---|
20 | |
---|
21 | */ |
---|
22 | |
---|
23 | #include "assert.h" |
---|
24 | #include "cf_defs.h" |
---|
25 | #include "canonicalform.h" |
---|
26 | #include "imm.h" |
---|
27 | #include "int_pp.h" |
---|
28 | #include "cf_primes.h" |
---|
29 | #include "cf_binom.h" |
---|
30 | |
---|
31 | static int theCharacteristic = 0; |
---|
32 | static int theDegree = 1; |
---|
33 | |
---|
34 | int initializeCharacteristic () |
---|
35 | { |
---|
36 | theCharacteristic = 0; |
---|
37 | theDegree = 1; |
---|
38 | return 1; |
---|
39 | } |
---|
40 | |
---|
41 | void setCharacteristic( int c ) |
---|
42 | { |
---|
43 | if ( c == 0 ) { |
---|
44 | theDegree = 0; |
---|
45 | CFFactory::settype( IntegerDomain ); |
---|
46 | theCharacteristic = 0; |
---|
47 | } |
---|
48 | else { |
---|
49 | theDegree = 1; |
---|
50 | CFFactory::settype( FiniteFieldDomain ); |
---|
51 | theCharacteristic = c; |
---|
52 | ff_big = c > cf_getSmallPrime( cf_getNumSmallPrimes()-1 ); |
---|
53 | ff_setprime( c ); |
---|
54 | resetFPT(); |
---|
55 | } |
---|
56 | } |
---|
57 | |
---|
58 | void setCharacteristic( int c, int n ) |
---|
59 | { |
---|
60 | ASSERT( c > 1 && n > 0, "illegal characteristic" ); |
---|
61 | setCharacteristic( c ); |
---|
62 | InternalPrimePower::setPrimePower( c, n ); |
---|
63 | CFFactory::settype( PrimePowerDomain ); |
---|
64 | } |
---|
65 | |
---|
66 | void setCharacteristic( int c, int n, char name ) |
---|
67 | { |
---|
68 | ASSERT( c != 0 && n > 1, "illegal GF(q)" ); |
---|
69 | setCharacteristic( c ); |
---|
70 | gf_setcharacteristic( c, n, name ); |
---|
71 | theDegree = n; |
---|
72 | CFFactory::settype( GaloisFieldDomain ); |
---|
73 | } |
---|
74 | |
---|
75 | int getCharacteristic() |
---|
76 | { |
---|
77 | return theCharacteristic; |
---|
78 | } |
---|
79 | |
---|
80 | int getGFDegree() |
---|
81 | { |
---|
82 | ASSERT( theDegree > 0, "not in GF(q)" ); |
---|
83 | return theDegree; |
---|
84 | } |
---|
85 | |
---|
86 | CanonicalForm getGFGenerator() |
---|
87 | { |
---|
88 | ASSERT( theDegree > 1, "not in GF(q)" ); |
---|
89 | return int2imm_gf( 1 ); |
---|
90 | } |
---|