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