My Project
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 *  parameter 
)

Definition at line 858 of file ffields.cc.

859 {
860  // the variables:
861  assume( getCoeffType(r) == n_GF );
862 
863  GFInfo* p = (GFInfo *)(parameter);
864  assume (p->GFChar > 0);
865  assume (p->GFDegree > 0);
866  if ((IsPrime(p->GFChar)==p->GFChar)&&(p->GFDegree==1)) /* for oscar-system/Singular.jl/issues/177 */
867  {
868  return npInitChar(r,(void*)(long)p->GFChar);
869  }
870  if(p->GFChar > (2<<15))
871  {
872 #ifndef SING_NDEBUG
873  WarnS("illegal characteristic");
874 #endif
875  return TRUE;
876  }
877 
878  const double check= log ((double) (p->GFChar));
879 
880  #define sixteenlog2 11.09035489
881  if( (p->GFDegree * check) > sixteenlog2 )
882  {
883 #ifndef SING_NDEBUG
884  Warn("Sorry: illegal size: %u ^ %u", p->GFChar, p->GFDegree );
885 #endif
886  return TRUE;
887  }
888 
889  r->is_field=TRUE;
890  r->is_domain=TRUE;
891  r->rep=n_rep_gf;
892  //r->cfInitChar=npInitChar;
893  r->cfKillChar=nfKillChar;
894  r->nCoeffIsEqual=nfCoeffIsEqual;
895  r->cfCoeffName=nfCoeffName;
896 
897  r->cfMult = nfMult;
898  r->cfSub = nfSub;
899  r->cfAdd = nfAdd;
900  r->cfDiv = nfDiv;
901  //r->cfIntMod= ndIntMod;
902  r->cfExactDiv= nfDiv;
903  r->cfInit = nfInit;
904  r->cfInitMPZ = nfInitMPZ;
905  //r->cfSize = ndSize;
906  r->cfInt = nfInt;
907  #ifdef HAVE_RINGS
908  //r->cfDivComp = NULL; // only for ring stuff
909  //r->cfIsUnit = NULL; // only for ring stuff
910  //r->cfGetUnit = NULL; // only for ring stuff
911  //r->cfExtGcd = NULL; // only for ring stuff
912  // r->cfDivBy = NULL; // only for ring stuff
913  #endif
914  r->cfInpNeg = nfNeg;
915  r->cfInvers= nfInvers;
916  //r->cfCopy = ndCopy;
917  //r->cfRePart = ndCopy;
918  //r->cfImPart = ndReturn0;
919 
920  r->cfWriteLong = nfWriteLong;
921  r->cfRead = nfRead;
922  //r->cfNormalize=ndNormalize;
923  r->cfGreater = nfGreater;
924  r->cfEqual = nfEqual;
925  r->cfIsZero = nfIsZero;
926  r->cfIsOne = nfIsOne;
927  r->cfIsMOne = nfIsMOne;
928  r->cfGreaterZero = nfGreaterZero;
929  r->cfPower = nfPower;
930  //r->cfGcd = ndGcd;
931  //r->cfLcm = ndGcd;
932  //r->cfDelete= ndDelete;
933  r->cfSetMap = nfSetMap;
934  //r->cfName = ndName;
935  // debug stuff
936  r->cfCoeffWrite=nfCoeffWrite;
937 
938  r->cfParDeg = nfParDeg;
939 
940  r->cfRandom = nfRandom;
941 
942 #ifdef LDEBUG
943  r->cfDBTest=nfDBTest;
944 #endif
945 
946 
947  const char * name = p->GFPar_name;
948 
949  r->m_nfCharQ = 0;
950  r->m_nfCharP = p->GFChar;
951  r->m_nfCharQ1 = 0;
952 
953  r->iNumberOfParameters = 1;
954  r->cfParameter = nfParameter;
955 
956  char ** pParameterNames = (char **) omAlloc(sizeof(char *));
957  assume( pParameterNames != NULL );
958  pParameterNames[0] = omStrDup(name);
959  assume( pParameterNames[0] != NULL );
960 
961  r->pParameterNames = (const char**)pParameterNames;
962 
963  r->m_nfPlus1Table= NULL;
964 
965  if (strlen(name) > 1)
966  r->cfWriteShort = nfWriteLong;
967  else
968  r->cfWriteShort = nfWriteShort;
969 
970  r->has_simple_Alloc=TRUE;
971  r->has_simple_Inverse=TRUE;
972 
973  int c = (int)pow ((double)p->GFChar, (double)p->GFDegree);
974 
975  nfReadTable(c, r);
976 
977  if( r->m_nfPlus1Table == NULL )
978  {
979  Werror("reading table for field with %d elements failed",c);
980  return TRUE;
981  }
982 
983 
984  assume (r -> m_nfCharQ > 0);
985 
986  r->ch = r->m_nfCharP;
987  assume( r->m_nfPlus1Table != NULL );
988 
989  return FALSE;
990 }
Rational pow(const Rational &a, int e)
Definition: GMPrat.cc:411
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
int p
Definition: cfModGcd.cc:4080
@ n_GF
\GF{p^n < 2^16}
Definition: coeffs.h:33
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
@ n_rep_gf
(int), see ffields.h
Definition: coeffs.h:120
Creation data needed for finite fields.
Definition: coeffs.h:94
#define Warn
Definition: emacs.cc:77
#define WarnS
Definition: emacs.cc:78
char name(const Variable &v)
Definition: factory.h:196
static BOOLEAN nfIsMOne(number a, const coeffs r)
Definition: ffields.cc:148
static number nfInitMPZ(mpz_t m, const coeffs cf)
Definition: ffields.cc:732
static number nfAdd(number a, number b, const coeffs R)
Definition: ffields.cc:258
static nMapFunc nfSetMap(const coeffs src, const coeffs dst)
Definition: ffields.cc:753
static number nfInit(long i, const coeffs r)
Definition: ffields.cc:191
BOOLEAN nfDBTest(number a, const char *f, const int l, const coeffs r)
Definition: ffields.cc:111
static void nfKillChar(coeffs r)
Definition: ffields.cc:812
static int nfParDeg(number n, const coeffs r)
Definition: ffields.cc:228
static long nfInt(number &n, const coeffs r)
Definition: ffields.cc:240
#define sixteenlog2
static number nfMult(number a, number b, const coeffs r)
Definition: ffields.cc:171
static BOOLEAN nfGreaterZero(number k, const coeffs r)
Definition: ffields.cc:160
static void nfWriteShort(number a, const coeffs r)
Definition: ffields.cc:440
static char * nfCoeffName(const coeffs r)
Definition: ffields.cc:820
static number nfSub(number a, number b, const coeffs r)
Definition: ffields.cc:315
static number nfRandom(siRandProc p, number, number, const coeffs cf)
Definition: ffields.cc:829
static BOOLEAN nfIsOne(number a, const coeffs r)
Definition: ffields.cc:324
static void nfCoeffWrite(const coeffs r, BOOLEAN details)
Definition: ffields.cc:834
static const char * nfRead(const char *s, number *a, const coeffs r)
Definition: ffields.cc:509
static BOOLEAN nfGreater(number a, number b, const coeffs r)
Definition: ffields.cc:382
static number nfNeg(number c, const coeffs r)
Definition: ffields.cc:297
static BOOLEAN nfIsZero(number a, const coeffs r)
Definition: ffields.cc:137
static BOOLEAN nfCoeffIsEqual(const coeffs, n_coeffType, void *)
Definition: ffields.cc:848
static BOOLEAN nfEqual(number a, number b, const coeffs r)
Definition: ffields.cc:394
static void nfReadTable(const int c, const coeffs r)
Definition: ffields.cc:592
static void nfWriteLong(number a, const coeffs r)
Definition: ffields.cc:406
static number nfDiv(number a, number b, const coeffs r)
Definition: ffields.cc:335
static number nfParameter(int i, const coeffs)
Definition: ffields.cc:215
static number nfInvers(number c, const coeffs r)
Definition: ffields.cc:363
static void nfPower(number a, int i, number *result, const coeffs r)
Definition: ffields.cc:473
VAR int check
Definition: libparse.cc:1106
#define assume(x)
Definition: mod2.h:387
BOOLEAN npInitChar(coeffs r, void *p)
Definition: modulop.cc:340
gmp_float log(const gmp_float &a)
Definition: mpr_complex.cc:343
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define NULL
Definition: omList.c:12
int IsPrime(int p)
Definition: prime.cc:61
void Werror(const char *fmt,...)
Definition: reporter.cc:189

◆ 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 551 of file ffields.cc.

552 {
553  int i=nfMinPoly[0];
554  int j=0;
555  loop
556  {
557  j++;
558  if (nfMinPoly[j]!=0)
559  StringAppend("%d*%s^%d",nfMinPoly[j],n_ParameterNames(r)[0],i);
560  i--;
561  if(i<0) break;
562  if (nfMinPoly[j]!=0)
563  StringAppendS("+");
564  }
565 }
int i
Definition: cfEzgcd.cc:132
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:802
#define StringAppend
Definition: emacs.cc:79
int j
Definition: facHensel.cc:110
STATIC_VAR int nfMinPoly[16]
Definition: ffields.cc:549
void StringAppendS(const char *st)
Definition: reporter.cc:107
#define loop
Definition: structs.h:80