My Project
Loading...
Searching...
No Matches
Typedefs | Functions
flintcf_Q.cc File Reference
#include <ctype.h>
#include "misc/auxiliary.h"
#include <flint/flint.h>
#include <flint/fmpz.h>
#include <flint/fmpq.h>
#include <flint/fmpq_poly.h>
#include "factory/factory.h"
#include "coeffs/coeffs.h"
#include "coeffs/numbers.h"
#include "coeffs/longrat.h"

Go to the source code of this file.

Typedefs

typedef fmpq_poly_structfmpq_poly_ptr
 
typedef fmpzfmpz_ptr
 

Functions

static charnlEatLong (char *s, mpz_ptr i)
 
static BOOLEAN CoeffIsEqual (const coeffs r, n_coeffType n, void *)
 
static void SetChar (const coeffs)
 
static number Mult (number a, number b, const coeffs)
 
static number Sub (number a, number b, const coeffs)
 
static number Add (number a, number b, const coeffs)
 
static number Div (number a, number b, const coeffs)
 
static number ExactDiv (number a, number b, const coeffs)
 
static number Init (long i, const coeffs)
 
static number InitMPZ (mpz_t i, const coeffs)
 
static int Size (number n, const coeffs)
 
static long Int (number &n, const coeffs)
 
static void MPZ (mpz_t result, number &n, const coeffs)
 
static number Neg (number a, const coeffs)
 
static number Invers (number a, const coeffs)
 
static number Copy (number a, const coeffs)
 
static BOOLEAN IsOne (number a, const coeffs)
 
static BOOLEAN IsZero (number a, const coeffs)
 
static void WriteShort (number a, const coeffs r)
 
static const charRead (const char *st, number *a, const coeffs r)
 
static void Normalize (number &a, const coeffs)
 
static BOOLEAN Greater (number a, number b, const coeffs)
 
static BOOLEAN Equal (number a, number b, const coeffs)
 
static BOOLEAN IsMOne (number k, const coeffs)
 
static BOOLEAN GreaterZero (number, const coeffs)
 
static void Power (number a, int i, number *result, const coeffs)
 
static number GetDenom (number &n, const coeffs)
 
static number GetNumerator (number &n, const coeffs)
 
static number Gcd (number a, number b, const coeffs)
 
static number ExtGcd (number a, number b, number *s, number *t, const coeffs)
 
static number Lcm (number, number, const coeffs)
 
static void Delete (number *a, const coeffs)
 
static nMapFunc SetMap (const coeffs, const coeffs)
 
static number Farey (number, number, const coeffs)
 
static number ChineseRemainder (number *, number *, int, BOOLEAN, CFArray &, const coeffs)
 
static int ParDeg (number x, const coeffs)
 
static number Parameter (const int, const coeffs)
 
static void WriteFd (number a, const ssiInfo *d, const coeffs)
 
static number ReadFd (const ssiInfo *d, const coeffs)
 
static number ConvFactoryNSingN (const CanonicalForm, const coeffs)
 
static CanonicalForm ConvSingNFactoryN (number, BOOLEAN, const coeffs)
 
charCoeffName (const coeffs r)
 
coeffs flintQInitCfByName (char *s, n_coeffType n)
 
static BOOLEAN DBTest (number, const char *, const int, const coeffs)
 
static void KillChar (coeffs cf)
 
BOOLEAN flintQ_InitChar (coeffs cf, void *infoStruct)
 

Typedef Documentation

◆ fmpq_poly_ptr

Definition at line 24 of file flintcf_Q.cc.

◆ fmpz_ptr

Definition at line 25 of file flintcf_Q.cc.

Function Documentation

◆ Add()

static number Add ( number a,
number b,
const coeffs  )
static

Definition at line 70 of file flintcf_Q.cc.

71{
75 return (number)res;
76}
CanonicalForm b
Definition cfModGcd.cc:4111
CanonicalForm res
Definition facAbsFact.cc:60
fmpq_poly_struct * fmpq_poly_ptr
Definition flintcf_Q.cc:24
#define omAlloc(size)

