source: git/factory/cf_char.cc @ 8c7a1c

spielwiese
Last change on this file since 8c7a1c was 8c7a1c, checked in by Hans Schönemann <hannes@…>, 16 years ago
*hannes: syntax git-svn-id: file:///usr/local/Singular/svn/trunk@11004 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.8 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2/* $Id: cf_char.cc,v 1.9 2008-08-18 11:16:05 Singular Exp $ */
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
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{
27    if ( c == 0 )
28    {
29        theDegree = 0;
30        CFFactory::settype( IntegerDomain );
31        theCharacteristic = 0;
32    }
33    else
34    {
35        theDegree = 1;
36        CFFactory::settype( FiniteFieldDomain );
37        theCharacteristic = c;
38        ff_big = c > cf_getSmallPrime( cf_getNumSmallPrimes()-1 );
39#ifdef SINGULAR
40        extern int errorreported;
41        extern "C" void  WerrorS(const char *s);
42        if (!errorreported && (c > 536870909)) WerrorS("characteristic too large(max is 2^29)");
43#endif
44        ff_setprime( c );
45        resetFPT();
46    }
47}
48
49void setCharacteristic( int c, int n )
50{
51    ASSERT( c > 1 && n > 0, "illegal characteristic" );
52    setCharacteristic( c );
53    InternalPrimePower::setPrimePower( c, n );
54    CFFactory::settype( PrimePowerDomain );
55}
56
57void setCharacteristic( int c, int n, char name )
58{
59    ASSERT( c != 0 && n > 1, "illegal GF(q)" );
60    setCharacteristic( c );
61    gf_setcharacteristic( c, n, name );
62    theDegree = n;
63    CFFactory::settype( GaloisFieldDomain );
64}
65
66int getCharacteristic()
67{
68    return theCharacteristic;
69}
70
71int getExp()
72{
73  return InternalPrimePower::getk();
74}
75
76
77int getGFDegree()
78{
79    ASSERT( theDegree > 0, "not in GF(q)" );
80    return theDegree;
81}
82
83CanonicalForm getGFGenerator()
84{
85    ASSERT( theDegree > 1, "not in GF(q)" );
86    return int2imm_gf( 1 );
87}
Note: See TracBrowser for help on using the repository browser.