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