13#include <flint/flint.h>
14#include <flint/fmpq_poly.h>
15#include "factory/factory.h"
31 while (*
s >=
'0' && *
s <=
'9')
s++;
34 mpz_set_str(
i,start,10);
40 mpz_set_str(
i,start,10);
122 fmpq_poly_set_si(
res,
i);
129 fmpq_poly_set_mpz(
res,
i);
148 long nl=mpz_get_si(
num);
149 if (mpz_cmp_si(
num,nl)!=0) nl=0;
150 long dl=mpz_get_si(
den);
151 if ((dl!=1)||(mpz_cmp_si(
den,dl)!=0)) nl=0;
171 int dl=(int)mpz_get_si(
den);
172 if ((dl!=1)||(mpz_cmp_si(
den,(
long)dl)!=0)) mpz_set_ui(
result,0);
244 int l=mpz_sizeinbase(
num,10);
248 char *z=mpz_get_str(
s,10,
num);
250 ||(mpz_cmp_si(
num,1)!=0)
251 ||(mpz_cmp_si(
den,1)!=0))
254 if (mpz_cmp_si(
den,1)!=0)
257 z=mpz_get_str(
s,10,
den);
274static const char*
Read(
const char * st, number * a,
const coeffs r)
279 *a=(number)
omAlloc(
sizeof(fmpq_poly_t));
282 if (*
s==
'-') { neg=
TRUE;
s++;}
297 else if(strncmp(
s,r->pParameterNames[0],strlen(r->pParameterNames[0]))==0)
300 s+=strlen(r->pParameterNames[0]);
352 int dl=(int)mpz_get_si(
den);
378 fmpq_poly_set_fmpz(
res,
den);
441 fmpq_poly_set_mpz(
res,
i->z);
452 WerrorS(
"not yet: ChineseRemainder");
463 fmpq_poly_set_coeff_si(
res,1,1);
470 int l=fmpq_poly_length(aa);
477 for(
int i=
l;
i>=0;
i--)
501 for (
int i=
l;
i>=0;
i--)
508 fmpq_poly_set_coeff_mpq(aa,
i,
m);
518 WerrorS(
"not yet: ConvFactoryNSingN");
523 WerrorS(
"not yet: ConvSingNFactoryN");
529 sprintf(CoeffName_flint_Q,
"flintQp[%s]",r->pParameterNames[0]);
530 return (
char*)CoeffName_flint_Q;
535 const char start[]=
"flintQp[";
536 const int start_len=strlen(start);
537 if (strncmp(
s,start,start_len)==0)
541 int l=sscanf(
s,
"%s",st);
544 while (st[strlen(st)-1]==
']') st[strlen(st)-1]=
'\0';
563 char *
pp=(
char*)infoStruct;
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.
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
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 number ExtGcd(number a, number b, number *s, number *t, const coeffs)
static void WriteShort(number a, const coeffs r)
static number Copy(number a, const coeffs)
static number ChineseRemainder(number *, number *, int, BOOLEAN, CFArray &, const coeffs)
static void Normalize(number &a, const coeffs)
static void SetChar(const coeffs)
static nMapFunc SetMap(const coeffs, const coeffs)
static number Farey(number, number, const coeffs)
static number GetDenom(number &n, const coeffs)
static const char * Read(const char *st, number *a, const coeffs r)
static BOOLEAN IsOne(number a, const coeffs)
char * CoeffName(const coeffs r)
static number ConvFactoryNSingN(const CanonicalForm, const coeffs)
BOOLEAN flintQ_InitChar(coeffs cf, void *infoStruct)
fmpq_poly_struct * fmpq_poly_ptr
static number InitMPZ(mpz_t i, const coeffs)
static int Size(number n, const coeffs)
static number Add(number a, number b, const coeffs)
static number Div(number a, number b, const coeffs)
static void WriteFd(number a, const ssiInfo *d, const coeffs)
coeffs flintQInitCfByName(char *s, n_coeffType n)
static void Delete(number *a, const coeffs)
static number Parameter(const int, const coeffs)
static BOOLEAN DBTest(number, const char *, const int, const coeffs)
static void KillChar(coeffs cf)
static CanonicalForm ConvSingNFactoryN(number, BOOLEAN, const coeffs)
static number Init(long i, const coeffs)
static void MPZ(mpz_t result, number &n, const coeffs)
static number ReadFd(const ssiInfo *d, const coeffs)
static number ExactDiv(number a, number b, const coeffs)
static void Power(number a, int i, number *result, const coeffs)
static BOOLEAN IsMOne(number k, const coeffs)
static number Sub(number a, number b, const coeffs)
static number GetNumerator(number &n, const coeffs)
static BOOLEAN GreaterZero(number, const coeffs)
static number Gcd(number a, number b, const coeffs)
static BOOLEAN CoeffIsEqual(const coeffs r, n_coeffType n, void *)
static number Mult(number a, number b, const coeffs)
static number Invers(number a, const coeffs)
static number Lcm(number, number, const coeffs)
static int ParDeg(number x, const coeffs)
static BOOLEAN IsZero(number a, const coeffs)
static number Neg(number a, const coeffs)
static BOOLEAN Equal(number a, number b, const coeffs)
static BOOLEAN Greater(number a, number b, const coeffs)
static long Int(number &n, const coeffs)
static char * nlEatLong(char *s, mpz_ptr i)
static number Init_bigint(number i, const coeffs dummy, const coeffs dst)
static number IntMod(number a, number b, const coeffs c)
The main handler for Singular numbers which are suitable for Singular polynomials.
char * nEati(char *s, int *i, int m)
divide by the first (leading) number and return it, i.e. make monic
const char *const nDivBy0
#define omFreeSize(addr, size)
void StringAppendS(const char *st)
void s_readmpz_base(s_buff F, mpz_ptr a, int base)