My Project
Loading...
Searching...
No Matches
Typedefs | Functions
flintcf_Q.cc File Reference
#include <ctype.h>
#include "misc/auxiliary.h"
#include <gmp.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 25 of file flintcf_Q.cc.

◆ fmpz_ptr

Definition at line 26 of file flintcf_Q.cc.

Function Documentation

◆ Add()

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

Definition at line 71 of file flintcf_Q.cc.

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

◆ ChineseRemainder()

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

Definition at line 500 of file flintcf_Q.cc.

501{
502 WerrorS("not yet: ChineseRemainder");
503 return NULL;
504}
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 49 of file flintcf_Q.cc.

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

◆ CoeffName()

char * CoeffName ( const coeffs  r)

Definition at line 601 of file flintcf_Q.cc.

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

◆ ConvFactoryNSingN()

static number ConvFactoryNSingN ( const CanonicalForm  ,
const coeffs   
)
static

Definition at line 591 of file flintcf_Q.cc.

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

◆ ConvSingNFactoryN()

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

Definition at line 596 of file flintcf_Q.cc.

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

◆ Copy()

static number Copy ( number  a,
const coeffs   
)
static

Definition at line 215 of file flintcf_Q.cc.

◆ DBTest()

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

Definition at line 626 of file flintcf_Q.cc.

627{
628 return TRUE;
629}
#define TRUE
Definition auxiliary.h:101

◆ Delete()

static void Delete ( number a,
const coeffs   
)
static

Definition at line 461 of file flintcf_Q.cc.

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

◆ Div()

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

Definition at line 78 of file flintcf_Q.cc.

79{
83 {
85 }
86 else
87 {
93 {
94 WerrorS("cannot divide");
95 }
97 }
98 return (number)res;
99}
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 381 of file flintcf_Q.cc.

382{
384}

◆ ExactDiv()

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

Definition at line 100 of file flintcf_Q.cc.

101{
105 {
107 }
108 else
110 return (number)res;
111}

◆ ExtGcd()

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

Definition at line 447 of file flintcf_Q.cc.

◆ Farey()

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

Definition at line 495 of file flintcf_Q.cc.

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

◆ flintQ_InitChar()

BOOLEAN flintQ_InitChar ( coeffs  cf,
void infoStruct 
)

Definition at line 636 of file flintcf_Q.cc.

