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