source: git/factory/cf_char.cc @ eebdf2

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