source: git/factory/cf_char.cc @ 3ae414

spielwiese
Last change on this file since 3ae414 was 3ae414, checked in by Max Horn <max@…>, 10 years ago
Get rid of initCanonicalForm and initializeCharacteristic
  • Property mode set to 100644
File size: 1.5 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2
3#ifdef HAVE_CONFIG_H
4#include "config.h"
5#endif /* HAVE_CONFIG_H */
6
7#include "cf_assert.h"
8
9#include "cf_defs.h"
10#include "canonicalform.h"
11#include "imm.h"
12#include "int_pp.h"
13#include "cf_primes.h"
14#include "cf_util.h"
15
16static int theCharacteristic = 0;
17static int theDegree = 1;
18
19void setCharacteristic( int c )
20{
21    if ( c == 0 )
22    {
23        theDegree = 0;
24        CFFactory::settype( IntegerDomain );
25        theCharacteristic = 0;
26    }
27    else
28    {
29        theDegree = 1;
30        CFFactory::settype( FiniteFieldDomain );
31        theCharacteristic = c;
32        ff_big = c > cf_getSmallPrime( cf_getNumSmallPrimes()-1 );
33        if (c > 536870909) factoryError("characteristic is too large(max is 2^29)");
34        ff_setprime( c );
35    }
36}
37
38void setCharacteristic( int c, int n )
39{
40    ASSERT( c > 1 && n > 0, "illegal characteristic" );
41    setCharacteristic( c );
42    InternalPrimePower::setPrimePower( c, n );
43    CFFactory::settype( PrimePowerDomain );
44}
45
46void setCharacteristic( int c, int n, char name )
47{
48    ASSERT( c != 0 && n > 1, "illegal GF(q)" );
49    setCharacteristic( c );
50    gf_setcharacteristic( c, n, name );
51    theDegree = n;
52    CFFactory::settype( GaloisFieldDomain );
53}
54
55int getCharacteristic()
56{
57    return theCharacteristic;
58}
59
60int getGFDegree()
61{
62    //ASSERT( theDegree > 0, "not in GF(q)" );
63    return theDegree;
64}
65
66CanonicalForm getGFGenerator()
67{
68    ASSERT( theDegree > 1, "not in GF(q)" );
69    return int2imm_gf( 1 );
70}
Note: See TracBrowser for help on using the repository browser.