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);
238 fmpq_poly_init2(
res,d+1);
239 _fmpq_poly_set_length (
res, d + 1);
254 fmpq_poly_init2(
res,d+1);
255 _fmpq_poly_set_length (
res, d + 1);
270 if (fmpq_poly_is_zero(
f))
return NULL;
271 int d=fmpq_poly_length(
f);
275 for(
int i=0;
i<=d;
i++)
277 fmpq_poly_get_coeff_fmpq(c,
f,
i);
293void convSingPFlintnmod_poly_t(nmod_poly_t
result,
const poly
p,
const ring r)
301 nmod_poly_set_coeff_ui(
result,0,0);
308void convSingMFlintFq_nmod_mat(
matrix m, fq_nmod_mat_t
M,
const fq_nmod_ctx_t
fq_con,
const ring r)
316 convSingPFlintnmod_poly_t (
M->rows[
i-1]+
j-1,
MATELEM(
m,
i,
j),r);
321poly convFlintFq_nmodSingP(
const fq_nmod_t Fp,
const fq_nmod_ctx_t ctx,
const ring r)
325 for (
int i= 0;
i < nmod_poly_length (Fp);
i++)
327 ulong coeff= nmod_poly_get_coeff_ui (Fp,
i);
340matrix convFlintFq_nmod_matSingM(fq_nmod_mat_t
m,
const fq_nmod_ctx_t
fq_con,
const ring r)
348 MATELEM(
M,
i,
j)=convFlintFq_nmodSingP(fq_nmod_mat_entry (
m,
i-1,
j-1),
393 fmpq_mat_init(FLINTM,r,c);
406 WerrorS(
"matrix for rref is not constant");
412 fmpq_mat_rref(FLINTM,FLINTM);
421 fmpq_mat_clear(FLINTM);
429 long rk= nmod_mat_rref (FLINTM);
432 nmod_mat_clear(FLINTM);
436 WerrorS(
"not implemented for these coefficients");
450 fmpq_mat_init(FLINTM,r,c);
461 WerrorS(
"smatrix for rref is not constant");
467 fmpq_mat_rref(FLINTM,FLINTM);
481 fmpq_mat_clear(FLINTM);
486 nmod_mat_init(FLINTM,r,c,
rChar(
R));
497 WerrorS(
"smatrix for rref is not constant");
503 nmod_mat_rref(FLINTM);
508 number n=
n_Init(nmod_mat_entry(FLINTM,
i-1,
j),
R->cf);
517 nmod_mat_clear(FLINTM);
521 WerrorS(
"not implemented for these coefficients");
537 long rk= nmod_mat_nullspace(FLINTX,FLINTM);
538 nmod_mat_clear(FLINTM);
541 nmod_mat_clear(FLINTX);
545 WerrorS(
"not implemented for these coefficients");
560 nmod_mat_init(FLINTM,r,c,
rChar(
R));
561 nmod_mat_init(FLINTX,r,c,
rChar(
R));
572 WerrorS(
"smatrix for rref is not constant");
578 nmod_mat_nullspace(FLINTX,FLINTM);
579 nmod_mat_clear(FLINTM);
584 number n=
n_Init(nmod_mat_entry(FLINTX,
i-1,
j),
R->cf);
593 nmod_mat_clear(FLINTX);
597 WerrorS(
"not implemented for these coefficients");
607 fmpz_mat_t
M, Transf;
608 fmpz_mat_init(
M, r, c);
611 fmpz_mat_init(Transf,
T->rows(),
T->rows());
623 fmpz_set(fmpz_mat_entry(
M,
i-1,
j-1), dummy);
629 for(
i=
T->rows();
i>0;
i--)
631 for(
j=
T->rows();
j>0;
j--)
636 fmpz_set(fmpz_mat_entry(Transf,
i-1,
j-1), dummy);
642 fmpz_lll_context_init_default(fl);
644 fmpz_lll(
M, Transf, fl);
646 fmpz_lll(
M,
NULL, fl);
659 for(
i=
T->rows();
i>0;
i--)
661 for(
j=
T->cols();
j>0;
j--)
679 fmpz_mat_init(
M, r, c);
681 fmpz_mat_init(Transf, r, r);
689 fmpz_set(fmpz_mat_entry(
M,
i-1,
j-1), dummy);
695 for(
i=
T->rows();
i>0;
i--)
697 for(
j=
T->rows();
j>0;
j--)
700 fmpz_set(fmpz_mat_entry(Transf,
i-1,
j-1), dummy);
706 fmpz_lll_context_init_default(fl);
708 fmpz_lll(
M, Transf, fl);
710 fmpz_lll(
M,
NULL, fl);
720 for(
i=Transf->r;
i>0;
i--)
722 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)
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
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
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)
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)
matrix singflint_kernel(matrix m, const ring R)
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)
bigintmat * singflint_LLL(bigintmat *A, bigintmat *T)
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 unsigned long p_SetComp(poly p, unsigned long c, ring r)
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)
static BOOLEAN rField_is_Zp(const ring r)
static BOOLEAN rField_is_Q(const ring r)
ideal idInit(int idsize, int rank)
initialise an ideal / module