637{
638 char *pp=(char*)infoStruct;
639 cf->cfCoeffName = CoeffName;
640 cf->nCoeffIsEqual = CoeffIsEqual;
641 cf->cfKillChar = KillChar;
642 cf->cfSetChar = SetChar;
643 cf->ch=0; //char 0
644 cf->cfMult = Mult;
645 cf->cfSub = Sub;
646 cf->cfAdd = Add;
647 cf->cfDiv = Div;
648 cf->cfExactDiv = ExactDiv; // ???
649 cf->cfInit =Init;
650 cf->cfInitMPZ =InitMPZ;
651 cf->cfSize = Size;
652 cf->cfInt = Int;
653 cf->cfMPZ = MPZ;
654 cf->cfInpNeg = Neg;
655 cf->cfInvers = Invers;
656 cf->cfCopy = Copy;
657 cf->cfRePart = Copy;
658 // default: cf->cfImPart = ndReturn0;
659 cf->cfWriteLong = WriteShort; //WriteLong;
660 cf->cfWriteShort = WriteShort;
661 cf->cfRead = Read;
662 cf->cfNormalize = Normalize;
663
664 //cf->cfDivComp=
665 //cf->cfIsUnit=
666 //cf->cfGetUnit=
667 //cf->cfDivBy=
668
669 cf->cfGreater=Greater;
670 cf->cfEqual =Equal;
671 cf->cfIsZero =IsZero;
672 cf->cfIsOne =IsOne;
673 cf->cfIsMOne =IsMOne;
674 cf->cfGreaterZero=GreaterZero;
675
676 cf->cfPower = Power;
677 cf->cfGetDenom = GetDenom;
678 cf->cfGetNumerator = GetNumerator;
679 cf->cfGcd = Gcd;
680 cf->cfExtGcd = ExtGcd;
681 cf->cfLcm = Lcm;
682 cf->cfDelete = Delete;
683 cf->cfSetMap = SetMap;
684 // default: cf->cfInpMult
685 // default: cf->cfInpAdd
686 cf->cfFarey =Farey;
687 cf->cfChineseRemainder=ChineseRemainder;
688 cf->cfParDeg = ParDeg;
689 cf->cfParameter = Parameter;
690 // cf->cfClearContent = ClearContent;
691 // cf->cfClearDenominators = ClearDenominators;
692 cf->convFactoryNSingN=ConvFactoryNSingN;
693 cf->convSingNFactoryN=ConvSingNFactoryN;
694 cf->cfWriteFd = WriteFd;
695 cf->cfReadFd = ReadFd;
696#ifdef LDEBUG
697 cf->cfDBTest = DBTest;
698#endif
699
700 cf->iNumberOfParameters = 1;
701 char **pn=(char**)omAlloc0(sizeof(char*));
702 pn[0]=omStrDup(pp);
703 cf->pParameterNames = (const char **)pn;
704 cf->has_simple_Inverse= FALSE;
705 cf->has_simple_Alloc= FALSE;
706 cf->is_field=FALSE;
707
708 return FALSE;
709}
#define FALSE
Definition auxiliary.h:97
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:447
static void WriteShort(number a, const coeffs r)
Definition flintcf_Q.cc:233
static number Copy(number a, const coeffs)
Definition flintcf_Q.cc:215
static number ChineseRemainder(number *, number *, int, BOOLEAN, CFArray &, const coeffs)
Definition flintcf_Q.cc:500
static void Normalize(number &a, const coeffs)
Definition flintcf_Q.cc:373
static void SetChar(const coeffs)
Definition flintcf_Q.cc:53
static nMapFunc SetMap(const coeffs, const coeffs)
Definition flintcf_Q.cc:470
static number Farey(number, number, const coeffs)
Definition flintcf_Q.cc:495
static number GetDenom(number &n, const coeffs)
Definition flintcf_Q.cc:423
static const char * Read(const char *st, number *a, const coeffs r)
Definition flintcf_Q.cc:326
static BOOLEAN IsOne(number a, const coeffs)
Definition flintcf_Q.cc:389
char * CoeffName(const coeffs r)
Definition flintcf_Q.cc:601
static number ConvFactoryNSingN(const CanonicalForm, const coeffs)
Definition flintcf_Q.cc:591
static number InitMPZ(mpz_t i, const coeffs)
Definition flintcf_Q.cc:128
static int Size(number n, const coeffs)
Definition flintcf_Q.cc:139
static number Add(number a, number b, const coeffs)
Definition flintcf_Q.cc:71
static number Div(number a, number b, const coeffs)
Definition flintcf_Q.cc:78
static void WriteFd(number a, const ssiInfo *d, const coeffs)
Definition flintcf_Q.cc:516
static void Delete(number *a, const coeffs)
Definition flintcf_Q.cc:461
static number Parameter(const int, const coeffs)
Definition flintcf_Q.cc:509
static BOOLEAN DBTest(number, const char *, const int, const coeffs)
Definition flintcf_Q.cc:626
static void KillChar(coeffs cf)
Definition flintcf_Q.cc:631
static CanonicalForm ConvSingNFactoryN(number, BOOLEAN, const coeffs)
Definition flintcf_Q.cc:596
static number Init(long i, const coeffs)
Definition flintcf_Q.cc:121
static void MPZ(mpz_t result, number &n, const coeffs)
Definition flintcf_Q.cc:159
static number ReadFd(const ssiInfo *d, const coeffs)
Definition flintcf_Q.cc:561
static number ExactDiv(number a, number b, const coeffs)
Definition flintcf_Q.cc:100
static void Power(number a, int i, number *result, const coeffs)
Definition flintcf_Q.cc:416
static BOOLEAN IsMOne(number k, const coeffs)
Definition flintcf_Q.cc:393
static number Sub(number a, number b, const coeffs)
Definition flintcf_Q.cc:64
static number GetNumerator(number &n, const coeffs)
Definition flintcf_Q.cc:431
static BOOLEAN GreaterZero(number, const coeffs)
Definition flintcf_Q.cc:410
static number Gcd(number a, number b, const coeffs)
Definition flintcf_Q.cc:440
static BOOLEAN CoeffIsEqual(const coeffs r, n_coeffType n, void *)
Definition flintcf_Q.cc:49
static number Mult(number a, number b, const coeffs)
Definition flintcf_Q.cc:57
static number Invers(number a, const coeffs)
Definition flintcf_Q.cc:195
static number Lcm(number, number, const coeffs)
Definition flintcf_Q.cc:456
static int ParDeg(number x, const coeffs)
Definition flintcf_Q.cc:505
static BOOLEAN IsZero(number a, const coeffs)
Definition flintcf_Q.cc:385
static number Neg(number a, const coeffs)
Definition flintcf_Q.cc:190
static BOOLEAN Equal(number a, number b, const coeffs)
Definition flintcf_Q.cc:381
static BOOLEAN Greater(number a, number b, const coeffs)
Definition flintcf_Q.cc:377
static long Int(number &n, const coeffs)
Definition flintcf_Q.cc:143
#define omStrDup(s)
#define omAlloc0(size)

