flintcf_Q.cc
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 /*
5 * ABSTRACT: flint: fmpq_poly
6 */
7 #include <ctype.h> /* isdigit*/
8 
9 #ifdef HAVE_CONFIG_H
10 #include "libpolysconfig.h"
11 #endif /* HAVE_CONFIG_H */
12 #include <misc/auxiliary.h>
13 
14 #ifdef SINGULAR_4_1
15 #ifdef HAVE_FLINT
16 
17 #include <flint/flint.h>
18 #include <flint/fmpq_poly.h>
19 #include <factory/factory.h>
20 
21 #include <omalloc/omalloc.h>
22 #include <coeffs/coeffs.h>
23 
24 #include <coeffs/numbers.h>
25 #include <coeffs/longrat.h>
26 
27 typedef fmpq_poly_struct *fmpq_poly_ptr;
28 typedef fmpz *fmpz_ptr;
29 /*2
30 * extracts a long integer from s, returns the rest
31 */
32 static char * nlEatLong(char *s, mpz_ptr i)
33 {
34  const char * start=s;
35 
36  while (*s >= '0' && *s <= '9') s++;
37  if (*s=='\0')
38  {
39  mpz_set_str(i,start,10);
40  }
41  else
42  {
43  char c=*s;
44  *s='\0';
45  mpz_set_str(i,start,10);
46  *s=c;
47  }
48  return s;
49 }
50 
51 static const char* Eati(const char *s, int *i)
52 {
53 
54  if (((*s) >= '0') && ((*s) <= '9'))
55  {
56  unsigned long ii=0L;
57  do
58  {
59  ii *= 10;
60  ii += *s++ - '0';
61  }
62  while (((*s) >= '0') && ((*s) <= '9'));
63  *i=(int)ii;
64  }
65  else (*i) = 1;
66  return s;
67 }
68 
69 
70 
71 static void CoeffWrite(const coeffs r, BOOLEAN details)
72 {
73  Print("// coefficients: flint fmpq_poly\n");
74 }
75 static BOOLEAN CoeffIsEqual(const coeffs r, n_coeffType n, void * parameter)
76 {
77  return (r->type==n);
78 }
79 static void KillChar(coeffs r)
80 {
81  // not yet
82 }
83 static void SetChar(const coeffs r)
84 {
85  // dummy
86 }
87 static number Mult(number a, number b, const coeffs c)
88 {
89  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
90  fmpq_poly_init(res);
91  fmpq_poly_mul(res,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
92  return (number)res;
93 }
94 static number Sub(number a, number b, const coeffs c)
95 {
96  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
97  fmpq_poly_init(res);
98  fmpq_poly_sub(res,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
99  return (number)res;
100 }
101 static number Add(number a, number b, const coeffs c)
102 {
103  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
104  fmpq_poly_init(res);
105  fmpq_poly_add(res,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
106  return (number)res;
107 }
108 static number Div(number a, number b, const coeffs c)
109 {
110  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
111  fmpq_poly_init(res);
112  if(fmpq_poly_is_zero((fmpq_poly_ptr)b))
113  {
114  WerrorS(nDivBy0);
115  }
116  else
117  {
118  fmpq_poly_div(res,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
119  fmpq_poly_t mod;
120  fmpq_poly_init(mod);
121  fmpq_poly_rem(mod,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
122  if (!fmpq_poly_is_zero((fmpq_poly_ptr)mod))
123  {
124  WerrorS("cannot divide");
125  }
126  fmpq_poly_clear(mod);
127  }
128  return (number)res;
129 }
130 static number ExactDiv(number a, number b, const coeffs c)
131 {
132  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
133  fmpq_poly_init(res);
134  if(fmpq_poly_is_zero((fmpq_poly_ptr)b))
135  {
136  WerrorS(nDivBy0);
137  }
138  else
139  fmpq_poly_div(res,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
140  return (number)res;
141 }
142 static number IntMod(number a, number b, const coeffs c)
143 {
144  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
145  fmpq_poly_init(res);
146  fmpq_poly_rem(res,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
147  return (number)res;
148 }
149 static number Init (long i, const coeffs r)
150 {
151  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
152  fmpq_poly_init(res);
153  fmpq_poly_set_si(res,i);
154  return (number)res;
155 }
156 static number InitMPZ (mpz_t i, const coeffs r)
157 {
158  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
159  fmpq_poly_init(res);
160  fmpq_poly_set_mpz(res,i);
161  return (number)res;
162 }
163 static int Size (number n, const coeffs r)
164 {
165  return fmpq_poly_degree((fmpq_poly_ptr)n);
166 }
167 static long Int (number &n, const coeffs r)
168 {
169  if (fmpq_poly_degree((fmpq_poly_ptr)n)==0)
170  {
171  mpq_t m;
172  mpq_init(m);
173  fmpq_poly_get_coeff_mpq(m,(fmpq_poly_ptr)n,0);
174  mpz_t num,den;
175  mpz_init(num);
176  mpz_init(den);
177  mpq_get_num(num,m);
178  mpq_get_den(den,m);
179  long nl=mpz_get_si(num);
180  if (mpz_cmp_si(num,nl)!=0) nl=0;
181  long dl=mpz_get_si(den);
182  if ((dl!=1)||(mpz_cmp_si(den,dl)!=0)) nl=0;
183  mpz_clear(num);
184  mpz_clear(den);
185  mpq_clear(m);
186  return nl;
187  }
188  return 0;
189 }
190 static void MPZ(mpz_t result, number &n, const coeffs r)
191 {
192  mpz_init(result);
193  if (fmpq_poly_degree((fmpq_poly_ptr)n)==0)
194  {
195  mpq_t m;
196  mpq_init(m);
197  fmpq_poly_get_coeff_mpq(m,(fmpq_poly_ptr)n,0);
198  mpz_t den;
199  mpz_init(den);
200  mpq_get_num(result,m);
201  mpq_get_den(den,m);
202  int dl=(int)mpz_get_si(den);
203  if ((dl!=1)||(mpz_cmp_si(den,(long)dl)!=0)) mpz_set_ui(result,0);
204  mpz_clear(den);
205  mpq_clear(m);
206  }
207 }
208 static number Neg(number a, const coeffs r)
209 {
210  fmpq_poly_neg((fmpq_poly_ptr)a,(fmpq_poly_ptr)a);
211  return a;
212 }
213 static number Invers(number a, const coeffs r)
214 {
215  if(fmpq_poly_is_zero((fmpq_poly_ptr)a))
216  {
217  WerrorS(nDivBy0);
218  return NULL;
219  }
220  if (fmpq_poly_degree((fmpq_poly_ptr)a)==0)
221  {
222  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
223  fmpq_poly_init(res);
224  fmpq_poly_inv(res,(fmpq_poly_ptr)a);
225  return (number)res;
226  }
227  else
228  {
229  WerrorS("not invertable");
230  return NULL;
231  }
232 }
233 static number Copy(number a, const coeffs r)
234 {
235  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
236  fmpq_poly_init(res);
237  fmpq_poly_set(res,(fmpq_poly_ptr)a);
238  return (number)res;
239 }
240 //static number RePart(number a, const coeffs r)
241 //{
242 //}
243 //static number ImPart(number a, const coeffs r)
244 //{
245 //}
246 static BOOLEAN IsOne (number a, const coeffs r);
247 static BOOLEAN IsZero (number a, const coeffs r);
248 //static void WriteLong(number &a, const coeffs r)
249 //{
250 //}
251 static void WriteShort(number a, const coeffs r)
252 {
253  //fmpq_poly_print_pretty((fmpq_poly_ptr)a,r->pParameterNames[0]);
254  if (IsOne(a,r)) StringAppendS("1");
255  else if (IsZero(a,r)) StringAppendS("0");
256  else
257  {
258  StringAppendS("(");
259  mpq_t m;
260  mpq_init(m);
261  mpz_t num,den;
262  mpz_init(num);
263  mpz_init(den);
264  BOOLEAN need_plus=FALSE;
265  for(int i=fmpq_poly_length((fmpq_poly_ptr)a);i>=0;i--)
266  {
267  fmpq_poly_get_coeff_mpq(m,(fmpq_poly_ptr)a,i);
268  mpq_get_num(num,m);
269  mpq_get_den(den,m);
270  if (mpz_cmp_ui(num,0)!=0)
271  {
272  if (need_plus && (mpz_cmp_si(num,0)>0))
273  StringAppendS("+");
274  need_plus=TRUE;
275  int l=mpz_sizeinbase(num,10);
276  l=si_max(l,(int)mpz_sizeinbase(den,10));
277  l+=2;
278  char *s=(char*)omAlloc(l);
279  char *z=mpz_get_str(s,10,num);
280  if ((i==0)
281  ||(mpz_cmp_si(num,1)!=0)
282  ||(mpz_cmp_si(den,1)!=0))
283  {
284  StringAppendS(z);
285  if (mpz_cmp_si(den,1)!=0)
286  {
287  StringAppendS("/");
288  z=mpz_get_str(s,10,den);
289  StringAppendS(z);
290  }
291  if (i!=0) StringAppendS("*");
292  }
293  if (i>1)
294  StringAppend("%s^%d",r->pParameterNames[0],i);
295  else if (i==1)
296  StringAppend("%s",r->pParameterNames[0]);
297  }
298  }
299  mpz_clear(den);
300  mpz_clear(num);
301  mpq_clear(m);
302  StringAppendS(")");
303  }
304 }
305 static const char* Read(const char * st, number * a, const coeffs r)
306 {
307 // we only read "monomials" (i.e. [-][digits][parameter]),
308 // everythings else (+,*,^,()) is left to the singular interpreter
309  const char *s=st;
310  *a=(number)omAlloc(sizeof(fmpq_poly_t));
311  fmpq_poly_init((fmpq_poly_ptr)(*a));
312  BOOLEAN neg=FALSE;
313  if (*s=='-') { neg=TRUE; s++;}
314  if (isdigit(*s))
315  {
316  mpz_t z;
317  mpz_init(z);
318  s=nlEatLong((char *)s, z);
319  fmpq_poly_set_mpz((fmpq_poly_ptr)(*a),z);
320  if (*s == '/')
321  {
322  s++;
323  s=nlEatLong((char *)s, z);
324  fmpq_poly_scalar_div_mpz((fmpq_poly_ptr)(*a),(fmpq_poly_ptr)(*a),z);
325  }
326  mpz_clear(z);
327  }
328  else if(strncmp(s,r->pParameterNames[0],strlen(r->pParameterNames[0]))==0)
329  {
330  fmpq_poly_set_coeff_si((fmpq_poly_ptr)(*a),1,1);
331  s+=strlen(r->pParameterNames[0]);
332  if(isdigit(*s))
333  {
334  int i=1;
335  s=Eati(s,&i);
336  if (i!=1)
337  {
338  fmpq_poly_set_coeff_si((fmpq_poly_ptr)(*a),1,0);
339  fmpq_poly_set_coeff_si((fmpq_poly_ptr)(*a),i,1);
340  }
341  }
342  }
343  if (neg)
344  fmpq_poly_neg((fmpq_poly_ptr)(*a),(fmpq_poly_ptr)(*a));
345  return s;
346 }
347 static void Normalize(number &a, const coeffs r)
348 {
349  fmpq_poly_canonicalise((fmpq_poly_ptr)a);
350 }
351 static BOOLEAN Greater (number a, number b, const coeffs r)
352 {
353  return (fmpq_poly_cmp((fmpq_poly_ptr)a,(fmpq_poly_ptr)b)>0);
354 }
355 static BOOLEAN Equal (number a, number b, const coeffs r)
356 {
357  return (fmpq_poly_equal((fmpq_poly_ptr)a,(fmpq_poly_ptr)b));
358 }
359 static BOOLEAN IsZero (number a, const coeffs r)
360 {
361  return fmpq_poly_is_zero((fmpq_poly_ptr)a);
362 }
363 static BOOLEAN IsOne (number a, const coeffs r)
364 {
365  return fmpq_poly_is_one((fmpq_poly_ptr)a);
366 }
367 static BOOLEAN IsMOne (number k, const coeffs r)
368 {
369  if (fmpq_poly_length((fmpq_poly_ptr)k)>0) return FALSE;
370  fmpq_poly_canonicalise((fmpq_poly_ptr)k);
371  mpq_t m;
372  mpq_init(m);
373  fmpq_poly_get_coeff_mpq(m,(fmpq_poly_ptr)k,0);
374  mpz_t num,den;
375  mpz_init(num);
376  mpq_get_num(num,m);
378  if (mpz_cmp_si(num,(long)-1)!=0) result=FALSE;
379  else
380  {
381  mpz_init(den);
382  mpq_get_den(den,m);
383  int dl=(int)mpz_get_si(den);
384  if ((dl!=1)||(mpz_cmp_si(den,(long)dl)!=0)) result=FALSE;
385  mpz_clear(den);
386  }
387  mpz_clear(num);
388  mpq_clear(m);
389  return (result);
390 }
391 static BOOLEAN GreaterZero (number k, const coeffs r)
392 {
393  // does it have a leading sign?
394  // no: 0 and 1 do not have, everything else is in (...)
395  return TRUE;
396 }
397 static void Power(number a, int i, number * result, const coeffs r)
398 {
399  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
400  fmpq_poly_init(res);
401  *result=(number)res;
402  fmpq_poly_pow((fmpq_poly_ptr)(*result),(fmpq_poly_ptr)a,i);
403 }
404 static number GetDenom(number &n, const coeffs r)
405 {
406  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
407  fmpq_poly_init(res);
408  fmpz_ptr den=fmpq_poly_denref(res);
409  fmpq_poly_set_fmpz(res,den);
410  return (number)res;
411 }
412 static number GetNumerator(number &n, const coeffs r)
413 {
414  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
415  fmpq_poly_init(res);
416  fmpq_poly_set(res,(fmpq_poly_ptr)n);
417  fmpz_ptr den=fmpq_poly_denref(res);
418  fmpq_poly_scalar_mul_fmpz(res,res,den);
419  return (number)res;
420 }
421 static number Gcd(number a, number b, const coeffs r)
422 {
423  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
424  fmpq_poly_init(res);
425  fmpq_poly_gcd(res,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
426  return (number)res;
427 }
428 static number ExtGcd(number a, number b, number *s, number *t,const coeffs r)
429 {
430  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
431  fmpq_poly_init(res);
432  fmpq_poly_init((fmpq_poly_ptr)*s);
433  fmpq_poly_init((fmpq_poly_ptr)*t);
434  fmpq_poly_xgcd(res,(fmpq_poly_ptr)*s,(fmpq_poly_ptr)*t,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
435  return (number)res;
436 }
437 static number Lcm(number a, number b, const coeffs r)
438 {
439  WerrorS("not yet: Lcm");
440 }
441 static void Delete(number * a, const coeffs r)
442 {
443  if ((*a)!=NULL)
444  {
445  fmpq_poly_clear((fmpq_poly_ptr)*a);
446  omFree(*a);
447  *a=NULL;
448  }
449 }
450 static nMapFunc SetMap(const coeffs src, const coeffs dst)
451 {
452  WerrorS("not yet: SetMap");
453  return NULL;
454 }
455 //static void InpMult(number &a, number b, const coeffs r)
456 //{
457 //}
458 //static void InpAdd(number &a, number b, const coeffs r)
459 //{
460 //}
461 static number Init_bigint(number i, const coeffs dummy, const coeffs dst)
462 {
463  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
464  fmpq_poly_init(res);
465  if (SR_HDL(i) & SR_INT)
466  {
467  fmpq_poly_set_si(res,SR_TO_INT(i));
468  }
469  else
470  fmpq_poly_set_mpz(res,i->z);
471  return (number)res;
472 }
473 static number Farey(number p, number n, const coeffs)
474 {
475  WerrorS("not yet: Farey");
476 }
477 static number ChineseRemainder(number *x, number *q,int rl, BOOLEAN sym,CFArray &inv_cache,const coeffs)
478 {
479  WerrorS("not yet: ChineseRemainder");
480 }
481 static int ParDeg(number x,const coeffs r)
482 {
483  return fmpq_poly_degree((fmpq_poly_ptr)x);
484 }
485 static number Parameter(const int i, const coeffs r)
486 {
487  fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
488  fmpq_poly_init(res);
489  fmpq_poly_set_coeff_si(res,1,1);
490  return (number)res;
491 }
492 static void WriteFd(number a, FILE *f, const coeffs)
493 {
494  // format: len a_len(num den) .. a_0
496  int l=fmpq_poly_length(aa);
497  fprintf(f,"%d ",l);
498  mpq_t m;
499  mpq_init(m);
500  mpz_t num,den;
501  mpz_init(num);
502  mpz_init(den);
503  for(int i=l; i>=0; i--)
504  {
505  fmpq_poly_get_coeff_mpq(m,(fmpq_poly_ptr)a,i);
506  mpq_get_num(num,m);
507  mpq_get_den(den,m);
508  mpz_out_str (f,SSI_BASE, num);
509  fputc(' ',f);
510  mpz_out_str (f,SSI_BASE, den);
511  fputc(' ',f);
512  }
513  mpz_clear(den);
514  mpz_clear(num);
515  mpq_clear(m);
516 }
517 static number ReadFd(s_buff f, const coeffs)
518 {
519  // format: len a_len .. a_0
520  fmpq_poly_ptr aa=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
521  fmpq_poly_init(aa);
522  int l=s_readint(f);
523  mpz_t nm;
524  mpz_init(nm);
525  mpq_t m;
526  mpq_init(m);
527  for (int i=l;i>=0;i--)
528  {
529 
530  s_readmpz_base (f,nm, SSI_BASE);
531  mpq_set_num(m,nm);
532  s_readmpz_base (f,nm, SSI_BASE);
533  mpq_set_den(m,nm);
534  fmpq_poly_set_coeff_mpq(aa,i,m);
535  }
536  mpz_clear(nm);
537  mpq_clear(m);
538  return (number)aa;
539 }
540 // cfClearContent
541 // cfClearDenominators
542 static number ConvFactoryNSingN( const CanonicalForm n, const coeffs r)
543 {
544  WerrorS("not yet: ConvFactoryNSingN");
545 }
546 static CanonicalForm ConvSingNFactoryN( number n, BOOLEAN setChar, const coeffs r )
547 {
548  WerrorS("not yet: ConvSingNFactoryN");
549 }
550 char * CoeffName(const coeffs r)
551 {
552  return (char*)"flint:Q[a]";
553 }
554 static char* CoeffString(const coeffs r)
555 {
556  return omStrDup(CoeffName(r));
557 }
558 #ifdef LDEBUG
559 static BOOLEAN DBTest(number a, const char *f, const int l, const coeffs r)
560 {
561  return TRUE;
562 }
563 #endif
564 BOOLEAN flintQ_InitChar(coeffs cf, void * infoStruct)
565 {
566  cf->cfCoeffString = CoeffString;
567  cf->cfCoeffName = CoeffName;
568  cf->cfCoeffWrite = CoeffWrite;
569  cf->nCoeffIsEqual = CoeffIsEqual;
570  cf->cfKillChar = KillChar;
571  cf->cfSetChar = SetChar;
572  cf->ch=0; //char 0
573  cf->cfMult = Mult;
574  cf->cfSub = Sub;
575  cf->cfAdd = Add;
576  cf->cfDiv = Div;
577  cf->cfExactDiv = ExactDiv; // ???
578  cf->cfInit =Init;
579  cf->cfInitMPZ =InitMPZ;
580  cf->cfSize = Size;
581  cf->cfInt = Int;
582  cf->cfMPZ = MPZ;
583  cf->cfInpNeg = Neg;
584  cf->cfInvers = Invers;
585  cf->cfCopy = Copy;
586  cf->cfRePart = Copy;
587  // default: cf->cfImPart = ndReturn0;
588  cf->cfWriteLong = WriteShort; //WriteLong;
589  cf->cfWriteShort = WriteShort;
590  cf->cfRead = Read;
591  cf->cfNormalize = Normalize;
592 
593  //cf->cfDivComp=
594  //cf->cfIsUnit=
595  //cf->cfGetUnit=
596  //cf->cfDivBy=
597 
598  cf->cfGreater=Greater;
599  cf->cfEqual =Equal;
600  cf->cfIsZero =IsZero;
601  cf->cfIsOne =IsOne;
602  cf->cfIsMOne =IsMOne;
603  cf->cfGreaterZero=GreaterZero;
604 
605  cf->cfPower = Power;
606  cf->cfGetDenom = GetDenom;
607  cf->cfGetNumerator = GetNumerator;
608  cf->cfGcd = Gcd;
609  cf->cfExtGcd = ExtGcd;
610  cf->cfLcm = Lcm;
611  cf->cfDelete = Delete;
612  cf->cfSetMap = SetMap;
613  // default: cf->cfInpMult
614  // default: cf->cfInpAdd
615  cf->cfFarey =Farey;
616  cf->cfChineseRemainder=ChineseRemainder;
617  cf->cfParDeg = ParDeg;
618  cf->cfParameter = Parameter;
619  // cf->cfClearContent = ClearContent;
620  // cf->cfClearDenominators = ClearDenominators;
621  cf->convFactoryNSingN=ConvFactoryNSingN;
622  cf->convSingNFactoryN=ConvSingNFactoryN;
623  cf->cfWriteFd = WriteFd;
624  cf->cfReadFd = ReadFd;
625 #ifdef LDEBUG
626  cf->cfDBTest = DBTest;
627 #endif
628 
629  cf->iNumberOfParameters = 1;
630  char **pn=(char**)omAlloc0(sizeof(char*));
631  pn[0]=(char*)omStrDup("a");
632  cf->pParameterNames = (const char **)pn;
633  cf->has_simple_Inverse= FALSE;
634  cf->has_simple_Alloc= FALSE;
635  cf->is_field=FALSE;
636 
637  return FALSE;
638 }
639 #endif
640 #endif
BOOLEAN flintQ_InitChar(coeffs cf, void *infoStruct)
Definition: flintcf_Q.cc:564
static number IntMod(number a, number b, const coeffs c)
Definition: flintcf_Q.cc:142
static number ReadFd(s_buff f, const coeffs)
Definition: flintcf_Q.cc:517
static number Copy(number a, const coeffs r)
Definition: flintcf_Q.cc:233
const CanonicalForm int s
Definition: facAbsFact.cc:55
static int ParDeg(number x, const coeffs r)
Definition: flintcf_Q.cc:481
const poly a
Definition: syzextra.cc:212
#define Print
Definition: emacs.cc:83
CF_NO_INLINE CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
Definition: cf_inline.cc:564
static long Int(number &n, const coeffs r)
Definition: flintcf_Q.cc:167
static number Parameter(const int i, const coeffs r)
Definition: flintcf_Q.cc:485
CanonicalForm num(const CanonicalForm &f)
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
static BOOLEAN Equal(number a, number b, const coeffs r)
Definition: flintcf_Q.cc:355
static void WriteShort(number a, const coeffs r)
Definition: flintcf_Q.cc:251
char * CoeffName(const coeffs r)
Definition: flintcf_Q.cc:550
static nMapFunc SetMap(const coeffs src, const coeffs dst)
Definition: flintcf_Q.cc:450
static int Size(number n, const coeffs r)
Definition: flintcf_Q.cc:163
static number Neg(number a, const coeffs r)
Definition: flintcf_Q.cc:208
static char * nlEatLong(char *s, mpz_ptr i)
Definition: flintcf_Q.cc:32
factory&#39;s main class
Definition: canonicalform.h:75
static number GetDenom(number &n, const coeffs r)
Definition: flintcf_Q.cc:404
#define TRUE
Definition: auxiliary.h:144
fmpz * fmpz_ptr
Definition: flintcf_Q.cc:28
static number GetNumerator(number &n, const coeffs r)
Definition: flintcf_Q.cc:412
static CanonicalForm ConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition: flintcf_Q.cc:546
static const char * Read(const char *st, number *a, const coeffs r)
Definition: flintcf_Q.cc:305
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
void s_readmpz_base(s_buff F, mpz_ptr a, int base)
Definition: s_buff.cc:217
static void KillChar(coeffs r)
Definition: flintcf_Q.cc:79
#define omAlloc(size)
Definition: omAllocDecl.h:210
poly res
Definition: myNF.cc:322
static void Power(number a, int i, number *result, const coeffs r)
Definition: flintcf_Q.cc:397
const ring r
Definition: syzextra.cc:208
Coefficient rings, fields and other domains suitable for Singular polynomials.
int s_readint(s_buff F)
Definition: s_buff.cc:120
static void Normalize(number &a, const coeffs r)
Definition: flintcf_Q.cc:347
#define omFree(addr)
Definition: omAllocDecl.h:261
The main handler for Singular numbers which are suitable for Singular polynomials.
static number ExtGcd(number a, number b, number *s, number *t, const coeffs r)
Definition: flintcf_Q.cc:428
void StringAppendS(const char *st)
Definition: reporter.cc:107
static number ChineseRemainder(number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs)
Definition: flintcf_Q.cc:477
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:72
static char * CoeffString(const coeffs r)
Definition: flintcf_Q.cc:554
static void MPZ(mpz_t result, number &n, const coeffs r)
Definition: flintcf_Q.cc:190
All the auxiliary stuff.
static BOOLEAN IsMOne(number k, const coeffs r)
Definition: flintcf_Q.cc:367
int m
Definition: cfEzgcd.cc:119
static void WriteFd(number a, FILE *f, const coeffs)
Definition: flintcf_Q.cc:492
const char *const nDivBy0
Definition: numbers.h:83
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
#define SSI_BASE
Definition: auxiliary.h:177
#define StringAppend
Definition: emacs.cc:82
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
static const char * Eati(const char *s, int *i)
Definition: flintcf_Q.cc:51
static number ExactDiv(number a, number b, const coeffs c)
Definition: flintcf_Q.cc:130
static number ConvFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: flintcf_Q.cc:542
static void Delete(number *a, const coeffs r)
Definition: flintcf_Q.cc:441
static number Gcd(number a, number b, const coeffs r)
Definition: flintcf_Q.cc:421
static BOOLEAN IsOne(number a, const coeffs r)
Definition: flintcf_Q.cc:363
static number Invers(number a, const coeffs r)
Definition: flintcf_Q.cc:213
#define SR_TO_INT(SR)
Definition: longrat.h:67
static number Init(long i, const coeffs r)
Definition: flintcf_Q.cc:149
static BOOLEAN Greater(number a, number b, const coeffs r)
Definition: flintcf_Q.cc:351
static BOOLEAN DBTest(number a, const char *f, const int l, const coeffs r)
Definition: flintcf_Q.cc:559
n_coeffType
Definition: coeffs.h:27
static number Div(number a, number b, const coeffs c)
Definition: flintcf_Q.cc:108
static number Sub(number a, number b, const coeffs c)
Definition: flintcf_Q.cc:94
CanonicalForm cf
Definition: cfModGcd.cc:4024
static BOOLEAN GreaterZero(number k, const coeffs r)
Definition: flintcf_Q.cc:391
#define NULL
Definition: omList.c:10
CanonicalForm den(const CanonicalForm &f)
#define SR_INT
Definition: longrat.h:65
static void SetChar(const coeffs r)
Definition: flintcf_Q.cc:83
Variable x
Definition: cfModGcd.cc:4023
static number Farey(number p, number n, const coeffs)
Definition: flintcf_Q.cc:473
static BOOLEAN IsZero(number a, const coeffs r)
Definition: flintcf_Q.cc:359
static number InitMPZ(mpz_t i, const coeffs r)
Definition: flintcf_Q.cc:156
#define SR_HDL(A)
Definition: tgb.cc:35
static void CoeffWrite(const coeffs r, BOOLEAN details)
Definition: flintcf_Q.cc:71
static BOOLEAN CoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: flintcf_Q.cc:75
fmpq_poly_struct * fmpq_poly_ptr
Definition: flintcf_Q.cc:27
int BOOLEAN
Definition: auxiliary.h:131
const poly b
Definition: syzextra.cc:213
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
return result
Definition: facAbsBiFact.cc:76
static number Add(number a, number b, const coeffs c)
Definition: flintcf_Q.cc:101
static number Mult(number a, number b, const coeffs c)
Definition: flintcf_Q.cc:87
static number Init_bigint(number i, const coeffs dummy, const coeffs dst)
Definition: flintcf_Q.cc:461
#define omStrDup(s)
Definition: omAllocDecl.h:263
static number Lcm(number a, number b, const coeffs r)
Definition: flintcf_Q.cc:437