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);
47 static const char*
Eati(
const char *
s,
int *
i)
50 if (((*
s) >=
'0') && ((*
s) <=
'9'))
58 while (((*
s) >=
'0') && ((*
s) <=
'9'));
122 fmpq_poly_clear(
mod);
149 fmpq_poly_set_si(
res,
i);
156 fmpq_poly_set_mpz(
res,
i);
175 long nl=mpz_get_si(
num);
176 if (mpz_cmp_si(
num,nl)!=0) nl=0;
177 long dl=mpz_get_si(
den);
178 if ((dl!=1)||(mpz_cmp_si(
den,dl)!=0)) nl=0;
198 int dl=(int)mpz_get_si(
den);
199 if ((dl!=1)||(mpz_cmp_si(
den,(
long)dl)!=0)) mpz_set_ui(
result,0);
271 int l=mpz_sizeinbase(
num,10);
275 char *z=mpz_get_str(
s,10,
num);
277 ||(mpz_cmp_si(
num,1)!=0)
278 ||(mpz_cmp_si(
den,1)!=0))
281 if (mpz_cmp_si(
den,1)!=0)
284 z=mpz_get_str(
s,10,
den);
301 static const char*
Read(
const char * st, number * a,
const coeffs r)
306 *a=(number)
omAlloc(
sizeof(fmpq_poly_t));
309 if (*
s==
'-') { neg=
TRUE;
s++;}
324 else if(strncmp(
s,r->pParameterNames[0],strlen(r->pParameterNames[0]))==0)
327 s+=strlen(r->pParameterNames[0]);
379 int dl=(int)mpz_get_si(
den);
405 fmpq_poly_set_fmpz(
res,
den);
466 fmpq_poly_set_mpz(
res,
i->z);
475 WerrorS(
"not yet: ChineseRemainder");
485 fmpq_poly_set_coeff_si(
res,1,1);
492 int l=fmpq_poly_length(aa);
499 for(
int i=
l;
i>=0;
i--)
523 for (
int i=
l;
i>=0;
i--)
530 fmpq_poly_set_coeff_mpq(aa,
i,
m);
540 WerrorS(
"not yet: ConvFactoryNSingN");
544 WerrorS(
"not yet: ConvSingNFactoryN");
548 return (
char*)
"flint:Q[a]";
625 cf->iNumberOfParameters = 1;
626 char **pn=(
char**)
omAlloc0(
sizeof(
char*));
628 cf->pParameterNames = (
const char **)pn;
static int si_max(const int a, const int b)
Coefficient rings, fields and other domains suitable for Singular polynomials.
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
const CanonicalForm int s
void WerrorS(const char *s)
static void WriteShort(number a, const coeffs r)
static number Lcm(number a, number b, const coeffs r)
static number ConvFactoryNSingN(const CanonicalForm n, const coeffs r)
static void MPZ(mpz_t result, number &n, const coeffs r)
static number Neg(number a, const coeffs r)
static BOOLEAN Greater(number a, number b, const coeffs r)
char * CoeffName(const coeffs r)
static number Mult(number a, number b, const coeffs c)
static number Init_bigint(number i, const coeffs dummy, const coeffs dst)
static number Sub(number a, number b, const coeffs c)
static long Int(number &n, const coeffs r)
static number GetDenom(number &n, const coeffs r)
static number Init(long i, const coeffs r)
static BOOLEAN CoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
static void Normalize(number &a, const coeffs r)
static number Gcd(number a, number b, const coeffs r)
BOOLEAN flintQ_InitChar(coeffs cf, void *infoStruct)
fmpq_poly_struct * fmpq_poly_ptr
static char * CoeffString(const coeffs r)
static number ExtGcd(number a, number b, number *s, number *t, const coeffs r)
static BOOLEAN GreaterZero(number k, const coeffs r)
static BOOLEAN DBTest(number a, const char *f, const int l, const coeffs r)
static void Delete(number *a, const coeffs r)
static CanonicalForm ConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
static void KillChar(coeffs r)
static number Copy(number a, const coeffs r)
static number GetNumerator(number &n, const coeffs r)
static number InitMPZ(mpz_t i, const coeffs r)
static number Div(number a, number b, const coeffs c)
static void CoeffWrite(const coeffs r, BOOLEAN details)
static void Power(number a, int i, number *result, const coeffs r)
static BOOLEAN Equal(number a, number b, const coeffs r)
static number Add(number a, number b, const coeffs c)
static BOOLEAN IsOne(number a, const coeffs r)
static number ReadFd(s_buff f, const coeffs)
static number Farey(number p, number n, const coeffs)
static BOOLEAN IsZero(number a, const coeffs r)
static int ParDeg(number x, const coeffs r)
static const char * Eati(const char *s, int *i)
static nMapFunc SetMap(const coeffs src, const coeffs dst)
static number ChineseRemainder(number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs)
static BOOLEAN IsMOne(number k, const coeffs r)
static void SetChar(const coeffs r)
static number Parameter(const int i, const coeffs r)
static number Invers(number a, const coeffs r)
static number IntMod(number a, number b, const coeffs c)
static char * nlEatLong(char *s, mpz_ptr i)
static const char * Read(const char *st, number *a, const coeffs r)
static int Size(number n, const coeffs r)
static number ExactDiv(number a, number b, const coeffs c)
static void WriteFd(number a, FILE *f, const coeffs)
The main handler for Singular numbers which are suitable for Singular polynomials.
const char *const nDivBy0
void StringAppendS(const char *st)
void PrintS(const char *s)
void s_readmpz_base(s_buff F, mpz_ptr a, int base)