28 4, 8, 16, 32, 64, 128, 256, 512,1024,2048,4096,8192,16384, 32768,
30 9, 27, 81,243,729,2187, 6561,19683,59049,
32 25,125,625,3125,15625,
110 if (((
long)a<0L) || ((
long)a>(
long)r->m_nfCharQ))
112 Print(
"wrong %d in %s:%d\n",(
int)((
long)a),
f,
l);
118 if (r->m_nfPlus1Table[
i]>r->m_nfCharQ)
120 Print(
"wrong table %d=%d in %s:%d\n",
i,r->m_nfPlus1Table[
i],
f,
l);
124 }
while (i<r->m_nfCharQ);
127#define nfTest(N, R) nfDBTest(N,__FILE__,__LINE__, R)
138 return (
long)r->m_nfCharQ == (long)a;
149 if (0L == (
long)a)
return FALSE;
150 return (
long)r->m_nfM1 == (long)a;
173 if (((
long)a == (
long)r->m_nfCharQ) || ((
long)
b == (
long)r->m_nfCharQ))
174 return (number)(long)r->m_nfCharQ;
176 int i=(
int)((long)a+(
long)
b);
177 if (
i>=r->m_nfCharQ1)
i-=r->m_nfCharQ1;
181 return (number)(long)
i;
192 if (
i==0)
return (number)(long)r->m_nfCharQ;
193 while (
i < 0)
i += r->m_nfCharP;
194 while (
i >= r->m_nfCharP)
i -= r->m_nfCharP;
195 if (
i==0)
return (number)(long)r->m_nfCharQ;
199 c=r->m_nfPlus1Table[c];
203 nfTest((number)(
long)c, r);
205 return (number)(long)c;
229 if((
long)r->m_nfCharQ == (
long)n)
return -1;
230 return (
int)((long)n);
239 unsigned short nn=(
unsigned short)(
long)n;
240 if (nn==r->m_nfCharQ)
return 0;
242 while ((c!=nn)&&(
i<r->m_nfCharP))
244 c=r->m_nfPlus1Table[c];
262 if ((
long)
R->m_nfCharQ == (
long)a)
return b;
263 if ((
long)
R->m_nfCharQ == (
long)
b)
return a;
265 if ((
long)a >= (
long)
b)
268 zab = (long)a-(
long)
b;
273 zab = (long)
b-(
long)a;
278 if (
R->m_nfPlus1Table[zab]==
R->m_nfCharQ) r=(long)
R->m_nfCharQ;
281 r= zb+(
long)
R->m_nfPlus1Table[zab];
282 if(r>=(
long)
R->m_nfCharQ1) r-=(
long)
R->m_nfCharQ1;
299 if ((
long)r->m_nfCharQ == (
long)c)
return c;
300 long i=(long)c+(
long)r->m_nfM1;
301 if (
i>=(
long)r->m_nfCharQ1)
i-=(
long)r->m_nfCharQ1;
314 return nfAdd(a,mb,r);
325 return 0L == (long)a;
336 if ((
long)
b==(
long)r->m_nfCharQ)
339 return (number)((long)r->m_nfCharQ);
344 if ((
long)a==(
long)r->m_nfCharQ)
345 return (number)((long)r->m_nfCharQ);
347 long s = (long)a - (
long)
b;
349 s += (long)r->m_nfCharQ1;
364 if ((
long)c==(
long)r->m_nfCharQ)
367 return (number)((long)r->m_nfCharQ);
370 nfTest(((number)((
long)r->m_nfCharQ1-(
long)c)), r);
372 return (number)((long)r->m_nfCharQ1-(
long)c);
384 return (
long)a != (long)
b;
396 return (
long)a == (long)
b;
414 unsigned short nn=(
unsigned short)(
long)a;
415 while ((c!=nn)&&(
i<r->m_nfCharQ))
417 c=r->m_nfPlus1Table[c];
448 unsigned short nn=(
unsigned short)(
long)a;
449 while ((c!=nn)&&(
i<r->m_nfCharQ))
451 c=r->m_nfPlus1Table[c];
485 if ((
long)a == (long)r->m_nfCharQ) rl=(long)r->m_nfCharQ;
486 else rl=((
long)a*(long)
i) % (long)r->m_nfCharQ1;
499 return nEati((
char *)
s,
i,r->m_nfCharP);
522 const int N = strlen(nf_Parameter);
523 if (strncmp(
s,nf_Parameter,
N)==0)
526 if ((*
s >=
'0') && (*
s <=
'9'))
529 while (
i>=r->m_nfCharQ1)
i-=r->m_nfCharQ1;
565 const char *
l=strchr(
s,
';')+1;
567 int i=strtol(
l,&n,10);
581 WerrorS(
"error in reading minpoly from gftables");
591 if ((c==r->m_nfCharQ)||(c== -r->m_nfCharQ))
607 if (r->m_nfCharQ > 1)
609 omFreeSize( (
ADDRESS)r->m_nfPlus1Table,(r->m_nfCharQ+1)*
sizeof(
unsigned short) );
610 r->m_nfPlus1Table=
NULL;
614 if (c>1) r->m_nfCharQ = c;
615 else r->m_nfCharQ = -c;
617 sprintf(
buf,
"gftables/%d",r->m_nfCharQ);
623 if(!fgets(
buf,
sizeof(
buf),
fp))
return;
624 if(strcmp(
buf,
"@@ factory GF(q) table @@\n")!=0)
636 res = sscanf(
buf,
"%d %d",&r->m_nfCharP,&q);
638 while((
res < 0) and (errno == EINTR));
641 r->m_nfCharQ1=r->m_nfCharQ-1;
643 r->m_nfPlus1Table= (
unsigned short *)
omAlloc0( (r->m_nfCharQ+1)*
sizeof(
unsigned short) );
648 while ( i < r->m_nfCharQ )
654 while ( (i < r->m_nfCharQ) && (
k < 30) )
657 if(r->m_nfPlus1Table[
i]>r->m_nfCharQ)
659 Print(
"wrong entry %d: %d(%c%c%c)\n",
i,r->m_nfPlus1Table[
i],bufptr[0],bufptr[1],bufptr[2]);
662 if (r->m_nfPlus1Table[
i]==r->m_nfCharQ)
676 r->m_nfPlus1Table[0]=r->m_nfPlus1Table[r->m_nfCharQ1];
685 Werror(
"illegal GF-table %d",r->m_nfCharQ);
693 return nfInit((
int)((
long)c), dst);
704 while (
i >src->m_nfCharQ1)
i-=src->m_nfCharQ1;
705 return (number)((long)
i);
712 int ex=(int)((
long)c);
716 return (number)(long)src->m_nfCharQ;
723 mpz_mod_ui(tmp,(mpz_ptr)c,dst->m_nfCharP);
724 long l=mpz_get_si(tmp);
732 mpz_mod_ui(tmp,
m,
cf->m_nfCharP);
733 long l=mpz_get_si(tmp);
739 long i=src->cfInt(c,src);
740 if (
i==0)
return (number)(long)dst->m_nfCharQ;
741 while (
i < 0)
i += dst->m_nfCharP;
742 while (
i >= dst->m_nfCharP)
i -= dst->m_nfCharP;
755 if ((src->m_nfCharQ % q)==0)
760 while(qq!=q) { qq *= r->m_nfCharP; n1++; }
763 while(qq!=src->m_nfCharQ) { qq *= r->m_nfCharP; n2++; }
767 int save_ch=r->m_nfCharQ;
769 int nn=r->m_nfPlus1Table[0];
775 else if ((n1 % n2)==0)
820 nfCoeffName_buf[31]=
'\0';
821 snprintf(nfCoeffName_buf,31,
"%d,%s",r->m_nfCharQ,
p);
822 return nfCoeffName_buf;
827 return (number)(long)(
p() %(
cf->m_nfCharQ+1));
841 else PrintS(
"// minpoly : ...");
848 int c = (int)
pow ((
double)
p->GFChar, (double)
p->GFDegree);
862 if(
p->GFChar > (2<<15))
865 WarnS(
"illegal characteristic");
870 const double check=
log ((
double) (
p->GFChar));
872 #define sixteenlog2 11.09035489
876 Warn(
"Sorry: illegal size: %u ^ %u",
p->GFChar,
p->GFDegree );
894 r->cfExactDiv=
nfDiv;
939 const char *
name =
p->GFPar_name;
942 r->m_nfCharP =
p->GFChar;
945 r->iNumberOfParameters = 1;
948 char ** pParameterNames = (
char **)
omAlloc(
sizeof(
char *));
953 r->pParameterNames = (
const char**)pParameterNames;
955 r->m_nfPlus1Table=
NULL;
957 if (strlen(
name) > 1)
962 r->has_simple_Alloc=
TRUE;
963 r->has_simple_Inverse=
TRUE;
965 int c = (
int)
pow ((
double)
p->GFChar, (
double)
p->GFDegree);
969 if( r->m_nfPlus1Table ==
NULL )
971 Werror(
"reading table for field with %d elements failed",c);
976 assume (r -> m_nfCharQ > 0);
978 r->ch = r->m_nfCharP;
Rational pow(const Rational &a, int e)
const CanonicalForm CFMap CFMap & N
Coefficient rings, fields and other domains suitable for Singular polynomials.
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
@ n_rep_gap_rat
(number), see longrat.h
@ n_rep_int
(int), see modulop.h
@ n_rep_gf
(int), see ffields.h
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Creation data needed for finite fields.
const CanonicalForm int s
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
void WerrorS(const char *s)
const char * eati(const char *s, int *i)
static number nfMapViaInt(number c, const coeffs src, const coeffs dst)
static BOOLEAN nfIsMOne(number a, const coeffs r)
static number nfInitMPZ(mpz_t m, const coeffs cf)
STATIC_VAR int nfMinPoly[16]
static number nfAdd(number a, number b, const coeffs R)
static number nfMapMPZ(number c, const coeffs, const coeffs dst)
int convertback62(char *p, int n)
STATIC_VAR int nfMapGG_factor
static nMapFunc nfSetMap(const coeffs src, const coeffs dst)
static void nfReadMipo(char *s)
static BOOLEAN nfDBTest(number a, const char *f, const int l, const coeffs r)
static number nfInit(long i, const coeffs r)
void nfShowMipo(const coeffs r)
Show the mininimal polynom.... NOTE: this is used by char * sleftv::String(void *d,...
int gf_tab_numdigits62(int q)
static void nfKillChar(coeffs r)
static int nfParDeg(number n, const coeffs r)
const unsigned short fftable[]
static long nfInt(number &n, const coeffs r)
static number nfMult(number a, number b, const coeffs r)
static BOOLEAN nfGreaterZero(number k, const coeffs r)
static char * nfCoeffName(const coeffs r)
BOOLEAN nfInitChar(coeffs r, void *parameter)
static void nfWriteShort(number a, const coeffs r)
static number nfSub(number a, number b, const coeffs r)
static number nfRandom(siRandProc p, number, number, const coeffs cf)
static BOOLEAN nfIsOne(number a, const coeffs r)
static void nfCoeffWrite(const coeffs r, BOOLEAN details)
static const char * nfRead(const char *s, number *a, const coeffs r)
static BOOLEAN nfGreater(number a, number b, const coeffs r)
static number nfNeg(number c, const coeffs r)
static const char * nfEati(const char *s, int *i, const coeffs r)
static BOOLEAN nfIsZero(number a, const coeffs r)
static BOOLEAN nfCoeffIsEqual(const coeffs, n_coeffType, void *)
static number nfMapGGrev(number c, const coeffs src, const coeffs)
static BOOLEAN nfEqual(number a, number b, const coeffs r)
static number nfMapP(number c, const coeffs, const coeffs dst)
static void nfReadTable(const int c, const coeffs r)
static void nfWriteLong(number a, const coeffs r)
static number nfDiv(number a, number b, const coeffs r)
static number nfParameter(int i, const coeffs)
static number nfMapGG(number c, const coeffs src, const coeffs)
static number nfInvers(number c, const coeffs r)
static void nfPower(number a, int i, number *result, const coeffs r)
number nlModP(number q, const coeffs, const coeffs Zp)
gmp_float log(const gmp_float &a)
The main handler for Singular numbers which are suitable for Singular polynomials.
char * nEati(char *s, int *i, int m)
divide by the first (leading) number and return it, i.e. make monic
const char *const nDivBy0
#define omFreeSize(addr, size)
void StringSetS(const char *st)
void StringAppendS(const char *st)
void PrintS(const char *s)
void Werror(const char *fmt,...)
int status int void * buf
int name
New type name for int.