coeffs.h
Go to the documentation of this file.
1 /*! \file coeffs/coeffs.h Coefficient rings, fields and other domains suitable for Singular polynomials
2 
3  The main interface for Singular coefficients: \ref coeffs is the main handler for Singular numbers
4 */
5 /****************************************
6 * Computer Algebra System SINGULAR *
7 ****************************************/
8 
9 #ifndef COEFFS_H
10 #define COEFFS_H
11 
12 # include <misc/auxiliary.h>
13 #include <omalloc/omalloc.h>
14 
15 #include <misc/sirandom.h>
16 /* for assume: */
17 #include <reporter/reporter.h>
18 #include <reporter/s_buff.h>
19 #include <factory/factory.h>
20 
21 #include <coeffs/si_gmp.h>
22 #include <coeffs/Enumerator.h>
23 #include <coeffs/numstats.h> // for STATISTIC(F) counting macro
24 
25 class CanonicalForm;
26 
28 {
30  n_Zp, /**< \F{p < 2^31} */
31  n_Q, /**< rational (GMP) numbers */
32  n_R, /**< single prescision (6,6) real numbers */
33  n_GF, /**< \GF{p^n < 2^16} */
34  n_long_R, /**< real floating point (GMP) numbers */
35  n_polyExt, /**< used to represent polys as coeffcients */
36  n_algExt, /**< used for all algebraic extensions, i.e.,
37  the top-most extension in an extension tower
38  is algebraic */
39  n_transExt, /**< used for all transcendental extensions, i.e.,
40  the top-most extension in an extension tower
41  is transcendental */
42  n_long_C, /**< complex floating point (GMP) numbers */
43  n_Z, /**< only used if HAVE_RINGS is defined */
44  n_Zn, /**< only used if HAVE_RINGS is defined */
45  n_Znm, /**< only used if HAVE_RINGS is defined */
46  n_Z2m, /**< only used if HAVE_RINGS is defined */
47  n_CF /**< ? */
48 };
49 
50 extern const unsigned short fftable[];
51 
52 struct snumber;
53 typedef struct snumber * number;
54 
55 /* standard types */
56 struct ip_sring;
57 typedef struct ip_sring * ring;
58 typedef struct ip_sring const * const_ring;
59 
60 /// @class coeffs coeffs.h coeffs/coeffs.h
61 ///
62 /// The main handler for Singular numbers which are suitable for Singular polynomials.
63 ///
64 /// With it one may implement a ring, a field, a domain etc.
65 ///
66 struct n_Procs_s;
67 typedef struct n_Procs_s *coeffs;
68 typedef struct n_Procs_s const * const_coeffs;
69 
70 typedef number (*numberfunc)(number a, number b, const coeffs r);
71 
72 /// maps "a", which lives in src, into dst
73 typedef number (*nMapFunc)(number a, const coeffs src, const coeffs dst);
74 
75 
76 /// Abstract interface for an enumerator of number coefficients for an
77 /// object, e.g. a polynomial
79 
80 /// goes over coeffs given by the ICoeffsEnumerator and changes them.
81 /// Additionally returns a number;
82 typedef void (*nCoeffsEnumeratorFunc)(ICoeffsEnumerator& numberCollectionEnumerator, number& output, const coeffs r);
83 
84 extern omBin rnumber_bin;
85 
86 #define FREE_RNUMBER(x) omFreeBin((void *)x, rnumber_bin)
87 #define ALLOC_RNUMBER() (number)omAllocBin(rnumber_bin)
88 #define ALLOC0_RNUMBER() (number)omAlloc0Bin(rnumber_bin)
89 
90 
91 /// Creation data needed for finite fields
92 typedef struct
93 {
94  int GFChar;
95  int GFDegree;
96  const char* GFPar_name;
97 } GFInfo;
98 
99 typedef struct
100 {
101  short float_len; /**< additional char-flags, rInit */
102  short float_len2; /**< additional char-flags, rInit */
103  const char* par_name; /**< parameter name */
105 
106 
108 {
110  n_rep_int, /**< (int), see modulop.h */
111  n_rep_gap_rat, /**< (number), see longrat.h */
112  n_rep_gap_gmp, /**< (), see rinteger.h, new impl. */
113  n_rep_poly, /**< (poly), see algext.h */
114  n_rep_rat_fct, /**< (fraction), see transext.h */
115  n_rep_gmp, /**< (mpz_ptr), see rmodulon,h */
116  n_rep_float, /**< (float), see shortfl.h */
117  n_rep_gmp_float, /**< (gmp_float), see */
118  n_rep_gmp_complex,/**< (gmp_complex), see gnumpc.h */
119  n_rep_gf /**< (int), see ffields.h */
120 };
121 
122 struct n_Procs_s
123 {
124  // administration of coeffs:
125  coeffs next;
126  int ref;
129  /// how many variables of factory are already used by this coeff
131 
132  // general properties:
133  /// TRUE, if nNew/nDelete/nCopy are dummies
135  /// TRUE, if std should make polynomials monic (if nInvers is cheap)
136  /// if false, then a gcd routine is used for a content computation
138 
139  /// TRUE, if cf is a field
141  /// TRUE, if cf is a domain
143 
144  // tests for numbers.cc:
145  BOOLEAN (*nCoeffIsEqual)(const coeffs r, n_coeffType n, void * parameter);
146 
147  /// output of coeff description via Print
148  void (*cfCoeffWrite)(const coeffs r, BOOLEAN details);
149 
150  /// string output of coeff description
151  char* (*cfCoeffString)(const coeffs r);
152 
153  /// default name of cf, should substitue cfCoeffWrite, cfCoeffString
154  char* (*cfCoeffName)(const coeffs r);
155 
156  // ?
157  // initialisation:
158  //void (*cfInitChar)(coeffs r, int parameter); // do one-time initialisations
159  void (*cfKillChar)(coeffs r); // undo all initialisations
160  // or NULL
161  void (*cfSetChar)(const coeffs r); // initialisations after each ring change
162  // or NULL
163  // general stuff
164  // if the ring has a meaningful Euclidean structure, hopefully
165  // supported by cfQuotRem, then
166  // IntMod, Div should give the same result
167  // Div(a,b) = QuotRem(a,b, &IntMod(a,b))
168  // if the ring is not Euclidean or a field, then IntMod should return 0
169  // and Div the exact quotient. It is assumed that the function is
170  // ONLY called on Euclidean rings or in the case of an exact division.
171  //
172  // cfDiv does an exact division, but has to handle illegal input
173  // cfExactDiv does an exact division, but no error checking
174  // (I'm not sure I understant and even less that this makes sense)
176 
177  /// init with an integer
178  number (*cfInit)(long i,const coeffs r);
179 
180  /// init with a GMP integer
181  number (*cfInitMPZ)(mpz_t i, const coeffs r);
182 
183  /// how complicated, (0) => 0, or positive
184  int (*cfSize)(number n, const coeffs r);
185 
186  /// convertion to long, 0 if impossible
187  long (*cfInt)(number &n, const coeffs r);
188 
189  /// Converts a non-negative number n into a GMP number, 0 if impossible
190  void (*cfMPZ)(mpz_t result, number &n, const coeffs r);
191 
192  /// changes argument inline: a:= -a
193  /// return -a! (no copy is returned)
194  /// the result should be assigned to the original argument: e.g. a = n_InpNeg(a,r)
195  number (*cfInpNeg)(number a, const coeffs r);
196  /// return 1/a
197  number (*cfInvers)(number a, const coeffs r);
198  /// return a copy of a
199  number (*cfCopy)(number a, const coeffs r);
200  number (*cfRePart)(number a, const coeffs r);
201  number (*cfImPart)(number a, const coeffs r);
202 
203  /// print a given number (long format)
204  void (*cfWriteLong)(number a, const coeffs r);
205 
206  /// print a given number in a shorter way, if possible
207  /// e.g. in K(a): a2 instead of a^2
208  void (*cfWriteShort)(number a, const coeffs r);
209 
210  // it is legal, but not always useful to have cfRead(s, a, r)
211  // just return s again.
212  // Useful application (read constants which are not an projection
213  // from int/bigint:
214  // Let ring r = R,x,dp;
215  // where R is a coeffs having "special" "named" elements (ie.
216  // the primitive element in some algebraic extension).
217  // If there is no interpreter variable of the same name, it is
218  // difficult to create non-trivial elements in R.
219  // Hence one can use the string to allow creation of R-elts using the
220  // unbound name of the special element.
221  const char * (*cfRead)(const char * s, number * a, const coeffs r);
222 
223  void (*cfNormalize)(number &a, const coeffs r);
224 
225  BOOLEAN (*cfGreater)(number a,number b, const coeffs r),
226  /// tests
227  (*cfEqual)(number a,number b, const coeffs r),
228  (*cfIsZero)(number a, const coeffs r),
229  (*cfIsOne)(number a, const coeffs r),
230  // IsMOne is used for printing os polynomials:
231  // -1 is only printed for constant monomials
232  (*cfIsMOne)(number a, const coeffs r),
233  //GreaterZero is used for printing of polynomials:
234  // a "+" is only printed in front of a coefficient
235  // if the element is >0. It is assumed that any element
236  // failing this will start printing with a leading "-"
237  (*cfGreaterZero)(number a, const coeffs r);
238 
239  void (*cfPower)(number a, int i, number * result, const coeffs r);
240  number (*cfGetDenom)(number &n, const coeffs r);
241  number (*cfGetNumerator)(number &n, const coeffs r);
242  //CF: a Euclidean ring is a commutative, unitary ring with an Euclidean
243  // function f s.th. for all a,b in R, b ne 0, we can find q, r s.th.
244  // a = qb+r and either r=0 or f(r) < f(b)
245  // Note that neither q nor r nor f(r) are unique.
246  number (*cfGcd)(number a, number b, const coeffs r);
247  number (*cfSubringGcd)(number a, number b, const coeffs r);
248  number (*cfExtGcd)(number a, number b, number *s, number *t,const coeffs r);
249  //given a and b in a Euclidean setting, return s,t,u,v sth.
250  // sa + tb = gcd
251  // ua + vb = 0
252  // sv + tu = 1
253  // ie. the 2x2 matrix (s t | u v) is unimodular and maps (a,b) to (g, 0)
254  //CF: note, in general, this cannot be derived from ExtGcd due to
255  // zero divisors
256  number (*cfXExtGcd)(number a, number b, number *s, number *t, number *u, number *v, const coeffs r);
257  //in a Euclidean ring, return the Euclidean norm as a bigint (of type number)
258  number (*cfEucNorm)(number a, const coeffs r);
259  //in a principal ideal ring (with zero divisors): the annihilator
260  // NULL otherwise
261  number (*cfAnn)(number a, const coeffs r);
262  //find a "canonical representative of a modulo the units of r
263  //return NULL if a is already normalized
264  //otherwise, the factor.
265  //(for Z: make positive, for z/nZ make the gcd with n
266  //aparently it is GetUnit!
267  //in a Euclidean ring, return the quotient and compute the remainder
268  //rem can be NULL
269  number (*cfQuotRem)(number a, number b, number *rem, const coeffs r);
270  number (*cfLcm)(number a, number b, const coeffs r);
271  number (*cfNormalizeHelper)(number a, number b, const coeffs r);
272  void (*cfDelete)(number * a, const coeffs r);
273 
274  //CF: tries to find a canonical map from src -> dst
275  nMapFunc (*cfSetMap)(const coeffs src, const coeffs dst);
276 
277  void (*cfWriteFd)(number a, FILE *f, const coeffs r);
278  number (*cfReadFd)( s_buff f, const coeffs r);
279 
280  /// Inplace: a *= b
281  void (*cfInpMult)(number &a, number b, const coeffs r);
282 
283  /// Inplace: a += b
284  void (*cfInpAdd)(number &a, number b, const coeffs r);
285 
286  /// rational reconstruction: "best" rational a/b with a/b = p mod n
287  // or a = bp mod n
288  // CF: no idea what this would be in general
289  // it seems to be extended to operate coefficient wise in extensions.
290  // I presume then n in coeffs_BIGINT while p in coeffs
291  number (*cfFarey)(number p, number n, const coeffs);
292 
293  /// chinese remainder
294  /// returns X with X mod q[i]=x[i], i=0..rl-1
295  //CF: by the looks of it: q[i] in Z (coeffs_BIGINT)
296  // strange things happen in naChineseRemainder for example.
297  number (*cfChineseRemainder)(number *x, number *q,int rl, BOOLEAN sym,CFArray &inv_cache,const coeffs);
298 
299  /// degree for coeffcients: -1 for 0, 0 for "constants", ...
300  int (*cfParDeg)(number x,const coeffs r);
301 
302  /// create i^th parameter or NULL if not possible
303  number (*cfParameter)(const int i, const coeffs r);
304 
305  /// a function returning random elements
306  number (*cfRandom)(siRandProc p, number p1, number p2, const coeffs cf);
307 
308  /// function pointer behind n_ClearContent
310 
311  /// function pointer behind n_ClearDenominators
313 
314  /// conversion to CanonicalForm(factory) to number
315  number (*convFactoryNSingN)( const CanonicalForm n, const coeffs r);
316  CanonicalForm (*convSingNFactoryN)( number n, BOOLEAN setChar, const coeffs r );
317 
318 
319  /// the 0 as constant, NULL by default
320  number nNULL;
321 
322  /// Number of Parameters in the coeffs (default 0)
324 
325  /// array containing the names of Parameters (default NULL)
326  char const ** pParameterNames;
327  // NOTE that it replaces the following:
328 // char* complex_parameter; //< the name of sqrt(-1) in n_long_C , i.e. 'i' or 'j' etc...?
329 // char * m_nfParameter; //< the name of parameter in n_GF
330 
331  /////////////////////////////////////////////
332  // the union stuff
333 
334  //-------------------------------------------
335 
336  /* for extension fields we need to be able to represent polynomials,
337  so here is the polynomial ring: */
338  ring extRing;
339 
340  //number minpoly; //< no longer needed: replaced by
341  // //< extRing->qideal->[0]
342 
343 
344  int ch; /* characteristic, set by the local *InitChar methods;
345  In field extensions or extensions towers, the
346  characteristic can be accessed from any of the
347  intermediate extension fields, i.e., in this case
348  it is redundant along the chain of field extensions;
349  CONTRARY to SINGULAR as it was, we do NO LONGER use
350  negative values for ch;
351  for rings, ch will also be set and is - per def -
352  the smallest number of 1's that sum up to zero;
353  however, in this case ch may not fit in an int,
354  thus ch may contain a faulty value */
355 
356  short float_len; /* additional char-flags, rInit */
357  short float_len2; /* additional char-flags, rInit */
358 
359 // BOOLEAN CanShortOut; //< if the elements can be printed in short format
360 // // this is set to FALSE if a parameter name has >2 chars
361 // BOOLEAN ShortOut; //< if the elements should print in short format
362 
363 // ---------------------------------------------------
364  // for n_GF
365 
366  int m_nfCharQ; ///< the number of elements: q
367  int m_nfM1; ///< representation of -1
368  int m_nfCharP; ///< the characteristic: p
369  int m_nfCharQ1; ///< q-1
370  unsigned short *m_nfPlus1Table;
372 
373 // ---------------------------------------------------
374 // for Zp:
375  unsigned short *npInvTable;
376  unsigned short *npExpTable;
377  unsigned short *npLogTable;
378  // int npPrimeM; // NOTE: npPrimeM is deprecated, please use ch instead!
379  int npPminus1M; ///< characteristic - 1
380 //-------------------------------------------
381  int (*cfDivComp)(number a,number b,const coeffs r);
382  BOOLEAN (*cfIsUnit)(number a,const coeffs r);
383  number (*cfGetUnit)(number a,const coeffs r);
384  //CF: test if b divides a
385  BOOLEAN (*cfDivBy)(number a, number b, const coeffs r);
386  /* The following members are for representing the ring Z/n,
387  where n is not a prime. We distinguish four cases:
388  1.) n has at least two distinct prime factors. Then
389  modBase stores n, modExponent stores 1, modNumber
390  stores n, and mod2mMask is not used;
391  2.) n = p^k for some odd prime p and k > 1. Then
392  modBase stores p, modExponent stores k, modNumber
393  stores n, and mod2mMask is not used;
394  3.) n = 2^k for some k > 1; moreover, 2^k - 1 fits in
395  an unsigned long. Then modBase stores 2, modExponent
396  stores k, modNumber is not used, and mod2mMask stores
397  2^k - 1, i.e., the bit mask '111..1' of length k.
398  4.) n = 2^k for some k > 1; but 2^k - 1 does not fit in
399  an unsigned long. Then modBase stores 2, modExponent
400  stores k, modNumber stores n, and mod2mMask is not
401  used;
402  Cases 1.), 2.), and 4.) are covered by the implementation
403  in the files rmodulon.h and rmodulon.cc, whereas case 3.)
404  is implemented in the files rmodulo2m.h and rmodulo2m.cc. */
405  mpz_ptr modBase;
406  unsigned long modExponent;
407  mpz_ptr modNumber;
408  unsigned long mod2mMask;
409  //returns coeffs with updated ch, modNumber and modExp
410  coeffs (*cfQuot1)(number c, const coeffs r);
411 
412  /*CF: for blackbox rings, contains data needed to define the ring.
413  * contents depends on the actual example.*/
414  void * data;
415 #ifdef LDEBUG
416  // must be last entry:
417  /// Test: is "a" a correct number?
418  // DB as in debug, not data base.
419  BOOLEAN (*cfDBTest)(number a, const char *f, const int l, const coeffs r);
420 #endif
421 };
422 
423 // test properties and type
424 /// Returns the type of coeffs domain
425 static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
426 { assume(r != NULL); return r->type; }
427 
428 /// one-time initialisations for new coeffs
429 /// in case of an error return NULL
430 coeffs nInitChar(n_coeffType t, void * parameter);
431 
432 /// "copy" coeffs, i.e. increment ref
433 static FORCE_INLINE coeffs nCopyCoeff(const coeffs r)
434 { assume(r!=NULL); r->ref++; return r;}
435 
436 /// undo all initialisations
437 void nKillChar(coeffs r);
438 
439 /// initialisations after each ring change
440 static FORCE_INLINE void nSetChar(const coeffs r)
441 { STATISTIC(nSetChar); assume(r!=NULL); assume(r->cfSetChar != NULL); r->cfSetChar(r); }
442 
443 void nNew(number * a);
444 #define n_New(n, r) nNew(n)
445 
446 
447 /// Return the characteristic of the coeff. domain.
448 static FORCE_INLINE int n_GetChar(const coeffs r)
449 { STATISTIC(n_GetChar); assume(r != NULL); return r->ch; }
450 
451 
452 // the access methods (part 2):
453 
454 /// return a copy of 'n'
455 static FORCE_INLINE number n_Copy(number n, const coeffs r)
456 { STATISTIC(n_Copy); assume(r != NULL); assume(r->cfCopy!=NULL); return r->cfCopy(n, r); }
457 
458 /// delete 'p'
459 static FORCE_INLINE void n_Delete(number* p, const coeffs r)
460 { STATISTIC(n_Delete); assume(r != NULL); assume(r->cfDelete!= NULL); r->cfDelete(p, r); }
461 
462 /// TRUE iff 'a' and 'b' represent the same number;
463 /// they may have different representations
464 static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
465 { STATISTIC(n_Equal); assume(r != NULL); assume(r->cfEqual!=NULL); return r->cfEqual(a, b, r); }
466 
467 /// TRUE iff 'n' represents the zero element
468 static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
469 { STATISTIC(n_IsZero); assume(r != NULL); assume(r->cfIsZero!=NULL); return r->cfIsZero(n,r); }
470 
471 /// TRUE iff 'n' represents the one element
472 static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
473 { STATISTIC(n_IsOne); assume(r != NULL); assume(r->cfIsOne!=NULL); return r->cfIsOne(n,r); }
474 
475 /// TRUE iff 'n' represents the additive inverse of the one element, i.e. -1
476 static FORCE_INLINE BOOLEAN n_IsMOne(number n, const coeffs r)
477 { STATISTIC(n_IsMOne); assume(r != NULL); assume(r->cfIsMOne!=NULL); return r->cfIsMOne(n,r); }
478 
479 /// ordered fields: TRUE iff 'n' is positive;
480 /// in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long
481 /// representing n
482 /// in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or
483 /// (Im(n) == 0 and Re(n) >= 0)
484 /// in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0))
485 /// in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0)
486 /// or (LC(numerator(n) is not a constant)
487 /// in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1)
488 /// in Z/mZ: TRUE iff the internal mpz is greater than zero
489 /// in Z: TRUE iff n > 0
490 ///
491 /// !!! Recommendation: remove implementations for unordered fields
492 /// !!! and raise errors instead, in these cases
493 /// !!! Do not follow this recommendation: while writing polys,
494 /// !!! between 2 monomials will be an additional + iff !n_GreaterZero(next coeff)
495 /// Then change definition to include n_GreaterZero => printing does NOT
496 /// start with -
497 ///
498 static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
499 { STATISTIC(n_GreaterZero); assume(r != NULL); assume(r->cfGreaterZero!=NULL); return r->cfGreaterZero(n,r); }
500 
501 /// ordered fields: TRUE iff 'a' is larger than 'b';
502 /// in Z/pZ: TRUE iff la > lb, where la and lb are the long's representing
503 // a and b, respectively
504 /// in C: TRUE iff (Im(a) > Im(b))
505 /// in K(a)/<p(a)>: TRUE iff (a != 0 and (b == 0 or deg(a) > deg(b))
506 /// in K(t_1, ..., t_n): TRUE only if one or both numerator polynomials are
507 /// zero or if their degrees are equal. In this case,
508 /// TRUE if LC(numerator(a)) > LC(numerator(b))
509 /// in Z/2^kZ: TRUE if n_DivBy(a, b)
510 /// in Z/mZ: TRUE iff the internal mpz's fulfill the relation '>'
511 /// in Z: TRUE iff a > b
512 ///
513 /// !!! Recommendation: remove implementations for unordered fields
514 /// !!! and raise errors instead, in these cases
515 static FORCE_INLINE BOOLEAN n_Greater(number a, number b, const coeffs r)
516 { STATISTIC(n_Greater); assume(r != NULL); assume(r->cfGreater!=NULL); return r->cfGreater(a,b,r); }
517 
518 /// TRUE iff n has a multiplicative inverse in the given coeff field/ring r
519 static FORCE_INLINE BOOLEAN n_IsUnit(number n, const coeffs r)
520 { STATISTIC(n_IsUnit); assume(r != NULL); assume(r->cfIsUnit!=NULL); return r->cfIsUnit(n,r); }
521 
522 static FORCE_INLINE coeffs n_CoeffRingQuot1(number c, const coeffs r)
523 { STATISTIC(n_CoeffRingQuot1); assume(r != NULL); assume(r->cfQuot1 != NULL); return r->cfQuot1(c, r); }
524 
525 #ifdef HAVE_RINGS
526 static FORCE_INLINE int n_DivComp(number a, number b, const coeffs r)
527 { STATISTIC(n_DivComp); assume(r != NULL); assume(r->cfDivComp!=NULL); return r->cfDivComp (a,b,r); }
528 
529 /// in Z: 1
530 /// in Z/kZ (where k is not a prime): largest divisor of n (taken in Z) that
531 /// is co-prime with k
532 /// in Z/2^kZ: largest odd divisor of n (taken in Z)
533 /// other cases: not implemented
534 // CF: shold imply that n/GetUnit(n) is normalized in Z/kZ
535 // it would make more sense to return the inverse...
536 static FORCE_INLINE number n_GetUnit(number n, const coeffs r)
537 { STATISTIC(n_GetUnit); assume(r != NULL); assume(r->cfGetUnit!=NULL); return r->cfGetUnit(n,r); }
538 
539 #endif
540 
541 /// a number representing i in the given coeff field/ring r
542 static FORCE_INLINE number n_Init(long i, const coeffs r)
543 { STATISTIC(n_Init); assume(r != NULL); assume(r->cfInit!=NULL); return r->cfInit(i,r); }
544 
545 /// conversion of a GMP integer to number
546 static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
547 { STATISTIC(n_InitMPZ); assume(r != NULL); assume(r->cfInitMPZ != NULL); return r->cfInitMPZ(n,r); }
548 
549 /// conversion of n to an int; 0 if not possible
550 /// in Z/pZ: the representing int lying in (-p/2 .. p/2]
551 static FORCE_INLINE long n_Int(number &n, const coeffs r)
552 { STATISTIC(n_Int); assume(r != NULL); assume(r->cfInt!=NULL); return r->cfInt(n,r); }
553 
554 /// conversion of n to a GMP integer; 0 if not possible
555 static FORCE_INLINE void n_MPZ(mpz_t result, number &n, const coeffs r)
556 { STATISTIC(n_MPZ); assume(r != NULL); assume(r->cfMPZ!=NULL); r->cfMPZ(result, n, r); }
557 
558 
559 /// in-place negation of n
560 /// MUST BE USED: n = n_InpNeg(n) (no copy is returned)
561 static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
562 { STATISTIC(n_InpNeg); assume(r != NULL); assume(r->cfInpNeg!=NULL); return r->cfInpNeg(n,r); }
563 
564 /// return the multiplicative inverse of 'a';
565 /// raise an error if 'a' is not invertible
566 ///
567 /// !!! Recommendation: rename to 'n_Inverse'
568 static FORCE_INLINE number n_Invers(number a, const coeffs r)
569 { STATISTIC(n_Invers); assume(r != NULL); assume(r->cfInvers!=NULL); return r->cfInvers(a,r); }
570 
571 /// return a non-negative measure for the complexity of n;
572 /// return 0 only when n represents zero;
573 /// (used for pivot strategies in matrix computations with entries from r)
574 static FORCE_INLINE int n_Size(number n, const coeffs r)
575 { STATISTIC(n_Size); assume(r != NULL); assume(r->cfSize!=NULL); return r->cfSize(n,r); }
576 
577 /// inplace-normalization of n;
578 /// produces some canonical representation of n;
579 ///
580 /// !!! Recommendation: remove this method from the user-interface, i.e.,
581 /// !!! this should be hidden
582 static FORCE_INLINE void n_Normalize(number& n, const coeffs r)
583 { STATISTIC(n_Normalize); assume(r != NULL); assume(r->cfNormalize!=NULL); r->cfNormalize(n,r); }
584 
585 /// write to the output buffer of the currently used reporter
586 //CF: the "&" should be removed, as one wants to write constants as well
587 static FORCE_INLINE void n_WriteLong(number& n, const coeffs r)
588 { STATISTIC(n_WriteLong); assume(r != NULL); assume(r->cfWriteLong!=NULL); r->cfWriteLong(n,r); }
589 
590 /// write to the output buffer of the currently used reporter
591 /// in a shortest possible way, e.g. in K(a): a2 instead of a^2
592 static FORCE_INLINE void n_WriteShort(number& n, const coeffs r)
593 { STATISTIC(n_WriteShort); assume(r != NULL); assume(r->cfWriteShort!=NULL); r->cfWriteShort(n,r); }
594 
595 static FORCE_INLINE void n_Write(number& n, const coeffs r, const BOOLEAN bShortOut = TRUE)
596 { STATISTIC(n_Write); if (bShortOut) n_WriteShort(n, r); else n_WriteLong(n, r); }
597 
598 
599 /// !!! Recommendation: This method is too cryptic to be part of the user-
600 /// !!! interface. As defined here, it is merely a helper
601 /// !!! method for parsing number input strings.
602 static FORCE_INLINE const char *n_Read(const char * s, number * a, const coeffs r)
603 { STATISTIC(n_Read); assume(r != NULL); assume(r->cfRead!=NULL); return r->cfRead(s, a, r); }
604 
605 /// return the denominator of n
606 /// (if elements of r are by nature not fractional, result is 1)
607 static FORCE_INLINE number n_GetDenom(number& n, const coeffs r)
608 { STATISTIC(n_GetDenom); assume(r != NULL); assume(r->cfGetDenom!=NULL); return r->cfGetDenom(n, r); }
609 
610 /// return the numerator of n
611 /// (if elements of r are by nature not fractional, result is n)
612 static FORCE_INLINE number n_GetNumerator(number& n, const coeffs r)
613 { STATISTIC(n_GetNumerator); assume(r != NULL); assume(r->cfGetNumerator!=NULL); return r->cfGetNumerator(n, r); }
614 
615 /// return the quotient of 'a' and 'b', i.e., a/b;
616 /// raises an error if 'b' is not invertible in r
617 /// exception in Z: raises an error if 'a' is not divisible by 'b'
618 /// always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a
619 static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
620 { STATISTIC(n_Div); assume(r != NULL); assume(r->cfDiv!=NULL); return r->cfDiv(a,b,r); }
621 
622 /// assume that there is a canonical subring in cf and we know
623 /// that division is possible for these a and b in the subring,
624 /// n_ExactDiv performs it, may skip additional tests.
625 /// Can always be substituted by n_Div at the cost of larger computing time.
626 static FORCE_INLINE number n_ExactDiv(number a, number b, const coeffs r)
627 { STATISTIC(n_ExactDiv); assume(r != NULL); assume(r->cfExactDiv!=NULL); return r->cfExactDiv(a,b,r); }
628 
629 /// for r a field, return n_Init(0,r)
630 /// always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a
631 /// n_IntMod(a,b,r) >=0
632 static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r)
633 { STATISTIC(n_IntMod); assume(r != NULL); return r->cfIntMod(a,b,r); }
634 
635 /// fill res with the power a^b
636 static FORCE_INLINE void n_Power(number a, int b, number *res, const coeffs r)
637 { STATISTIC(n_Power); assume(r != NULL); assume(r->cfPower!=NULL); r->cfPower(a,b,res,r); }
638 
639 /// return the product of 'a' and 'b', i.e., a*b
640 static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
641 { STATISTIC(n_Mult); assume(r != NULL); assume(r->cfMult!=NULL); return r->cfMult(a, b, r); }
642 
643 /// multiplication of 'a' and 'b';
644 /// replacement of 'a' by the product a*b
645 static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
646 { STATISTIC(n_InpMult); assume(r != NULL); assume(r->cfInpMult!=NULL); r->cfInpMult(a,b,r); }
647 
648 /// addition of 'a' and 'b';
649 /// replacement of 'a' by the sum a+b
650 static FORCE_INLINE void n_InpAdd(number &a, number b, const coeffs r)
651 { STATISTIC(n_InpAdd); assume(r != NULL); assume(r->cfInpAdd!=NULL); r->cfInpAdd(a,b,r);
652 
653 #ifdef HAVE_NUMSTATS
654  // avoid double counting
655  if( r->cfIsZero(a,r) ) STATISTIC(n_CancelOut);
656 #endif
657 }
658 
659 /// return the sum of 'a' and 'b', i.e., a+b
660 static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
661 { STATISTIC(n_Add); assume(r != NULL); assume(r->cfAdd!=NULL); const number sum = r->cfAdd(a, b, r);
662 
663 #ifdef HAVE_NUMSTATS
664  // avoid double counting
665  if( r->cfIsZero(sum,r) ) STATISTIC(n_CancelOut);
666 #endif
667 
668  return sum;
669 }
670 
671 
672 /// return the difference of 'a' and 'b', i.e., a-b
673 static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
674 { STATISTIC(n_Sub); assume(r != NULL); assume(r->cfSub!=NULL); const number d = r->cfSub(a, b, r);
675 
676 #ifdef HAVE_NUMSTATS
677  // avoid double counting
678  if( r->cfIsZero(d,r) ) STATISTIC(n_CancelOut);
679 #endif
680 
681  return d;
682 }
683 
684 /// in Z: return the gcd of 'a' and 'b'
685 /// in Z/nZ, Z/2^kZ: computed as in the case Z
686 /// in Z/pZ, C, R: not implemented
687 /// in Q: return the gcd of the numerators of 'a' and 'b'
688 /// in K(a)/<p(a)>: not implemented
689 /// in K(t_1, ..., t_n): not implemented
690 static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
691 { STATISTIC(n_Gcd); assume(r != NULL); assume(r->cfGcd!=NULL); return r->cfGcd(a,b,r); }
692 static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
693 { STATISTIC(n_SubringGcd); assume(r != NULL); assume(r->cfSubringGcd!=NULL); return r->cfSubringGcd(a,b,r); }
694 
695 /// beware that ExtGCD is only relevant for a few chosen coeff. domains
696 /// and may perform something unexpected in some cases...
697 static FORCE_INLINE number n_ExtGcd(number a, number b, number *s, number *t, const coeffs r)
698 { STATISTIC(n_ExtGcd); assume(r != NULL); assume(r->cfExtGcd!=NULL); return r->cfExtGcd (a,b,s,t,r); }
699 static FORCE_INLINE number n_XExtGcd(number a, number b, number *s, number *t, number *u, number *v, const coeffs r)
700 { STATISTIC(n_XExtGcd); assume(r != NULL); assume(r->cfXExtGcd!=NULL); return r->cfXExtGcd (a,b,s,t,u,v,r); }
701 static FORCE_INLINE number n_EucNorm(number a, const coeffs r)
702 { STATISTIC(n_EucNorm); assume(r != NULL); assume(r->cfEucNorm!=NULL); return r->cfEucNorm (a,r); }
703 /// if r is a ring with zero divisors, return an annihilator!=0 of b
704 /// otherwise return NULL
705 static FORCE_INLINE number n_Ann(number a, const coeffs r)
706 { STATISTIC(n_Ann); assume(r != NULL); return r->cfAnn (a,r); }
707 static FORCE_INLINE number n_QuotRem(number a, number b, number *q, const coeffs r)
708 { STATISTIC(n_QuotRem); assume(r != NULL); assume(r->cfQuotRem!=NULL); return r->cfQuotRem (a,b,q,r); }
709 
710 
711 /// in Z: return the lcm of 'a' and 'b'
712 /// in Z/nZ, Z/2^kZ: computed as in the case Z
713 /// in Z/pZ, C, R: not implemented
714 /// in K(a)/<p(a)>: not implemented
715 /// in K(t_1, ..., t_n): not implemented
716 static FORCE_INLINE number n_Lcm(number a, number b, const coeffs r)
717 { STATISTIC(n_Lcm); assume(r != NULL); assume(r->cfLcm!=NULL); return r->cfLcm(a,b,r); }
718 
719 /// assume that r is a quotient field (otherwise, return 1)
720 /// for arguments (a1/a2,b1/b2) return (lcm(a1,b2)/1)
721 static FORCE_INLINE number n_NormalizeHelper(number a, number b, const coeffs r)
722 { STATISTIC(n_NormalizeHelper); assume(r != NULL); assume(r->cfNormalizeHelper!=NULL); return r->cfNormalizeHelper(a,b,r); }
723 
724 /// set the mapping function pointers for translating numbers from src to dst
725 static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
726 { STATISTIC(n_SetMap); assume(src != NULL && dst != NULL); assume(dst->cfSetMap!=NULL); return dst->cfSetMap(src,dst); }
727 
728 #ifdef LDEBUG
729 /// test whether n is a correct number;
730 /// only used if LDEBUG is defined
731 static FORCE_INLINE BOOLEAN n_DBTest(number n, const char *filename, const int linenumber, const coeffs r)
732 { STATISTIC(n_Test); assume(r != NULL); assume(r->cfDBTest != NULL); return r->cfDBTest(n, filename, linenumber, r); }
733 #else
734 // is it really necessary to define this function in any case?
735 /// test whether n is a correct number;
736 /// only used if LDEBUG is defined
737 static FORCE_INLINE BOOLEAN n_DBTest(number, const char*, const int, const coeffs)
738 { STATISTIC(n_Test); return TRUE; }
739 #endif
740 
741 /// BOOLEAN n_Test(number a, const coeffs r)
742 #define n_Test(a,r) n_DBTest(a, __FILE__, __LINE__, r)
743 
744 /// output the coeff description
745 static FORCE_INLINE void n_CoeffWrite(const coeffs r, BOOLEAN details = TRUE)
746 { STATISTIC(n_CoeffWrite); assume(r != NULL); assume(r->cfCoeffWrite != NULL); r->cfCoeffWrite(r, details); }
747 
748 // Tests:
749 #ifdef HAVE_RINGS
751 { assume(r != NULL); return (getCoeffType(r)==n_Z2m); }
752 
754 { assume(r != NULL); return (getCoeffType(r)==n_Zn); }
755 
757 { assume(r != NULL); return (getCoeffType(r)==n_Znm); }
758 
759 static FORCE_INLINE BOOLEAN nCoeff_is_Ring_Z(const coeffs r)
760 { assume(r != NULL); return (getCoeffType(r)==n_Z); }
761 
762 static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
763 { assume(r != NULL); return (r->is_field==0); }
764 #else
765 #define nCoeff_is_Ring_2toM(A) 0
766 #define nCoeff_is_Ring_ModN(A) 0
767 #define nCoeff_is_Ring_PtoM(A) 0
768 #define nCoeff_is_Ring_Z(A) 0
769 #define nCoeff_is_Ring(A) 0
770 #endif
771 
772 /// returns TRUE, if r is a field or r has no zero divisors (i.e is a domain)
773 static FORCE_INLINE BOOLEAN nCoeff_is_Domain(const coeffs r)
774 {
775  assume(r != NULL);
776  return (r->is_domain);
777 }
778 
779 /// test whether 'a' is divisible 'b';
780 /// for r encoding a field: TRUE iff 'b' does not represent zero
781 /// in Z: TRUE iff 'b' divides 'a' (with remainder = zero)
782 /// in Z/nZ: TRUE iff (a = 0 and b divides n in Z) or
783 /// (a != 0 and b/gcd(a, b) is co-prime with n, i.e.
784 /// a unit in Z/nZ)
785 /// in Z/2^kZ: TRUE iff ((a = 0 mod 2^k) and (b = 0 or b is a power of 2))
786 /// or ((a, b <> 0) and (b/gcd(a, b) is odd))
787 static FORCE_INLINE BOOLEAN n_DivBy(number a, number b, const coeffs r)
788 { STATISTIC(n_DivBy); assume(r != NULL);
789 #ifdef HAVE_RINGS
790  if( nCoeff_is_Ring(r) )
791  {
792  assume(r->cfDivBy!=NULL); return r->cfDivBy(a,b,r);
793  }
794 #endif
795  return !n_IsZero(b, r);
796 }
797 
798 static FORCE_INLINE number n_ChineseRemainderSym(number *a, number *b, int rl, BOOLEAN sym,CFArray &inv_cache,const coeffs r)
799 { STATISTIC(n_ChineseRemainderSym); assume(r != NULL); assume(r->cfChineseRemainder != NULL); return r->cfChineseRemainder(a,b,rl,sym,inv_cache,r); }
800 
801 static FORCE_INLINE number n_Farey(number a, number b, const coeffs r)
802 { STATISTIC(n_Farey); assume(r != NULL); assume(r->cfFarey != NULL); return r->cfFarey(a,b,r); }
803 
804 static FORCE_INLINE int n_ParDeg(number n, const coeffs r)
805 { STATISTIC(n_ParDeg); assume(r != NULL); assume(r->cfParDeg != NULL); return r->cfParDeg(n,r); }
806 
807 /// Returns the number of parameters
808 static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
809 { STATISTIC(n_NumberOfParameters); assume(r != NULL); return r->iNumberOfParameters; }
810 
811 /// Returns a (const!) pointer to (const char*) names of parameters
812 static FORCE_INLINE char const * * n_ParameterNames(const coeffs r)
813 { STATISTIC(n_ParameterNames); assume(r != NULL); return r->pParameterNames; }
814 
815 /// return the (iParameter^th) parameter as a NEW number
816 /// NOTE: parameter numbering: 1..n_NumberOfParameters(...)
817 static FORCE_INLINE number n_Param(const int iParameter, const coeffs r)
818 { assume(r != NULL);
819  assume((iParameter >= 1) || (iParameter <= n_NumberOfParameters(r)));
820  assume(r->cfParameter != NULL);
821  STATISTIC(n_Param); return r->cfParameter(iParameter, r);
822 }
823 
824 static FORCE_INLINE number n_RePart(number i, const coeffs cf)
825 { STATISTIC(n_RePart); assume(cf != NULL); assume(cf->cfRePart!=NULL); return cf->cfRePart(i,cf); }
826 
827 static FORCE_INLINE number n_ImPart(number i, const coeffs cf)
828 { STATISTIC(n_ImPart); assume(cf != NULL); assume(cf->cfImPart!=NULL); return cf->cfImPart(i,cf); }
829 
830 /// returns TRUE, if r is not a field and r has non-trivial units
831 static FORCE_INLINE BOOLEAN nCoeff_has_Units(const coeffs r)
832 { assume(r != NULL); return ((getCoeffType(r)==n_Zn) || (getCoeffType(r)==n_Z2m) || (getCoeffType(r)==n_Znm)); }
833 
834 static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
835 { assume(r != NULL); return getCoeffType(r)==n_Zp; }
836 
837 static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r, int p)
838 { assume(r != NULL); return ((getCoeffType(r)==n_Zp) && (r->ch == p)); }
839 
840 static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
841 { assume(r != NULL); return getCoeffType(r)==n_Q && (r->is_field); }
842 
843 static FORCE_INLINE BOOLEAN nCoeff_is_Q_or_BI(const coeffs r)
844 { assume(r != NULL); return getCoeffType(r)==n_Q; }
845 
846 static FORCE_INLINE BOOLEAN nCoeff_is_numeric(const coeffs r) /* R, long R, long C */
847 { assume(r != NULL); return (getCoeffType(r)==n_R) || (getCoeffType(r)==n_long_R) || (getCoeffType(r)==n_long_C); }
848 // (r->ringtype == 0) && (r->ch == -1); ??
849 
850 static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
851 { assume(r != NULL); return getCoeffType(r)==n_R; }
852 
853 static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
854 { assume(r != NULL); return getCoeffType(r)==n_GF; }
855 
856 static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r, int q)
857 { assume(r != NULL); return (getCoeffType(r)==n_GF) && (r->ch == q); }
858 
859 /* TRUE iff r represents an algebraic or transcendental extension field */
861 {
862  assume(r != NULL);
863  return (getCoeffType(r)==n_algExt) || (getCoeffType(r)==n_transExt);
864 }
865 
866 /* DO NOT USE (only kept for compatibility reasons towards the SINGULAR
867  svn trunk);
868  intension: should be TRUE iff the given r is an extension field above
869  some Z/pZ;
870  actually: TRUE iff the given r is an extension tower of arbitrary
871  height above some field of characteristic p (may be Z/pZ or some
872  Galois field of characteristic p) */
873 static FORCE_INLINE BOOLEAN nCoeff_is_Zp_a(const coeffs r)
874 {
875  assume(r != NULL);
876  return ((!nCoeff_is_Ring(r)) && (n_GetChar(r) != 0) && nCoeff_is_Extension(r));
877 }
878 
879 /* DO NOT USE (only kept for compatibility reasons towards the SINGULAR
880  svn trunk);
881  intension: should be TRUE iff the given r is an extension field above
882  Z/pZ (with p as provided);
883  actually: TRUE iff the given r is an extension tower of arbitrary
884  height above some field of characteristic p (may be Z/pZ or some
885  Galois field of characteristic p) */
886 static FORCE_INLINE BOOLEAN nCoeff_is_Zp_a(const coeffs r, int p)
887 {
888  assume(r != NULL);
889  assume(p != 0);
890  return ((!nCoeff_is_Ring(r)) && (n_GetChar(r) == p) && nCoeff_is_Extension(r));
891 }
892 
893 /* DO NOT USE (only kept for compatibility reasons towards the SINGULAR
894  svn trunk);
895  intension: should be TRUE iff the given r is an extension field
896  above Q;
897  actually: TRUE iff the given r is an extension tower of arbitrary
898  height above some field of characteristic 0 (may be Q, R, or C) */
899 static FORCE_INLINE BOOLEAN nCoeff_is_Q_a(const coeffs r)
900 {
901  assume(r != NULL);
902  return ((n_GetChar(r) == 0) && nCoeff_is_Extension(r));
903 }
904 
905 static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
906 { assume(r != NULL); return getCoeffType(r)==n_long_R; }
907 
908 static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
909 { assume(r != NULL); return getCoeffType(r)==n_long_C; }
910 
911 static FORCE_INLINE BOOLEAN nCoeff_is_CF(const coeffs r)
912 { assume(r != NULL); return getCoeffType(r)==n_CF; }
913 
914 /// TRUE, if the computation of the inverse is fast,
915 /// i.e. prefer leading coeff. 1 over content
917 { assume(r != NULL); return r->has_simple_Inverse; }
918 
919 /// TRUE if n_Delete/n_New are empty operations
921 { assume(r != NULL); return r->has_simple_Alloc; }
922 
923 /// TRUE iff r represents an algebraic extension field
924 static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
925 { assume(r != NULL); return (getCoeffType(r)==n_algExt); }
926 
927 /// is it an alg. ext. of Q?
929 { assume(r != NULL); return ((n_GetChar(r) == 0) && nCoeff_is_algExt(r)); }
930 
931 /// TRUE iff r represents a transcendental extension field
933 { assume(r != NULL); return (getCoeffType(r)==n_transExt); }
934 
935 /// Computes the content and (inplace) divides it out on a collection
936 /// of numbers
937 /// number @em c is the content (i.e. the GCD of all the coeffs, which
938 /// we divide out inplace)
939 /// NOTE: it assumes all coefficient numbers to be integer!!!
940 /// NOTE/TODO: see also the description by Hans
941 /// TODO: rename into n_ClearIntegerContent
942 static FORCE_INLINE void n_ClearContent(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs r)
943 { STATISTIC(n_ClearContent); assume(r != NULL); r->cfClearContent(numberCollectionEnumerator, c, r); }
944 
945 /// (inplace) Clears denominators on a collection of numbers
946 /// number @em d is the LCM of all the coefficient denominators (i.e. the number
947 /// with which all the number coeffs. were multiplied)
948 /// NOTE/TODO: see also the description by Hans
949 static FORCE_INLINE void n_ClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, number& d, const coeffs r)
950 { STATISTIC(n_ClearDenominators); assume(r != NULL); r->cfClearDenominators(numberCollectionEnumerator, d, r); }
951 
952 // convenience helpers (no number returned - but the input enumeration
953 // is to be changed
954 // TODO: do we need separate hooks for these as our existing code does
955 // *different things* there: compare p_Cleardenom (which calls
956 // *p_Content) and p_Cleardenom_n (which doesn't)!!!
957 
958 static FORCE_INLINE void n_ClearContent(ICoeffsEnumerator& numberCollectionEnumerator, const coeffs r)
959 { STATISTIC(n_ClearContent); number c; n_ClearContent(numberCollectionEnumerator, c, r); n_Delete(&c, r); }
960 
961 static FORCE_INLINE void n_ClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, const coeffs r)
962 { STATISTIC(n_ClearDenominators); assume(r != NULL); number d; n_ClearDenominators(numberCollectionEnumerator, d, r); n_Delete(&d, r); }
963 
964 
965 /// print a number (BEWARE of string buffers!)
966 /// mostly for debugging
967 void n_Print(number& a, const coeffs r);
968 
969 
970 
971 /// TODO: make it a virtual method of coeffs, together with:
972 /// Decompose & Compose, rParameter & rPar
973 static FORCE_INLINE char * nCoeffString(const coeffs cf)
974 { STATISTIC(nCoeffString); assume( cf != NULL ); return cf->cfCoeffString(cf); }
975 
976 
977 static FORCE_INLINE char * nCoeffName (const coeffs cf)
978 { STATISTIC(nCoeffName); assume( cf != NULL ); return cf->cfCoeffName(cf); }
979 
980 static FORCE_INLINE number n_Random(siRandProc p, number p1, number p2, const coeffs cf)
981 { STATISTIC(n_Random); assume( cf != NULL ); assume( cf->cfRandom != NULL ); return cf->cfRandom(p, p1, p2, cf); }
982 
983 /// io via ssi:
984 static FORCE_INLINE void n_WriteFd(number a, FILE *f, const coeffs r)
985 { STATISTIC(n_WriteFd); assume(r != NULL); assume(r->cfWriteFd != NULL); return r->cfWriteFd(a, f, r); }
986 
987 /// io via ssi:
988 static FORCE_INLINE number n_ReadFd( s_buff f, const coeffs r)
989 { STATISTIC(n_ReadFd); assume(r != NULL); assume(r->cfReadFd != NULL); return r->cfReadFd(f, r); }
990 
991 
992 // the following wrappers went to numbers.cc since they needed factory
993 // knowledge!
994 number n_convFactoryNSingN( const CanonicalForm n, const coeffs r);
995 
996 CanonicalForm n_convSingNFactoryN( number n, BOOLEAN setChar, const coeffs r );
997 
998 
999 // TODO: remove the following functions...
1000 // the following 2 inline functions are just convenience shortcuts for Frank's code:
1001 static FORCE_INLINE void number2mpz(number n, coeffs c, mpz_t m){ n_MPZ(m, n, c); }
1002 static FORCE_INLINE number mpz2number(mpz_t m, coeffs c){ return n_InitMPZ(m, c); }
1003 
1004 #endif
1005 
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of &#39;a&#39; and &#39;b&#39;, i.e., a-b
Definition: coeffs.h:673
int ch
Definition: coeffs.h:344
BOOLEAN(* cfDivBy)(number a, number b, const coeffs r)
Definition: coeffs.h:385
short float_len2
Definition: coeffs.h:357
static FORCE_INLINE BOOLEAN n_Greater(number a, number b, const coeffs r)
ordered fields: TRUE iff &#39;a&#39; is larger than &#39;b&#39;; in Z/pZ: TRUE iff la > lb, where la and lb are the l...
Definition: coeffs.h:515
#define STATISTIC(f)
Definition: numstats.h:16
static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r)
for r a field, return n_Init(0,r) always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a n_IntMod(a,b,r) >=0
Definition: coeffs.h:632
static FORCE_INLINE number n_GetNumerator(number &n, const coeffs r)
return the numerator of n (if elements of r are by nature not fractional, result is n) ...
Definition: coeffs.h:612
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 char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:812
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
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_ModN(const coeffs r)
Definition: coeffs.h:753
static FORCE_INLINE number n_EucNorm(number a, const coeffs r)
Definition: coeffs.h:701
void rem(unsigned long *a, unsigned long *q, unsigned long p, int &dega, int degq)
Definition: minpoly.cc:574
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:846
static FORCE_INLINE BOOLEAN n_IsUnit(number n, const coeffs r)
TRUE iff n has a multiplicative inverse in the given coeff field/ring r.
Definition: coeffs.h:519
int m_nfCharQ1
q-1
Definition: coeffs.h:369
const poly a
Definition: syzextra.cc:212
static FORCE_INLINE const char * n_Read(const char *s, number *a, const coeffs r)
!!! Recommendation: This method is too cryptic to be part of the user- !!! interface. As defined here, it is merely a helper !!! method for parsing number input strings.
Definition: coeffs.h:602
number(* cfExtGcd)(number a, number b, number *s, number *t, const coeffs r)
Definition: coeffs.h:248
omBin_t * omBin
Definition: omStructs.h:12
only used if HAVE_RINGS is defined
Definition: coeffs.h:44
numberfunc cfIntMod
Definition: coeffs.h:175
int(* cfDivComp)(number a, number b, const coeffs r)
Definition: coeffs.h:381
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:834
number nNULL
the 0 as constant, NULL by default
Definition: coeffs.h:320
static FORCE_INLINE number n_XExtGcd(number a, number b, number *s, number *t, number *u, number *v, const coeffs r)
Definition: coeffs.h:699
?
Definition: coeffs.h:47
static FORCE_INLINE BOOLEAN nCoeff_is_Zp_a(const coeffs r)
Definition: coeffs.h:873
number(* cfRandom)(siRandProc p, number p1, number p2, const coeffs cf)
a function returning random elements
Definition: coeffs.h:306
BOOLEAN(* cfDBTest)(number a, const char *f, const int l, const coeffs r)
Test: is "a" a correct number?
Definition: coeffs.h:419
unsigned short * m_nfPlus1Table
Definition: coeffs.h:370
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
&#39;SR_INT&#39; is the type of those integers small enough to fit into 29 bits.
Definition: longrat.h:49
void(* cfSetChar)(const coeffs r)
Definition: coeffs.h:161
only used if HAVE_RINGS is defined
Definition: coeffs.h:46
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
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 n_convFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: numbers.cc:573
coeffs next
Definition: coeffs.h:125
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:905
mpz_ptr modNumber
Definition: coeffs.h:407
static FORCE_INLINE void nSetChar(const coeffs r)
initialisations after each ring change
Definition: coeffs.h:440
void(* cfDelete)(number *a, const coeffs r)
Definition: coeffs.h:272
number(* cfXExtGcd)(number a, number b, number *s, number *t, number *u, number *v, const coeffs r)
Definition: coeffs.h:256
BOOLEAN(*)(*)(*)(*) cfIsOne(number a, const coeffs r)
Definition: coeffs.h:229
rational (GMP) numbers
Definition: coeffs.h:31
const char * GFPar_name
Definition: coeffs.h:96
static FORCE_INLINE number n_ReadFd(s_buff f, const coeffs r)
io via ssi:
Definition: coeffs.h:988
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_Z(const coeffs r)
Definition: coeffs.h:759
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
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
Definition: coeffs.h:850
static FORCE_INLINE BOOLEAN nCoeff_is_Q_or_BI(const coeffs r)
Definition: coeffs.h:843
number(* cfSubringGcd)(number a, number b, const coeffs r)
Definition: coeffs.h:247
{p < 2^31}
Definition: coeffs.h:30
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
Definition: coeffs.h:750
(), see rinteger.h, new impl.
Definition: coeffs.h:112
int m_nfCharQ
the number of elements: q
Definition: coeffs.h:366
numberfunc cfAdd
Definition: coeffs.h:175
number(* cfInvers)(number a, const coeffs r)
return 1/a
Definition: coeffs.h:197
static FORCE_INLINE BOOLEAN nCoeff_has_simple_inverse(const coeffs r)
TRUE, if the computation of the inverse is fast, i.e. prefer leading coeff. 1 over content...
Definition: coeffs.h:916
BOOLEAN(* cfGreater)(number a, number b, const coeffs r)
Definition: coeffs.h:225
static FORCE_INLINE BOOLEAN n_DBTest(number n, const char *filename, const int linenumber, const coeffs r)
test whether n is a correct number; only used if LDEBUG is defined
Definition: coeffs.h:731
void(* cfNormalize)(number &a, const coeffs r)
Definition: coeffs.h:223
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
Definition: ring.h:255
#define TRUE
Definition: auxiliary.h:101
#define FORCE_INLINE
Definition: auxiliary.h:331
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
void(* cfCoeffWrite)(const coeffs r, BOOLEAN details)
output of coeff description via Print
Definition: coeffs.h:148
number(* numberfunc)(number a, number b, const coeffs r)
Definition: coeffs.h:70
BOOLEAN is_field
TRUE, if cf is a field.
Definition: coeffs.h:140
n_coeffRep rep
Definition: coeffs.h:127
static FORCE_INLINE number n_NormalizeHelper(number a, number b, const coeffs r)
assume that r is a quotient field (otherwise, return 1) for arguments (a1/a2,b1/b2) return (lcm(a1...
Definition: coeffs.h:721
int factoryVarOffset
how many variables of factory are already used by this coeff
Definition: coeffs.h:130
(fraction), see transext.h
Definition: coeffs.h:114
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
void(* nCoeffsEnumeratorFunc)(ICoeffsEnumerator &numberCollectionEnumerator, number &output, const coeffs r)
goes over coeffs given by the ICoeffsEnumerator and changes them. Additionally returns a number; ...
Definition: coeffs.h:82
number(* cfFarey)(number p, number n, const coeffs)
rational reconstruction: "best" rational a/b with a/b = p mod n
Definition: coeffs.h:291
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:908
static FORCE_INLINE int n_ParDeg(number n, const coeffs r)
Definition: coeffs.h:804
IEnumerator< number > ICoeffsEnumerator
Abstract interface for an enumerator of number coefficients for an object, e.g. a polynomial...
Definition: coeffs.h:78
BOOLEAN has_simple_Alloc
TRUE, if nNew/nDelete/nCopy are dummies.
Definition: coeffs.h:134
number(* cfInitMPZ)(mpz_t i, const coeffs r)
init with a GMP integer
Definition: coeffs.h:181
static FORCE_INLINE void n_InpAdd(number &a, number b, const coeffs r)
addition of &#39;a&#39; and &#39;b&#39;; replacement of &#39;a&#39; by the sum a+b
Definition: coeffs.h:650
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
Definition: coeffs.h:762
CanonicalForm n_convSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition: numbers.cc:578
Creation data needed for finite fields.
Definition: coeffs.h:92
unsigned short * npLogTable
Definition: coeffs.h:377
static FORCE_INLINE BOOLEAN nCoeff_is_Q_a(const coeffs r)
Definition: coeffs.h:899
static FORCE_INLINE void number2mpz(number n, coeffs c, mpz_t m)
Definition: coeffs.h:1001
static FORCE_INLINE number n_Ann(number a, const coeffs r)
if r is a ring with zero divisors, return an annihilator!=0 of b otherwise return NULL ...
Definition: coeffs.h:705
real floating point (GMP) numbers
Definition: coeffs.h:34
Abstract API for enumerators.
short float_len2
additional char-flags, rInit
Definition: coeffs.h:102
(poly), see algext.h
Definition: coeffs.h:113
static FORCE_INLINE number n_Random(siRandProc p, number p1, number p2, const coeffs cf)
Definition: coeffs.h:980
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:808
BOOLEAN(* nCoeffIsEqual)(const coeffs r, n_coeffType n, void *parameter)
Definition: coeffs.h:145
static FORCE_INLINE number n_Param(const int iParameter, const coeffs r)
return the (iParameter^th) parameter as a NEW number NOTE: parameter numbering: 1..n_NumberOfParameters(...)
Definition: coeffs.h:817
poly res
Definition: myNF.cc:322
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:640
single prescision (6,6) real numbers
Definition: coeffs.h:32
n_coeffRep
Definition: coeffs.h:107
number(* cfInit)(long i, const coeffs r)
init with an integer
Definition: coeffs.h:178
static FORCE_INLINE void n_ClearContent(ICoeffsEnumerator &numberCollectionEnumerator, number &c, const coeffs r)
Computes the content and (inplace) divides it out on a collection of numbers number c is the content ...
Definition: coeffs.h:942
number(* cfNormalizeHelper)(number a, number b, const coeffs r)
Definition: coeffs.h:271
short float_len
additional char-flags, rInit
Definition: coeffs.h:101
const ring r
Definition: syzextra.cc:208
unsigned short * npInvTable
Definition: coeffs.h:375
static FORCE_INLINE number mpz2number(mpz_t m, coeffs c)
Definition: coeffs.h:1002
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:924
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ...
Definition: coeffs.h:551
long(* cfInt)(number &n, const coeffs r)
convertion to long, 0 if impossible
Definition: coeffs.h:187
static FORCE_INLINE BOOLEAN nCoeff_is_CF(const coeffs r)
Definition: coeffs.h:911
void(* cfInpMult)(number &a, number b, const coeffs r)
Inplace: a *= b.
Definition: coeffs.h:281
ring extRing
Definition: coeffs.h:338
numberfunc cfSub
Definition: coeffs.h:175
only used if HAVE_RINGS is defined
Definition: coeffs.h:45
number(* cfImPart)(number a, const coeffs r)
Definition: coeffs.h:201
#define assume(x)
Definition: mod2.h:403
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.
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of &#39;a&#39; and &#39;b&#39;, i.e., a+b
Definition: coeffs.h:660
Templated enumerator interface for simple iteration over a generic collection of T&#39;s.
Definition: Enumerator.h:124
BOOLEAN has_simple_Inverse
TRUE, if std should make polynomials monic (if nInvers is cheap) if false, then a gcd routine is used...
Definition: coeffs.h:137
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
int GFDegree
Definition: coeffs.h:95
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
static FORCE_INLINE BOOLEAN n_DivBy(number a, number b, const coeffs r)
test whether &#39;a&#39; is divisible &#39;b&#39;; for r encoding a field: TRUE iff &#39;b&#39; does not represent zero in Z:...
Definition: coeffs.h:787
static FORCE_INLINE number n_ChineseRemainderSym(number *a, number *b, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs r)
Definition: coeffs.h:798
static FORCE_INLINE BOOLEAN nCoeff_has_simple_Alloc(const coeffs r)
TRUE if n_Delete/n_New are empty operations.
Definition: coeffs.h:920
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition: coeffs.h:977
(gmp_complex), see gnumpc.h
Definition: coeffs.h:118
static FORCE_INLINE void n_Write(number &n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:595
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
static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
Definition: coeffs.h:546
All the auxiliary stuff.
const unsigned short fftable[]
Definition: ffields.cc:61
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
static FORCE_INLINE number n_QuotRem(number a, number b, number *q, const coeffs r)
Definition: coeffs.h:707
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition: coeffs.h:561
int m_nfCharP
the characteristic: p
Definition: coeffs.h:368
only used if HAVE_RINGS is defined
Definition: coeffs.h:43
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_PtoM(const coeffs r)
Definition: coeffs.h:756
int npPminus1M
characteristic - 1
Definition: coeffs.h:379
BOOLEAN is_domain
TRUE, if cf is a domain.
Definition: coeffs.h:142
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:932
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
n_coeffType type
Definition: coeffs.h:128
(mpz_ptr), see rmodulon,h
Definition: coeffs.h:115
numberfunc cfDiv
Definition: coeffs.h:175
static FORCE_INLINE int n_DivComp(number a, number b, const coeffs r)
Definition: coeffs.h:526
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:853
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:725
static FORCE_INLINE number n_Lcm(number a, number b, const coeffs r)
in Z: return the lcm 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:716
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
void * data
Definition: coeffs.h:414
numberfunc cfMult
Definition: coeffs.h:175
int(* siRandProc)()
Definition: sirandom.h:9
unsigned long mod2mMask
Definition: coeffs.h:408
short float_len
Definition: coeffs.h:356
static FORCE_INLINE number n_ImPart(number i, const coeffs cf)
Definition: coeffs.h:827
static FORCE_INLINE number n_Farey(number a, number b, const coeffs r)
Definition: coeffs.h:801
static FORCE_INLINE coeffs nCopyCoeff(const coeffs r)
"copy" coeffs, i.e. increment ref
Definition: coeffs.h:433
(number), see longrat.h
Definition: coeffs.h:111
static FORCE_INLINE number n_ExtGcd(number a, number b, number *s, number *t, const coeffs r)
beware that ExtGCD is only relevant for a few chosen coeff. domains and may perform something unexpec...
Definition: coeffs.h:697
int GFChar
Definition: coeffs.h:94
static FORCE_INLINE void n_WriteFd(number a, FILE *f, const coeffs r)
io via ssi:
Definition: coeffs.h:984
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
n_coeffType
Definition: coeffs.h:27
static FORCE_INLINE void n_Power(number a, int b, number *res, const coeffs r)
fill res with the power a^b
Definition: coeffs.h:636
CanonicalForm cf
Definition: cfModGcd.cc:4024
static FORCE_INLINE void n_CoeffWrite(const coeffs r, BOOLEAN details=TRUE)
output the coeff description
Definition: coeffs.h:745
static FORCE_INLINE BOOLEAN nCoeff_is_Domain(const coeffs r)
returns TRUE, if r is a field or r has no zero divisors (i.e is a domain)
Definition: coeffs.h:773
#define NULL
Definition: omList.c:10
{p^n < 2^16}
Definition: coeffs.h:33
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
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:36
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
(gmp_float), see
Definition: coeffs.h:117
number(* cfGcd)(number a, number b, const coeffs r)
Definition: coeffs.h:246
Count number operarions over coefficient rings, fields and other domains suitable for Singular polyno...
number(* cfReadFd)(s_buff f, const coeffs r)
Definition: coeffs.h:278
static FORCE_INLINE BOOLEAN nCoeff_is_Q_algext(const coeffs r)
is it an alg. ext. of Q?
Definition: coeffs.h:928
number(* cfLcm)(number a, number b, const coeffs r)
Definition: coeffs.h:270
Variable x
Definition: cfModGcd.cc:4023
number(* convFactoryNSingN)(const CanonicalForm n, const coeffs r)
conversion to CanonicalForm(factory) to number
Definition: coeffs.h:315
static FORCE_INLINE number n_GetDenom(number &n, const coeffs r)
return the denominator of n (if elements of r are by nature not fractional, result is 1) ...
Definition: coeffs.h:607
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 FORCE_INLINE number n_RePart(number i, const coeffs cf)
Definition: coeffs.h:824
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff &#39;a&#39; and &#39;b&#39; represent the same number; they may have different representations.
Definition: coeffs.h:464
const char * par_name
parameter name
Definition: coeffs.h:103
static FORCE_INLINE number n_ExactDiv(number a, number b, const coeffs r)
assume that there is a canonical subring in cf and we know that division is possible for these a and ...
Definition: coeffs.h:626
nMapFunc(* cfSetMap)(const coeffs src, const coeffs dst)
Definition: coeffs.h:275
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition: coeffs.h:692
unsigned long modExponent
Definition: coeffs.h:406
#define const
Definition: fegetopt.c:41
void nNew(number *a)
Definition: numbers.cc:49
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition: coeffs.h:860
int(* cfSize)(number n, const coeffs r)
how complicated, (0) => 0, or positive
Definition: coeffs.h:184
(int), see modulop.h
Definition: coeffs.h:110
END_NAMESPACE const void * p2
Definition: syzextra.cc:202
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
static FORCE_INLINE BOOLEAN n_IsMOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the additive inverse of the one element, i.e. -1.
Definition: coeffs.h:476
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:498
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
static FORCE_INLINE char * nCoeffString(const coeffs cf)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar...
Definition: coeffs.h:973
int * m_nfMinPoly
Definition: coeffs.h:371
BOOLEAN(*)(*)(*)(*)(*) cfIsMOne(number a, const coeffs r)
Definition: coeffs.h:232
CanonicalForm(* convSingNFactoryN)(number n, BOOLEAN setChar, const coeffs r)
Definition: coeffs.h:316
(int), see ffields.h
Definition: coeffs.h:119
void(* cfKillChar)(coeffs r)
Definition: coeffs.h:159
number(* cfEucNorm)(number a, const coeffs r)
Definition: coeffs.h:258
int BOOLEAN
Definition: auxiliary.h:88
const poly b
Definition: syzextra.cc:213
mpz_ptr modBase
Definition: coeffs.h:405
coeffs(* cfQuot1)(number c, const coeffs r)
Definition: coeffs.h:410
static FORCE_INLINE void n_WriteShort(number &n, const coeffs r)
write to the output buffer of the currently used reporter in a shortest possible way, e.g. in K(a): a2 instead of a^2
Definition: coeffs.h:592
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition: coeffs.h:574
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:490
void(* cfInpAdd)(number &a, number b, const coeffs r)
Inplace: a += b.
Definition: coeffs.h:284
omBin rnumber_bin
Definition: longrat0.cc:23
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
void(* cfWriteFd)(number a, FILE *f, const coeffs r)
Definition: coeffs.h:277
static FORCE_INLINE void n_MPZ(mpz_t result, number &n, const coeffs r)
conversion of n to a GMP integer; 0 if not possible
Definition: coeffs.h:555
int iNumberOfParameters
Number of Parameters in the coeffs (default 0)
Definition: coeffs.h:323
int l
Definition: cfEzgcd.cc:94
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
static FORCE_INLINE coeffs n_CoeffRingQuot1(number c, const coeffs r)
Definition: coeffs.h:522
static FORCE_INLINE void n_WriteLong(number &n, const coeffs r)
write to the output buffer of the currently used reporter
Definition: coeffs.h:587
BOOLEAN(*)(*) cfEqual(number a, number b, const coeffs r)
tests
Definition: coeffs.h:227
static FORCE_INLINE void n_ClearDenominators(ICoeffsEnumerator &numberCollectionEnumerator, number &d, const coeffs r)
(inplace) Clears denominators on a collection of numbers number d is the LCM of all the coefficient d...
Definition: coeffs.h:949
used to represent polys as coeffcients
Definition: coeffs.h:35
void n_Print(number &a, const coeffs r)
print a number (BEWARE of string buffers!) mostly for debugging
Definition: numbers.cc:562
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:329
(float), see shortfl.h
Definition: coeffs.h:116
unsigned short * npExpTable
Definition: coeffs.h:376
nCoeffsEnumeratorFunc cfClearDenominators
function pointer behind n_ClearDenominators
Definition: coeffs.h:312
int m_nfM1
representation of -1
Definition: coeffs.h:367
int(* cfParDeg)(number x, const coeffs r)
degree for coeffcients: -1 for 0, 0 for "constants", ...
Definition: coeffs.h:300