◆ ChineseRemainder()

static number ChineseRemainder ( number * ,
number * ,
int ,
BOOLEAN ,
CFArray & ,
const coeffs  )
static

Definition at line 499 of file flintcf_Q.cc.

500{
501 WerrorS("not yet: ChineseRemainder");
502 return NULL;
503}
void WerrorS(const char *s)
Definition feFopen.cc:24
#define NULL
Definition omList.c:12

◆ CoeffIsEqual()

static BOOLEAN CoeffIsEqual ( const coeffs r,
n_coeffType n,
void *  )
static

Definition at line 48 of file flintcf_Q.cc.

49{
50 return (r->type==n);
51}

◆ CoeffName()

char * CoeffName ( const coeffs r)

Definition at line 600 of file flintcf_Q.cc.

601{
603 sprintf(CoeffName_flint_Q,"flintQp[%s]",r->pParameterNames[0]);
604 return (char*)CoeffName_flint_Q;
605
606}
#define STATIC_VAR
Definition globaldefs.h:7

◆ ConvFactoryNSingN()

static number ConvFactoryNSingN ( const CanonicalForm ,
const coeffs  )
static

Definition at line 590 of file flintcf_Q.cc.

591{
592 WerrorS("not yet: ConvFactoryNSingN");
593 return NULL;
594}

◆ ConvSingNFactoryN()

static CanonicalForm ConvSingNFactoryN ( number ,
BOOLEAN ,
const coeffs  )
static

Definition at line 595 of file flintcf_Q.cc.

596{
597 WerrorS("not yet: ConvSingNFactoryN");
598 return CanonicalForm(0);
599}
factory's main class

◆ Copy()

static number Copy ( number a,
const coeffs  )
static

Definition at line 214 of file flintcf_Q.cc.

◆ DBTest()

static BOOLEAN DBTest ( number ,
const char * ,
const int ,
const coeffs  )
static

Definition at line 625 of file flintcf_Q.cc.

626{
627 return TRUE;
628}
#define TRUE
Definition auxiliary.h:100

◆ Delete()

static void Delete ( number * a,
const coeffs  )
static

Definition at line 460 of file flintcf_Q.cc.

461{
462 if ((*a)!=NULL)
463 {
465 omFree(*a);
466 *a=NULL;
467 }
468}
#define omFree(addr)

◆ Div()

static number Div ( number a,
number b,
const coeffs  )
static

Definition at line 77 of file flintcf_Q.cc.

78{
82 {
84 }
85 else
86 {
92 {
93 WerrorS("cannot divide");
94 }
96 }
97 return (number)res;
98}
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
const char *const nDivBy0
Definition numbers.h:89

◆ Equal()

static BOOLEAN Equal ( number a,
number b,
const coeffs  )
static

Definition at line 380 of file flintcf_Q.cc.

381{
383}

◆ ExactDiv()

static number ExactDiv ( number a,
number b,
const coeffs  )
static

Definition at line 99 of file flintcf_Q.cc.

100{
104 {
106 }
107 else
109 return (number)res;
110}

◆ ExtGcd()

static number ExtGcd ( number a,
number b,
number * s,
number * t,
const coeffs  )
static

Definition at line 446 of file flintcf_Q.cc.

◆ Farey()

static number Farey ( number ,
number ,
const coeffs  )
static

Definition at line 494 of file flintcf_Q.cc.

495{
496 WerrorS("not yet: Farey");
497 return NULL;
498}

◆ flintQ_InitChar()

BOOLEAN flintQ_InitChar ( coeffs cf,
void * infoStruct )

Definition at line 635 of file flintcf_Q.cc.

