Loading...
Searching...
No Matches
cf_char.cc
Go to the documentation of this file.
/* emacs edit mode for this file is -*- C++ -*- */
/**
* @file cf_char.cc
*
* getting and setting the characteristic of a finite field
**/
#include "config.h"
#include "cf_assert.h"
#include "cf_defs.h"
#include "canonicalform.h"
#include "imm.h"
#include "cf_primes.h"
#include "cf_util.h"
#include "int_pp.h"
#ifdef HAVE_FLINT
#include "FLINTconvert.h" // for __FLINT_RELEASE
#endif
STATIC_VAR int theCharacteristic = 0;
STATIC_VAR int theDegree = 1;
void setCharacteristic( int c )
{
if ( c == 0 )
{
theDegree = 0;
CFFactory::settype( IntegerDomain );
theCharacteristic = 0;
}
else
{
theDegree = 1;
CFFactory::settype( FiniteFieldDomain );
ff_big = c > cf_getSmallPrime( cf_getNumSmallPrimes()-1 );
if (c!=theCharacteristic)
{
if (c > 536870909) factoryError("characteristic is too large(max is 2^29)");
ff_setprime( c );
}
theCharacteristic = c;
}
}
#if !defined(HAVE_NTL)
void setCharacteristic( int c, int n )
{
ASSERT( c > 1 && n > 0, "illegal characteristic" );
setCharacteristic( c );
InternalPrimePower::setPrimePower( c, n );
CFFactory::settype( PrimePowerDomain );
}
#endif
void setCharacteristic( int c, int n, char name )
{
ASSERT( c != 0 && n > 1, "illegal GF(q)" );
setCharacteristic( c );
gf_setcharacteristic( c, n, name );
theDegree = n;
CFFactory::settype( GaloisFieldDomain );
}
int getCharacteristic()
{
return theCharacteristic;
}
int getGFDegree()
{
//ASSERT( theDegree > 0, "not in GF(q)" );
return theDegree;
}
CanonicalForm getGFGenerator()
{
ASSERT( theDegree > 1, "not in GF(q)" );
return int2imm_gf( 1 );
}
FLINTconvert.h
This file defines functions for conversion to FLINT (www.flintlib.org) and back.
canonicalform.h
Header for factory's main class CanonicalForm.
cf_assert.h
assertions for Factory
ASSERT
#define ASSERT(expression, message)
Definition cf_assert.h:99
getCharacteristic
int getCharacteristic()
Definition cf_char.cc:70
getGFDegree
int getGFDegree()
Definition cf_char.cc:75
theCharacteristic
STATIC_VAR int theCharacteristic
Definition cf_char.cc:25
theDegree
STATIC_VAR int theDegree
Definition cf_char.cc:26
getGFGenerator
CanonicalForm getGFGenerator()
Definition cf_char.cc:81
setCharacteristic
void setCharacteristic(int c)
Definition cf_char.cc:28
cf_defs.h
factory switches.
PrimePowerDomain
#define PrimePowerDomain
Definition cf_defs.h:17
FiniteFieldDomain
#define FiniteFieldDomain
Definition cf_defs.h:19
IntegerDomain
#define IntegerDomain
Definition cf_defs.h:21
GaloisFieldDomain
#define GaloisFieldDomain
Definition cf_defs.h:18
cf_getNumSmallPrimes
int cf_getNumSmallPrimes()
Definition cf_primes.cc:34
cf_getSmallPrime
int cf_getSmallPrime(int i)
Definition cf_primes.cc:28
cf_primes.h
access to prime tables
factoryError
VAR void(* factoryError)(const char *s)
Definition cf_util.cc:80
cf_util.h
CFFactory::settype
static void settype(int type)
Definition cf_factory.h:29
CanonicalForm
factory's main class
Definition canonicalform.h:86
InternalPrimePower::setPrimePower
static void setPrimePower(int p, int k)
name
char name(const Variable &v)
Definition factory.h:189
ff_big
VAR bool ff_big
Definition ffops.cc:25
ff_setprime
void ff_setprime(const int p)
Definition ffops.cc:28
gf_setcharacteristic
void gf_setcharacteristic(int p, int n, char name)
Definition gfops.cc:202
STATIC_VAR
#define STATIC_VAR
Definition globaldefs.h:7
imm.h
operations on immediates, that is elements of F_p, GF, Z, Q that fit into intrinsic int,...
int2imm_gf
InternalCF * int2imm_gf(long i)
Definition imm.h:106
int_pp.h