32 4, 8, 16, 32, 64, 128, 256, 512,1024,2048,4096,8192,16384, 32768,
34 9, 27, 81,243,729,2187, 6561,19683,59049,
36 25,125,625,3125,15625,
114 if (((
long)a<0L) || ((
long)a>(
long)r->m_nfCharQ))
116 Print(
"wrong %d in %s:%d\n",(
int)((
long)a),
f,
l);
122 if (r->m_nfPlus1Table[
i]>r->m_nfCharQ)
124 Print(
"wrong table %d=%d in %s:%d\n",
i,r->m_nfPlus1Table[
i],
f,
l);
128 }
while (i<r->m_nfCharQ);
131 #define nfTest(N, R) nfDBTest(N,__FILE__,__LINE__, R) 142 return (
long)r->m_nfCharQ == (long)a;
153 if (0L == (
long)a)
return FALSE;
154 return (
long)r->m_nfM1 == (long)a;
177 if (((
long)a == (
long)r->m_nfCharQ) || ((
long)
b == (
long)r->m_nfCharQ))
178 return (number)(long)r->m_nfCharQ;
180 int i=(
int)((long)a+(
long)
b);
181 if (
i>=r->m_nfCharQ1)
i-=r->m_nfCharQ1;
185 return (number)(long)
i;
196 if (
i==0)
return (number)(long)r->m_nfCharQ;
197 while (
i < 0)
i += r->m_nfCharP;
198 while (
i >= r->m_nfCharP)
i -= r->m_nfCharP;
199 if (
i==0)
return (number)(long)r->m_nfCharQ;
203 c=r->m_nfPlus1Table[c];
207 nfTest((number)(
long)c, r);
209 return (number)(long)c;
233 if((
long)r->m_nfCharQ == (
long)n)
return -1;
234 return (
int)((long)n);
243 unsigned short nn=(
unsigned short)(
long)n;
244 if (nn==r->m_nfCharQ)
return 0;
246 while ((c!=nn)&&(
i<r->m_nfCharP))
248 c=r->m_nfPlus1Table[c];
266 if ((
long)
R->m_nfCharQ == (
long)a)
return b;
267 if ((
long)
R->m_nfCharQ == (
long)
b)
return a;
269 if ((
long)a >= (
long)
b)
272 zab = (long)a-(
long)
b;
277 zab = (long)
b-(
long)a;
282 if (
R->m_nfPlus1Table[zab]==
R->m_nfCharQ) r=(long)
R->m_nfCharQ;
285 r= zb+(
long)
R->m_nfPlus1Table[zab];
286 if(r>=(
long)
R->m_nfCharQ1) r-=(
long)
R->m_nfCharQ1;
303 if ((
long)r->m_nfCharQ == (
long)c)
return c;
304 long i=(long)c+(
long)r->m_nfM1;
305 if (
i>=(
long)r->m_nfCharQ1)
i-=(
long)r->m_nfCharQ1;
318 return nfAdd(a,mb,r);
329 return 0L == (long)a;
340 if ((
long)
b==(
long)r->m_nfCharQ)
343 return (number)((long)r->m_nfCharQ);
348 if ((
long)a==(
long)r->m_nfCharQ)
349 return (number)((long)r->m_nfCharQ);
351 long s = (long)a - (
long)
b;
353 s += (long)r->m_nfCharQ1;
368 if ((
long)c==(
long)r->m_nfCharQ)
371 return (number)((long)r->m_nfCharQ);
374 nfTest(((number)((
long)r->m_nfCharQ1-(
long)c)), r);
376 return (number)((long)r->m_nfCharQ1-(
long)c);
388 return (
long)a != (long)
b;
400 return (
long)a == (long)
b;
418 unsigned short nn=(
unsigned short)(
long)a;
419 while ((c!=nn)&&(
i<r->m_nfCharQ))
421 c=r->m_nfPlus1Table[c];
452 unsigned short nn=(
unsigned short)(
long)a;
453 while ((c!=nn)&&(
i<r->m_nfCharQ))
455 c=r->m_nfPlus1Table[c];
489 if ((
long)a == (long)r->m_nfCharQ) rl=(long)r->m_nfCharQ;
490 else rl=((
long)a*(long)
i) % (long)r->m_nfCharQ1;
503 return nEati((
char *)
s,
i,r->m_nfCharP);
526 const int N = strlen(nf_Parameter);
527 if (strncmp(
s,nf_Parameter,
N)==0)
530 if ((*
s >=
'0') && (*
s <=
'9'))
533 while (
i>=r->m_nfCharQ1)
i-=r->m_nfCharQ1;
569 const char *
l=strchr(
s,
';')+1;
571 int i=strtol(
l,&n,10);
585 WerrorS(
"error in reading minpoly from gftables");
595 if ((c==r->m_nfCharQ)||(c== -r->m_nfCharQ))
611 if (r->m_nfCharQ > 1)
613 omFreeSize( (
ADDRESS)r->m_nfPlus1Table,(r->m_nfCharQ+1)*
sizeof(
unsigned short) );
614 r->m_nfPlus1Table=
NULL;
618 if (c>1) r->m_nfCharQ = c;
619 else r->m_nfCharQ = -c;
621 sprintf(
buf,
"gftables/%d",r->m_nfCharQ);
627 if(!fgets(
buf,
sizeof(
buf),
fp))
return;
628 if(strcmp(
buf,
"@@ factory GF(q) table @@\n")!=0)
640 res = sscanf(
buf,
"%d %d",&r->m_nfCharP,&q);
642 while((
res < 0) and (errno == EINTR));
645 r->m_nfCharQ1=r->m_nfCharQ-1;
647 r->m_nfPlus1Table= (
unsigned short *)
omAlloc0( (r->m_nfCharQ+1)*
sizeof(
unsigned short) );
652 while ( i < r->m_nfCharQ )
658 while ( (i < r->m_nfCharQ) && (
k < 30) )
661 if(r->m_nfPlus1Table[
i]>r->m_nfCharQ)
663 Print(
"wrong entry %d: %d(%c%c%c)\n",
i,r->m_nfPlus1Table[
i],bufptr[0],bufptr[1],bufptr[2]);
666 if (r->m_nfPlus1Table[
i]==r->m_nfCharQ)
680 r->m_nfPlus1Table[0]=r->m_nfPlus1Table[r->m_nfCharQ1];
689 Werror(
"illegal GF-table %d",r->m_nfCharQ);
697 return nfInit((
int)((
long)c), dst);
708 while (
i >src->m_nfCharQ1)
i-=src->m_nfCharQ1;
709 return (number)((long)
i);
716 int ex=(int)((
long)c);
720 return (number)(long)src->m_nfCharQ;
736 if ((src->m_nfCharQ % q)==0)
741 while(qq!=q) { qq *= r->m_nfCharP; n1++; }
744 while(qq!=src->m_nfCharQ) { qq *= r->m_nfCharP; n2++; }
748 int save_ch=r->m_nfCharQ;
750 int nn=r->m_nfPlus1Table[0];
756 else if ((n1 % n2)==0)
786 for(
int i = 1;
i <= P;
i++ )
797 sprintf(
s,
"%d,%s",r->m_nfCharQ,
p);
803 static char nfCoeffName_buf[32];
805 nfCoeffName_buf[31]=
'\0';
806 snprintf(nfCoeffName_buf,31,
"ZZ/%d[%s]",r->m_nfCharQ,
p);
807 return nfCoeffName_buf;
812 return (number)(long)(
p() %(
cf->m_nfCharQ+1));
826 else PrintS(
"// minpoly : ...");
833 int c = (int)
pow ((
double)
p->GFChar, (double)
p->GFDegree);
855 r->cfExactDiv=
nfDiv;
905 const char *
name =
p->GFPar_name;
908 r->m_nfCharP =
p->GFChar;
911 r->iNumberOfParameters = 1;
914 char ** pParameterNames = (
char **)
omAlloc0(
sizeof(
char *));
920 r->pParameterNames = (
const char**)pParameterNames;
925 r->m_nfPlus1Table=
NULL;
927 if (strlen(
name) > 1)
932 r->has_simple_Alloc=
TRUE;
933 r->has_simple_Inverse=
TRUE;
935 if(
p->GFChar > (2<<15))
938 WarnS(
"illegal characteristic");
943 const double check=
log ((
double) (
p->GFChar));
945 #define sixteenlog2 11.09035489 949 Warn(
"Sorry: illegal size: %u ^ %u",
p->GFChar,
p->GFDegree );
954 int c = (int)
pow ((
double)
p->GFChar, (double)
p->GFDegree);
958 if( r->m_nfPlus1Table ==
NULL )
964 assume (r -> m_nfCharQ > 0);
966 r->ch = r->m_nfCharP;
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)
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)
static number nfDiv(number a, number b, const coeffs r)
static BOOLEAN nfGreaterZero(number k, const coeffs r)
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
static const char * nfRead(const char *s, number *a, const coeffs r)
static int nfMapGG_factor
#define omFreeSize(addr, size)
char * nEati(char *s, int *i, int m)
divide by the first (leading) number and return it, i.e. make monic
gmp_float log(const gmp_float &a)
BOOLEAN nfDBTest(number a, const char *f, const int l, const coeffs r)
static number nfSub(number a, number b, const coeffs r)
static BOOLEAN nfIsOne(number a, const coeffs r)
static number nfParameter(int i, const coeffs)
void WerrorS(const char *s)
static number nfNeg(number c, const coeffs r)
static number nfMapGG(number c, const coeffs src, const coeffs)
static void nfKillChar(coeffs r)
static number nfMapP(number c, const coeffs, const coeffs dst)
Creation data needed for finite fields.
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
static void nfPower(number a, int i, number *result, 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,...
Coefficient rings, fields and other domains suitable for Singular polynomials.
const CanonicalForm CFMap CFMap & N
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
static BOOLEAN nfIsZero(number a, const coeffs r)
static number nfAdd(number a, number b, const coeffs R)
void StringAppendS(const char *st)
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
static nMapFunc nfSetMap(const coeffs src, const coeffs dst)
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)
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
const unsigned short fftable[]
static number nfMult(number a, number b, const coeffs r)
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
BOOLEAN nfInitChar(coeffs r, void *parameter)
static int nfParDeg(number n, const coeffs r)
static number nfInvers(number c, const coeffs r)
static void nfWriteLong(number a, const coeffs r)
static number nfInit(long i, const coeffs r)
static char * nfCoeffName(const coeffs r)
static number nfMapGGrev(number c, const coeffs src, const coeffs)
static void nfReadTable(const int c, const coeffs r)
static void nfCoeffWrite(const coeffs r, BOOLEAN details)
int convertback62(char *p, int n)
Rational pow(const Rational &a, int e)
static BOOLEAN nfEqual(number a, number b, const coeffs r)
static BOOLEAN nfIsMOne(number a, const coeffs r)
void Werror(const char *fmt,...)
static long nfInt(number &n, const coeffs r)
static BOOLEAN nfGreater(number a, number b, const coeffs r)