15#if __FLINT_RELEASE >= 20500
50#if __FLINT_RELEASE > 20502
71#if __FLINT_RELEASE > 20502
72 if (getCoeffType(
cf)==
n_Q)
82 fmpq_get_mpz_frac(a,
b,
f);
83 if (mpz_cmp_si(
b,1L)!=0)
109#if __FLINT_RELEASE > 20502
116 fmpz_get_mpz((mpz_ptr)z,
f);
122 long i=fmpz_get_si(
f);
143#if __FLINT_RELEASE > 20502
144 if (fmpz_is_one(fmpq_denref(
f)))
146 if (fmpz_fits_si(fmpq_numref(
f)))
148 long i=fmpz_get_si(fmpq_numref(
f));
157 if (fmpz_is_one(fmpq_denref(
f)))
160 fmpz_get_mpz(z->z,fmpq_numref(
f));
166 fmpq_get_mpz_frac(z->z,z->n,
f);
184 fmpz_set_mpz(
f,(mpz_ptr)n);
196 fmpz_set_mpz(fmpq_numref(
f), n->z);
197 fmpz_set_mpz(fmpq_denref(
f), n->n);
201 fmpz_set_mpz(fmpq_numref(
f), n->z);
202 fmpz_set_si(fmpq_denref(
f), 1);
211 number nn=nMap(n,
cf,QQ);
225 fmpz_set_mpz(fmpq_numref(
f), n->z);
226 fmpz_set_mpz(fmpq_denref(
f), n->n);
231 mpz_init_set_si(one,1);
232 fmpz_set_mpz(fmpq_numref(
f), n->z);
233 fmpz_set_mpz(fmpq_denref(
f), one);
255 int d=p_GetExp(
p,1,r);
256 fmpq_poly_init2(
res,d+1);
257 _fmpq_poly_set_length (
res, d + 1);
260 number n=pGetCoeff(
p);
263 fmpq_poly_set_coeff_fmpq(
res,p_GetExp(
p,1,r),c);
271 int d=p_GetExp(
p,1,r);
272 fmpq_poly_init2(
res,d+1);
273 _fmpq_poly_set_length (
res, d + 1);
279 fmpq_poly_set_coeff_fmpq(
res,p_GetExp(
p,1,r),c);
288 if (fmpq_poly_is_zero(
f))
return NULL;
289 int d=fmpq_poly_length(
f);
293 for(
int i=0;
i<=d;
i++)
295 fmpq_poly_get_coeff_fmpq(c,
f,
i);
297 if(!n_IsZero(n,r->cf))
311void convSingPFlintnmod_poly_t(nmod_poly_t
result,
const poly
p,
const ring r)
319 nmod_poly_set_coeff_ui(
result,0,0);
321 nmod_poly_set_coeff_ui(
result,p_GetExp(
h,1,r),n_Int(pGetCoeff(
h),r->cf)+
rChar(r));
326void convSingMFlintFq_nmod_mat(
matrix m, fq_nmod_mat_t
M,
const fq_nmod_ctx_t
fq_con,
const ring r)
334 convSingPFlintnmod_poly_t (fq_nmod_mat_entry(
M,
i-1,
j-1),
MATELEM(
m,
i,
j),r);
339poly convFlintFq_nmodSingP(
const fq_nmod_t Fp,
const fq_nmod_ctx_t ctx,
const ring r)
343 for (
int i= 0;
i < nmod_poly_length (Fp);
i++)
345 ulong coeff= nmod_poly_get_coeff_ui (Fp,
i);
347 h=
p_NSet(n_Init(coeff,r->cf),r);
358matrix convFlintFq_nmod_matSingM(fq_nmod_mat_t
m,
const fq_nmod_ctx_t
fq_con,
const ring r)
366 MATELEM(
M,
i,
j)=convFlintFq_nmodSingP(fq_nmod_mat_entry (
m,
i-1,
j-1),
383 nmod_mat_entry(
M,
i-1,
j-1)=(long)pGetCoeff(
h);
411 fmpq_mat_init(FLINTM,r,c);
420 if (p_Totaldegree(
h,
R)==0)
424 WerrorS(
"matrix for rref is not constant");
430 fmpq_mat_rref(FLINTM,FLINTM);
439 fmpq_mat_clear(FLINTM);
441 else if (rField_is_Zp(
R))
447 long rk= nmod_mat_rref (FLINTM);
450 nmod_mat_clear(FLINTM);
454 WerrorS(
"not implemented for these coefficients");
468 fmpq_mat_init(FLINTM,r,c);
475 if (p_Totaldegree(
h,
R)==0)
479 WerrorS(
"smatrix for rref is not constant");
485 fmpq_mat_rref(FLINTM,FLINTM);
491 if(!n_IsZero(n,
R->cf))
495 M->m[
j]=p_Add_q(
M->m[
j],
p,
R);
499 fmpq_mat_clear(FLINTM);
501 else if (rField_is_Zp(
R))
504 nmod_mat_init(FLINTM,r,c,
rChar(
R));
511 if (p_Totaldegree(
h,
R)==0)
515 WerrorS(
"smatrix for rref is not constant");
521 nmod_mat_rref(FLINTM);
526 number n=n_Init(nmod_mat_entry(FLINTM,
i-1,
j),
R->cf);
527 if(!n_IsZero(n,
R->cf))
531 M->m[
j]=p_Add_q(
M->m[
j],
p,
R);
535 nmod_mat_clear(FLINTM);
539 WerrorS(
"not implemented for these coefficients");
555 long rk= nmod_mat_nullspace(FLINTX,FLINTM);
556 nmod_mat_clear(FLINTM);
559 nmod_mat_clear(FLINTX);
563 WerrorS(
"not implemented for these coefficients");
578 nmod_mat_init(FLINTM,r,c,
rChar(
R));
579 nmod_mat_init(FLINTX,r,c,
rChar(
R));
586 if (p_Totaldegree(
h,
R)==0)
590 WerrorS(
"smatrix for rref is not constant");
596 nmod_mat_nullspace(FLINTX,FLINTM);
597 nmod_mat_clear(FLINTM);
602 number n=n_Init(nmod_mat_entry(FLINTX,
i-1,
j),
R->cf);
603 if(!n_IsZero(n,
R->cf))
607 M->m[
j]=p_Add_q(
M->m[
j],
p,
R);
611 nmod_mat_clear(FLINTX);
615 WerrorS(
"not implemented for these coefficients");
625 fmpz_mat_t
M, Transf;
626 fmpz_mat_init(
M, r, c);
629 fmpz_mat_init(Transf,
T->rows(),
T->rows());
641 fmpz_set(fmpz_mat_entry(
M,
i-1,
j-1), dummy);
647 for(
i=
T->rows();
i>0;
i--)
649 for(
j=
T->rows();
j>0;
j--)
654 fmpz_set(fmpz_mat_entry(Transf,
i-1,
j-1), dummy);
660 fmpz_lll_context_init_default(fl);
662 fmpz_lll(
M, Transf, fl);
664 fmpz_lll(
M,
NULL, fl);
677 for(
i=
T->rows();
i>0;
i--)
679 for(
j=
T->cols();
j>0;
j--)
697 fmpz_mat_init(
M, r, c);
699 fmpz_mat_init(Transf, r, r);
707 fmpz_set(fmpz_mat_entry(
M,
i-1,
j-1), dummy);
713 for(
i=
T->rows();
i>0;
i--)
715 for(
j=
T->rows();
j>0;
j--)
718 fmpz_set(fmpz_mat_entry(Transf,
i-1,
j-1), dummy);
724 fmpz_lll_context_init_default(fl);
726 fmpz_lll(
M, Transf, fl);
728 fmpz_lll(
M,
NULL, fl);
738 for(
i=Transf->r;
i>0;
i--)
740 for(
j=Transf->r;
j>0;
j--)
#define BIMATELEM(M, I, J)
Coefficient rings, fields and other domains suitable for Singular polynomials.
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r).
@ n_Q
rational (GMP) numbers
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 number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
@ n_rep_gmp
(mpz_ptr), see rmodulon,h
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
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)
get numerator as mpz_t
matrix mpNew(int r, int c)
create a r x c zero-matrix
#define MATELEM(mat, i, j)
1-based access to matrix
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)
number nrzInit(long i, const coeffs r)
ideal idInit(int idsize, int rank)
initialise an ideal / module