Loading...
Searching...
No Matches
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_struct * | fmpq_poly_ptr
typedef fmpz * | fmpz_ptr

## Functions

static char * | nlEatLong (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 char * | Read (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)
char * | CoeffName (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

typedef fmpq_poly_struct* fmpq_poly_ptr

Definition at line 25 of file flintcf_Q.cc.

## fmpz_ptr

typedef fmpz* fmpz_ptr

Definition at line 26 of file flintcf_Q.cc.

## Function Documentation

## Add()

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

static

Definition at line 71 of file flintcf_Q.cc.

{
fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init(res);
fmpq_poly_add(res,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
return (number)res;
}
b
CanonicalForm b
Definition cfModGcd.cc:4111
res
CanonicalForm res
Definition facAbsFact.cc:60
fmpq_poly_ptr
fmpq_poly_struct * fmpq_poly_ptr
Definition flintcf_Q.cc:25
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210

## ChineseRemainder()

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

static

Definition at line 500 of file flintcf_Q.cc.

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

## CoeffIsEqual()

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

static

Definition at line 49 of file flintcf_Q.cc.

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

## CoeffName()

char * CoeffName | ( | const coeffs | r | ) |

Definition at line 601 of file flintcf_Q.cc.

{
STATIC_VAR char CoeffName_flint_Q[20];
snprintf(CoeffName_flint_Q,20,"flintQp[%s]",r->pParameterNames[0]);
return (char*)CoeffName_flint_Q;
}
STATIC_VAR
#define STATIC_VAR
Definition globaldefs.h:7

## ConvFactoryNSingN()

number ConvFactoryNSingN | ( | const CanonicalForm | ,
|  | const coeffs | )

static

Definition at line 591 of file flintcf_Q.cc.

{
WerrorS("not yet: ConvFactoryNSingN");
return NULL;
}

## ConvSingNFactoryN()

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

static

Definition at line 596 of file flintcf_Q.cc.

{
WerrorS("not yet: ConvSingNFactoryN");
return CanonicalForm(0);
}
CanonicalForm
factory's main class
Definition canonicalform.h:86

## Copy()

number Copy | ( | number | a,
|  | const coeffs | )

static

Definition at line 215 of file flintcf_Q.cc.

{
fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init(res);
fmpq_poly_set(res,(fmpq_poly_ptr)a);
return (number)res;
}

## DBTest()

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

static

Definition at line 626 of file flintcf_Q.cc.

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

## Delete()

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

static

Definition at line 461 of file flintcf_Q.cc.

{
if ((*a)!=NULL)
{
fmpq_poly_clear((fmpq_poly_ptr)*a);
omFree(*a);
*a=NULL;
}
}
omFree
#define omFree(addr)
Definition omAllocDecl.h:261

## Div()

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

static

Definition at line 78 of file flintcf_Q.cc.

{
fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init(res);
if(fmpq_poly_is_zero((fmpq_poly_ptr)b))
{
WerrorS(nDivBy0);
}
else
{
fmpq_poly_div(res,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
fmpq_poly_t mod;
fmpq_poly_init(mod);
fmpq_poly_rem(mod,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
if (!fmpq_poly_is_zero((fmpq_poly_ptr)mod))
{
WerrorS("cannot divide");
}
fmpq_poly_clear(mod);
}
return (number)res;
}
mod
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
nDivBy0
const char *const nDivBy0
Definition numbers.h:90

## Equal()

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

static

Definition at line 381 of file flintcf_Q.cc.

{
return (fmpq_poly_equal((fmpq_poly_ptr)a,(fmpq_poly_ptr)b));
}

## ExactDiv()

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

static

Definition at line 100 of file flintcf_Q.cc.

{
fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init(res);
if(fmpq_poly_is_zero((fmpq_poly_ptr)b))
{
WerrorS(nDivBy0);
}
else
fmpq_poly_div(res,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
return (number)res;
}

## ExtGcd()

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

static

Definition at line 447 of file flintcf_Q.cc.

{
fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init(res);
fmpq_poly_init((fmpq_poly_ptr)*s);
fmpq_poly_init((fmpq_poly_ptr)*t);
fmpq_poly_xgcd(res,(fmpq_poly_ptr)*s,(fmpq_poly_ptr)*t,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
return (number)res;
}
s
const CanonicalForm int s
Definition facAbsFact.cc:51

## Farey()

number Farey | ( | number | ,
|  | number | ,
|  | const coeffs | )

static

Definition at line 495 of file flintcf_Q.cc.

{
WerrorS("not yet: Farey");
return NULL;
}

## flintQ_InitChar()

BOOLEAN flintQ_InitChar | ( | coeffs | cf,
|  | void * | infoStruct )

Definition at line 636 of file flintcf_Q.cc.

{
char *pp=(char*)infoStruct;
cf->cfCoeffName = CoeffName;
cf->nCoeffIsEqual = CoeffIsEqual;
cf->cfKillChar = KillChar;
cf->cfSetChar = SetChar;
cf->ch=0; //char 0
cf->cfMult = Mult;
cf->cfSub = Sub;
cf->cfAdd = Add;
cf->cfDiv = Div;
cf->cfExactDiv = ExactDiv; // ???
cf->cfInit =Init;
cf->cfInitMPZ =InitMPZ;
cf->cfSize = Size;
cf->cfInt = Int;
cf->cfMPZ = MPZ;
cf->cfInpNeg = Neg;
cf->cfInvers = Invers;
cf->cfCopy = Copy;
cf->cfRePart = Copy;
// default: cf->cfImPart = ndReturn0;
cf->cfWriteLong = WriteShort; //WriteLong;
cf->cfWriteShort = WriteShort;
cf->cfRead = Read;
cf->cfNormalize = Normalize;
//cf->cfDivComp=
//cf->cfIsUnit=
//cf->cfGetUnit=
//cf->cfDivBy=
cf->cfGreater=Greater;
cf->cfEqual =Equal;
cf->cfIsZero =IsZero;
cf->cfIsOne =IsOne;
cf->cfIsMOne =IsMOne;
cf->cfGreaterZero=GreaterZero;
cf->cfPower = Power;
cf->cfGetDenom = GetDenom;
cf->cfGetNumerator = GetNumerator;
cf->cfGcd = Gcd;
cf->cfExtGcd = ExtGcd;
cf->cfLcm = Lcm;
cf->cfDelete = Delete;
cf->cfSetMap = SetMap;
// default: cf->cfInpMult
// default: cf->cfInpAdd
cf->cfFarey =Farey;
cf->cfChineseRemainder=ChineseRemainder;
cf->cfParDeg = ParDeg;
cf->cfParameter = Parameter;
// cf->cfClearContent = ClearContent;
// cf->cfClearDenominators = ClearDenominators;
cf->convFactoryNSingN=ConvFactoryNSingN;
cf->convSingNFactoryN=ConvSingNFactoryN;
cf->cfWriteFd = WriteFd;
cf->cfReadFd = ReadFd;
#ifdef LDEBUG
cf->cfDBTest = DBTest;
#endif
cf->iNumberOfParameters = 1;
char **pn=(char**)omAlloc0(sizeof(char*));
pn[0]=omStrDup(pp);
cf->pParameterNames = (const char **)pn;
cf->has_simple_Inverse= FALSE;
cf->has_simple_Alloc= FALSE;
cf->is_field=FALSE;
return FALSE;
}
FALSE
#define FALSE
Definition auxiliary.h:97
pp
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f ).
Definition cf_gcd.cc:676
cf
CanonicalForm cf
Definition cfModGcd.cc:4091
ExtGcd
static number ExtGcd(number a, number b, number *s, number *t, const coeffs)
Definition flintcf_Q.cc:447
WriteShort
static void WriteShort(number a, const coeffs r)
Definition flintcf_Q.cc:233
Copy
static number Copy(number a, const coeffs)
Definition flintcf_Q.cc:215
ChineseRemainder
static number ChineseRemainder(number *, number *, int, BOOLEAN, CFArray &, const coeffs)
Definition flintcf_Q.cc:500
Normalize
static void Normalize(number &a, const coeffs)
Definition flintcf_Q.cc:373
SetChar
static void SetChar(const coeffs)
Definition flintcf_Q.cc:53
SetMap
static nMapFunc SetMap(const coeffs, const coeffs)
Definition flintcf_Q.cc:470
Farey
static number Farey(number, number, const coeffs)
Definition flintcf_Q.cc:495
GetDenom
static number GetDenom(number &n, const coeffs)
Definition flintcf_Q.cc:423
Read
static const char * Read(const char *st, number *a, const coeffs r)
Definition flintcf_Q.cc:326
IsOne
static BOOLEAN IsOne(number a, const coeffs)
Definition flintcf_Q.cc:389
CoeffName
char * CoeffName(const coeffs r)
Definition flintcf_Q.cc:601
ConvFactoryNSingN
static number ConvFactoryNSingN(const CanonicalForm, const coeffs)
Definition flintcf_Q.cc:591
InitMPZ
static number InitMPZ(mpz_t i, const coeffs)
Definition flintcf_Q.cc:128
Size
static int Size(number n, const coeffs)
Definition flintcf_Q.cc:139
Add
static number Add(number a, number b, const coeffs)
Definition flintcf_Q.cc:71
Div
static number Div(number a, number b, const coeffs)
Definition flintcf_Q.cc:78
WriteFd
static void WriteFd(number a, const ssiInfo *d, const coeffs)
Definition flintcf_Q.cc:516
Delete
static void Delete(number *a, const coeffs)
Definition flintcf_Q.cc:461
Parameter
static number Parameter(const int, const coeffs)
Definition flintcf_Q.cc:509
DBTest
static BOOLEAN DBTest(number, const char *, const int, const coeffs)
Definition flintcf_Q.cc:626
KillChar
static void KillChar(coeffs cf)
Definition flintcf_Q.cc:631
ConvSingNFactoryN
static CanonicalForm ConvSingNFactoryN(number, BOOLEAN, const coeffs)
Definition flintcf_Q.cc:596
Init
static number Init(long i, const coeffs)
Definition flintcf_Q.cc:121
MPZ
static void MPZ(mpz_t result, number &n, const coeffs)
Definition flintcf_Q.cc:159
ReadFd
static number ReadFd(const ssiInfo *d, const coeffs)
Definition flintcf_Q.cc:561
ExactDiv
static number ExactDiv(number a, number b, const coeffs)
Definition flintcf_Q.cc:100
Power
static void Power(number a, int i, number *result, const coeffs)
Definition flintcf_Q.cc:416
IsMOne
static BOOLEAN IsMOne(number k, const coeffs)
Definition flintcf_Q.cc:393
Sub
static number Sub(number a, number b, const coeffs)
Definition flintcf_Q.cc:64
GetNumerator
static number GetNumerator(number &n, const coeffs)
Definition flintcf_Q.cc:431
GreaterZero
static BOOLEAN GreaterZero(number, const coeffs)
Definition flintcf_Q.cc:410
Gcd
static number Gcd(number a, number b, const coeffs)
Definition flintcf_Q.cc:440
CoeffIsEqual
static BOOLEAN CoeffIsEqual(const coeffs r, n_coeffType n, void *)
Definition flintcf_Q.cc:49
Mult
static number Mult(number a, number b, const coeffs)
Definition flintcf_Q.cc:57
Invers
static number Invers(number a, const coeffs)
Definition flintcf_Q.cc:195
Lcm
static number Lcm(number, number, const coeffs)
Definition flintcf_Q.cc:456
ParDeg
static int ParDeg(number x, const coeffs)
Definition flintcf_Q.cc:505
IsZero
static BOOLEAN IsZero(number a, const coeffs)
Definition flintcf_Q.cc:385
Neg
static number Neg(number a, const coeffs)
Definition flintcf_Q.cc:190
Equal
static BOOLEAN Equal(number a, number b, const coeffs)
Definition flintcf_Q.cc:381
Int
static long Int(number &n, const coeffs)
Definition flintcf_Q.cc:143
Greater
static bool Greater(mono_type m1, mono_type m2)
Definition interpolation.cc:285
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211

## flintQInitCfByName()

coeffs flintQInitCfByName | ( | char * | s,
|  | n_coeffType | n )

Definition at line 608 of file flintcf_Q.cc.

{
const char start[]="flintQp[";
const int start_len=strlen(start);
if (strncmp(s,start,start_len)==0)
{
s+=start_len;
char st[10];
int l=sscanf(s,"%s",st);
if (l==1)
{
while (st[strlen(st)-1]==']') st[strlen(st)-1]='\0';
return nInitChar(n,(void*)st);
}
}
return NULL;
}
l
int l
Definition cfEzgcd.cc:100
nInitChar
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:412

## Gcd()

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

static

Definition at line 440 of file flintcf_Q.cc.

{
fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init(res);
fmpq_poly_gcd(res,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
return (number)res;
}

## GetDenom()

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

static

Definition at line 423 of file flintcf_Q.cc.

{
fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init(res);
fmpz_ptr den=fmpq_poly_denref((fmpq_poly_ptr)n);
fmpq_poly_set_fmpz(res,den);
return (number)res;
}
den
CanonicalForm den(const CanonicalForm &f)
Definition canonicalform.h:340
fmpz_ptr
fmpz * fmpz_ptr
Definition flintcf_Q.cc:26

## GetNumerator()

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

static

Definition at line 431 of file flintcf_Q.cc.

{
fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init(res);
fmpq_poly_set(res,(fmpq_poly_ptr)n);
fmpz_ptr den=fmpq_poly_denref(res);
fmpq_poly_scalar_mul_fmpz(res,res,den);
return (number)res;
}

## Greater()

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

static

Definition at line 377 of file flintcf_Q.cc.

{
return (fmpq_poly_cmp((fmpq_poly_ptr)a,(fmpq_poly_ptr)b)>0);
}

## GreaterZero()

BOOLEAN GreaterZero | ( | number | ,
|  | const coeffs | )

static

Definition at line 410 of file flintcf_Q.cc.

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

## Init()

number Init | ( | long | i,
|  | const coeffs | )

static

Definition at line 121 of file flintcf_Q.cc.

{
fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init(res);
fmpq_poly_set_si(res,i);
return (number)res;
}
i
int i
Definition cfEzgcd.cc:132

## InitMPZ()

number InitMPZ | ( | mpz_t | i,
|  | const coeffs | )

static

Definition at line 128 of file flintcf_Q.cc.

{
fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init(res);
fmpq_poly_fit_length(res, 1);
fmpz_set_mpz(res->coeffs, i);
fmpz_one(res->den);
_fmpq_poly_set_length(res, 1);
_fmpq_poly_normalise(res);
return (number)res;
}

## Int()

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

static

Definition at line 143 of file flintcf_Q.cc.

{
if (fmpq_poly_degree((fmpq_poly_ptr)n)==0)
{
fmpq_t m;
fmpq_init(m);
fmpq_poly_get_coeff_fmpq(m,(fmpq_poly_ptr)n,0);
long nl=fmpz_get_si(fmpq_numref(m));
if (fmpz_cmp_si(fmpq_numref(m),nl)!=0) nl=0;
long dl=fmpz_get_si(fmpq_denref(m));
if ((dl!=1)||(fmpz_cmp_si(fmpq_denref(m),dl)!=0)) nl=0;
fmpq_clear(m);
return nl;
}
return 0;
}
m
int m
Definition cfEzgcd.cc:128

## Invers()

number Invers | ( | number | a,
|  | const coeffs | )

static

Definition at line 195 of file flintcf_Q.cc.

{
if(fmpq_poly_is_zero((fmpq_poly_ptr)a))
{
WerrorS(nDivBy0);
return NULL;
}
if (fmpq_poly_degree((fmpq_poly_ptr)a)==0)
{
fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init(res);
fmpq_poly_inv(res,(fmpq_poly_ptr)a);
return (number)res;
}
else
{
WerrorS("not invertable");
return NULL;
}
}

## IsMOne()

BOOLEAN IsMOne | ( | number | k,
|  | const coeffs | )

static

Definition at line 393 of file flintcf_Q.cc.

{
if (fmpq_poly_length((fmpq_poly_ptr)k)>0) return FALSE;
fmpq_poly_canonicalise((fmpq_poly_ptr)k);
fmpq_t m;
fmpq_init(m);
fmpq_poly_get_coeff_fmpq(m,(fmpq_poly_ptr)k,0);
BOOLEAN result=TRUE;
if (fmpz_cmp_si(fmpq_numref(m),(long)-1)!=0) result=FALSE;
else
{
int dl=(int)fmpz_get_si(fmpq_denref(m));
if ((dl!=1)||(fmpz_cmp_si(fmpq_denref(m),(long)dl)!=0)) result=FALSE;
}
fmpq_clear(m);
return (result);
}
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
k
int k
Definition cfEzgcd.cc:99
result
return result
Definition facAbsBiFact.cc:76

## IsOne()

BOOLEAN IsOne | ( | number | a,
|  | const coeffs | )

static

Definition at line 389 of file flintcf_Q.cc.

{
return fmpq_poly_is_one((fmpq_poly_ptr)a);
}

## IsZero()

BOOLEAN IsZero | ( | number | a,
|  | const coeffs | )

static

Definition at line 385 of file flintcf_Q.cc.

{
return fmpq_poly_is_zero((fmpq_poly_ptr)a);
}

## KillChar()

void KillChar | ( | coeffs | cf | ) |

static

Definition at line 631 of file flintcf_Q.cc.

{
omFree((ADDRESS)(cf->pParameterNames[0]));
omFreeSize(cf->pParameterNames,sizeof(char*));
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260

## Lcm()

number Lcm | ( | number | ,
|  | number | ,
|  | const coeffs | )

static

Definition at line 456 of file flintcf_Q.cc.

{
WerrorS("not yet: Lcm");
return NULL;
}

## MPZ()

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

static

Definition at line 159 of file flintcf_Q.cc.

{
mpz_init(result);
if (fmpq_poly_degree((fmpq_poly_ptr)n)==0)
{
#if __FLINT_RELEASE >= 20503
fmpq_t m;
fmpq_init(m);
fmpq_poly_get_coeff_fmpq(m,(fmpq_poly_ptr)n,0);
mpz_t den;
mpz_init(den);
fmpq_get_mpz_frac(result,den,m);
int dl=(int)mpz_get_si(den);
if ((dl!=1)||(mpz_cmp_si(den,(long)dl)!=0)) mpz_set_ui(result,0);
mpz_clear(den);
fmpq_clear(m);
#else
mpq_t m;
mpq_init(m);
fmpq_poly_get_coeff_mpq(m,(fmpq_poly_ptr)n,0);
mpz_t den;
mpz_init(den);
mpq_get_num(result,m);
mpq_get_den(den,m);
int dl=(int)mpz_get_si(den);
if ((dl!=1)||(mpz_cmp_si(den,(long)dl)!=0)) mpz_set_ui(result,0);
mpz_clear(den);
mpq_clear(m);
#endif
}
}

## Mult()

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

static

Definition at line 57 of file flintcf_Q.cc.

{
fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init(res);
fmpq_poly_mul(res,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
return (number)res;
}

## Neg()

number Neg | ( | number | a,
|  | const coeffs | )

static

Definition at line 190 of file flintcf_Q.cc.

{
fmpq_poly_neg((fmpq_poly_ptr)a,(fmpq_poly_ptr)a);
return a;
}

## nlEatLong()

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

static

Definition at line 30 of file flintcf_Q.cc.

{
const char * start=s;
while (*s >= '0' && *s <= '9') s++;
if (*s=='\0')
{
mpz_set_str(i,start,10);
}
else
{
char c=*s;
*s='\0';
mpz_set_str(i,start,10);
*s=c;
}
return s;
}

## Normalize()

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

static

Definition at line 373 of file flintcf_Q.cc.

{
fmpq_poly_canonicalise((fmpq_poly_ptr)a);
}

## Parameter()

number Parameter | ( | const int | ,
|  | const coeffs | )

static

Definition at line 509 of file flintcf_Q.cc.

{
fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init(res);
fmpq_poly_set_coeff_si(res,1,1);
return (number)res;
}

## ParDeg()

int ParDeg | ( | number | x,
|  | const coeffs | )

static

Definition at line 505 of file flintcf_Q.cc.

{
return fmpq_poly_degree((fmpq_poly_ptr)x);
}
x
Variable x
Definition cfModGcd.cc:4090

## Power()

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

static

Definition at line 416 of file flintcf_Q.cc.

{
fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init(res);
*result=(number)res;
fmpq_poly_pow((fmpq_poly_ptr)(*result),(fmpq_poly_ptr)a,i);
}

## Read()

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

static

Definition at line 326 of file flintcf_Q.cc.

{
// we only read "monomials" (i.e. [-][digits][parameter]),
// everything else (+,*,^,()) is left to the singular interpreter
char *s=(char *)st;
*a=(number)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init((fmpq_poly_ptr)(*a));
BOOLEAN neg=FALSE;
if (*s=='-') { neg=TRUE; s++;}
if (isdigit(*s))
{
mpz_t z;
mpz_init(z);
fmpz_t z1;
fmpz_init(z1);
s=nlEatLong((char *)s, z);
fmpz_set_mpz(z1,z);
fmpq_poly_set_fmpz((fmpq_poly_ptr)(*a),z1);
if (*s == '/')
{
s++;
s=nlEatLong((char *)s, z);
fmpz_set_mpz(z1,z);
fmpq_poly_scalar_div_fmpz((fmpq_poly_ptr)(*a),(fmpq_poly_ptr)(*a),z1);
}
fmpz_clear(z1);
mpz_clear(z);
}
else if(strncmp(s,r->pParameterNames[0],strlen(r->pParameterNames[0]))==0)
{
fmpq_poly_set_coeff_si((fmpq_poly_ptr)(*a),1,1);
s+=strlen(r->pParameterNames[0]);
if(isdigit(*s))
{
int i=1;
s=nEati(s,&i,0);
if (i!=1)
{
fmpq_poly_set_coeff_si((fmpq_poly_ptr)(*a),1,0);
fmpq_poly_set_coeff_si((fmpq_poly_ptr)(*a),i,1);
}
}
}
if (neg)
fmpq_poly_neg((fmpq_poly_ptr)(*a),(fmpq_poly_ptr)(*a));
return s;
}
nlEatLong
static char * nlEatLong(char *s, mpz_ptr i)
Definition flintcf_Q.cc:30
nEati
char * nEati(char *s, int *i, int m)
divide by the first (leading) number and return it, i.e. make monic
Definition numbers.cc:672

## ReadFd()

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

static

Definition at line 561 of file flintcf_Q.cc.

{
// format: len a_len .. a_0
fmpq_poly_ptr aa=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init(aa);
int l=s_readint(d->f_read);
mpz_t tmp;
mpz_init(tmp);
fmpq_t m;
fmpq_init(m);
fmpz_t num,den;
fmpz_init(num);
fmpz_init(den);
for (int i=l;i>=0;i--)
{
s_readmpz_base (d->f_read,tmp, SSI_BASE);
fmpz_set_mpz(num, tmp);
s_readmpz_base (d->f_read,tmp, SSI_BASE);
fmpz_set_mpz(den, tmp);
fmpq_set_fmpz_frac(m,num,den);
fmpq_poly_set_coeff_fmpq(aa,i,m);
}
mpz_clear(tmp);
fmpz_clear(den);
fmpz_clear(num);
fmpq_clear(m);
return (number)aa;
}
SSI_BASE
#define SSI_BASE
Definition auxiliary.h:136
num
CanonicalForm num(const CanonicalForm &f)
Definition canonicalform.h:337
s_readmpz_base
void s_readmpz_base(s_buff F, mpz_ptr a, int base)
Definition s_buff.cc:264
s_readint
int s_readint(s_buff F)
Definition s_buff.cc:113
ssiInfo::f_read
s_buff f_read
Definition s_buff.h:22

## SetChar()

void SetChar | ( | const coeffs |  | ) |

static

Definition at line 53 of file flintcf_Q.cc.

{
// dummy
}

## SetMap()

nMapFunc SetMap | ( | const coeffs | ,
|  | const coeffs | )

static

Definition at line 470 of file flintcf_Q.cc.

{
WerrorS("not yet: SetMap");
return NULL;
}

## Size()

int Size | ( | number | n,
|  | const coeffs | )

static

Definition at line 139 of file flintcf_Q.cc.

{
return fmpq_poly_degree((fmpq_poly_ptr)n);
}

## Sub()

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

static

Definition at line 64 of file flintcf_Q.cc.

{
fmpq_poly_ptr res=(fmpq_poly_ptr)omAlloc(sizeof(fmpq_poly_t));
fmpq_poly_init(res);
fmpq_poly_sub(res,(fmpq_poly_ptr)a,(fmpq_poly_ptr)b);
return (number)res;
}

## WriteFd()

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

static

Definition at line 516 of file flintcf_Q.cc.

{
// format: len a_len(num den) .. a_0
fmpq_poly_ptr aa=(fmpq_poly_ptr)a;
int l=fmpq_poly_length(aa);
fprintf(d->f_write,"%d ",l);
#if __FLINT_RELEASE >= 20503
fmpq_t m;
fmpq_init(m);
mpz_t num,den;
mpz_init(num);
mpz_init(den);
for(int i=l; i>=0; i--)
{
fmpq_poly_get_coeff_fmpq(m,(fmpq_poly_ptr)a,i);
fmpq_get_mpz_frac(num,den,m);
mpz_out_str (d->f_write,SSI_BASE, num);
fputc(' ',d->f_write);
mpz_out_str (d->f_write,SSI_BASE, den);
fputc(' ',d->f_write);
}
mpz_clear(den);
mpz_clear(num);
fmpq_clear(m);
#else
mpq_t m;
mpq_init(m);
mpz_t num,den;
mpz_init(num);
mpz_init(den);
for(int i=l; i>=0; i--)
{
fmpq_poly_get_coeff_mpq(m,(fmpq_poly_ptr)a,i);
mpq_get_num(num,m);
mpq_get_den(den,m);
mpz_out_str (d->f_write,SSI_BASE, num);
fputc(' ',d->f_write);
mpz_out_str (d->f_write,SSI_BASE, den);
fputc(' ',d->f_write);
}
mpz_clear(den);
mpz_clear(num);
mpq_clear(m);
#endif
}
ssiInfo::f_write
FILE * f_write
Definition s_buff.h:23

## WriteShort()

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

static

Definition at line 233 of file flintcf_Q.cc.

{
//fmpq_poly_print_pretty((fmpq_poly_ptr)a,r->pParameterNames[0]);
if (IsOne(a,r)) StringAppendS("1");
else if (IsZero(a,r)) StringAppendS("0");
else
{
StringAppendS("(");
#if __FLINT_RELEASE >= 20503
fmpq_t m;
fmpq_init(m);
BOOLEAN need_plus=FALSE;
for(int i=fmpq_poly_length((fmpq_poly_ptr)a);i>=0;i--)
{
fmpq_poly_get_coeff_fmpq(m,(fmpq_poly_ptr)a,i);
if (!fmpq_is_zero(m))
{
if (need_plus && (fmpq_cmp_ui(m,0)>0))
StringAppendS("+");
need_plus=TRUE;
int l=fmpz_sizeinbase(fmpq_numref(m),10);
l=si_max(l,(int)fmpz_sizeinbase(fmpq_denref(m),10));
l+=2;
char *s=(char*)omAlloc(l);
char *z=fmpz_get_str(s,10,fmpq_numref(m));
if ((i==0)
||(fmpz_cmp_si(fmpq_numref(m),1)!=0)
||(fmpz_cmp_si(fmpq_denref(m),1)!=0))
{
StringAppendS(z);
if (fmpz_cmp_si(fmpq_denref(m),1)!=0)
{
StringAppendS("/");
z=fmpz_get_str(s,10,fmpq_denref(m));
StringAppendS(z);
}
if (i!=0) StringAppendS("*");
}
if (i>1)
StringAppend("%s^%d",r->pParameterNames[0],i);
else if (i==1)
StringAppend("%s",r->pParameterNames[0]);
}
}
fmpq_clear(m);
#else
mpq_t m;
mpq_init(m);
mpz_t num,den;
mpz_init(num);
mpz_init(den);
BOOLEAN need_plus=FALSE;
for(int i=fmpq_poly_length((fmpq_poly_ptr)a);i>=0;i--)
{
fmpq_poly_get_coeff_mpq(m,(fmpq_poly_ptr)a,i);
mpq_get_num(num,m);
mpq_get_den(den,m);
if (mpz_sgn1(num)!=0)
{
if (need_plus && (mpz_sgn1(num)>0))
StringAppendS("+");
need_plus=TRUE;
int l=mpz_sizeinbase(num,10);
l=si_max(l,(int)mpz_sizeinbase(den,10));
l+=2;
char *s=(char*)omAlloc(l);
char *z=mpz_get_str(s,10,num);
if ((i==0)
||(mpz_cmp_si(num,1)!=0)
||(mpz_cmp_si(den,1)!=0))
{
StringAppendS(z);
if (mpz_cmp_si(den,1)!=0)
{
StringAppendS("/");
z=mpz_get_str(s,10,den);
StringAppendS(z);
}
if (i!=0) StringAppendS("*");
}
if (i>1)
StringAppend("%s^%d",r->pParameterNames[0],i);
else if (i==1)
StringAppend("%s",r->pParameterNames[0]);
}
}
mpz_clear(den);
mpz_clear(num);
mpq_clear(m);
#endif
StringAppendS(")");
}
}
si_max
static int si_max(const int a, const int b)
Definition auxiliary.h:125
StringAppend
#define StringAppend
Definition emacs.cc:79
StringAppendS
void StringAppendS(const char *st)
Definition reporter.cc:107
mpz_sgn1
#define mpz_sgn1(A)
Definition si_gmp.h:18