62 4, 8, 16, 32, 64, 128, 256, 512,1024,2048,4096,8192,16384, 32768,
64 9, 27, 81,243,729,2187, 6561,19683,59049,
66 25,125,625,3125,15625,
144 if (((
long)a<0L) || ((
long)a>(
long)r->m_nfCharQ))
146 Print(
"wrong %d in %s:%d\n",(
int)((
long)a),f,l);
152 if (r->m_nfPlus1Table[i]>r->m_nfCharQ)
154 Print(
"wrong table %d=%d in %s:%d\n",i,r->m_nfPlus1Table[i],f,l);
158 }
while (i<r->m_nfCharQ);
161 #define nfTest(N, R) nfDBTest(N,__FILE__,__LINE__, R) 184 if (((
long)a == (
long)r->m_nfCharQ) || ((
long)b == (
long)r->m_nfCharQ))
185 return (number)(long)r->m_nfCharQ;
187 int i=(
int)((long)a+(
long)
b);
188 if (
i>=r->m_nfCharQ1)
i-=r->m_nfCharQ1;
192 return (number)(long)i;
203 if (i==0)
return (number)(long)r->m_nfCharQ;
204 while (i < 0) i += r->m_nfCharP;
205 while (i >= r->m_nfCharP) i -= r->m_nfCharP;
206 if (i==0)
return (number)(long)r->m_nfCharQ;
210 c=r->m_nfPlus1Table[c];
214 nfTest((number)(
long)c, r);
216 return (number)(long)c;
240 if((
long)r->m_nfCharQ == (
long)n)
return -1;
241 return (
int)((long)n);
263 if ((
long)R->m_nfCharQ == (
long)a)
return b;
264 if ((
long)R->m_nfCharQ == (
long)b)
return a;
266 if ((
long)a >= (
long)b)
269 zab = (long)a-(
long)
b;
274 zab = (long)b-(
long)
a;
279 if (R->m_nfPlus1Table[zab]==R->m_nfCharQ) r=(long)R->m_nfCharQ;
282 r= zb+(
long)R->m_nfPlus1Table[zab];
283 if(r>=(
long)R->m_nfCharQ1) r-=(
long)R->m_nfCharQ1;
296 number mb =
nfNeg(b, r);
297 return nfAdd(a,mb,r);
308 return (
long)r->m_nfCharQ == (long)a;
319 return 0L == (long)a;
330 if (0L == (
long)a)
return FALSE;
331 return (
long)r->m_nfM1 == (long)a;
342 if ((
long)b==(
long)r->m_nfCharQ)
345 return (number)((long)r->m_nfCharQ);
350 if ((
long)a==(
long)r->m_nfCharQ)
351 return (number)((long)r->m_nfCharQ);
353 long s = (long)a - (
long)
b;
355 s += (long)r->m_nfCharQ1;
370 if ((
long)c==(
long)r->m_nfCharQ)
373 return (number)((long)r->m_nfCharQ);
376 nfTest(((number)((
long)r->m_nfCharQ1-(
long)c)), r);
378 return (number)((long)r->m_nfCharQ1-(
long)c);
390 if ((
long)r->m_nfCharQ == (
long)c)
return c;
391 long i=(long)c+(
long)r->m_nfM1;
392 if (i>=(
long)r->m_nfCharQ1) i-=(
long)r->m_nfCharQ1;
408 return (
long)a != (long)b;
420 return (
long)a == (long)b;
476 if (((
long)a==(
long)r->m_nfCharQ) || ((
long)a==0L))
return NULL;
477 else if ((
long)a==1L)
483 s=(
char *)
omAlloc(4+strlen(nf_Parameter));
484 sprintf(s,
"%s%d",nf_Parameter,(
int)((
long)a));
498 *result = (number)0L;
507 if ((
long)a == (long)r->m_nfCharQ) rl=(long)r->m_nfCharQ;
508 else rl=((
long)a*(long)i) % (long)r->m_nfCharQ1;
509 *result = (number)rl;
521 if (*s >=
'0' && *s <=
'9')
528 if (*i > (
MAX_INT_VAL / 10)) *i = *i % r->m_nfCharP;
530 while (*s >=
'0' && *s <=
'9');
531 if (*i >= r->m_nfCharP) *i = *i % r->m_nfCharP;
557 const int N = strlen(nf_Parameter);
558 if (strncmp(s,nf_Parameter, N)==0)
561 if ((*s >=
'0') && (*s <=
'9'))
564 while (i>=r->m_nfCharQ1) i-=r->m_nfCharQ1;
600 const char *
l=strchr(s,
';')+1;
602 int i=strtol(l,&n,10);
616 WerrorS(
"error in reading minpoly from gftables");
626 if ((c==r->m_nfCharQ)||(c==-r->m_nfCharQ))
639 if (r->m_nfCharQ > 1)
642 r->m_nfPlus1Table=
NULL;
646 if (c>1) r->m_nfCharQ = c;
647 else r->m_nfCharQ = -c;
649 sprintf(buf,
"gftables/%d",r->m_nfCharQ);
655 if(!fgets( buf,
sizeof(buf), fp))
return;
656 if(strcmp(buf,
"@@ factory GF(q) table @@\n")!=0)
660 if(!fgets( buf,
sizeof(buf), fp))
668 res = sscanf(buf,
"%d %d",&r->m_nfCharP,&q);
670 while((res < 0) and (errno == EINTR));
673 r->m_nfCharQ1=r->m_nfCharQ-1;
675 r->m_nfPlus1Table= (
unsigned short *)
omAlloc( (r->m_nfCharQ)*
sizeof(
unsigned short) );
680 while ( i < r->m_nfCharQ )
682 (void)fgets( buf,
sizeof(buf),
fp);
686 while ( (i < r->m_nfCharQ) && (k < 30) )
689 if(r->m_nfPlus1Table[i]>r->m_nfCharQ)
691 Print(
"wrong entry %d: %d(%c%c%c)\n",i,r->m_nfPlus1Table[i],bufptr[0],bufptr[1],bufptr[2]);
694 if (r->m_nfPlus1Table[i]==r->m_nfCharQ)
708 r->m_nfPlus1Table[0]=r->m_nfPlus1Table[r->m_nfCharQ1];
717 Werror(
"illegal GF-table %d",r->m_nfCharQ);
725 return nfInit((
int)((
long)c), dst);
736 while (i >src->m_nfCharQ1) i-=src->m_nfCharQ1;
737 return (number)((long)i);
744 int ex=(int)((
long)c);
746 return (number)(((long)ex) / ((long)nfMapGG_factor));
748 return (number)(long)src->m_nfCharQ;
764 if ((src->m_nfCharQ % q)==0)
769 while(qq!=q) { qq *= r->m_nfCharP; n1++; }
772 while(qq!=src->m_nfCharQ) { qq *= r->m_nfCharP; n2++; }
776 int save_ch=r->m_nfCharQ;
778 int nn=r->m_nfPlus1Table[0];
784 else if ((n1 % n2)==0)
814 for(
int i = 1;
i <=
P;
i++ )
824 char *
s=(
char*)
omAlloc(11+1+strlen(p));
825 sprintf(s,
"%d,%s",r->m_nfCharQ,p);
831 return (number)(long)(
p() %(cf->m_nfCharQ+1));
849 r->cfExactDiv=
nfDiv;
893 r->nNULL = (number)0;
906 r->iNumberOfParameters = 1;
909 char ** pParameterNames = (
char **)
omAlloc0(
sizeof(
char *));
910 pParameterNames[0] =
omStrDup(name);
915 r->pParameterNames = (
const char**)pParameterNames;
920 r->m_nfPlus1Table=
NULL;
922 if (strlen(name) > 1)
927 r->has_simple_Alloc=
TRUE;
928 r->has_simple_Inverse=
TRUE;
933 Warn(
"illegal characteristic");
952 if( r->m_nfPlus1Table ==
NULL )
958 assume (r -> m_nfCharQ > 0);
960 r->ch = r->m_nfCharP;
970 Print(
"// # ground field : %d\n",r->m_nfCharQ);
979 else PrintS(
"// minpoly : ...\n");
char * nfName(number n, const coeffs r)
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
const CanonicalForm int s
const char * eati(const char *s, int *i)
static const char * nfEati(const char *s, int *i, const coeffs r)
BOOLEAN nfIsZero(number a, const coeffs r)
void nfReadTable(const int c, const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
static BOOLEAN nfCoeffIsEqual(const coeffs, n_coeffType, void *)
static number nfRandom(siRandProc p, number, number, const coeffs cf)
number nlModP(number q, const coeffs, const coeffs Zp)
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
number nfInit(long i, const coeffs r)
#define omFreeSize(addr, size)
number nfNeg(number c, const coeffs r)
gmp_float log(const gmp_float &a)
BOOLEAN nfDBTest(number a, const char *f, const int l, const coeffs r)
number nfParameter(int i, const coeffs r)
void WerrorS(const char *s)
BOOLEAN nfIsMOne(number a, const coeffs r)
static void nfKillChar(coeffs r)
BOOLEAN nfGreater(number a, number b, const coeffs r)
Creation data needed for finite fields.
number nfDiv(number a, number b, const coeffs r)
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
number nfAdd(number a, number b, const coeffs r)
static void nfReadMipo(char *s)
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.
BOOLEAN nfGreaterZero(number k, const coeffs r)
Coefficient rings, fields and other domains suitable for Singular polynomials.
const CanonicalForm CFMap CFMap & N
number nfMapP(number c, const coeffs, const coeffs dst)
static char * nfCoeffString(const coeffs r)
int gf_tab_numdigits62(int q)
static void nfWriteShort(number a, const coeffs r)
The main handler for Singular numbers which are suitable for Singular polynomials.
void StringSetS(const char *st)
int status int void * buf
void StringAppendS(const char *st)
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
long nfInt(number &n, const coeffs r)
static const n_coeffType ID
Our Type!
const char *const nDivBy0
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
void PrintS(const char *s)
char name(const Variable &v)
number nfSub(number a, number b, const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
void nfPower(number a, int i, number *result, const coeffs r)
const unsigned short fftable[]
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
BOOLEAN nfInitChar(coeffs r, void *parameter)
number nfInvers(number c, const coeffs r)
static int nfParDeg(number n, const coeffs r)
void nfCoeffWrite(const coeffs r, BOOLEAN details)
number nfMult(number a, number b, const coeffs r)
number nfMapGGrev(number c, const coeffs src, const coeffs)
nMapFunc nfSetMap(const coeffs src, const coeffs dst)
BOOLEAN nfEqual(number a, number b, const coeffs r)
static void nfWriteLong(number a, const coeffs r)
int convertback62(char *p, int n)
Rational pow(const Rational &a, int e)
number nfMapGG(number c, const coeffs src, const coeffs)
void Werror(const char *fmt,...)
const char * nfRead(const char *s, number *a, const coeffs r)
BOOLEAN nfIsOne(number a, const coeffs r)