source: git/factory/cf_char.cc

spielwiese
Last change on this file was 564dd8, checked in by Hans Schoenemann <hannes@…>, 4 years ago
factorize in Z[x,..] w/o NTL
  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[493c477]1/* emacs edit mode for this file is -*- C++ -*- */
[2dd068]2
[abddbe]3/**
4 * @file cf_char.cc
5 *
6 * getting and setting the characteristic of a finite field
7**/
[9f7665]8
[e4fe2b]9#include "config.h"
[9f7665]10
[cc1367]11
[650f2d8]12#include "cf_assert.h"
[cc1367]13
[2dd068]14#include "cf_defs.h"
15#include "canonicalform.h"
16#include "imm.h"
[e82860]17#include "cf_primes.h"
[a41f4b6]18#include "cf_util.h"
[e73082]19#include "int_pp.h"
[2dd068]20
[7fdedf]21#ifdef HAVE_FLINT
22#include "FLINTconvert.h" // for __FLINT_RELEASE
23#endif
24
[a3f0fea]25STATIC_VAR int theCharacteristic = 0;
26STATIC_VAR int theDegree = 1;
[2dd068]27
28void setCharacteristic( int c )
29{
[d09118]30    if ( c == 0 )
31    {
32        theDegree = 0;
33        CFFactory::settype( IntegerDomain );
34        theCharacteristic = 0;
[2dd068]35    }
[d09118]36    else
37    {
38        theDegree = 1;
39        CFFactory::settype( FiniteFieldDomain );
40        ff_big = c > cf_getSmallPrime( cf_getNumSmallPrimes()-1 );
[35a153]41        if (c!=theCharacteristic)
42        {
43          if (c > 536870909) factoryError("characteristic is too large(max is 2^29)");
44          ff_setprime( c );
45        }
46        theCharacteristic = c;
[2dd068]47    }
48}
49
[7fdedf]50#if !defined(HAVE_NTL)
[e73082]51void setCharacteristic( int c, int n )
52{
53    ASSERT( c > 1 && n > 0, "illegal characteristic" );
54    setCharacteristic( c );
55    InternalPrimePower::setPrimePower( c, n );
56    CFFactory::settype( PrimePowerDomain );
57}
58#endif
59
60
[2dd068]61void setCharacteristic( int c, int n, char name )
62{
63    ASSERT( c != 0 && n > 1, "illegal GF(q)" );
64    setCharacteristic( c );
65    gf_setcharacteristic( c, n, name );
66    theDegree = n;
67    CFFactory::settype( GaloisFieldDomain );
68}
69
70int getCharacteristic()
71{
72    return theCharacteristic;
73}
74
75int getGFDegree()
76{
[050d1b]77    //ASSERT( theDegree > 0, "not in GF(q)" );
[2dd068]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.