15 #if __FLINT_RELEASE >= 20500
65 #if __FLINT_RELEASE > 20502
76 fmpq_get_mpz_frac(z->z,z->n,
f);
83 fmpq_get_mpz_frac(a,
b,
f);
103 #if __FLINT_RELEASE > 20502
121 #if __FLINT_RELEASE > 20502
122 if (fmpz_is_one(fmpq_denref(
f)))
124 if (fmpz_fits_si(fmpq_numref(
f)))
126 long i=fmpz_get_si(fmpq_numref(
f));
135 if (fmpz_is_one(fmpq_denref(
f)))
138 fmpz_get_mpz(z->z,fmpq_numref(
f));
144 fmpq_get_mpz_frac(z->z,z->n,
f);
163 fmpz_set_mpz(
f,(mpz_ptr)n);
175 fmpz_set_mpz(fmpq_numref(
f), n->z);
176 fmpz_set_mpz(fmpq_denref(
f), n->n);
181 mpz_init_set_si(one,1);
182 fmpz_set_mpz(fmpq_numref(
f), n->z);
183 fmpz_set_mpz(fmpq_denref(
f), one);
193 number nn=nMap(n,
cf,QQ);
207 fmpz_set_mpz(fmpq_numref(
f), n->z);
208 fmpz_set_mpz(fmpq_denref(
f), n->n);
213 mpz_init_set_si(one,1);
214 fmpz_set_mpz(fmpq_numref(
f), n->z);
215 fmpz_set_mpz(fmpq_denref(
f), one);
233 fmpq_poly_init2(
res,d+1);
234 _fmpq_poly_set_length (
res, d + 1);
249 fmpq_poly_init2(
res,d+1);
250 _fmpq_poly_set_length (
res, d + 1);
265 int d=fmpq_poly_length(
f);
269 for(
int i=0;
i<=d;
i++)
271 fmpq_poly_get_coeff_fmpq(c,
f,
i);
284 void convSingPFlintnmod_poly_t(nmod_poly_t
result,
const poly
p,
const ring r)
292 nmod_poly_set_coeff_ui(
result,0,0);
299 void convSingMFlintFq_nmod_mat(
matrix m, fq_nmod_mat_t
M,
const fq_nmod_ctx_t
fq_con,
const ring r)
307 convSingPFlintnmod_poly_t (
M->rows[
i-1]+
j-1,
MATELEM(
m,
i,
j),r);
312 poly convFlintFq_nmodSingP(
const fq_nmod_t Fp,
const fq_nmod_ctx_t ctx,
const ring r)
316 for (
int i= 0;
i < nmod_poly_length (Fp);
i++)
318 ulong coeff= nmod_poly_get_coeff_ui (Fp,
i);
331 matrix convFlintFq_nmod_matSingM(fq_nmod_mat_t
m,
const fq_nmod_ctx_t
fq_con,
const ring r)
339 MATELEM(
M,
i,
j)=convFlintFq_nmodSingP(fq_nmod_mat_entry (
m,
i-1,
j-1),
356 nmod_mat_entry(
M,
i-1,
j-1)=0;
386 fmpq_mat_init(FLINTM,r,c);
399 WerrorS(
"matrix for rref is nor constant");
405 fmpq_mat_rref(FLINTM,FLINTM);
414 fmpq_mat_clear(FLINTM);
422 long rk= nmod_mat_rref (FLINTM);
425 nmod_mat_clear(FLINTM);
432 fq_nmod_ctx_init(ctx,
p,1,
"t");
433 fq_nmod_mat_t FLINTM;
435 convSingMFlintFq_nmod_mat(
M,FLINTM,ctx,
currRing);
437 long rk= fq_nmod_mat_rref (FLINTM,ctx);
438 res->data=(
void*)convFlintFq_nmod_matSingM(FLINTM,ctx,
currRing);
440 fq_nmod_mat_clear (FLINTM,ctx);
444 WerrorS(
"not implemented for these coefficients");
454 fmpz_mat_t
M, Transf;
455 fmpz_mat_init(
M, r, c);
458 fmpz_mat_init(Transf,
T->rows(),
T->rows());
470 fmpz_set(fmpz_mat_entry(
M,
i-1,
j-1), dummy);
476 for(
i=
T->rows();
i>0;
i--)
478 for(
j=
T->rows();
j>0;
j--)
483 fmpz_set(fmpz_mat_entry(Transf,
i-1,
j-1), dummy);
489 fmpz_lll_context_init_default(fl);
491 fmpz_lll(
M, Transf, fl);
493 fmpz_lll(
M,
NULL, fl);
506 for(
i=
T->rows();
i>0;
i--)
508 for(
j=
T->cols();
j>0;
j--)
526 fmpz_mat_init(
M, r, c);
528 fmpz_mat_init(Transf, r, r);
536 fmpz_set(fmpz_mat_entry(
M,
i-1,
j-1), dummy);
542 for(
i=
T->rows();
i>0;
i--)
544 for(
j=
T->rows();
j>0;
j--)
547 fmpz_set(fmpz_mat_entry(Transf,
i-1,
j-1), dummy);
553 fmpz_lll_context_init_default(fl);
555 fmpz_lll(
M, Transf, fl);
557 fmpz_lll(
M,
NULL, fl);
567 for(
i=Transf->r;
i>0;
i--)
569 for(
j=Transf->r;
j>0;
j--)
#define BIMATELEM(M, I, J)
Coefficient rings, fields and other domains suitable for Singular polynomials.
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
@ n_Q
rational (GMP) numbers
static FORCE_INLINE void n_MPZ(mpz_t result, number &n, const coeffs r)
conversion of n to a GMP integer; 0 if not possible
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
static FORCE_INLINE number n_RePart(number i, const coeffs cf)
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
static FORCE_INLINE number n_ImPart(number i, const coeffs cf)
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
void nKillChar(coeffs r)
undo all initialisations
fq_nmod_ctx_clear(fq_con)
void WerrorS(const char *s)
This file is work in progress and currently not part of the official Singular.
void convSingPFlintP(fmpq_poly_t res, poly p, const ring r)
void convSingNFlintN(fmpz_t f, mpz_t z)
bigintmat * singflint_LLL(bigintmat *A, bigintmat *T)
matrix convFlintNmod_matSingM(nmod_mat_t m, const ring r)
void convSingNFlintNN(fmpq_t re, fmpq_t im, number n, const coeffs cf)
void convSingIFlintI(fmpz_t f, int p)
void convSingNFlintN_QQ(fmpq_t f, number n)
void convFlintNSingN(mpz_t z, fmpz_t f)
matrix singflint_rref(matrix m, const ring R)
poly convFlintPSingP(fmpq_poly_t f, const ring r)
void convSingImPFlintP(fmpq_poly_t res, poly p, const ring r)
int convFlintISingI(fmpz_t f)
number convFlintNSingN_QQ(fmpq_t f, const coeffs cf)
void convSingMFlintNmod_mat(matrix m, nmod_mat_t M, const ring r)
#define IMATELEM(M, I, J)
void nlMPZ(mpz_t m, number &n, const coeffs r)
matrix mpNew(int r, int c)
create a r x c zero-matrix
#define MATELEM(mat, i, j)
1-based access to matrix
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
The main handler for Singular numbers which are suitable for Singular polynomials.
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
long p_Deg(poly a, const ring r)
static poly p_Add_q(poly p, poly q, const ring r)
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
static void p_Setm(poly p, const ring r)
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
static poly p_Init(const ring r, omBin bin)
static long p_Totaldegree(poly p, const ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
static BOOLEAN rField_is_Zp(const ring r)
static BOOLEAN rField_is_Q(const ring r)