source: git/factory/cf_char.cc @ 5079887

spielwiese
Last change on this file since 5079887 was 362fc67, checked in by Martin Lee <martinlee84@…>, 12 years ago
chg: remove $Id$
  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[493c477]1/* emacs edit mode for this file is -*- C++ -*- */
[2dd068]2
[e4fe2b]3#include "config.h"
[cc1367]4
[650f2d8]5#include "cf_assert.h"
[cc1367]6
[2dd068]7#include "cf_defs.h"
8#include "canonicalform.h"
9#include "imm.h"
10#include "int_pp.h"
[e82860]11#include "cf_primes.h"
[88e0d34]12#include "cf_binom.h"
[a41f4b6]13#include "cf_util.h"
[2dd068]14
15static int theCharacteristic = 0;
16static int theDegree = 1;
17
18int initializeCharacteristic ()
19{
20    theCharacteristic = 0;
21    theDegree = 1;
22    return 1;
23}
24
25void setCharacteristic( int c )
26{
[d09118]27    if ( c == 0 )
28    {
29        theDegree = 0;
30        CFFactory::settype( IntegerDomain );
31        theCharacteristic = 0;
[2dd068]32    }
[d09118]33    else
34    {
35        theDegree = 1;
36        CFFactory::settype( FiniteFieldDomain );
37        theCharacteristic = c;
38        ff_big = c > cf_getSmallPrime( cf_getNumSmallPrimes()-1 );
[806c18]39        if (c > 536870909) factoryError("characteristic is too large(max is 2^29)");
[d09118]40        ff_setprime( c );
41        resetFPT();
[2dd068]42    }
43}
44
45void setCharacteristic( int c, int n )
46{
47    ASSERT( c > 1 && n > 0, "illegal characteristic" );
48    setCharacteristic( c );
49    InternalPrimePower::setPrimePower( c, n );
50    CFFactory::settype( PrimePowerDomain );
51}
52
53void setCharacteristic( int c, int n, char name )
54{
55    ASSERT( c != 0 && n > 1, "illegal GF(q)" );
56    setCharacteristic( c );
57    gf_setcharacteristic( c, n, name );
58    theDegree = n;
59    CFFactory::settype( GaloisFieldDomain );
60}
61
62int getCharacteristic()
63{
64    return theCharacteristic;
65}
66
[a99e31]67int getExp()
68{
69  return InternalPrimePower::getk();
70}
71
72
[2dd068]73int getGFDegree()
74{
[050d1b]75    //ASSERT( theDegree > 0, "not in GF(q)" );
[2dd068]76    return theDegree;
77}
78
79CanonicalForm getGFGenerator()
80{
81    ASSERT( theDegree > 1, "not in GF(q)" );
82    return int2imm_gf( 1 );
83}
Note: See TracBrowser for help on using the repository browser.