636{
637 char *pp=(char*)infoStruct;
638 cf->cfCoeffName = CoeffName;
639 cf->nCoeffIsEqual = CoeffIsEqual;
640 cf->cfKillChar = KillChar;
641 cf->cfSetChar = SetChar;
642 cf->ch=0; //char 0
643 cf->cfMult = Mult;
644 cf->cfSub = Sub;
645 cf->cfAdd = Add;
646 cf->cfDiv = Div;
647 cf->cfExactDiv = ExactDiv; // ???
648 cf->cfInit =Init;
649 cf->cfInitMPZ =InitMPZ;
650 cf->cfSize = Size;
651 cf->cfInt = Int;
652 cf->cfMPZ = MPZ;
653 cf->cfInpNeg = Neg;
654 cf->cfInvers = Invers;
655 cf->cfCopy = Copy;
656 cf->cfRePart = Copy;
657 // default: cf->cfImPart = ndReturn0;
658 cf->cfWriteLong = WriteShort; //WriteLong;
659 cf->cfWriteShort = WriteShort;
660 cf->cfRead = Read;
661 cf->cfNormalize = Normalize;
662
663 //cf->cfDivComp=
664 //cf->cfIsUnit=
665 //cf->cfGetUnit=
666 //cf->cfDivBy=
667
668 cf->cfGreater=Greater;
669 cf->cfEqual =Equal;
670 cf->cfIsZero =IsZero;
671 cf->cfIsOne =IsOne;
672 cf->cfIsMOne =IsMOne;
673 cf->cfGreaterZero=GreaterZero;
674
675 cf->cfPower = Power;
676 cf->cfGetDenom = GetDenom;
677 cf->cfGetNumerator = GetNumerator;
678 cf->cfGcd = Gcd;
679 cf->cfExtGcd = ExtGcd;
680 cf->cfLcm = Lcm;
681 cf->cfDelete = Delete;
682 cf->cfSetMap = SetMap;
683 // default: cf->cfInpMult
684 // default: cf->cfInpAdd
685 cf->cfFarey =Farey;
686 cf->cfChineseRemainder=ChineseRemainder;
687 cf->cfParDeg = ParDeg;
688 cf->cfParameter = Parameter;
689 // cf->cfClearContent = ClearContent;
690 // cf->cfClearDenominators = ClearDenominators;
691 cf->convFactoryNSingN=ConvFactoryNSingN;
692 cf->convSingNFactoryN=ConvSingNFactoryN;
693 cf->cfWriteFd = WriteFd;
694 cf->cfReadFd = ReadFd;
695#ifdef LDEBUG
696 cf->cfDBTest = DBTest;
697#endif
698
699 cf->iNumberOfParameters = 1;
700 char **pn=(char**)omAlloc0(sizeof(char*));
701 pn[0]=omStrDup(pp);
702 cf->pParameterNames = (const char **)pn;
703 cf->has_simple_Inverse= FALSE;
704 cf->has_simple_Alloc= FALSE;
705 cf->is_field=FALSE;
706
707 return FALSE;
708}
#define FALSE
Definition auxiliary.h:96
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition cf_gcd.cc:676
CanonicalForm cf
Definition cfModGcd.cc:4091
static number ExtGcd(number a, number b, number *s, number *t, const coeffs)
Definition flintcf_Q.cc:446
static void WriteShort(number a, const coeffs r)
Definition flintcf_Q.cc:232
static number Copy(number a, const coeffs)
Definition flintcf_Q.cc:214
static number ChineseRemainder(number *, number *, int, BOOLEAN, CFArray &, const coeffs)
Definition flintcf_Q.cc:499
static void Normalize(number &a, const coeffs)
Definition flintcf_Q.cc:372
static void SetChar(const coeffs)
Definition flintcf_Q.cc:52
static nMapFunc SetMap(const coeffs, const coeffs)
Definition flintcf_Q.cc:469
static number Farey(number, number, const coeffs)
Definition flintcf_Q.cc:494
static number GetDenom(number &n, const coeffs)
Definition flintcf_Q.cc:422
static const char * Read(const char *st, number *a, const coeffs r)
Definition flintcf_Q.cc:325
static BOOLEAN IsOne(number a, const coeffs)
Definition flintcf_Q.cc:388
char * CoeffName(const coeffs r)
Definition flintcf_Q.cc:600
static number ConvFactoryNSingN(const CanonicalForm, const coeffs)
Definition flintcf_Q.cc:590
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:515
static void Delete(number *a, const coeffs)
Definition flintcf_Q.cc:460
static number Parameter(const int, const coeffs)
Definition flintcf_Q.cc:508
static BOOLEAN DBTest(number, const char *, const int, const coeffs)
Definition flintcf_Q.cc:625
static void KillChar(coeffs cf)
Definition flintcf_Q.cc:630
static CanonicalForm ConvSingNFactoryN(number, BOOLEAN, const coeffs)
Definition flintcf_Q.cc:595
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:560
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:415
static BOOLEAN IsMOne(number k, const coeffs)
Definition flintcf_Q.cc:392
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:430
static BOOLEAN GreaterZero(number, const coeffs)
Definition flintcf_Q.cc:409
static number Gcd(number a, number b, const coeffs)
Definition flintcf_Q.cc:439
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:194
static number Lcm(number, number, const coeffs)
Definition flintcf_Q.cc:455
static int ParDeg(number x, const coeffs)
Definition flintcf_Q.cc:504
static BOOLEAN IsZero(number a, const coeffs)
Definition flintcf_Q.cc:384
static number Neg(number a, const coeffs)
Definition flintcf_Q.cc:189
static BOOLEAN Equal(number a, number b, const coeffs)
Definition flintcf_Q.cc:380
static BOOLEAN Greater(number a, number b, const coeffs)
Definition flintcf_Q.cc:376
static long Int(number &n, const coeffs)
Definition flintcf_Q.cc:142
#define omStrDup(s)
#define omAlloc0(size)

