source: git/factory/cf_char.cc @ 9f7665

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