My Project
modulop.cc
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 /*
5 * ABSTRACT: numbers modulo p (<=32749)
6 */
7 
8 #include "misc/auxiliary.h"
9 
10 #include "factory/factory.h"
11 
12 #include "misc/mylimits.h"
13 #include "misc/sirandom.h"
14 
15 #include "reporter/reporter.h"
16 
17 #include "coeffs/coeffs.h"
18 #include "coeffs/numbers.h"
19 #include "coeffs/mpr_complex.h"
20 
21 #include "coeffs/longrat.h"
22 #include "coeffs/modulop.h"
23 
24 #include <string.h>
25 
26 static BOOLEAN npGreaterZero (number k, const coeffs r);
27 static BOOLEAN npIsMOne (number a,const coeffs r);
28 static number npDiv (number a, number b,const coeffs r);
29 static number npNeg (number c,const coeffs r);
30 static number npInvers (number c,const coeffs r);
31 static BOOLEAN npGreater (number a, number b,const coeffs r);
32 static BOOLEAN npEqual (number a, number b,const coeffs r);
33 static void npWrite (number a, const coeffs r);
34 static const char * npRead (const char *s, number *a,const coeffs r);
35 static void nvInpMult(number &a, number b, const coeffs r);
36 
37 #ifdef LDEBUG
38 static BOOLEAN npDBTest (number a, const char *f, const int l, const coeffs r);
39 #endif
40 
41 static nMapFunc npSetMap(const coeffs src, const coeffs dst);
42 
43 #include "coeffs/modulop_inl.h" // npMult, npInit
44 
45 #ifdef NV_OPS
46 static number nvDiv (number a, number b, const coeffs r);
47 number nvInvers (number c, const coeffs r);
48 //void nvPower (number a, int i, number * result, const coeffs r);
49 #endif
50 
51 static BOOLEAN npGreaterZero (number k, const coeffs r)
52 {
53  n_Test(k, r);
54 
55  int h = (int)((long) k);
56  return ((int)h !=0) && (h <= (r->ch>>1));
57 }
58 
59 //unsigned long npMultMod(unsigned long a, unsigned long b, int npPrimeM)
60 //{
61 // unsigned long c = a*b;
62 // c = c % npPrimeM;
63 // assume(c == (unsigned long) npMultM((number) a, (number) b, npPrimeM));
64 // return c;
65 //}
66 
67 
68 void npInpMult (number &a,number b, const coeffs r)
69 {
70  n_Test(a, r);
71  n_Test(b, r);
72 
73  if (((long)a == 0) || ((long)b == 0))
74  a=(number)0;
75  else
76  a = npMultM(a,b, r);
77  n_Test(a, r);
78 }
79 
80 /*2
81  * convert a number to an int in (-p/2 .. p/2]
82  */
83 long npInt(number &n, const coeffs r)
84 {
85  n_Test(n, r);
86 
87  if ((long)n > (((long)r->ch) >>1)) return ((long)n -((long)r->ch));
88  else return ((long)n);
89 }
90 
91 static BOOLEAN npIsMOne (number a, const coeffs r)
92 {
93  n_Test(a, r);
94 
95  return ((r->npPminus1M == (long)a) &&(1L!=(long)a))/*for char 2*/;
96 }
97 
98 static number npDiv (number a,number b, const coeffs r)
99 {
100  n_Test(a, r);
101  n_Test(b, r);
102 
103  if ((long)b==0L)
104  {
105  WerrorS(nDivBy0);
106  return (number)0L;
107  }
108  if ((long)a==0) return (number)0L;
109 
110  number d;
111 #ifndef HAVE_GENERIC_MULT
112  int s = r->npLogTable[(long)a] - r->npLogTable[(long)b];
113  #ifdef HAVE_GENERIC_ADD
114  if (s < 0)
115  s += r->npPminus1M;
116  #else
117  #if SIZEOF_LONG == 8
118  s += ((long)s >> 63) & r->npPminus1M;
119  #else
120  s += ((long)s >> 31) & r->npPminus1M;
121  #endif
122  #endif
123  d = (number)(long)r->npExpTable[s];
124 #else
125  number inv=npInversM(b,r);
126  d = npMultM(a,inv,r);
127 #endif
128 
129  n_Test(d, r);
130  return d;
131 
132 }
133 static number npInvers (number c, const coeffs r)
134 {
135  n_Test(c, r);
136 
137  if ((long)c==0L)
138  {
139  WerrorS("1/0");
140  return (number)0L;
141  }
142  number d = npInversM(c,r);
143 
144  n_Test(d, r);
145  return d;
146 }
147 
148 static number npNeg (number c, const coeffs r)
149 {
150  n_Test(c, r);
151 
152  if ((long)c==0L) return c;
153 
154 #if 0
155  number d = npNegM(c,r);
156  n_Test(d, r);
157  return d;
158 #else
159  c = npNegM(c,r);
160  n_Test(c, r);
161  return c;
162 #endif
163 }
164 
165 static BOOLEAN npGreater (number a,number b, const coeffs r)
166 {
167  n_Test(a, r);
168  n_Test(b, r);
169 
170  //return (long)a != (long)b;
171  return ((long)a) > ((long)b);
172 }
173 
174 static BOOLEAN npEqual (number a,number b, const coeffs r)
175 {
176  n_Test(a, r);
177  n_Test(b, r);
178 
179 // return (long)a == (long)b;
180 
181  return npEqualM(a,b,r);
182 }
183 
184 static void npWrite (number a, const coeffs r)
185 {
186  n_Test(a, r);
187 
188  if ((long)a>(((long)r->ch) >>1)) StringAppend("-%d",(int)(((long)r->ch)-((long)a)));
189  else StringAppend("%d",(int)((long)a));
190 }
191 
192 #if 0
193 static void npPower (number a, int i, number * result, const coeffs r)
194 {
195  n_Test(a, r);
196 
197  if (i==0)
198  {
199  //npInit(1,result);
200  *(long *)result = 1;
201  }
202  else if (i==1)
203  {
204  *result = a;
205  }
206  else
207  {
208  npPower(a,i-1,result,r);
209  *result = npMultM(a,*result,r);
210  }
211 }
212 #endif
213 
214 static inline const char* npEati(const char *s, int *i, const coeffs r)
215 {
216  return nEati((char *)s,i,(int)r->ch);
217 }
218 
219 static const char * npRead (const char *s, number *a, const coeffs r)
220 {
221  int z;
222  int n=1;
223 
224  s = npEati(s, &z, r);
225  if ((*s) == '/')
226  {
227  s++;
228  s = npEati(s, &n, r);
229  }
230  if (n == 1)
231  *a = (number)(long)z;
232  else
233  {
234  if ((z==0)&&(n==0))
235  {
236  WerrorS(nDivBy0);
237  *a=(number)0L;
238  }
239  else
240  {
241 #ifdef NV_OPS
242  if (r->ch>NV_MAX_PRIME)
243  *a = nvDiv((number)(long)z,(number)(long)n,r);
244  else
245 #endif
246  *a = npDiv((number)(long)z,(number)(long)n,r);
247  }
248  }
249  n_Test(*a, r);
250  return s;
251 }
252 
253 /*2
254 * set the charcteristic (allocate and init tables)
255 */
256 
258 {
259  #ifdef HAVE_INVTABLE
260  if (r->npInvTable!=NULL)
261  {
262  omFreeSize( (void *)r->npInvTable, r->ch*sizeof(unsigned short) );
263  r->npInvTable=NULL;
264  }
265  #endif
266  #ifndef HAVE_GENERIC_MULT
267  if (r->npExpTable!=NULL)
268  {
269  omFreeSize( (void *)r->npExpTable, r->ch*sizeof(unsigned short) );
270  omFreeSize( (void *)r->npLogTable, r->ch*sizeof(unsigned short) );
271  r->npExpTable=NULL; r->npLogTable=NULL;
272  }
273  #endif
274 }
275 
276 static BOOLEAN npCoeffsEqual(const coeffs r, n_coeffType n, void * parameter)
277 {
278  /* test, if r is an instance of nInitCoeffs(n,parameter) */
279  return (n==n_Zp) && (r->ch==(int)(long)parameter);
280 }
281 CanonicalForm npConvSingNFactoryN( number n, BOOLEAN setChar, const coeffs r )
282 {
283  if (setChar) setCharacteristic( r->ch );
284  return CanonicalForm(npInt( n,r ));
285 }
286 
287 number npConvFactoryNSingN( const CanonicalForm n, const coeffs r)
288 {
289  if (n.isImm())
290  {
291  return npInit(n.intval(),r);
292  }
293  else
294  {
295  assume(0);
296  return NULL;
297  }
298 }
299 
300 static char* npCoeffName(const coeffs cf)
301 {
302  STATIC_VAR char npCoeffName_buf[15];
303  snprintf(npCoeffName_buf,14,"ZZ/%d",cf->ch);
304  return npCoeffName_buf;
305 }
306 
307 static void npWriteFd(number n, const ssiInfo* d, const coeffs)
308 {
309  fprintf(d->f_write,"%d ",(int)(long)n);
310 }
311 
312 static number npReadFd(const ssiInfo *d, const coeffs)
313 {
314  // read int
315  int dd;
316  dd=s_readint(d->f_read);
317  return (number)(long)dd;
318 }
319 
320 static number npRandom(siRandProc p, number, number, const coeffs cf)
321 {
322  return npInit(p(),cf);
323 }
324 
325 
326 #ifndef HAVE_GENERIC_MULT
327 static number npPar(int, coeffs r)
328 {
329  return (number)(long)r->npExpTable[1];
330 }
331 #endif
332 
333 static number npInitMPZ(mpz_t m, const coeffs r)
334 {
335  return (number)mpz_fdiv_ui(m, r->ch);
336 }
337 
339 {
340  assume( getCoeffType(r) == n_Zp );
341  const int c = (int) (long) p;
342 
343  assume( c > 0 );
344 
345  int i, w;
346 
347  r->is_field=TRUE;
348  r->is_domain=TRUE;
349  r->rep=n_rep_int;
350 
351  r->ch = c;
352  r->npPminus1M = c /*r->ch*/ - 1;
353 
354  //r->cfInitChar=npInitChar;
355  r->cfKillChar=npKillChar;
356  r->nCoeffIsEqual=npCoeffsEqual;
357  r->cfCoeffName=npCoeffName;
358 
359  r->cfMult = npMult;
360  r->cfInpMult = npInpMult;
361  r->cfSub = npSubM;
362  r->cfAdd = npAddM;
363  r->cfInpAdd = npInpAddM;
364  r->cfDiv = npDiv;
365  r->cfInit = npInit;
366  //r->cfSize = ndSize;
367  r->cfInt = npInt;
368  r->cfInitMPZ = npInitMPZ;
369  #ifdef HAVE_RINGS
370  //r->cfDivComp = NULL; // only for ring stuff
371  //r->cfIsUnit = NULL; // only for ring stuff
372  //r->cfGetUnit = NULL; // only for ring stuff
373  //r->cfExtGcd = NULL; // only for ring stuff
374  // r->cfDivBy = NULL; // only for ring stuff
375  #endif
376  r->cfInpNeg = npNeg;
377  r->cfInvers= npInvers;
378  //r->cfCopy = ndCopy;
379  //r->cfRePart = ndCopy;
380  //r->cfImPart = ndReturn0;
381  r->cfWriteLong = npWrite;
382  r->cfRead = npRead;
383  //r->cfNormalize=ndNormalize;
384  r->cfGreater = npGreater;
385  r->cfEqual = npEqual;
386  r->cfIsZero = npIsZero;
387  r->cfIsOne = npIsOne;
388  r->cfIsMOne = npIsMOne;
389  r->cfGreaterZero = npGreaterZero;
390  //r->cfPower = npPower;
391  //r->cfGetDenom = ndGetDenom;
392  //r->cfGetNumerator = ndGetNumerator;
393  //r->cfGcd = ndGcd;
394  //r->cfLcm = ndGcd;
395  //r->cfDelete= ndDelete;
396  r->cfSetMap = npSetMap;
397  //r->cfName = ndName;
398  //r->cfInpMult=ndInpMult;
399  r->convSingNFactoryN=npConvSingNFactoryN;
400  r->convFactoryNSingN=npConvFactoryNSingN;
401  r->cfRandom=npRandom;
402 #ifdef LDEBUG
403  // debug stuff
404  r->cfDBTest=npDBTest;
405 #endif
406 
407  // io via ssi
408  r->cfWriteFd=npWriteFd;
409  r->cfReadFd=npReadFd;
410 
411  // the variables:
412  r->type = n_Zp;
413  r->has_simple_Alloc=TRUE;
414  r->has_simple_Inverse=TRUE;
415 
416  // the tables
417 #ifdef NV_OPS
418  if (r->ch <=NV_MAX_PRIME)
419 #endif
420  {
421 #ifdef HAVE_INVTABLE
422  r->npInvTable=(unsigned short*)omAlloc0( r->ch*sizeof(unsigned short) );
423 #endif
424 #ifndef HAVE_GENERIC_MULT
425  r->cfParameter=npPar; /* Singular.jl */
426  r->npExpTable=(unsigned short *)omAlloc0( r->ch*sizeof(unsigned short) );
427  r->npLogTable=(unsigned short *)omAlloc0( r->ch*sizeof(unsigned short) );
428  r->npExpTable[0] = 1;
429  r->npLogTable[0] = 0;
430  if (r->ch > 2)
431  {
432  w = 1;
433  loop
434  {
435  r->npLogTable[1] = 0;
436  w++;
437  i = 0;
438  loop
439  {
440  i++;
441  r->npExpTable[i] =(int)(((long)w * (long)r->npExpTable[i-1]) % r->ch);
442  r->npLogTable[r->npExpTable[i]] = i;
443  if /*(i == r->ch - 1 ) ||*/ (/*(*/ r->npExpTable[i] == 1 /*)*/)
444  break;
445  }
446  if (i == r->ch - 1)
447  break;
448  }
449  }
450  else
451  {
452  r->npExpTable[1] = 1;
453  r->npLogTable[1] = 0;
454  }
455 #endif
456  }
457 #ifdef NV_OPS
458  else /*if (c>NV_MAX_PRIME)*/
459  {
460  r->cfMult = nvMult;
461  r->cfDiv = nvDiv;
462  r->cfExactDiv = nvDiv;
463  r->cfInvers = nvInvers;
464  r->cfInpMult = nvInpMult;
465  //r->cfPower= nvPower;
466  //if (c>FACTORY_MAX_PRIME) // factory will catch this error
467  //{
468  // r->convSingNFactoryN=ndConvSingNFactoryN;
469  //}
470  }
471 #endif
472  return FALSE;
473 }
474 
475 #ifdef LDEBUG
476 static BOOLEAN npDBTest (number a, const char *f, const int l, const coeffs r)
477 {
478  if (((long)a<0L) || ((long)a>(long)r->ch))
479  {
480  Print("wrong mod p number %ld at %s,%d\n",(long)a,f,l);
481  return FALSE;
482  }
483  return TRUE;
484 }
485 #endif
486 
487 static number npMapP(number from, const coeffs src, const coeffs dst_r)
488 {
489  long i = (long)from;
490  if (i>src->ch/2)
491  {
492  i-=src->ch;
493  while (i < 0) i+=dst_r->ch;
494  }
495  i%=dst_r->ch;
496  return (number)i;
497 }
498 
499 static number npMapLongR(number from, const coeffs /*src*/, const coeffs dst_r)
500 {
501  gmp_float *ff=(gmp_float*)from;
502  mpf_t *f=ff->_mpfp();
503  number res;
504  mpz_ptr dest,ndest;
505  int size,i;
506  int e,al,bl;
507  long iz;
508  mp_ptr qp,dd,nn;
509 
510  size = (*f)[0]._mp_size;
511  if (size == 0)
512  return npInit(0,dst_r);
513  if(size<0)
514  size = -size;
515 
516  qp = (*f)[0]._mp_d;
517  while(qp[0]==0)
518  {
519  qp++;
520  size--;
521  }
522 
523  if(dst_r->ch>2)
524  e=(*f)[0]._mp_exp-size;
525  else
526  e=0;
527  res = ALLOC_RNUMBER();
528 #if defined(LDEBUG)
529  res->debug=123456;
530 #endif
531  dest = res->z;
532 
533  long in=0;
534  if (e<0)
535  {
536  al = dest->_mp_size = size;
537  if (al<2) al = 2;
538  dd = (mp_ptr)omAlloc(sizeof(mp_limb_t)*al);
539  for (i=0;i<size;i++) dd[i] = qp[i];
540  bl = 1-e;
541  nn = (mp_ptr)omAlloc(sizeof(mp_limb_t)*bl);
542  nn[bl-1] = 1;
543  for (i=bl-2;i>=0;i--) nn[i] = 0;
544  ndest = res->n;
545  ndest->_mp_d = nn;
546  ndest->_mp_alloc = ndest->_mp_size = bl;
547  res->s = 0;
548  in=mpz_fdiv_ui(ndest,dst_r->ch);
549  mpz_clear(ndest);
550  }
551  else
552  {
553  al = dest->_mp_size = size+e;
554  if (al<2) al = 2;
555  dd = (mp_ptr)omAlloc(sizeof(mp_limb_t)*al);
556  for (i=0;i<size;i++) dd[i+e] = qp[i];
557  for (i=0;i<e;i++) dd[i] = 0;
558  res->s = 3;
559  }
560 
561  dest->_mp_d = dd;
562  dest->_mp_alloc = al;
563  iz=mpz_fdiv_ui(dest,dst_r->ch);
564  mpz_clear(dest);
565  if(res->s==0)
566  iz=(long)npDiv((number)iz,(number)in,dst_r);
567  FREE_RNUMBER(res); // Q!?
568  return (number)iz;
569 }
570 
571 #ifdef HAVE_RINGS
572 /*2
573 * convert from a GMP integer
574 */
575 static number npMapGMP(number from, const coeffs /*src*/, const coeffs dst)
576 {
577  return (number)mpz_fdiv_ui((mpz_ptr) from, dst->ch);
578 }
579 
580 static number npMapZ(number from, const coeffs src, const coeffs dst)
581 {
582  if (SR_HDL(from) & SR_INT)
583  {
584  long f_i=SR_TO_INT(from);
585  return npInit(f_i,dst);
586  }
587  return npMapGMP(from,src,dst);
588 }
589 
590 /*2
591 * convert from an machine long
592 */
593 static number npMapMachineInt(number from, const coeffs /*src*/,const coeffs dst)
594 {
595  long i = (long) (((unsigned long) from) % dst->ch);
596  return (number) i;
597 }
598 #endif
599 
600 static number npMapCanonicalForm (number a, const coeffs /*src*/, const coeffs dst)
601 {
602  setCharacteristic (dst ->ch);
604  return (number) (f.intval());
605 }
606 
607 static nMapFunc npSetMap(const coeffs src, const coeffs)
608 {
609 #ifdef HAVE_RINGS
610  if ((src->rep==n_rep_int) && nCoeff_is_Ring_2toM(src))
611  {
612  return npMapMachineInt;
613  }
614  if (src->rep==n_rep_gmp) //nCoeff_is_Z(src) || nCoeff_is_Ring_PtoM(src) || nCoeff_is_Zn(src))
615  {
616  return npMapGMP;
617  }
618  if (src->rep==n_rep_gap_gmp) //nCoeff_is_Z(src)
619  {
620  return npMapZ;
621  }
622 #endif
623  if (src->rep==n_rep_gap_rat) /* Q, Z */
624  {
625  return nlModP; // npMap0; // FIXME? TODO? // extern number nlModP(number q, const coeffs Q, const coeffs Zp); // Map q \in QQ \to Zp // FIXME!
626  }
627  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src) )
628  {
629  return npMapP;
630  }
631  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
632  {
633  return npMapLongR;
634  }
635  if (nCoeff_is_CF (src))
636  {
637  return npMapCanonicalForm;
638  }
639  return NULL; /* default */
640 }
641 
642 // -----------------------------------------------------------
643 // operation for very large primes (32749< p < 2^31-1)
644 // ----------------------------------------------------------
645 #ifdef NV_OPS
646 static void nvInpMult(number &a, number b, const coeffs r)
647 {
648  number n=nvMult(a,b,r);
649  a=n;
650 }
651 
652 static inline number nvInversM (number c, const coeffs r)
653 {
654  long inv=npInvMod((long)c,r);
655  return (number)inv;
656 }
657 
658 static number nvDiv (number a,number b, const coeffs r)
659 {
660  if ((long)a==0L)
661  return (number)0L;
662  else if ((long)b==0L)
663  {
664  WerrorS(nDivBy0);
665  return (number)0L;
666  }
667  else
668  {
669  number inv=nvInversM(b,r);
670  return nvMult(a,inv,r);
671  }
672 }
673 number nvInvers (number c, const coeffs r)
674 {
675  if ((long)c==0L)
676  {
677  WerrorS(nDivBy0);
678  return (number)0L;
679  }
680  return nvInversM(c,r);
681 }
682 #if 0
683 void nvPower (number a, int i, number * result, const coeffs r)
684 {
685  if (i==0)
686  {
687  //npInit(1,result);
688  *(long *)result = 1;
689  }
690  else if (i==1)
691  {
692  *result = a;
693  }
694  else
695  {
696  nvPower(a,i-1,result,r);
697  *result = nvMult(a,*result,r);
698  }
699 }
700 #endif
701 #endif
702 
All the auxiliary stuff.
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
void FACTORY_PUBLIC setCharacteristic(int c)
Definition: cf_char.cc:28
int l
Definition: cfEzgcd.cc:100
int m
Definition: cfEzgcd.cc:128
int i
Definition: cfEzgcd.cc:132
int k
Definition: cfEzgcd.cc:99
int p
Definition: cfModGcd.cc:4078
CanonicalForm cf
Definition: cfModGcd.cc:4083
CanonicalForm b
Definition: cfModGcd.cc:4103
FILE * f
Definition: checklibs.c:9
factory's main class
Definition: canonicalform.h:86
long intval() const
conversion functions
bool isImm() const
virtual class for internal CanonicalForm's
Definition: int_cf.h:47
mpf_t * _mpfp()
Definition: mpr_complex.h:134
Coefficient rings, fields and other domains suitable for Singular polynomials.
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:888
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:709
n_coeffType
Definition: coeffs.h:27
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:29
static FORCE_INLINE BOOLEAN nCoeff_is_CF(const coeffs r)
Definition: coeffs.h:894
#define ALLOC_RNUMBER()
Definition: coeffs.h:87
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:797
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
Definition: coeffs.h:721
#define FREE_RNUMBER(x)
Definition: coeffs.h:86
@ n_rep_gap_rat
(number), see longrat.h
Definition: coeffs.h:111
@ n_rep_gap_gmp
(), see rinteger.h, new impl.
Definition: coeffs.h:112
@ n_rep_int
(int), see modulop.h
Definition: coeffs.h:110
@ n_rep_gmp_float
(gmp_float), see
Definition: coeffs.h:117
@ n_rep_gmp
(mpz_ptr), see rmodulon,h
Definition: coeffs.h:115
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
#define Print
Definition: emacs.cc:80
#define StringAppend
Definition: emacs.cc:79
return result
Definition: facAbsBiFact.cc:75
const CanonicalForm int s
Definition: facAbsFact.cc:51
CanonicalForm res
Definition: facAbsFact.cc:60
const CanonicalForm & w
Definition: facAbsFact.cc:51
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define STATIC_VAR
Definition: globaldefs.h:7
STATIC_VAR Poly * h
Definition: janet.cc:971
number nlModP(number q, const coeffs, const coeffs Zp)
Definition: longrat.cc:1577
#define SR_INT
Definition: longrat.h:67
#define SR_TO_INT(SR)
Definition: longrat.h:69
#define assume(x)
Definition: mod2.h:389
static BOOLEAN npCoeffsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: modulop.cc:276
static number npMapMachineInt(number from, const coeffs, const coeffs dst)
Definition: modulop.cc:593
static const char * npRead(const char *s, number *a, const coeffs r)
Definition: modulop.cc:219
static number npInitMPZ(mpz_t m, const coeffs r)
Definition: modulop.cc:333
static void npWrite(number a, const coeffs r)
Definition: modulop.cc:184
CanonicalForm npConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition: modulop.cc:281
static void npWriteFd(number n, const ssiInfo *d, const coeffs)
Definition: modulop.cc:307
BOOLEAN npInitChar(coeffs r, void *p)
Definition: modulop.cc:338
static number nvDiv(number a, number b, const coeffs r)
Definition: modulop.cc:658
static number npDiv(number a, number b, const coeffs r)
Definition: modulop.cc:98
static number npMapP(number from, const coeffs src, const coeffs dst_r)
Definition: modulop.cc:487
number nvInvers(number c, const coeffs r)
Definition: modulop.cc:673
static number npPar(int, coeffs r)
Definition: modulop.cc:327
static number npInvers(number c, const coeffs r)
Definition: modulop.cc:133
static BOOLEAN npEqual(number a, number b, const coeffs r)
Definition: modulop.cc:174
static number npNeg(number c, const coeffs r)
Definition: modulop.cc:148
static BOOLEAN npGreater(number a, number b, const coeffs r)
Definition: modulop.cc:165
static char * npCoeffName(const coeffs cf)
Definition: modulop.cc:300
void npInpMult(number &a, number b, const coeffs r)
Definition: modulop.cc:68
static BOOLEAN npIsMOne(number a, const coeffs r)
Definition: modulop.cc:91
static BOOLEAN npGreaterZero(number k, const coeffs r)
Definition: modulop.cc:51
static number npMapLongR(number from, const coeffs, const coeffs dst_r)
Definition: modulop.cc:499
static BOOLEAN npDBTest(number a, const char *f, const int l, const coeffs r)
Definition: modulop.cc:476
static nMapFunc npSetMap(const coeffs src, const coeffs dst)
Definition: modulop.cc:607
static number npMapZ(number from, const coeffs src, const coeffs dst)
Definition: modulop.cc:580
static number npMapGMP(number from, const coeffs, const coeffs dst)
Definition: modulop.cc:575
static number npReadFd(const ssiInfo *d, const coeffs)
Definition: modulop.cc:312
static void nvInpMult(number &a, number b, const coeffs r)
Definition: modulop.cc:646
static number nvInversM(number c, const coeffs r)
Definition: modulop.cc:652
static number npRandom(siRandProc p, number, number, const coeffs cf)
Definition: modulop.cc:320
static const char * npEati(const char *s, int *i, const coeffs r)
Definition: modulop.cc:214
long npInt(number &n, const coeffs r)
Definition: modulop.cc:83
void npKillChar(coeffs r)
Definition: modulop.cc:257
static number npMapCanonicalForm(number a, const coeffs, const coeffs dst)
Definition: modulop.cc:600
number npConvFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: modulop.cc:287
static BOOLEAN npIsOne(number a, const coeffs)
Definition: modulop.h:179
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:124
static number npMultM(number a, number b, const coeffs r)
Definition: modulop.h:71
static number npNegM(number a, const coeffs r)
Definition: modulop.h:174
#define NV_MAX_PRIME
Definition: modulop.h:37
#define npEqualM(A, B, r)
Definition: modulop.h:259
static long npInvMod(long a, const coeffs R)
Definition: modulop.h:184
static number npInversM(number c, const coeffs r)
Definition: modulop.h:223
static void npInpAddM(number &a, number b, const coeffs r)
Definition: modulop.h:129
static number npSubM(number a, number b, const coeffs r)
Definition: modulop.h:134
static number npInit(long i, const coeffs r)
Definition: modulop_inl.h:27
static number nvMult(number a, number b, const coeffs r)
Definition: modulop_inl.h:50
static number npMult(number a, number b, const coeffs r)
Definition: modulop_inl.h:12
static BOOLEAN npIsZero(number a, const coeffs r)
Definition: modulop_inl.h:38
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
Definition: numbers.cc:677
const char *const nDivBy0
Definition: numbers.h:89
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define NULL
Definition: omList.c:12
int s_readint(s_buff F)
Definition: s_buff.cc:112
s_buff f_read
Definition: s_buff.h:22
FILE * f_write
Definition: s_buff.h:23
Definition: s_buff.h:21
int(* siRandProc)(void)
Definition: sirandom.h:9
#define loop
Definition: structs.h:75
#define SR_HDL(A)
Definition: tgb.cc:35