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