◆ flintQInitCfByName()

coeffs flintQInitCfByName ( char s,
n_coeffType  n 
)

Definition at line 608 of file flintcf_Q.cc.

609{
610 const char start[]="flintQp[";
611 const int start_len=strlen(start);
612 if (strncmp(s,start,start_len)==0)
613 {
614 s+=start_len;
615 char st[10];
616 int l=sscanf(s,"%s",st);
617 if (l==1)
618 {
619 while (st[strlen(st)-1]==']') st[strlen(st)-1]='\0';
620 return nInitChar(n,(void*)st);
621 }
622 }
623 return NULL;
624}
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 440 of file flintcf_Q.cc.

◆ GetDenom()

static number GetDenom ( number n,
const coeffs   
)
static

Definition at line 423 of file flintcf_Q.cc.

424{
429 return (number)res;
430}
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 377 of file flintcf_Q.cc.

378{
380}

◆ GreaterZero()

static BOOLEAN GreaterZero ( number  ,
const coeffs   
)
static

Definition at line 410 of file flintcf_Q.cc.

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

◆ Init()

static number Init ( long  i,
const coeffs   
)
static

Definition at line 121 of file flintcf_Q.cc.

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

◆ InitMPZ()

static number InitMPZ ( mpz_t  i,
const coeffs   
)
static

Definition at line 128 of file flintcf_Q.cc.

129{
133 fmpz_set_mpz(res->coeffs, i);
134 fmpz_one(res->den);
137 return (number)res;
138}
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 143 of file flintcf_Q.cc.

144{
146 {
147 fmpq_t m;
148 fmpq_init(m);
151 if (fmpz_cmp_si(fmpq_numref(m),nl)!=0) nl=0;
153 if ((dl!=1)||(fmpz_cmp_si(fmpq_denref(m),dl)!=0)) nl=0;
154 fmpq_clear(m);
155 return nl;
156 }
157 return 0;
158}
int m
Definition cfEzgcd.cc:128

◆ Invers()

static number Invers ( number  a,
const coeffs   
)
static

Definition at line 195 of file flintcf_Q.cc.

196{
198 {
200 return NULL;
201 }
203 {
207 return (number)res;
208 }
209 else
210 {
211 WerrorS("not invertable");
212 return NULL;
213 }
214}

◆ IsMOne()

static BOOLEAN IsMOne ( number  k,
const coeffs   
)
static

Definition at line 393 of file flintcf_Q.cc.

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

◆ IsOne()

static BOOLEAN IsOne ( number  a,
const coeffs   
)
static

Definition at line 389 of file flintcf_Q.cc.

390{
392}

◆ IsZero()

static BOOLEAN IsZero ( number  a,
const coeffs   
)
static

Definition at line 385 of file flintcf_Q.cc.

386{
388}

◆ KillChar()

static void KillChar ( coeffs  cf)
static

Definition at line 631 of file flintcf_Q.cc.

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

◆ Lcm()

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

Definition at line 456 of file flintcf_Q.cc.

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

◆ MPZ()

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

Definition at line 159 of file flintcf_Q.cc.

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

◆ Mult()

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

Definition at line 57 of file flintcf_Q.cc.

