1 | // emacs edit mode for this file is -*- C++ -*- |
---|
2 | // $Id: cf_char.cc,v 1.0 1996-05-17 10:59:43 stobbe Exp $ |
---|
3 | |
---|
4 | /* |
---|
5 | $Log: not supported by cvs2svn $ |
---|
6 | */ |
---|
7 | |
---|
8 | #include "assert.h" |
---|
9 | #include "cf_defs.h" |
---|
10 | #include "canonicalform.h" |
---|
11 | #include "imm.h" |
---|
12 | #include "int_pp.h" |
---|
13 | |
---|
14 | static int theCharacteristic = 0; |
---|
15 | static int theDegree = 1; |
---|
16 | |
---|
17 | int initializeCharacteristic () |
---|
18 | { |
---|
19 | theCharacteristic = 0; |
---|
20 | theDegree = 1; |
---|
21 | return 1; |
---|
22 | } |
---|
23 | |
---|
24 | void setCharacteristic( int c ) |
---|
25 | { |
---|
26 | if ( c == 0 ) { |
---|
27 | theDegree = 0; |
---|
28 | CFFactory::settype( IntegerDomain ); |
---|
29 | theCharacteristic = 0; |
---|
30 | } |
---|
31 | else { |
---|
32 | theDegree = 1; |
---|
33 | CFFactory::settype( FiniteFieldDomain ); |
---|
34 | theCharacteristic = c; |
---|
35 | ff_setprime( c ); |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | void setCharacteristic( int c, int n ) |
---|
40 | { |
---|
41 | ASSERT( c > 1 && n > 0, "illegal characteristic" ); |
---|
42 | setCharacteristic( c ); |
---|
43 | InternalPrimePower::setPrimePower( c, n ); |
---|
44 | CFFactory::settype( PrimePowerDomain ); |
---|
45 | } |
---|
46 | |
---|
47 | void setCharacteristic( int c, int n, char name ) |
---|
48 | { |
---|
49 | ASSERT( c != 0 && n > 1, "illegal GF(q)" ); |
---|
50 | setCharacteristic( c ); |
---|
51 | gf_setcharacteristic( c, n, name ); |
---|
52 | theDegree = n; |
---|
53 | CFFactory::settype( GaloisFieldDomain ); |
---|
54 | } |
---|
55 | |
---|
56 | int getCharacteristic() |
---|
57 | { |
---|
58 | return theCharacteristic; |
---|
59 | } |
---|
60 | |
---|
61 | int getGFDegree() |
---|
62 | { |
---|
63 | ASSERT( theDegree > 0, "not in GF(q)" ); |
---|
64 | return theDegree; |
---|
65 | } |
---|
66 | |
---|
67 | CanonicalForm getGFGenerator() |
---|
68 | { |
---|
69 | ASSERT( theDegree > 1, "not in GF(q)" ); |
---|
70 | return int2imm_gf( 1 ); |
---|
71 | } |
---|