source: git/factory/cf_char.cc @ 341696

spielwiese
Last change on this file since 341696 was 341696, checked in by Hans Schönemann <hannes@…>, 14 years ago
Adding Id property to all files git-svn-id: file:///usr/local/Singular/svn/trunk@12231 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2/* $Id$ */
3
4#include <config.h>
5
6#include "assert.h"
7
8#include "cf_defs.h"
9#include "canonicalform.h"
10#include "imm.h"
11#include "int_pp.h"
12#include "cf_primes.h"
13#include "cf_binom.h"
14#ifdef SINGULAR
15#include "singext.h"
16#endif
17
18static int theCharacteristic = 0;
19static int theDegree = 1;
20
21int initializeCharacteristic ()
22{
23    theCharacteristic = 0;
24    theDegree = 1;
25    return 1;
26}
27
28void setCharacteristic( int c )
29{
30    if ( c == 0 )
31    {
32        theDegree = 0;
33        CFFactory::settype( IntegerDomain );
34        theCharacteristic = 0;
35    }
36    else
37    {
38        theDegree = 1;
39        CFFactory::settype( FiniteFieldDomain );
40        theCharacteristic = c;
41        ff_big = c > cf_getSmallPrime( cf_getNumSmallPrimes()-1 );
42#ifdef SINGULAR
43        if (!errorreported && (c > 536870909)) Werror("characteristic %d is too large(max is 2^29)",c);
44#endif
45        ff_setprime( c );
46        resetFPT();
47    }
48}
49
50void setCharacteristic( int c, int n )
51{
52    ASSERT( c > 1 && n > 0, "illegal characteristic" );
53    setCharacteristic( c );
54    InternalPrimePower::setPrimePower( c, n );
55    CFFactory::settype( PrimePowerDomain );
56}
57
58void setCharacteristic( int c, int n, char name )
59{
60    ASSERT( c != 0 && n > 1, "illegal GF(q)" );
61    setCharacteristic( c );
62    gf_setcharacteristic( c, n, name );
63    theDegree = n;
64    CFFactory::settype( GaloisFieldDomain );
65}
66
67int getCharacteristic()
68{
69    return theCharacteristic;
70}
71
72int getExp()
73{
74  return InternalPrimePower::getk();
75}
76
77
78int getGFDegree()
79{
80    ASSERT( theDegree > 0, "not in GF(q)" );
81    return theDegree;
82}
83
84CanonicalForm getGFGenerator()
85{
86    ASSERT( theDegree > 1, "not in GF(q)" );
87    return int2imm_gf( 1 );
88}
Note: See TracBrowser for help on using the repository browser.