◆ flintQInitCfByName()

coeffs flintQInitCfByName ( char * s,
n_coeffType n )

Definition at line 607 of file flintcf_Q.cc.

608{
609 const char start[]="flintQp[";
610 const int start_len=strlen(start);
611 if (strncmp(s,start,start_len)==0)
612 {
613 s+=start_len;
614 char st[10];
615 int l=sscanf(s,"%s",st);
616 if (l==1)
617 {
618 while (st[strlen(st)-1]==']') st[strlen(st)-1]='\0';
619 return nInitChar(n,(void*)st);
620 }
621 }
622 return NULL;
623}
int l
Definition cfEzgcd.cc:100
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:406

◆ Gcd()

static number Gcd ( number a,
number b,
const coeffs  )
static

Definition at line 439 of file flintcf_Q.cc.

◆ GetDenom()

static number GetDenom ( number & n,
const coeffs  )
static

Definition at line 422 of file flintcf_Q.cc.

423{
428 return (number)res;
429}
CanonicalForm den(const CanonicalForm &f)

◆ GetNumerator()

static number GetNumerator ( number & n,
const coeffs  )
static

◆ Greater()

static BOOLEAN Greater ( number a,
number b,
const coeffs  )
static

Definition at line 376 of file flintcf_Q.cc.

377{
379}

◆ GreaterZero()

static BOOLEAN GreaterZero ( number ,
const coeffs  )
static

Definition at line 409 of file flintcf_Q.cc.

410{
411 // does it have a leading sign?
412 // no: 0 and 1 do not have, everything else is in (...)
413 return TRUE;
414}

◆ Init()

static number Init ( long i,
const coeffs  )
static

Definition at line 120 of file flintcf_Q.cc.

121{
125 return (number)res;
126}
int i
Definition cfEzgcd.cc:132

◆ InitMPZ()

static number InitMPZ ( mpz_t i,
const coeffs  )
static

Definition at line 127 of file flintcf_Q.cc.

