10 #include "libpolysconfig.h" 17 #include <flint/flint.h> 18 #include <flint/fmpq_poly.h> 19 #include <factory/factory.h> 36 while (*s >=
'0' && *s <=
'9') s++;
39 mpz_set_str(i,start,10);
45 mpz_set_str(i,start,10);
51 static const char*
Eati(
const char *
s,
int *
i)
54 if (((*s) >=
'0') && ((*s) <=
'9'))
62 while (((*s) >=
'0') && ((*s) <=
'9'));
73 Print(
"// flint fmpq_poly\n");
126 fmpq_poly_clear(mod);
153 fmpq_poly_set_si(res,i);
160 fmpq_poly_set_mpz(res,i);
179 long nl=mpz_get_si(num);
180 if (mpz_cmp_si(num,nl)!=0) nl=0;
181 long dl=mpz_get_si(den);
182 if ((dl!=1)||(mpz_cmp_si(den,dl)!=0)) nl=0;
200 mpq_get_num(result,m);
202 int dl=(int)mpz_get_si(den);
203 if ((dl!=1)||(mpz_cmp_si(den,(
long)dl)!=0)) mpz_set_ui(result,0);
270 if (mpz_cmp_ui(num,0)!=0)
272 if (need_plus && (mpz_cmp_si(num,0)>0))
275 int l=mpz_sizeinbase(num,10);
276 l=
si_max(l,(
int)mpz_sizeinbase(den,10));
279 char *z=mpz_get_str(s,10,num);
281 ||(mpz_cmp_si(num,1)!=0)
282 ||(mpz_cmp_si(den,1)!=0))
285 if (mpz_cmp_si(den,1)!=0)
288 z=mpz_get_str(s,10,den);
305 static const char*
Read(
const char * st, number *
a,
const coeffs r)
310 *a=(number)
omAlloc(
sizeof(fmpq_poly_t));
313 if (*s==
'-') { neg=
TRUE; s++;}
328 else if(strncmp(s,r->pParameterNames[0],strlen(r->pParameterNames[0]))==0)
331 s+=strlen(r->pParameterNames[0]);
378 if (mpz_cmp_si(num,(
long)-1)!=0) result=
FALSE;
383 int dl=(int)mpz_get_si(den);
384 if ((dl!=1)||(mpz_cmp_si(den,(
long)dl)!=0)) result=
FALSE;
397 return (mpq_cmp_si(m,0,1)>0);
411 fmpq_poly_set_fmpz(res,den);
420 fmpq_poly_scalar_mul_fmpz(res,res,den);
472 fmpq_poly_set_mpz(res,i->z);
481 WerrorS(
"not yet: ChineseRemainder");
491 fmpq_poly_set_coeff_si(res,1,1);
501 WerrorS(
"not yet: ConvSingNFactoryN");
570 cf->iNumberOfParameters = 1;
571 char **pn=(
char**)
omAlloc0(
sizeof(
char*));
573 cf->pParameterNames = (
const char **)pn;
574 cf->has_simple_Inverse=
FALSE;
575 cf->has_simple_Alloc=
FALSE;
BOOLEAN flintQ_InitChar(coeffs cf, void *infoStruct)
static number IntMod(number a, number b, const coeffs c)
static number Copy(number a, const coeffs r)
const CanonicalForm int s
static int ParDeg(number x, const coeffs r)
static long Int(number &n, const coeffs r)
static number Parameter(const int i, const coeffs r)
static BOOLEAN Equal(number a, number b, const coeffs r)
static void WriteShort(number a, const coeffs r)
static nMapFunc SetMap(const coeffs src, const coeffs dst)
static int Size(number n, const coeffs r)
static number Neg(number a, const coeffs r)
static char * nlEatLong(char *s, mpz_ptr i)
static number GetDenom(number &n, const coeffs r)
static number GetNumerator(number &n, const coeffs r)
static CanonicalForm ConvSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
static const char * Read(const char *st, number *a, const coeffs r)
void WerrorS(const char *s)
static void KillChar(coeffs r)
static void Power(number a, int i, number *result, const coeffs r)
Coefficient rings, fields and other domains suitable for Singular polynomials.
static void Normalize(number &a, const coeffs r)
The main handler for Singular numbers which are suitable for Singular polynomials.
static number ExtGcd(number a, number b, number *s, number *t, const coeffs r)
void StringAppendS(const char *st)
static number ChineseRemainder(number *x, number *q, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs)
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
static void MPZ(mpz_t result, number &n, const coeffs r)
static BOOLEAN IsMOne(number k, const coeffs r)
const char *const nDivBy0
static int si_max(const int a, const int b)
static const char * Eati(const char *s, int *i)
static number ExactDiv(number a, number b, const coeffs c)
static number ConvFactoryNSingN(const CanonicalForm n, const coeffs r)
static void Delete(number *a, const coeffs r)
static number Gcd(number a, number b, const coeffs r)
static BOOLEAN IsOne(number a, const coeffs r)
static number Invers(number a, const coeffs r)
static number Init(long i, const coeffs r)
static BOOLEAN Greater(number a, number b, const coeffs r)
static BOOLEAN DBTest(number a, const char *f, const int l, const coeffs r)
static number Div(number a, number b, const coeffs c)
static number Sub(number a, number b, const coeffs c)
static BOOLEAN GreaterZero(number k, const coeffs r)
BOOLEAN CoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
static void SetChar(const coeffs r)
static number Farey(number p, number n, const coeffs)
static BOOLEAN IsZero(number a, const coeffs r)
static number InitMPZ(mpz_t i, const coeffs r)
static void CoeffWrite(const coeffs r, BOOLEAN details)
fmpq_poly_struct * fmpq_poly_ptr
static number Add(number a, number b, const coeffs c)
static number Mult(number a, number b, const coeffs c)
static number Init_bigint(number i, const coeffs dummy, const coeffs dst)
static number Lcm(number a, number b, const coeffs r)