 |
My Project
UNKNOWN_GIT_VERSION
|
Go to the documentation of this file.
13 #include <flint/flint.h>
14 #include <flint/fmpq_poly.h>
15 #include "factory/factory.h"
32 while (*
s >=
'0' && *
s <=
'9')
s++;
35 mpz_set_str(
i,start,10);
41 mpz_set_str(
i,start,10);
55 static number
Mult(number a, number
b,
const coeffs c)
62 static number
Sub(number a, number
b,
const coeffs c)
69 static number
Add(number a, number
b,
const coeffs c)
76 static number
Div(number a, number
b,
const coeffs c)
121 fmpq_poly_set_si(
res,
i);
128 fmpq_poly_set_mpz(
res,
i);
135 static long Int (number &n,
const coeffs r)
147 long nl=mpz_get_si(
num);
148 if (mpz_cmp_si(
num,nl)!=0) nl=0;
149 long dl=mpz_get_si(
den);
150 if ((dl!=1)||(mpz_cmp_si(
den,dl)!=0)) nl=0;
170 int dl=(int)mpz_get_si(
den);
171 if ((dl!=1)||(mpz_cmp_si(
den,(
long)dl)!=0)) mpz_set_ui(
result,0);
176 static number
Neg(number a,
const coeffs r)
243 int l=mpz_sizeinbase(
num,10);
247 char *z=mpz_get_str(
s,10,
num);
249 ||(mpz_cmp_si(
num,1)!=0)
250 ||(mpz_cmp_si(
den,1)!=0))
253 if (mpz_cmp_si(
den,1)!=0)
256 z=mpz_get_str(
s,10,
den);
273 static const char*
Read(
const char * st, number * a,
const coeffs r)
278 *a=(number)
omAlloc(
sizeof(fmpq_poly_t));
281 if (*
s==
'-') { neg=
TRUE;
s++;}
296 else if(strncmp(
s,r->pParameterNames[0],strlen(r->pParameterNames[0]))==0)
299 s+=strlen(r->pParameterNames[0]);
351 int dl=(int)mpz_get_si(
den);
377 fmpq_poly_set_fmpz(
res,
den);
389 static number
Gcd(number a, number
b,
const coeffs r)
396 static number
ExtGcd(number a, number
b, number *
s, number *t,
const coeffs r)
405 static number
Lcm(number a, number
b,
const coeffs r)
438 fmpq_poly_set_mpz(
res,
i->z);
447 WerrorS(
"not yet: ChineseRemainder");
457 fmpq_poly_set_coeff_si(
res,1,1);
464 int l=fmpq_poly_length(aa);
471 for(
int i=
l;
i>=0;
i--)
495 for (
int i=
l;
i>=0;
i--)
502 fmpq_poly_set_coeff_mpq(aa,
i,
m);
512 WerrorS(
"not yet: ConvFactoryNSingN");
516 WerrorS(
"not yet: ConvSingNFactoryN");
520 static char CoeffName_flint_Q[20];
521 sprintf(CoeffName_flint_Q,
"flint:QQ[%s]",r->pParameterNames[0]);
522 return (
char*)CoeffName_flint_Q;
527 char *
buf=(
char*)
omAlloc(12+strlen(r->pParameterNames[0]));
528 sprintf(
buf,
"flintQ(\"%s\")",r->pParameterNames[0]);
537 const char start[]=
"flint:QQ[";
538 const int start_len=strlen(start);
539 if (strncmp(
s,start,start_len)==0)
543 int l=sscanf(
s,
"%s",st);
546 while (st[strlen(st)-1]==
']') st[strlen(st)-1]=
'\0';
565 char *
pp=(
char*)infoStruct;
629 cf->iNumberOfParameters = 1;
630 char **pn=(
char**)
omAlloc0(
sizeof(
char*));
632 cf->pParameterNames = (
const char **)pn;
static number ExtGcd(number a, number b, number *s, number *t, const coeffs r)
static BOOLEAN Equal(number a, number b, const coeffs r)
static char * CoeffString(const coeffs r)
void StringAppendS(const char *st)
static number ExactDiv(number a, number b, const coeffs c)
static void Power(number a, int i, number *result, const coeffs r)
static BOOLEAN IsOne(number a, const coeffs r)
static number Gcd(number a, number b, const coeffs r)
static void Normalize(number &a, const coeffs r)
static number Init(long i, const coeffs r)
static void CoeffWrite(const coeffs r, BOOLEAN details)
static number Sub(number a, number b, const coeffs c)
char * CoeffName(const coeffs r)
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
static int Size(number n, const coeffs r)
static number GetDenom(number &n, const coeffs r)
BOOLEAN flintQ_InitChar(coeffs cf, void *infoStruct)
static BOOLEAN Greater(number a, number b, const coeffs r)
static number InitMPZ(mpz_t i, const coeffs r)
static number GetNumerator(number &n, const coeffs r)
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
int status int void * buf
static number Parameter(const int i, const coeffs r)
fmpq_poly_struct * fmpq_poly_ptr
const char *const nDivBy0
void PrintS(const char *s)
#define omFreeSize(addr, size)
static BOOLEAN IsMOne(number k, const coeffs r)
static number Add(number a, number b, const coeffs c)
static void MPZ(mpz_t result, number &n, const coeffs r)
static number Mult(number a, number b, const coeffs c)
static number Lcm(number a, number b, const coeffs r)
static number IntMod(number a, number b, const coeffs c)
static number ConvFactoryNSingN(const CanonicalForm n, const coeffs r)
static number Neg(number a, const coeffs r)
static int ParDeg(number x, const coeffs r)
static long Int(number &n, const coeffs r)
coeffs flintQInitCfByName(char *s, n_coeffType n)
static void KillChar(coeffs cf)
static number ChineseRemainder(number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs)
static BOOLEAN GreaterZero(number k, const coeffs r)
static void WriteShort(number a, const coeffs r)
static nMapFunc SetMap(const coeffs src, const coeffs dst)
static BOOLEAN IsZero(number a, const coeffs r)
static int si_max(const int a, const int b)
static char * nlEatLong(char *s, mpz_ptr i)
static CanonicalForm ConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
void WerrorS(const char *s)
static const char * Read(const char *st, number *a, const coeffs r)
static number Invers(number a, const coeffs r)
static void WriteFd(number a, const ssiInfo *d, const coeffs)
static BOOLEAN DBTest(number a, const char *f, const int l, const coeffs r)
static number Div(number a, number b, const coeffs c)
char * nEati(char *s, int *i, int m)
divide by the first (leading) number and return it, i.e. make monic
const CanonicalForm int s
static number Farey(number p, number n, const coeffs)
void s_readmpz_base(s_buff F, mpz_ptr a, int base)
static void SetChar(const coeffs r)
static number Copy(number a, const coeffs r)
static number Init_bigint(number i, const coeffs dummy, const coeffs dst)
static void Delete(number *a, const coeffs r)
static number ReadFd(const ssiInfo *d, const coeffs)
static BOOLEAN CoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)