numbers.cc
Go to the documentation of this file.
1 /*****************************************
2 * Computer Algebra System SINGULAR *
3 *****************************************/
4 
5 /*
6 * ABSTRACT: interface to coefficient aritmetics
7 */
8 
9 #include <string.h>
10 #include <stdlib.h>
11 
12 #include <misc/auxiliary.h>
13 #include <omalloc/omalloc.h>
14 #include <factory/factory.h>
15 
16 #include <reporter/reporter.h>
17 
18 #include <coeffs/coeffs.h>
19 #include <coeffs/numbers.h>
20 
21 #include <coeffs/longrat.h>
22 #include <coeffs/modulop.h>
23 #include <coeffs/gnumpfl.h>
24 #include <coeffs/gnumpc.h>
25 #include <coeffs/ffields.h>
26 #include <coeffs/shortfl.h>
27 
28 #ifdef HAVE_RINGS
29 # include <coeffs/rmodulo2m.h>
30 # include <coeffs/rmodulon.h>
31 # include <coeffs/rintegers.h>
32 #endif
33 
34 #ifdef HAVE_POLYEXTENSIONS
37 #endif
38 
39 
40 #ifdef HAVE_NUMSTATS
41 struct SNumberStatistic number_stats;
42 #endif /* HAVE_NUMSTATS */
43 
44 //static int characteristic = 0;
45 //extern int IsPrime(int p);
46 
48 
49 void nNew(number* d) { *d=NULL; }
50 
51 
52 static void ndDelete(number* d, const coeffs) { *d=NULL; }
53 static number ndAnn(number, const coeffs) { return NULL;}
54 static char* ndCoeffString(const coeffs r)
55 {
56  char *s=(char *)omAlloc(11);snprintf(s,11,"Coeffs(%d)",r->type);
57  return s;
58 }
59 static char* ndCoeffName(const coeffs r)
60 {
61  static char s[20];
62  snprintf(s,11,"Coeffs(%d)",r->type);
63  return s;
64 }
65 static void ndInpMult(number &a, number b, const coeffs r)
66 {
67  number n=r->cfMult(a,b,r);
68  r->cfDelete(&a,r);
69  a=n;
70 }
71 static void ndInpAdd(number &a, number b, const coeffs r)
72 {
73  number n=r->cfAdd(a,b,r);
74  r->cfDelete(&a,r);
75  a=n;
76 }
77 
78 static void ndPower(number a, int i, number * res, const coeffs r)
79 {
80  if (i==0)
81  {
82  *res = r->cfInit(1, r);
83  }
84  else if (i==1)
85  {
86  *res = r->cfCopy(a, r);
87  }
88  else if (i==2)
89  {
90  *res = r->cfMult(a, a, r);
91  }
92  else if (i<0)
93  {
94  number b = r->cfInvers(a, r);
95  ndPower(b, -i, res, r);
96  r->cfDelete(&b, r);
97  }
98  else
99  {
100  ndPower(a, i/2, res, r);
101  r->cfInpMult(*res, *res, r);
102  if (i&1)
103  {
104  r->cfInpMult(*res, a, r);
105  }
106  }
107 }
108 
109 static BOOLEAN ndIsUnit(number a, const coeffs r) { return !r->cfIsZero(a,r); }
110 #ifdef LDEBUG
111 // static void nDBDummy1(number* d,char *, int) { *d=NULL; }
112 static BOOLEAN ndDBTest(number, const char *, const int, const coeffs){ return TRUE; }
113 #endif
114 
115 static number ndFarey(number,number,const coeffs r)
116 {
117  Werror("farey not implemented for %s (c=%d)",r->cfCoeffString(r),getCoeffType(r));
118  return NULL;
119 }
120 static number ndChineseRemainder(number *,number *,int,BOOLEAN,CFArray&,const coeffs r)
121 {
122  Werror("ChineseRemainder not implemented for %s (c=%d)",r->cfCoeffString(r),getCoeffType(r));
123  return r->cfInit(0,r);
124 }
125 
126 static int ndParDeg(number n, const coeffs r)
127 {
128  return (-r->cfIsZero(n,r));
129 }
130 
131 static number ndParameter(const int, const coeffs r)
132 {
133  Werror("ndParameter: n_Parameter is not implemented/relevant for (coeff_type = %d)",getCoeffType(r));
134  return NULL;
135 }
136 
138 {
139  int c = n_GetChar(r);
140  BOOLEAN ret = n_IsZero(a, r);
141  if( (c != 0) && !ret )
142  {
143  number ch = n_Init( c, r );
144  number g = n_Gcd( ch, a, r );
145  ret = !n_IsOne (g, r);
146  n_Delete(&ch, r);
147  n_Delete(&g, r);
148  }
149  return ret;
150 }
151 
152 static void ndNormalize(number&, const coeffs) { }
153 static number ndReturn0(number, const coeffs r) { return r->cfInit(0,r); }
154 static number ndGcd(number, number, const coeffs r) { return r->cfInit(1,r); }
155 static number ndIntMod(number, number, const coeffs r) { return r->cfInit(0,r); }
156 static number ndGetDenom(number &, const coeffs r) { return r->cfInit(1,r); }
157 static number ndGetNumerator(number &a,const coeffs r) { return r->cfCopy(a,r); }
158 static int ndSize(number a, const coeffs r) { return (int)r->cfIsZero(a,r)==FALSE; }
159 
160 static void ndClearContent(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs r)
161 {
162  assume(r != NULL);
163 
164  // no fractions
165  assume(!( nCoeff_is_Q(r) ));
166  // all coeffs are given by integers!!!
167 
168  numberCollectionEnumerator.Reset();
169 
170  if( !numberCollectionEnumerator.MoveNext() ) // empty zero polynomial?
171  {
172  c = n_Init(1, r);
173  return;
174  }
175 
176  number &curr = numberCollectionEnumerator.Current();
177 
178 #ifdef HAVE_RINGS
179  /// TODO: move to a separate implementation
180  if (nCoeff_is_Ring(r))
181  {
182  if (nCoeff_has_Units(r))
183  {
184  c = n_GetUnit(curr, r);
185 
186  if (!n_IsOne(c, r))
187  {
188  number inv = n_Invers(c, r);
189 
190  n_InpMult(curr, inv, r);
191 
192  while( numberCollectionEnumerator.MoveNext() )
193  {
194  number &n = numberCollectionEnumerator.Current();
195  n_Normalize(n, r); // ?
196  n_InpMult(n, inv, r); // TODO: either this or directly divide!!!?
197  }
198 
199  n_Delete(&inv, r);
200  }
201  } else c = n_Init(1, r);
202 
203  return;
204  }
205 #endif
206 
207  assume(!nCoeff_is_Ring(r));
209 
210  n_Normalize(curr, r); // Q: good/bad/ugly??
211 
212  if (!n_IsOne(curr, r))
213  {
214  number t = curr; // takes over the curr! note: not a reference!!!
215 
216  curr = n_Init(1, r); // ???
217 
218  number inv = n_Invers(t, r);
219 
220  while( numberCollectionEnumerator.MoveNext() )
221  {
222  number &n = numberCollectionEnumerator.Current();
223  n_InpMult(n, inv, r); // TODO: either this or directly divide!!!?
224 // n_Normalize(n, r); // ?
225  }
226 
227  n_Delete(&inv, r);
228 
229  c = t;
230  } else
231  c = n_Copy(curr, r); // c == 1 and nothing else to do...
232 }
233 
234 static void ndClearDenominators(ICoeffsEnumerator& /*numberCollectionEnumerator*/, number& d, const coeffs r)
235 {
236  assume( r != NULL );
239 
240  d = n_Init(1, r);
241 }
242 
243 static number ndCopy(number a, const coeffs) { return a; }
244 number ndCopyMap(number a, const coeffs aRing, const coeffs r)
245 {
246  // aRing and r need not be the same, but must be the same representation
247  assume(aRing->rep==r->rep);
249  return a;
250  else
251  return r->cfCopy(a, r);
252 }
253 
254 static void ndKillChar(coeffs) {}
255 static void ndSetChar(const coeffs) {}
256 
257 number nd_Copy(number a, const coeffs r) { return r->cfCopy(a, r); }
258 
259 #ifdef HAVE_RINGS
260 static BOOLEAN ndDivBy(number, number, const coeffs) { return TRUE; } // assume a,b !=0
261 static int ndDivComp(number, number, const coeffs) { return 2; }
262 static number ndExtGcd (number, number, number *, number *, const coeffs r) { return r->cfInit(1,r); }
263 #endif
264 
265 static CanonicalForm ndConvSingNFactoryN( number, BOOLEAN /*setChar*/, const coeffs)
266 {
267  CanonicalForm term(0);
268  WerrorS("no conversion to factory");
269  return term;
270 }
271 
272 static number ndConvFactoryNSingN( const CanonicalForm, const coeffs)
273 {
274  WerrorS("no conversion from factory");
275  return NULL;
276 }
277 
278 /**< [in, out] a bigint number >= 0 */
279 /**< [out] the GMP equivalent */
280 /// Converts a non-negative bigint number into a GMP number.
281 static void ndMPZ(mpz_t result, number &n, const coeffs r)
282 {
283  mpz_init_set_si( result, r->cfInt(n, r) );
284 }
286 static number ndInitMPZ(mpz_t m, const coeffs r)
287 {
288  return r->cfInit( mpz_get_si(m), r);
289 }
290 
292 static BOOLEAN ndCoeffIsEqual(const coeffs r, n_coeffType n, void *)
293 {
294  /* test, if r is an instance of nInitCoeffs(n,parameter) */
295  /* if parameter is not needed */
296  return (n==r->type);
297 }
299 static number ndQuotRem (number a, number b, number * r, const coeffs R)
300 {
301  // implementation for a field: r: 0, result: n_Div
302  assume(R->is_field);
303  *r=n_Init(0,R);
304  return n_Div(a,b,R);
305 }
308 { NULL, /*n_unknown */
309  npInitChar, /* n_Zp */
310  nlInitChar, /* n_Q */
311  nrInitChar, /* n_R */
312  nfInitChar, /* n_GF */
313  ngfInitChar, /* n_long_R */
314  #ifdef HAVE_POLYEXTENSIONS
315  n2pInitChar, /* n_polyExt */
316  naInitChar, /* n_algExt */
317  ntInitChar, /* n_transExt */
318  #else
319  NULL, /* n_polyExt */
320  NULL, /* n_algExt */
321  NULL, /* n_transExt */
322  #endif
323  ngcInitChar, /* n_long_C */
324  #ifdef HAVE_RINGS
325  nrzInitChar, /* n_Z */
326  nrnInitChar, /* n_Zn */
327  nrnInitChar, /* n_Znm */
328  nr2mInitChar, /* n_Z2m */
329  #else
330  NULL, /* n_Z */
331  NULL, /* n_Zn */
332  NULL, /* n_Znm */
333  NULL, /* n_Z2m */
334  #endif
335  NULL /* n_CF */
336 };
339 /*2
340 * init operations for coeffs r
341 */
342 coeffs nInitChar(n_coeffType t, void * parameter)
343 {
344  n_Procs_s *n=cf_root;
345 
346  while((n!=NULL) && (n->nCoeffIsEqual!=NULL) && (!n->nCoeffIsEqual(n,t,parameter)))
347  n=n->next;
348 
349  if (n==NULL)
350  {
351  n=(n_Procs_s*)omAlloc0(sizeof(n_Procs_s));
352  n->next=cf_root;
353  n->ref=1;
354  n->type=t;
355 
356  // default entries (different from NULL) for some routines:
358  n->cfSize = ndSize;
361  n->cfImPart=ndReturn0;
362  n->cfDelete= ndDelete;
363  n->cfAnn = ndAnn;
364  n->cfCoeffString = ndCoeffString; // should alway be changed!
365  n->cfCoeffName = ndCoeffName; // should alway be changed!
366  n->cfInpMult=ndInpMult;
367  n->cfInpAdd=ndInpAdd;
368  n->cfCopy = ndCopy;
369  n->cfIntMod=ndIntMod; /* dummy !! */
371  n->cfGcd = ndGcd;
372  n->cfNormalizeHelper = ndGcd; /* tricky, isn't it ?*/
373  n->cfLcm = ndGcd; /* tricky, isn't it ?*/
374  n->cfInitMPZ = ndInitMPZ;
375  n->cfMPZ = ndMPZ;
376  n->cfPower = ndPower;
377  n->cfQuotRem = ndQuotRem;
378 
379  n->cfKillChar = ndKillChar; /* dummy */
380  n->cfSetChar = ndSetChar; /* dummy */
381  // temp. removed to catch all the coeffs which miss to implement this!
382 
384  n->cfFarey = ndFarey;
385  n->cfParDeg = ndParDeg;
386 
388 
391 
392  n->cfIsUnit = ndIsUnit;
393 #ifdef HAVE_RINGS
394  n->cfDivComp = ndDivComp;
395  n->cfDivBy = ndDivBy;
396  n->cfExtGcd = ndExtGcd;
397  //n->cfGetUnit = (nMapFunc)NULL;
398 #endif
399 
400 #ifdef LDEBUG
401  n->cfDBTest=ndDBTest;
402 #endif
403 
406 
407  BOOLEAN nOK=TRUE;
408  // init
409  if ((t<=nLastCoeffs) && (nInitCharTable[t]!=NULL))
410  nOK = (nInitCharTable[t])(n,parameter);
411  else
412  Werror("Sorry: the coeff type [%d] was not registered: it is missing in nInitCharTable", (int)t);
413  if (nOK)
414  {
415  omFreeSize(n,sizeof(*n));
416  return NULL;
417  }
418  cf_root=n;
419  // post init settings:
420  if (n->cfRePart==NULL) n->cfRePart=n->cfCopy;
421  if (n->cfExactDiv==NULL) n->cfExactDiv=n->cfDiv;
422  if (n->cfSubringGcd==NULL) n->cfSubringGcd=n->cfGcd;
423 
424 #ifdef HAVE_RINGS
425  if (n->cfGetUnit==NULL) n->cfGetUnit=n->cfCopy;
426 #endif
427 
428  if(n->cfWriteShort==NULL)
429  n->cfWriteShort = n->cfWriteLong;
430 
432  assume(n->cfSetChar!=NULL);
435  assume(n->cfMult!=NULL);
436  assume(n->cfSub!=NULL);
437  assume(n->cfAdd!=NULL);
438  assume(n->cfDiv!=NULL);
439  assume(n->cfIntMod!=NULL);
440  assume(n->cfExactDiv!=NULL);
441  assume(n->cfInit!=NULL);
442  assume(n->cfInitMPZ!=NULL);
443  assume(n->cfSize!=NULL);
444  assume(n->cfInt!=NULL);
445  assume(n->cfMPZ!=NULL);
446  //assume(n->n->cfDivComp!=NULL);
447  //assume(n->cfIsUnit!=NULL);
448  //assume(n->cfGetUnit!=NULL);
449  //assume(n->cfExtGcd!=NULL);
450  assume(n->cfInpNeg!=NULL);
451  assume(n->cfCopy!=NULL);
452 
453  assume(n->cfWriteLong!=NULL);
454  assume(n->cfWriteShort!=NULL);
455 
456  assume(n->iNumberOfParameters>= 0);
457 
458  assume( (n->iNumberOfParameters == 0 && n->pParameterNames == NULL) ||
459  (n->iNumberOfParameters > 0 && n->pParameterNames != NULL) );
460 
461  assume(n->cfParameter!=NULL);
462  assume(n->cfParDeg!=NULL);
463 
464  assume(n->cfRead!=NULL);
465  assume(n->cfNormalize!=NULL);
466  assume(n->cfGreater!=NULL);
467  //assume(n->cfDivBy!=NULL);
468  assume(n->cfEqual!=NULL);
469  assume(n->cfIsZero!=NULL);
470  assume(n->cfIsOne!=NULL);
471  assume(n->cfIsMOne!=NULL);
473  assume(n->cfGetDenom!=NULL);
475  assume(n->cfGcd!=NULL);
477  assume(n->cfDelete!=NULL);
478  assume(n->cfSetMap!=NULL);
479  assume(n->cfInpMult!=NULL);
480 // assume(n->cfInit_bigint!=NULL);
481  assume(n->cfCoeffWrite != NULL);
482 
483  assume(n->cfClearContent != NULL);
485 
486  assume(n->type==t);
487 
488 #ifndef SING_NDEBUG
489  if(n->cfKillChar==NULL) Warn("cfKillChar is NULL for coeff %d",t);
490  if(n->cfWriteLong==NULL) Warn("cfWrite is NULL for coeff %d",t);
491  if(n->cfWriteShort==NULL) Warn("cfWriteShort is NULL for coeff %d",t);
492  if(n->cfCoeffString==ndCoeffString) Warn("cfCoeffString is undefined for coeff %d",t);
493 #endif
494 
495  if( n->nNULL == NULL )
496  n->nNULL = n->cfInit(0, n); // may still remain NULL
497  }
498  else
499  {
500  n->ref++;
501  }
502  return n;
503 }
505 void nKillChar(coeffs r)
506 {
508  if (r!=NULL)
509  {
510  r->ref--;
511  if (r->ref<=0)
512  {
513  n_Procs_s tmp;
514  n_Procs_s* n=&tmp;
515  tmp.next=cf_root;
516  while((n->next!=NULL) && (n->next!=r)) n=n->next;
517  if (n->next==r)
518  {
519  n->next=n->next->next;
520  if (cf_root==r) cf_root=n->next;
521  n_Delete(&(r->nNULL),r);
522  assume (r->cfKillChar!=NULL); r->cfKillChar(r); // STATISTIC(nKillChar);
523  omFreeSize((void *)r, sizeof(n_Procs_s));
524  r=NULL;
525  }
526  else
527  {
528  WarnS("cf_root list destroyed");
529  }
530  }
531  }
532 }
535 {
536  if (n==n_unknown)
537  {
540  {
542  ((int)nLastCoeffs+1)*sizeof(cfInitCharProc));
544  ((int)nLastCoeffs)*sizeof(cfInitCharProc));
545  }
546  else
547  {
549  ((int)nLastCoeffs)*sizeof(cfInitCharProc),
550  (((int)nLastCoeffs)+1)*sizeof(cfInitCharProc));
551  }
552 
554  return nLastCoeffs;
555  }
556  else
557  {
558  if (nInitCharTable[n]!=NULL) Print("coeff %d already initialized\n",n);
559  nInitCharTable[n]=p;
560  return n;
561  }
562 }
564 coeffs nFindCoeffByName(const char *cf_name)
565 {
566  n_Procs_s* n=cf_root;
567  while(n!=NULL)
568  {
569  if ((n->cfCoeffName!=NULL)
570  && (strcmp(cf_name,n->cfCoeffName(n))==0)) return n;
571  n=n->next;
572  }
573  // TODO: parametrized cf, e.g. flint:Z/26[a]
574  return NULL;
575 }
577 void n_Print(number& a, const coeffs r)
578 {
579  assume(r != NULL);
580  n_Test(a,r);
581 
582  StringSetS("");
583  n_Write(a, r);
584  { char* s = StringEndS(); Print("%s", s); omFree(s); }
585 }
586 
588 number n_convFactoryNSingN( const CanonicalForm n, const coeffs r)
589 { STATISTIC(n_convFactoryNSingN); assume(r != NULL); assume(r->convFactoryNSingN != NULL); return r->convFactoryNSingN(n, r); }
590 
591 
593 CanonicalForm n_convSingNFactoryN( number n, BOOLEAN setChar, const coeffs r )
594 { STATISTIC(n_convSingNFactoryN); assume(r != NULL); assume(r->convSingNFactoryN != NULL); return r->convSingNFactoryN(n, setChar, r); }
number nd_Copy(number a, const coeffs r)
Definition: numbers.cc:257
static BOOLEAN ndIsUnit(number a, const coeffs r)
Definition: numbers.cc:109
void n_Print(number &a, const coeffs r)
print a number (BEWARE of string buffers!) mostly for debugging
Definition: numbers.cc:576
BOOLEAN(* cfDivBy)(number a, number b, const coeffs r)
Definition: coeffs.h:385
#define STATISTIC(f)
Definition: numstats.h:16
BOOLEAN nrInitChar(coeffs n, void *p)
Initialize r.
Definition: shortfl.cc:730
static FORCE_INLINE number n_GetUnit(number n, const coeffs r)
in Z: 1 in Z/kZ (where k is not a prime): largest divisor of n (taken in Z) that is co-prime with k i...
Definition: coeffs.h:536
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of &#39;a&#39; and &#39;b&#39; in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
Definition: coeffs.h:690
const CanonicalForm int s
Definition: facAbsFact.cc:55
number(* cfCopy)(number a, const coeffs r)
return a copy of a
Definition: coeffs.h:199
static FORCE_INLINE BOOLEAN nCoeff_is_numeric(const coeffs r)
Definition: coeffs.h:849
const poly a
Definition: syzextra.cc:212
number(* cfExtGcd)(number a, number b, number *s, number *t, const coeffs r)
Definition: coeffs.h:248
#define Print
Definition: emacs.cc:83
numberfunc cfIntMod
Definition: coeffs.h:175
int(* cfDivComp)(number a, number b, const coeffs r)
Definition: coeffs.h:381
coeffs nFindCoeffByName(const char *cf_name)
find an existing coeff by its "CoeffName"
Definition: numbers.cc:563
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:834
static void ndPower(number a, int i, number *res, const coeffs r)
Definition: numbers.cc:78
static number ndParameter(const int, const coeffs r)
Definition: numbers.cc:131
number nNULL
the 0 as constant, NULL by default
Definition: coeffs.h:320
static void ndKillChar(coeffs)
Definition: numbers.cc:254
?
Definition: coeffs.h:47
static FORCE_INLINE BOOLEAN nCoeff_is_Zp_a(const coeffs r)
Definition: coeffs.h:876
static number ndQuotRem(number a, number b, number *r, const coeffs R)
Definition: numbers.cc:298
static BOOLEAN ndDBTest(number, const char *, const int, const coeffs)
Definition: numbers.cc:112
BOOLEAN(* cfDBTest)(number a, const char *f, const int l, const coeffs r)
Test: is "a" a correct number?
Definition: coeffs.h:419
void(* cfMPZ)(mpz_t result, number &n, const coeffs r)
Converts a non-negative number n into a GMP number, 0 if impossible.
Definition: coeffs.h:190
void(* cfSetChar)(const coeffs r)
Definition: coeffs.h:161
Definition: int_poly.h:33
BOOLEAN naInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.
Definition: algext.cc:1406
static BOOLEAN ndDivBy(number, number, const coeffs)
Definition: numbers.cc:260
#define FALSE
Definition: auxiliary.h:94
number(* cfQuotRem)(number a, number b, number *rem, const coeffs r)
Definition: coeffs.h:269
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of &#39;a&#39; and &#39;b&#39;; replacement of &#39;a&#39; by the product a*b
Definition: coeffs.h:645
return P p
Definition: myNF.cc:203
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:472
char const ** pParameterNames
array containing the names of Parameters (default NULL)
Definition: coeffs.h:326
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:244
coeffs next
Definition: coeffs.h:125
static number ndCopy(number a, const coeffs)
Definition: numbers.cc:243
static n_coeffType nLastCoeffs
Definition: numbers.cc:305
static number ndChineseRemainder(number *, number *, int, BOOLEAN, CFArray &, const coeffs r)
Definition: numbers.cc:120
void(* cfDelete)(number *a, const coeffs r)
Definition: coeffs.h:272
static void ndNormalize(number &, const coeffs)
Definition: numbers.cc:152
BOOLEAN(*)(*)(*)(*) cfIsOne(number a, const coeffs r)
Definition: coeffs.h:229
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
number(* cfSubringGcd)(number a, number b, const coeffs r)
Definition: coeffs.h:247
BOOLEAN n_IsZeroDivisor(number a, const coeffs r)
Test whether a is a zero divisor in r i.e. not coprime with char. of r very inefficient implementatio...
Definition: numbers.cc:137
static number ndConvFactoryNSingN(const CanonicalForm, const coeffs)
[in, out] a bigint number >= 0
Definition: numbers.cc:272
number n_convFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: numbers.cc:587
numberfunc cfAdd
Definition: coeffs.h:175
BOOLEAN(* cfGreater)(number a, number b, const coeffs r)
Definition: coeffs.h:225
void(* cfNormalize)(number &a, const coeffs r)
Definition: coeffs.h:223
static char * ndCoeffString(const coeffs r)
Definition: numbers.cc:54
number(* cfRePart)(number a, const coeffs r)
Definition: coeffs.h:200
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:448
factory&#39;s main class
Definition: canonicalform.h:75
#define TRUE
Definition: auxiliary.h:98
static void ndDelete(number *d, const coeffs)
Definition: numbers.cc:52
static int ndDivComp(number, number, const coeffs)
Definition: numbers.cc:261
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:582
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:341
void(* cfCoeffWrite)(const coeffs r, BOOLEAN details)
output of coeff description via Print
Definition: coeffs.h:148
g
Definition: cfModGcd.cc:4031
void WerrorS(const char *s)
Definition: feFopen.cc:24
BOOLEAN nr2mInitChar(coeffs r, void *p)
Definition: rmodulo2m.cc:767
char * StringEndS()
Definition: reporter.cc:151
static char * ndCoeffName(const coeffs r)
Definition: numbers.cc:59
BOOLEAN(* cfIsUnit)(number a, const coeffs r)
Definition: coeffs.h:382
number(* cfGetUnit)(number a, const coeffs r)
Definition: coeffs.h:383
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:840
number(* cfFarey)(number p, number n, const coeffs)
rational reconstruction: "best" rational a/b with a/b = p mod n
Definition: coeffs.h:291
#define WarnS
Definition: emacs.cc:81
BOOLEAN npInitChar(coeffs r, void *p)
Definition: modulop.cc:475
BOOLEAN nlInitChar(coeffs r, void *p)
Definition: longrat.cc:3324
#define omAlloc(size)
Definition: omAllocDecl.h:210
number(* cfInitMPZ)(mpz_t i, const coeffs r)
init with a GMP integer
Definition: coeffs.h:181
char *(* cfCoeffString)(const coeffs r)
string output of coeff description
Definition: coeffs.h:151
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
Definition: coeffs.h:762
BOOLEAN n2pInitChar(coeffs cf, void *infoStruct)
Definition: algext.cc:1691
BOOLEAN(* nCoeffIsEqual)(const coeffs r, n_coeffType n, void *parameter)
Definition: coeffs.h:145
static number ndReturn0(number, const coeffs r)
Definition: numbers.cc:153
poly res
Definition: myNF.cc:322
static void ndInpMult(number &a, number b, const coeffs r)
Definition: numbers.cc:65
virtual void Reset()=0
Sets the enumerator to its initial position: -1, which is before the first element in the collection...
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:220
number(* cfInit)(long i, const coeffs r)
init with an integer
Definition: coeffs.h:178
number(* cfNormalizeHelper)(number a, number b, const coeffs r)
Definition: coeffs.h:271
BOOLEAN(* cfInitCharProc)(coeffs, void *)
initialize an object of type coeff, return FALSE in case of success
Definition: numbers.h:89
static number ndInitMPZ(mpz_t m, const coeffs r)
Definition: numbers.cc:285
BOOLEAN ngcInitChar(coeffs n, void *parameter)
Initialize r (n_long_C)
Definition: gnumpc.cc:546
const ring r
Definition: syzextra.cc:208
static int ndParDeg(number n, const coeffs r)
Definition: numbers.cc:126
Coefficient rings, fields and other domains suitable for Singular polynomials.
BOOLEAN(*)(*)(*)(*)(*)(*) cfGreaterZero(number a, const coeffs r)
Definition: coeffs.h:237
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:927
long(* cfInt)(number &n, const coeffs r)
convertion to long, 0 if impossible
Definition: coeffs.h:187
void(* cfInpMult)(number &a, number b, const coeffs r)
Inplace: a *= b.
Definition: coeffs.h:281
n_coeffType nRegister(n_coeffType n, cfInitCharProc p)
Definition: numbers.cc:533
numberfunc cfSub
Definition: coeffs.h:175
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:504
static void ndClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs r)
Definition: numbers.cc:160
BOOLEAN nrnInitChar(coeffs r, void *p)
Definition: rmodulon.cc:902
static number ndGetDenom(number &, const coeffs r)
Definition: numbers.cc:156
#define omFree(addr)
Definition: omAllocDecl.h:261
number(* cfImPart)(number a, const coeffs r)
Definition: coeffs.h:201
#define assume(x)
Definition: mod2.h:394
number(* cfInpNeg)(number a, const coeffs r)
changes argument inline: a:= -a return -a! (no copy is returned) the result should be assigned to the...
Definition: coeffs.h:195
The main handler for Singular numbers which are suitable for Singular polynomials.
BOOLEAN nrzInitChar(coeffs r, void *)
Definition: rintegers.cc:571
Templated enumerator interface for simple iteration over a generic collection of T&#39;s.
Definition: Enumerator.h:124
static int ndSize(number a, const coeffs r)
Definition: numbers.cc:158
void StringSetS(const char *st)
Definition: reporter.cc:128
static FORCE_INLINE BOOLEAN nCoeff_has_Units(const coeffs r)
returns TRUE, if r is not a field and r has non-trivial units
Definition: coeffs.h:831
int ref
Definition: coeffs.h:126
void(* cfPower)(number a, int i, number *result, const coeffs r)
Definition: coeffs.h:239
const ring R
Definition: DebugPrint.cc:36
static FORCE_INLINE BOOLEAN nCoeff_has_simple_Alloc(const coeffs r)
TRUE if n_Delete/n_New are empty operations.
Definition: coeffs.h:923
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:595
virtual reference Current()=0
Gets the current element in the collection (read and write).
nCoeffsEnumeratorFunc cfClearContent
function pointer behind n_ClearContent
Definition: coeffs.h:309
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:742
All the auxiliary stuff.
n_Procs_s * cf_root
Definition: numbers.cc:47
void nNew(number *d)
Definition: numbers.cc:49
static FORCE_INLINE number n_Invers(number a, const coeffs r)
return the multiplicative inverse of &#39;a&#39;; raise an error if &#39;a&#39; is not invertible ...
Definition: coeffs.h:568
int m
Definition: cfEzgcd.cc:119
numberfunc cfExactDiv
Definition: coeffs.h:175
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:935
int i
Definition: cfEzgcd.cc:123
static BOOLEAN ndCoeffIsEqual(const coeffs r, n_coeffType n, void *)
Definition: numbers.cc:291
n_coeffType type
Definition: coeffs.h:128
static CanonicalForm ndConvSingNFactoryN(number, BOOLEAN, const coeffs)
Definition: numbers.cc:265
numberfunc cfDiv
Definition: coeffs.h:175
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition: coeffs.h:856
const char *(* cfRead)(const char *s, number *a, const coeffs r)
Definition: coeffs.h:221
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
numberfunc cfMult
Definition: coeffs.h:175
BOOLEAN nfInitChar(coeffs r, void *parameter)
Definition: ffields.cc:815
cfInitCharProc nInitCharTableDefault[]
Definition: numbers.cc:306
static number ndGcd(number, number, const coeffs r)
Definition: numbers.cc:154
n_coeffType
Definition: coeffs.h:27
static number ndExtGcd(number, number, number *, number *, const coeffs r)
Definition: numbers.cc:262
static cfInitCharProc * nInitCharTable
Definition: numbers.cc:337
#define NULL
Definition: omList.c:10
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:455
void(* cfWriteLong)(number a, const coeffs r)
print a given number (long format)
Definition: coeffs.h:204
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of &#39;a&#39; and &#39;b&#39;, i.e., a/b; raises an error if &#39;b&#39; is not invertible in r exceptio...
Definition: coeffs.h:619
BOOLEAN ngfInitChar(coeffs n, void *parameter)
Initialize r.
Definition: gnumpfl.cc:509
virtual bool MoveNext()=0
Advances the enumerator to the next element of the collection. returns true if the enumerator was suc...
number(* cfGcd)(number a, number b, const coeffs r)
Definition: coeffs.h:246
static void ndSetChar(const coeffs)
Definition: numbers.cc:255
static FORCE_INLINE BOOLEAN nCoeff_is_Q_algext(const coeffs r)
is it an alg. ext. of Q?
Definition: coeffs.h:931
number(* cfLcm)(number a, number b, const coeffs r)
Definition: coeffs.h:270
static void ndInpAdd(number &a, number b, const coeffs r)
Definition: numbers.cc:71
number(* convFactoryNSingN)(const CanonicalForm n, const coeffs r)
conversion to CanonicalForm(factory) to number
Definition: coeffs.h:315
number(* cfChineseRemainder)(number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs)
chinese remainder returns X with X mod q[i]=x[i], i=0..rl-1
Definition: coeffs.h:297
static number ndGetNumerator(number &a, const coeffs r)
Definition: numbers.cc:157
static number ndAnn(number, const coeffs)
Definition: numbers.cc:53
static number ndIntMod(number, number, const coeffs r)
Definition: numbers.cc:155
CanonicalForm n_convSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition: numbers.cc:592
static number ndFarey(number, number, const coeffs r)
Definition: numbers.cc:115
static void ndClearDenominators(ICoeffsEnumerator &, number &d, const coeffs r)
Definition: numbers.cc:234
nMapFunc(* cfSetMap)(const coeffs src, const coeffs dst)
Definition: coeffs.h:275
char *(* cfCoeffName)(const coeffs r)
default name of cf, should substitue cfCoeffWrite, cfCoeffString
Definition: coeffs.h:154
int(* cfSize)(number n, const coeffs r)
how complicated, (0) => 0, or positive
Definition: coeffs.h:184
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
number(* cfAnn)(number a, const coeffs r)
Definition: coeffs.h:261
number(* cfParameter)(const int i, const coeffs r)
create i^th parameter or NULL if not possible
Definition: coeffs.h:303
BOOLEAN(*)(*)(*)(*)(*) cfIsMOne(number a, const coeffs r)
Definition: coeffs.h:232
CanonicalForm(* convSingNFactoryN)(number n, BOOLEAN setChar, const coeffs r)
Definition: coeffs.h:316
void(* cfKillChar)(coeffs r)
Definition: coeffs.h:159
int BOOLEAN
Definition: auxiliary.h:85
const poly b
Definition: syzextra.cc:213
static void ndMPZ(mpz_t result, number &n, const coeffs r)
Converts a non-negative bigint number into a GMP number.
Definition: numbers.cc:280
void Werror(const char *fmt,...)
Definition: reporter.cc:189
void(* cfInpAdd)(number &a, number b, const coeffs r)
Inplace: a += b.
Definition: coeffs.h:284
number(* cfGetNumerator)(number &n, const coeffs r)
Definition: coeffs.h:241
void(* cfWriteShort)(number a, const coeffs r)
print a given number in a shorter way, if possible e.g. in K(a): a2 instead of a^2 ...
Definition: coeffs.h:208
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int iNumberOfParameters
Number of Parameters in the coeffs (default 0)
Definition: coeffs.h:323
return result
Definition: facAbsBiFact.cc:76
number(* cfGetDenom)(number &n, const coeffs r)
Definition: coeffs.h:240
BOOLEAN(*)(*)(*) cfIsZero(number a, const coeffs r)
Definition: coeffs.h:228
BOOLEAN(*)(*) cfEqual(number a, number b, const coeffs r)
tests
Definition: coeffs.h:227
BOOLEAN ntInitChar(coeffs cf, void *infoStruct)
Initialize the coeffs object.
Definition: transext.cc:2498
nCoeffsEnumeratorFunc cfClearDenominators
function pointer behind n_ClearDenominators
Definition: coeffs.h:312
#define Warn
Definition: emacs.cc:80
int(* cfParDeg)(number x, const coeffs r)
degree for coeffcients: -1 for 0, 0 for "constants", ...
Definition: coeffs.h:300