37 #ifndef __GMP_BITS_PER_MP_LIMB 38 #define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS 40 #include <flint/fmpz.h> 41 #include <flint/fmpq.h> 42 #include <flint/fmpz_poly.h> 43 #include <flint/fmpz_mod_poly.h> 44 #include <flint/nmod_poly.h> 45 #include <flint/fmpq_poly.h> 46 #include <flint/nmod_mat.h> 47 #include <flint/fmpz_mat.h> 48 #if ( __FLINT_RELEASE >= 20400) 50 #include <flint/fq_poly.h> 51 #include <flint/fq_nmod.h> 52 #include <flint/fq_nmod_poly.h> 53 #include <flint/fq_nmod_mat.h> 64 fmpz_set_si (result, f.
intval());
69 fmpz_set_mpz (result, gmp_val);
76 fmpz_poly_init2 (result,
degree (f)+1);
77 _fmpz_poly_set_length(result,
degree(f)+1);
87 long coeff= fmpz_get_si (coefficient);
94 fmpz_get_mpz (gmp_val, coefficient);
105 for (
int i= 0;
i < fmpz_poly_length (poly);
i++)
107 coeff= fmpz_poly_get_coeff_ptr (poly,
i);
108 if (!fmpz_is_zero (coeff))
127 printf(
"convertCF2nmod_poly_t: coefficient not immediate!, char=%d\n",
131 nmod_poly_set_coeff_ui (result,
i.exp(), c.
intval());
140 for (
int i= 0;
i < nmod_poly_length (poly);
i++)
142 ulong coeff= nmod_poly_get_coeff_ui (poly,
i);
164 fmpz_set_mpz (tmp1, gmp_val);
167 fmpz_set_mpz (tmp2, gmp_val);
171 fmpz_set (fmpq_numref (result), tmp1);
172 fmpz_set (fmpq_denref (result), tmp2);
187 fmpz_get_mpz (nnum, fmpq_numref (q));
188 fmpz_get_mpz (nden, fmpq_denref (q));
204 result=
make_cf (nnum, nden,
false);
217 for (
long i= 0;
i < n;
i++)
220 fmpq_poly_get_coeff_fmpq (coeff, p,
i);
221 if (fmpq_is_zero (coeff))
244 fmpq_poly_init2 (result,
degree (f)+1);
245 _fmpq_poly_set_length (result,
degree (f) + 1);
256 const mp_limb_t leadingCoeff,
261 if (leadingCoeff != 1)
266 for (i = 0; i < fac->num; i++)
268 (nmod_poly_t &)fac->p[i],x),
273 #if __FLINT_RELEASE >= 20400 277 const fq_nmod_ctx_t
fq_con 284 for (i = 0; i < fac->num; i++)
286 (fq_nmod_poly_t &)fac->poly[i], x, alpha, fq_con),
296 fmpz_mod_poly_init2 (result, p,
degree (f) + 1);
299 fmpz_mod_poly_set_fmpz_poly (result, buf);
300 fmpz_poly_clear (buf);
308 fmpz_poly_init (buf);
309 fmpz_mod_poly_get_fmpz_poly (buf, poly);
311 fmpz_poly_clear (buf);
315 #if __FLINT_RELEASE >= 20400 318 const fq_nmod_ctx_t ctx)
329 printf(
"convertFacCF2Fq_nmod_t: coefficient not immediate!, char=%d\n",
334 STICKYASSERT (
i.exp() <= fq_nmod_ctx_degree(ctx),
"convertFacCF2Fq_nmod_t: element is not reduced");
335 nmod_poly_set_coeff_ui (result,
i.exp(), c.
intval());
350 fmpz_poly_init2 (result, fq_ctx_degree(ctx));
351 ASSERT (
degree (f) < fq_ctx_degree (ctx),
"input is not reduced");
352 _fmpz_poly_set_length(result,
degree(f)+1);
355 _fmpz_vec_scalar_mod_fmpz (result->coeffs, result->coeffs,
degree (f) + 1,
357 _fmpz_poly_normalise (result);
370 fq_poly_init2 (result,
degree (f)+1, ctx);
371 _fq_poly_set_length (result,
degree (f) + 1, ctx);
376 _fmpz_vec_scalar_mod_fmpz (buf->coeffs, buf->coeffs,
degree (
i.coeff()) + 1,
378 _fmpz_poly_normalise (buf);
379 fq_poly_set_coeff (result,
i.exp(),
buf, ctx);
380 fmpz_poly_clear (buf);
386 const fq_nmod_ctx_t ctx)
388 fq_nmod_poly_init2 (result,
degree (f)+1, ctx);
389 _fq_nmod_poly_set_length (result,
degree (f) + 1, ctx);
391 fq_nmod_init2 (buf, ctx);
395 fq_nmod_poly_set_coeff (result,
i.exp(),
buf, ctx);
396 fq_nmod_zero (buf, ctx);
398 fq_nmod_clear (buf, ctx);
407 long n= fq_poly_length (p, ctx);
408 fq_init2 (coeff, ctx);
409 for (
long i= 0;
i < n;
i++)
411 fq_poly_get_coeff (coeff, p,
i, ctx);
412 if (fq_is_zero (coeff, ctx))
415 fq_zero (coeff, ctx);
417 fq_clear (coeff, ctx);
428 long n= fq_nmod_poly_length (p, ctx);
429 fq_nmod_init2 (coeff, ctx);
430 for (
long i= 0;
i < n;
i++)
432 fq_nmod_poly_get_coeff (coeff, p,
i, ctx);
433 if (fq_nmod_is_zero (coeff, ctx))
436 fq_nmod_zero (coeff, ctx);
438 fq_nmod_clear (coeff, ctx);
446 fmpz_mat_init (M, (
long) m.
rows(), (long) m.
columns());
449 for(i=m.
rows();i>0;i--)
461 for(i=res->
rows();i>0;i--)
478 for(i=m.
rows();i>0;i--)
482 if(!(
m(i,j)).isImm()) printf(
"convertFacCFMatrix2FLINTmat_zz_p: not imm.\n");
483 nmod_mat_entry (M,i-1,j-1)= (
m(i,j)).intval();
493 for(i=res->
rows();i>0;i--)
503 #if __FLINT_RELEASE >= 20400 510 for(i=m.
rows();i>0;i--)
521 const fq_nmod_ctx_t&
fq_con,
525 fq_nmod_mat_ncols (m, fq_con));
527 for(i=res->
rows();i>0;i--)
CFMatrix * convertNmod_mat_t2FacCFMatrix(const nmod_mat_t m)
conversion of a FLINT matrix over Z/p to a factory matrix
CanonicalForm convertFq_t2FacCF(const fq_t poly, const Variable &alpha)
conversion of a FLINT element of F_q with non-word size p to a CanonicalForm with alg...
void convertFacCF2Fmpz_poly_t(fmpz_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomial over Z to a fmpz_poly_t
This file defines functions for conversion to FLINT (www.flintlib.org) and back.
void convertCF2Fmpz(fmpz_t result, const CanonicalForm &f)
conversion of a factory integer to fmpz_t
void convertFacCFMatrix2nmod_mat_t(nmod_mat_t M, const CFMatrix &m)
conversion of a factory matrix over Z/p to a nmod_mat_t
void convertFacCF2Fq_t(fq_t result, const CanonicalForm &f, const fq_ctx_t ctx)
conversion of a factory element of F_q (for non-word size p) to a FLINT fq_t
CanonicalForm convertFq_nmod_t2FacCF(const fq_nmod_t poly, const Variable &alpha)
conversion of a FLINT element of F_q to a CanonicalForm with alg. variable alpha
void convertCF2Fmpq(fmpq_t result, const CanonicalForm &f)
conversion of a factory rationals to fmpq_t
factory's class for variables
void convertFacCF2Fq_nmod_poly_t(fq_nmod_poly_t result, const CanonicalForm &f, const fq_nmod_ctx_t ctx)
conversion of a factory univariate poly over F_q to a FLINT fq_nmod_poly_t
CFFList convertFLINTFq_nmod_poly_factor2FacCFFList(const fq_nmod_poly_factor_t fac, const Variable &x, const Variable &alpha, const fq_nmod_ctx_t fq_con)
conversion of a FLINT factorization over Fq (for word size p) to a CFFList
CanonicalForm convertFmpz2CF(const fmpz_t coefficient)
conversion of a FLINT integer to CanonicalForm
CanonicalForm make_cf(const mpz_ptr n)
CFMatrix * convertFmpz_mat_t2FacCFMatrix(const fmpz_mat_t m)
conversion of a FLINT matrix over Z to a factory matrix
CanonicalForm convertFq_nmod_poly_t2FacCF(const fq_nmod_poly_t p, const Variable &x, const Variable &alpha, const fq_nmod_ctx_t ctx)
conversion of a FLINT poly over Fq to a CanonicalForm with alg. variable alpha and polynomial variabl...
helper functions for conversion to and from Singular
void convertFacCF2nmod_poly_t(nmod_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomials over Z/p (for word size p) to nmod_poly_t ...
CFFList convertFLINTnmod_poly_factor2FacCFFList(const nmod_poly_factor_t fac, const mp_limb_t leadingCoeff, const Variable &x)
conversion of a FLINT factorization over Z/p (for word size p) to a CFFList
int status int void * buf
Interface to generate InternalCF's over various domains from intrinsic types or mpz_t's.
void convertFacCF2Fq_nmod_t(fq_nmod_t result, const CanonicalForm &f, const fq_nmod_ctx_t ctx)
conversion of a factory element of F_q to a FLINT fq_nmod_t, does not do any memory allocation for po...
static const int SW_RATIONAL
set to 1 for computations over Q
Iterators for CanonicalForm's.
void convertFacCFMatrix2Fq_nmod_mat_t(fq_nmod_mat_t M, const fq_nmod_ctx_t fq_con, const CFMatrix &m)
conversion of a factory matrix over F_q to a fq_nmod_mat_t
static InternalCF * basic(long value)
declarations of higher level algorithms.
CanonicalForm bCommonDen(const CanonicalForm &f)
CanonicalForm bCommonDen ( const CanonicalForm & f )
CFMatrix * convertFq_nmod_mat_t2FacCFMatrix(const fq_nmod_mat_t m, const fq_nmod_ctx_t &fq_con, const Variable &alpha)
conversion of a FLINT matrix over F_q to a factory matrix
class to iterate through CanonicalForm's
void gmp_numerator(const CanonicalForm &f, mpz_ptr result)
void convertFacCF2Fmpq_poly_t(fmpq_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomials over Q to fmpq_poly_t
CanonicalForm convertFmpz_poly_t2FacCF(const fmpz_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z to CanonicalForm
#define STICKYASSERT(expression, message)
utility functions for gmp
void convertFacCF2Fmpz_mod_poly_t(fmpz_mod_poly_t result, const CanonicalForm &f, const fmpz_t p)
conversion of a factory univariate poly over Z to a FLINT poly over Z/p (for non word size p) ...
CanonicalForm convertFmpz_mod_poly_t2FacCF(const fmpz_mod_poly_t poly, const Variable &x, const modpk &b)
conversion of a FLINT poly over Z/p (for non word size p) to a CanonicalForm over Z ...
CanonicalForm convertFmpq_t2CF(const fmpq_t q)
#define ASSERT(expression, message)
operations mod p^k and some other useful functions for factorization
CanonicalForm convertFmpq_poly_t2FacCF(const fmpq_poly_t p, const Variable &x)
conversion of a FLINT poly over Q to CanonicalForm
static const int SW_SYMMETRIC_FF
set to 1 for symmetric representation over F_q
bool mpz_is_imm(const mpz_t mpi)
void convertFacCFMatrix2Fmpz_mat_t(fmpz_mat_t M, const CFMatrix &m)
conversion of a factory matrix over Z to a fmpz_mat_t
void convertFacCF2Fq_poly_t(fq_poly_t result, const CanonicalForm &f, const fq_ctx_t ctx)
conversion of a factory univariate poly over F_q (for non-word size p) to a FLINT fq_poly_t ...
void convertFacCF2Fmpz_array(fmpz *result, const CanonicalForm &f)
class to do operations mod p^k for int's p and k
CanonicalForm convertFq_poly_t2FacCF(const fq_poly_t p, const Variable &x, const Variable &alpha, const fq_ctx_t ctx)
conversion of a FLINT poly over Fq (for non-word size p) to a CanonicalForm with alg. variable alpha and polynomial variable x
CanonicalForm convertnmod_poly_t2FacCF(const nmod_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z/p to CanonicalForm
void gmp_denominator(const CanonicalForm &f, mpz_ptr result)