source: git/factory/cf_char.cc @ ba5e9e

spielwiese
Last change on this file since ba5e9e was 16f511, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
Fixed the usage of "config.h" (if defined HAVE_CONFIG_H)
  • Property mode set to 100644
File size: 1.7 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_binom.h"
15#include "cf_util.h"
16
17static int theCharacteristic = 0;
18static int theDegree = 1;
19
20int initializeCharacteristic ()
21{
22    theCharacteristic = 0;
23    theDegree = 1;
24    return 1;
25}
26
27void setCharacteristic( int c )
28{
29    if ( c == 0 )
30    {
31        theDegree = 0;
32        CFFactory::settype( IntegerDomain );
33        theCharacteristic = 0;
34    }
35    else
36    {
37        theDegree = 1;
38        CFFactory::settype( FiniteFieldDomain );
39        theCharacteristic = c;
40        ff_big = c > cf_getSmallPrime( cf_getNumSmallPrimes()-1 );
41        if (c > 536870909) factoryError("characteristic is too large(max is 2^29)");
42        ff_setprime( c );
43        resetFPT();
44    }
45}
46
47void setCharacteristic( int c, int n )
48{
49    ASSERT( c > 1 && n > 0, "illegal characteristic" );
50    setCharacteristic( c );
51    InternalPrimePower::setPrimePower( c, n );
52    CFFactory::settype( PrimePowerDomain );
53}
54
55void setCharacteristic( int c, int n, char name )
56{
57    ASSERT( c != 0 && n > 1, "illegal GF(q)" );
58    setCharacteristic( c );
59    gf_setcharacteristic( c, n, name );
60    theDegree = n;
61    CFFactory::settype( GaloisFieldDomain );
62}
63
64int getCharacteristic()
65{
66    return theCharacteristic;
67}
68
69int getExp()
70{
71  return InternalPrimePower::getk();
72}
73
74
75int getGFDegree()
76{
77    //ASSERT( theDegree > 0, "not in GF(q)" );
78    return theDegree;
79}
80
81CanonicalForm getGFGenerator()
82{
83    ASSERT( theDegree > 1, "not in GF(q)" );
84    return int2imm_gf( 1 );
85}
Note: See TracBrowser for help on using the repository browser.