◆ Neg()

static number Neg ( number  a,
const coeffs   
)
static

Definition at line 190 of file flintcf_Q.cc.

191{
193 return a;
194}

◆ nlEatLong()

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

Definition at line 30 of file flintcf_Q.cc.

31{
32 const char * start=s;
33
34 while (*s >= '0' && *s <= '9') s++;
35 if (*s=='\0')
36 {
37 mpz_set_str(i,start,10);
38 }
39 else
40 {
41 char c=*s;
42 *s='\0';
43 mpz_set_str(i,start,10);
44 *s=c;
45 }
46 return s;
47}

◆ Normalize()

static void Normalize ( number a,
const coeffs   
)
static

Definition at line 373 of file flintcf_Q.cc.

◆ Parameter()

static number Parameter ( const int  ,
const coeffs   
)
static

Definition at line 509 of file flintcf_Q.cc.

510{
514 return (number)res;
515}

◆ ParDeg()

static int ParDeg ( number  x,
const coeffs   
)
static

Definition at line 505 of file flintcf_Q.cc.

506{
508}
Variable x
Definition cfModGcd.cc:4090

◆ Power()

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

Definition at line 416 of file flintcf_Q.cc.

◆ Read()

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

Definition at line 326 of file flintcf_Q.cc.

327{
328// we only read "monomials" (i.e. [-][digits][parameter]),
329// everything else (+,*,^,()) is left to the singular interpreter
330 char *s=(char *)st;
331 *a=(number)omAlloc(sizeof(fmpq_poly_t));
333 BOOLEAN neg=FALSE;
334 if (*s=='-') { neg=TRUE; s++;}
335 if (isdigit(*s))
336 {
337 mpz_t z;
338 mpz_init(z);
339 fmpz_t z1;
340 fmpz_init(z1);
341 s=nlEatLong((char *)s, z);
342 fmpz_set_mpz(z1,z);
344 if (*s == '/')
345 {
346 s++;
347 s=nlEatLong((char *)s, z);
348 fmpz_set_mpz(z1,z);
350 }
351 fmpz_clear(z1);
352 mpz_clear(z);
353 }
354 else if(strncmp(s,r->pParameterNames[0],strlen(r->pParameterNames[0]))==0)
355 {
357 s+=strlen(r->pParameterNames[0]);
358 if(isdigit(*s))
359 {
360 int i=1;
361 s=nEati(s,&i,0);
362 if (i!=1)
363 {
366 }
367 }
368 }
369 if (neg)
371 return s;
372}
static char * nlEatLong(char *s, mpz_ptr i)
Definition flintcf_Q.cc:30
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 561 of file flintcf_Q.cc.

562{
563 // format: len a_len .. a_0
566 int l=s_readint(d->f_read);
567 mpz_t tmp;
568 mpz_init(tmp);
569 fmpq_t m;
570 fmpq_init(m);
571 fmpz_t num,den;
572 fmpz_init(num);
573 fmpz_init(den);
574 for (int i=l;i>=0;i--)
575 {
582 }
583 mpz_clear(tmp);
586 fmpq_clear(m);
587 return (number)aa;
588}
#define SSI_BASE
Definition auxiliary.h:136
CanonicalForm num(const CanonicalForm &f)
void s_readmpz_base(s_buff F, mpz_ptr a, int base)
Definition s_buff.cc:210
int s_readint(s_buff F)
Definition s_buff.cc:113
s_buff f_read
Definition s_buff.h:22

◆ SetChar()

static void SetChar ( const coeffs  )
static

Definition at line 53 of file flintcf_Q.cc.

54{
55 // dummy
56}

◆ SetMap()

static nMapFunc SetMap ( const coeffs  ,
const coeffs   
)
static

Definition at line 470 of file flintcf_Q.cc.

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

◆ Size()

static int Size ( number  n,
const coeffs   
)
static

Definition at line 139 of file flintcf_Q.cc.

140{
142}

◆ Sub()

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

Definition at line 64 of file flintcf_Q.cc.

◆ WriteFd()

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

Definition at line 516 of file flintcf_Q.cc.

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

◆ WriteShort()

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

Definition at line 233 of file flintcf_Q.cc.

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