128{
132 fmpz_set_mpz(res->coeffs, i);
133 fmpz_one(res->den);
136 return (number)res;
137}
CanonicalForm den() const
den() returns the denominator of CO if CO is a rational number, 1 (from the current domain!...

◆ Int()

static long Int ( number & n,
const coeffs  )
static

Definition at line 142 of file flintcf_Q.cc.

143{
145 {
146 fmpq_t m;
147 fmpq_init(m);
150 if (fmpz_cmp_si(fmpq_numref(m),nl)!=0) nl=0;
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}
int m
Definition cfEzgcd.cc:128

◆ Invers()

static number Invers ( number a,
const coeffs  )
static

Definition at line 194 of file flintcf_Q.cc.

195{
197 {
199 return NULL;
200 }
202 {
206 return (number)res;
207 }
208 else
209 {
210 WerrorS("not invertable");
211 return NULL;
212 }
213}

◆ IsMOne()

static BOOLEAN IsMOne ( number k,
const coeffs  )
static

Definition at line 392 of file flintcf_Q.cc.

393{
394 if (fmpq_poly_length((fmpq_poly_ptr)k)>0) return FALSE;
396 fmpq_t m;
397 fmpq_init(m);
400 if (fmpz_cmp_si(fmpq_numref(m),(long)-1)!=0) result=FALSE;
401 else
402 {
404 if ((dl!=1)||(fmpz_cmp_si(fmpq_denref(m),(long)dl)!=0)) result=FALSE;
405 }
406 fmpq_clear(m);
407 return (result);
408}
int BOOLEAN
Definition auxiliary.h:87
int k
Definition cfEzgcd.cc:99
return result

◆ IsOne()

static BOOLEAN IsOne ( number a,
const coeffs  )
static

Definition at line 388 of file flintcf_Q.cc.

389{
391}

◆ IsZero()

static BOOLEAN IsZero ( number a,
const coeffs  )
static

Definition at line 384 of file flintcf_Q.cc.

385{
387}

◆ KillChar()

static void KillChar ( coeffs cf)
static

Definition at line 630 of file flintcf_Q.cc.

631{
632 omFree((ADDRESS)(cf->pParameterNames[0]));
633 omFreeSize(cf->pParameterNames,sizeof(char*));
634}
#define omFreeSize(addr, size)

◆ Lcm()

static number Lcm ( number ,
number ,
const coeffs  )
static

Definition at line 455 of file flintcf_Q.cc.

456{
457 WerrorS("not yet: Lcm");
458 return NULL;
459}

◆ MPZ()

static void MPZ ( mpz_t result,
number & n,
const coeffs  )
static

Definition at line 158 of file flintcf_Q.cc.

159{
162 {
163#if __FLINT_RELEASE >= 20503
164 fmpq_t m;
165 fmpq_init(m);
167 mpz_t den;
168 mpz_init(den);
170 int dl=(int)mpz_get_si(den);
171 if ((dl!=1)||(mpz_cmp_si(den,(long)dl)!=0)) mpz_set_ui(result,0);
172 mpz_clear(den);
173 fmpq_clear(m);
174#else
175 mpq_t m;
176 mpq_init(m);
178 mpz_t den;
179 mpz_init(den);
182 int dl=(int)mpz_get_si(den);
183 if ((dl!=1)||(mpz_cmp_si(den,(long)dl)!=0)) mpz_set_ui(result,0);
184 mpz_clear(den);
185 mpq_clear(m);
186#endif
187 }
188}

◆ Mult()

static number Mult ( number a,
number b,
const coeffs  )
static

Definition at line 56 of file flintcf_Q.cc.

◆ Neg()

static number Neg ( number a,
const coeffs  )
static

Definition at line 189 of file flintcf_Q.cc.

190{
192 return a;
193}

◆ nlEatLong()

static char * nlEatLong ( char * s,
mpz_ptr i )
static

Definition at line 29 of file flintcf_Q.cc.

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}

◆ Normalize()

static void Normalize ( number & a,
const coeffs  )
static

Definition at line 372 of file flintcf_Q.cc.

◆ Parameter()

static number Parameter ( const int ,
const coeffs  )
static

Definition at line 508 of file flintcf_Q.cc.

509{
513 return (number)res;
514}

◆ ParDeg()

static int ParDeg ( number x,
const coeffs  )
static

Definition at line 504 of file flintcf_Q.cc.

505{
507}
Variable x
Definition cfModGcd.cc:4090

◆ Power()

static void Power ( number a,
int i,
number * result,
const coeffs  )
static

Definition at line 415 of file flintcf_Q.cc.

◆ Read()

static const char * Read ( const char * st,
number * a,
const coeffs r )
static

Definition at line 325 of file flintcf_Q.cc.

326{
327// we only read "monomials" (i.e. [-][digits][parameter]),
328// everythings else (+,*,^,()) is left to the singular interpreter
329 char *s=(char *)st;
330 *a=(number)omAlloc(sizeof(fmpq_poly_t));
332 BOOLEAN neg=FALSE;
333 if (*s=='-') { neg=TRUE; s++;}
334 if (isdigit(*s))
335 {
336 mpz_t z;
337 mpz_init(z);
338 fmpz_t z1;
339 fmpz_init(z1);
340 s=nlEatLong((char *)s, z);
341 fmpz_set_mpz(z1,z);
343 if (*s == '/')
344 {
345 s++;
346 s=nlEatLong((char *)s, z);
347 fmpz_set_mpz(z1,z);
349 }
350 fmpz_clear(z1);
351 mpz_clear(z);
352 }
353 else if(strncmp(s,r->pParameterNames[0],strlen(r->pParameterNames[0]))==0)
354 {
356 s+=strlen(r->pParameterNames[0]);
357 if(isdigit(*s))
358 {
359 int i=1;
360 s=nEati(s,&i,0);
361 if (i!=1)
362 {
365 }
366 }
367 }
368 if (neg)
370 return s;
371}
static char * nlEatLong(char *s, mpz_ptr i)
Definition flintcf_Q.cc:29
char * nEati(char *s, int *i, int m)
divide by the first (leading) number and return it, i.e. make monic
Definition numbers.cc:665

◆ ReadFd()

static number ReadFd ( const ssiInfo * d,
const coeffs  )
static

Definition at line 560 of file flintcf_Q.cc.

561{
562 // format: len a_len .. a_0
565 int l=s_readint(d->f_read);
566 mpz_t tmp;
567 mpz_init(tmp);
568 fmpq_t m;
569 fmpq_init(m);
570 fmpz_t num,den;
571 fmpz_init(num);
572 fmpz_init(den);
573 for (int i=l;i>=0;i--)
574 {
581 }
582 mpz_clear(tmp);
585 fmpq_clear(m);
586 return (number)aa;
587}
#define SSI_BASE
Definition auxiliary.h:135
CanonicalForm num(const CanonicalForm &f)
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

◆ SetChar()

static void SetChar ( const coeffs )
static

Definition at line 52 of file flintcf_Q.cc.

53{
54 // dummy
55}

◆ SetMap()

static nMapFunc SetMap ( const coeffs ,
const coeffs  )
static

Definition at line 469 of file flintcf_Q.cc.

470{
471 WerrorS("not yet: SetMap");
472 return NULL;
473}

◆ Size()

static int Size ( number n,
const coeffs  )
static

Definition at line 138 of file flintcf_Q.cc.

139{
141}

◆ Sub()

static number Sub ( number a,
number b,
const coeffs  )
static

Definition at line 63 of file flintcf_Q.cc.

◆ WriteFd()

static void WriteFd ( number a,
const ssiInfo * d,
const coeffs  )
static

Definition at line 515 of file flintcf_Q.cc.

516{
517 // format: len a_len(num den) .. a_0
519 int l=fmpq_poly_length(aa);
520 fprintf(d->f_write,"%d ",l);
521#if __FLINT_RELEASE >= 20503
522 fmpq_t m;
523 fmpq_init(m);
524 mpz_t num,den;
525 mpz_init(num);
526 mpz_init(den);
527 for(int i=l; i>=0; i--)
528 {
532 fputc(' ',d->f_write);
534 fputc(' ',d->f_write);
535 }
536 mpz_clear(den);
537 mpz_clear(num);
538 fmpq_clear(m);
539#else
540 mpq_t m;
541 mpq_init(m);
542 mpz_t num,den;
543 mpz_init(num);
544 mpz_init(den);
545 for(int i=l; i>=0; i--)
546 {
551 fputc(' ',d->f_write);
553 fputc(' ',d->f_write);
554 }
555 mpz_clear(den);
556 mpz_clear(num);
557 mpq_clear(m);
558#endif
559}
FILE * f_write
Definition s_buff.h:23

◆ WriteShort()

static void WriteShort ( number a,
const coeffs r )
static

Definition at line 232 of file flintcf_Q.cc.

233{
234 //fmpq_poly_print_pretty((fmpq_poly_ptr)a,r->pParameterNames[0]);
235 if (IsOne(a,r)) StringAppendS("1");
236 else if (IsZero(a,r)) StringAppendS("0");
237 else
238 {
239 StringAppendS("(");
240#if __FLINT_RELEASE >= 20503
241 fmpq_t m;
242 fmpq_init(m);
244 for(int i=fmpq_poly_length((fmpq_poly_ptr)a);i>=0;i--)
245 {
247 if (!fmpq_is_zero(m))
248 {
249 if (need_plus && (fmpq_cmp_ui(m,0)>0))
250 StringAppendS("+");
254 l+=2;
255 char *s=(char*)omAlloc(l);
256 char *z=fmpz_get_str(s,10,fmpq_numref(m));
257 if ((i==0)
258 ||(fmpz_cmp_si(fmpq_numref(m),1)!=0)
259 ||(fmpz_cmp_si(fmpq_denref(m),1)!=0))
260 {
261 StringAppendS(z);
262 if (fmpz_cmp_si(fmpq_denref(m),1)!=0)
263 {
264 StringAppendS("/");
266 StringAppendS(z);
267 }
268 if (i!=0) StringAppendS("*");
269 }
270 if (i>1)
271 StringAppend("%s^%d",r->pParameterNames[0],i);
272 else if (i==1)
273 StringAppend("%s",r->pParameterNames[0]);
274 }
275 }
276 fmpq_clear(m);
277#else
278 mpq_t m;
279 mpq_init(m);
280 mpz_t num,den;
281 mpz_init(num);
282 mpz_init(den);
284 for(int i=fmpq_poly_length((fmpq_poly_ptr)a);i>=0;i--)
285 {
289 if (mpz_sgn1(num)!=0)
290 {
291 if (need_plus && (mpz_sgn1(num)>0))
292 StringAppendS("+");
294 int l=mpz_sizeinbase(num,10);
295 l=si_max(l,(int)mpz_sizeinbase(den,10));
296 l+=2;
297 char *s=(char*)omAlloc(l);
298 char *z=mpz_get_str(s,10,num);
299 if ((i==0)
300 ||(mpz_cmp_si(num,1)!=0)
301 ||(mpz_cmp_si(den,1)!=0))
302 {
303 StringAppendS(z);
304 if (mpz_cmp_si(den,1)!=0)
305 {
306 StringAppendS("/");
307 z=mpz_get_str(s,10,den);
308 StringAppendS(z);
309 }
310 if (i!=0) StringAppendS("*");
311 }
312 if (i>1)
313 StringAppend("%s^%d",r->pParameterNames[0],i);
314 else if (i==1)
315 StringAppend("%s",r->pParameterNames[0]);
316 }
317 }
318 mpz_clear(den);
319 mpz_clear(num);
320 mpq_clear(m);
321#endif
322 StringAppendS(")");
323 }
324}
static int si_max(const int a, const int b)
Definition auxiliary.h:124
#define StringAppend
Definition emacs.cc:79
void StringAppendS(const char *st)
Definition reporter.cc:107
#define mpz_sgn1(A)
Definition si_gmp.h:18