Functions
ffields.h File Reference
#include <misc/auxiliary.h>

Go to the source code of this file.

Functions

BOOLEAN nfInitChar (coeffs r, void *)
 
void nfShowMipo (const coeffs r)
 Show the mininimal polynom.... NOTE: this is used by char * sleftv::String(void *d, BOOLEAN typed, int dim) (from Singular/subexpr.cc) for printing minpoly. More...
 

Function Documentation

◆ nfInitChar()

BOOLEAN nfInitChar ( coeffs  r,
void *   
)

Definition at line 815 of file ffields.cc.

816 {
817  r->is_field=TRUE;
818  r->is_domain=TRUE;
819  r->rep=n_rep_gf;
820  //r->cfInitChar=npInitChar;
821  r->cfKillChar=nfKillChar;
822  r->nCoeffIsEqual=nfCoeffIsEqual;
823  r->cfCoeffString=nfCoeffString;
824  r->cfCoeffName=nfCoeffName;
825 
826  r->cfMult = nfMult;
827  r->cfSub = nfSub;
828  r->cfAdd = nfAdd;
829  r->cfDiv = nfDiv;
830  //r->cfIntMod= ndIntMod;
831  r->cfExactDiv= nfDiv;
832  r->cfInit = nfInit;
833  //r->cfSize = ndSize;
834  r->cfInt = nfInt;
835  #ifdef HAVE_RINGS
836  //r->cfDivComp = NULL; // only for ring stuff
837  //r->cfIsUnit = NULL; // only for ring stuff
838  //r->cfGetUnit = NULL; // only for ring stuff
839  //r->cfExtGcd = NULL; // only for ring stuff
840  // r->cfDivBy = NULL; // only for ring stuff
841  #endif
842  r->cfInpNeg = nfNeg;
843  r->cfInvers= nfInvers;
844  //r->cfCopy = ndCopy;
845  //r->cfRePart = ndCopy;
846  //r->cfImPart = ndReturn0;
847 
848  r->cfWriteLong = nfWriteLong;
849  r->cfRead = nfRead;
850  //r->cfNormalize=ndNormalize;
851  r->cfGreater = nfGreater;
852  r->cfEqual = nfEqual;
853  r->cfIsZero = nfIsZero;
854  r->cfIsOne = nfIsOne;
855  r->cfIsMOne = nfIsMOne;
856  r->cfGreaterZero = nfGreaterZero;
857  r->cfPower = nfPower;
858  //r->cfGcd = ndGcd;
859  //r->cfLcm = ndGcd;
860  //r->cfDelete= ndDelete;
861  r->cfSetMap = nfSetMap;
862  //r->cfName = ndName;
863  // debug stuff
864  r->cfCoeffWrite=nfCoeffWrite;
865 
866  r->cfParDeg = nfParDeg;
867 
868  r->cfRandom = nfRandom;
869 
870 #ifdef LDEBUG
871  r->cfDBTest=nfDBTest;
872 #endif
873 
874  // the variables:
875  r->nNULL = (number)0;
876  assume( getCoeffType(r) == n_GF );
877 
878  GFInfo* p = (GFInfo *)(parameter);
879  assume (p->GFChar > 0);
880  assume (p->GFDegree > 0);
881 
882  const char * name = p->GFPar_name;
883 
884  r->m_nfCharQ = 0;
885  r->m_nfCharP = p->GFChar;
886  r->m_nfCharQ1 = 0;
887 
888  r->iNumberOfParameters = 1;
889  r->cfParameter = nfParameter;
890 
891  char ** pParameterNames = (char **) omAlloc0(sizeof(char *));
892  pParameterNames[0] = omStrDup(name); //TODO use omAlloc for allocating memory and use strcpy?
893 
894  assume( pParameterNames != NULL );
895  assume( pParameterNames[0] != NULL );
896 
897  r->pParameterNames = (const char**)pParameterNames;
898  // NOTE: r->m_nfParameter was replaced by n_ParameterNames(r)[0]
899 
900  // TODO: nfKillChar MUST destroy r->pParameterNames[0] (0-term. string) && r->pParameterNames (array of size 1)
901 
902  r->m_nfPlus1Table= NULL;
903 
904  if (strlen(name) > 1)
905  r->cfWriteShort = nfWriteLong;
906  else
907  r->cfWriteShort = nfWriteShort;
908 
909  r->has_simple_Alloc=TRUE;
910  r->has_simple_Inverse=TRUE;
911 
912  if(p->GFChar > (2<<15))
913  {
914 #ifndef SING_NDEBUG
915  Warn("illegal characteristic");
916 #endif
917  return TRUE;
918  }
919 
920  const double check= log ((double) (p->GFChar));
921 
922  #define sixteenlog2 11.09035489
923  if( (p->GFDegree * check) > sixteenlog2 )
924  {
925 #ifndef SING_NDEBUG
926  Warn("Sorry: illegal size: %u ^ %u", p->GFChar, p->GFDegree );
927 #endif
928  return TRUE;
929  }
930 
931  int c = pow (p->GFChar, p->GFDegree);
932 
933  nfReadTable(c, r);
934 
935  if( r->m_nfPlus1Table == NULL )
936  {
937  return TRUE;
938  }
939 
940 
941  assume (r -> m_nfCharQ > 0);
942 
943  r->ch = r->m_nfCharP;
944  assume( r->m_nfPlus1Table != NULL );
945 
946  return FALSE;
947 
948 }
static long nfInt(number &n, const coeffs)
Definition: ffields.cc:240
static BOOLEAN nfCoeffIsEqual(const coeffs, n_coeffType, void *)
Definition: ffields.cc:805
static number nfRandom(siRandProc p, number, number, const coeffs cf)
Definition: ffields.cc:786
int check
Definition: libparse.cc:1104
#define FALSE
Definition: auxiliary.h:94
return P p
Definition: myNF.cc:203
static number nfDiv(number a, number b, const coeffs r)
Definition: ffields.cc:325
static BOOLEAN nfGreaterZero(number k, const coeffs r)
Definition: ffields.cc:160
static const char * nfRead(const char *s, number *a, const coeffs r)
Definition: ffields.cc:488
const char * GFPar_name
Definition: coeffs.h:96
gmp_float log(const gmp_float &a)
Definition: mpr_complex.cc:345
#define TRUE
Definition: auxiliary.h:98
BOOLEAN nfDBTest(number a, const char *f, const int l, const coeffs r)
Definition: ffields.cc:111
static number nfSub(number a, number b, const coeffs r)
Definition: ffields.cc:305
static BOOLEAN nfIsOne(number a, const coeffs r)
Definition: ffields.cc:314
static number nfParameter(int i, const coeffs)
Definition: ffields.cc:215
static number nfNeg(number c, const coeffs r)
Definition: ffields.cc:287
static void nfKillChar(coeffs r)
Definition: ffields.cc:756
Creation data needed for finite fields.
Definition: coeffs.h:92
static void nfPower(number a, int i, number *result, const coeffs r)
Definition: ffields.cc:439
static char * nfCoeffString(const coeffs r)
Definition: ffields.cc:769
#define assume(x)
Definition: mod2.h:394
static void nfWriteShort(number a, const coeffs r)
Definition: ffields.cc:418
static BOOLEAN nfIsZero(number a, const coeffs r)
Definition: ffields.cc:137
static number nfAdd(number a, number b, const coeffs R)
Definition: ffields.cc:248
int GFDegree
Definition: coeffs.h:95
static nMapFunc nfSetMap(const coeffs src, const coeffs dst)
Definition: ffields.cc:702
char name(const Variable &v)
Definition: factory.h:178
static number nfMult(number a, number b, const coeffs r)
Definition: ffields.cc:171
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
static int nfParDeg(number n, const coeffs r)
Definition: ffields.cc:228
int GFChar
Definition: coeffs.h:94
#define NULL
Definition: omList.c:10
static number nfInvers(number c, const coeffs r)
Definition: ffields.cc:353
{p^n < 2^16}
Definition: coeffs.h:33
static void nfWriteLong(number a, const coeffs r)
Definition: ffields.cc:396
static number nfInit(long i, const coeffs r)
Definition: ffields.cc:191
static char * nfCoeffName(const coeffs r)
Definition: ffields.cc:778
static void nfReadTable(const int c, const coeffs r)
Definition: ffields.cc:571
static void nfCoeffWrite(const coeffs r, BOOLEAN details)
Definition: ffields.cc:791
(int), see ffields.h
Definition: coeffs.h:119
Rational pow(const Rational &a, int e)
Definition: GMPrat.cc:418
static BOOLEAN nfEqual(number a, number b, const coeffs r)
Definition: ffields.cc:384
static BOOLEAN nfIsMOne(number a, const coeffs r)
Definition: ffields.cc:148
static BOOLEAN nfGreater(number a, number b, const coeffs r)
Definition: ffields.cc:372
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define sixteenlog2
#define Warn
Definition: emacs.cc:80
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ nfShowMipo()

void nfShowMipo ( const coeffs  r)

Show the mininimal polynom.... NOTE: this is used by char * sleftv::String(void *d, BOOLEAN typed, int dim) (from Singular/subexpr.cc) for printing minpoly.

Definition at line 530 of file ffields.cc.

531 {
532  int i=nfMinPoly[0];
533  int j=0;
534  loop
535  {
536  j++;
537  if (nfMinPoly[j]!=0)
538  StringAppend("%d*%s^%d",nfMinPoly[j],n_ParameterNames(r)[0],i);
539  i--;
540  if(i<0) break;
541  if (nfMinPoly[j]!=0)
542  StringAppendS("+");
543  }
544 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:812
loop
Definition: myNF.cc:98
int j
Definition: myNF.cc:70
void StringAppendS(const char *st)
Definition: reporter.cc:107
#define StringAppend
Definition: emacs.cc:82
int i
Definition: cfEzgcd.cc:123
static int nfMinPoly[16]
Definition: ffields.cc:528