Loading...
Searching...
No Matches
FLINTconvert.h
Go to the documentation of this file.
/*****************************************************************************\
* Computer Algebra System SINGULAR
\*****************************************************************************/
/** @file FLINTconvert.h
*
* This file defines functions for conversion to FLINT (www.flintlib.org)
* and back.
*
* @author Martin Lee
*
**/
/*****************************************************************************/
#ifndef FLINT_CONVERT_H
#define FLINT_CONVERT_H
// #include "config.h"
#include "canonicalform.h"
#include "fac_util.h"
#ifdef HAVE_FLINT
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef __GMP_BITS_PER_MP_LIMB
#define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS
#endif
#include <flint/fmpz.h>
#include <flint/fmpq.h>
#include <flint/fmpz_poly.h>
#include <flint/fmpz_mod_poly.h>
#include <flint/fmpq_poly.h>
#include <flint/nmod_poly.h>
#include <flint/nmod_mat.h>
#include <flint/fmpz_mat.h>
#if ( __FLINT_RELEASE >= 20400)
#include <flint/fq.h>
#include <flint/fq_poly.h>
#include <flint/fq_nmod.h>
#include <flint/fq_nmod_poly.h>
#include <flint/fq_nmod_mat.h>
#if ( __FLINT_RELEASE >= 20503)
#include <flint/fmpq_mpoly.h>
#endif
#if ( __FLINT_RELEASE >= 20700)
#include <flint/fq_nmod_mpoly_factor.h>
#include <flint/fmpz_mod.h>
#endif
#if ( __FLINT_RELEASE >= 30000)
#include <flint/nmod.h>
#include <flint/nmod_mpoly.h>
#include <flint/fmpz_vec.h>
#endif
#endif
EXTERN_VAR flint_rand_t FLINTrandom;
#ifdef __cplusplus
}
#endif
#include "factory/cf_gmp.h"
/// conversion of a factory integer to fmpz_t
void
convertCF2Fmpz (fmpz_t result, ///< [out] an fmpz_t
const CanonicalForm& f ///< [in] a CanonicalForm wrapping an
///< integer
);
/// conversion of a factory integer to fmpz_t(init.)
void
convertCF2initFmpz (fmpz_t result, ///< [in,out] an fmpz_t
const CanonicalForm& f ///< [in] a CanonicalForm wrapping an
///< integer
);
/// conversion of a factory univariate polynomial over Z to a fmpz_poly_t
void
convertFacCF2Fmpz_poly_t (fmpz_poly_t result, ///< [in,out] an fmpz_poly_t
const CanonicalForm& f ///< [in] univariate poly over
///< Z
);
/// conversion of a FLINT integer to CanonicalForm
CanonicalForm
convertFmpz2CF (const fmpz_t coefficient ///< [in] a FLINT integer
);
/// conversion of a FLINT poly over Z to CanonicalForm
CanonicalForm
convertFmpz_poly_t2FacCF (const fmpz_poly_t poly, ///< [in] an fmpz_poly_t
const Variable& x ///< [in] variable the result should
///< have
);
/// conversion of a factory univariate polynomials over Z/p (for word size p)
/// to nmod_poly_t
void
convertFacCF2nmod_poly_t (nmod_poly_t result, ///< [in, out] a nmod_poly_t
const CanonicalForm& f ///< [in] univariate poly over
///< Z/p
);
/// conversion of a FLINT poly over Z/p to CanonicalForm
CanonicalForm
convertnmod_poly_t2FacCF (const nmod_poly_t poly, ///< [in] a nmod_poly_t
const Variable& x ///< [in] variable the result should
///< have
);
/// conversion of a factory rationals to fmpq_t
void
convertCF2Fmpq (fmpq_t result, ///< [in,out] an fmpq_t
const CanonicalForm& f ///< [in] a CanonicalForm wrapping a
///< rational
);
/// conversion of a FLINT rational to CanonicalForm
CanonicalForm convertFmpq2CF (const fmpq_t q);
/// conversion of a factory univariate polynomials over Q to fmpq_poly_t
void
convertFacCF2Fmpq_poly_t (fmpq_poly_t result, ///< [in,out] an fmpq_poly_t
const CanonicalForm& f ///< [in] univariate poly over
///< Q
);
/// conversion of a FLINT poly over Q to CanonicalForm
CanonicalForm
convertFmpq_poly_t2FacCF (const fmpq_poly_t p, ///< [in] an fmpq_poly_t
const Variable& x ///< [in] variable the result should
///< have
);
/// conversion of a FLINT factorization over Z/p (for word size p) to a
/// CFFList
CFFList
convertFLINTnmod_poly_factor2FacCFFList (
const nmod_poly_factor_t fac, ///< [in] a nmod_poly_factor_t
const mp_limb_t leadingCoeff, ///< [in] leading coefficient
const Variable& x ///< [in] variable the result should
///< have
);
/// conversion of a FLINT factorization over Z to a CFFList
CFFList
convertFLINTfmpz_poly_factor2FacCFFList (
const fmpz_poly_factor_t fac, ///< [in] a fmpz_poly_factor_t
const Variable& x ///< [in] variable the result should
///< have
);
#if ( __FLINT_RELEASE >= 20700)
/// conversion of a FLINT factorization over Zp(a) to a CFFList
CFFList
convertFLINTFq_nmod_mpoly_factor2FacCFFList (
fq_nmod_mpoly_factor_t fac, ///< [in] a fq_nmod_mpoly_factor_t
const fq_nmod_mpoly_ctx_t& ctx,///< [in] context
const int N, ///< [in] #vars
const fq_nmod_ctx_t& fq_ctx, ///< [in] fq context
const Variable alpha ///< [in] alpha
);
#endif
/// conversion of a factory univariate poly over Z to a FLINT poly over
/// Z/p (for non word size p)
void
convertFacCF2Fmpz_mod_poly_t (
fmpz_mod_poly_t result, ///< [in,out] fmpz_mod_poly_t
const CanonicalForm& f, ///< [in] univariate poly over
///< Z
const fmpz_t p ///< [in] some integer p
);
/// conversion of a FLINT poly over Z/p (for non word size p) to a CanonicalForm
/// over Z
CanonicalForm
convertFmpz_mod_poly_t2FacCF (
const fmpz_mod_poly_t poly, ///< [in] fmpz_mod_poly_t
const Variable& x, ///< [in] variable the result
///< should have
const modpk& b ///< [in] coeff bound to map
///< coeffs in (-p/2,p/2)
);
#if __FLINT_RELEASE >= 20400
/// conversion of a FLINT element of F_q to a CanonicalForm with alg. variable
/// alpha
CanonicalForm
convertFq_nmod_t2FacCF (const fq_nmod_t poly, ///< [in] fq_nmod_t
const Variable& alpha, ///< [in] algebraic variable
const fq_nmod_ctx_t ctx ///<[in] context
);
/// conversion of a FLINT element of F_q with non-word size p to a CanonicalForm
/// with alg. variable alpha
CanonicalForm
convertFq_t2FacCF (const fq_t poly, ///< [in] fq_t
const Variable& alpha ///< [in] algebraic variable
);
/// conversion of a factory element of F_q to a FLINT fq_nmod_t, does not do any
/// memory allocation for poly
void
convertFacCF2Fq_nmod_t (fq_nmod_t result, ///< [in,out] fq_nmod_t
const CanonicalForm& f, ///< [in] element of Fq
const fq_nmod_ctx_t ctx ///< [in] Fq context
);
#if ( __FLINT_RELEASE >= 20700)
/// conversion of a factory polynomial over of F_q to a FLINT fq_nmod_mpoly_t, does not do any
/// memory allocation for poly
void
convertFacCF2Fq_nmod_mpoly_t (fq_nmod_mpoly_t result, ///< [in,out] fq_nmod_mpoly__t
const CanonicalForm& f, ///< [in] poly over Fq
const fq_nmod_mpoly_ctx_t ctx,///< [in] context
const int N, ///< [in] #vars
const fq_nmod_ctx_t fq_ctx ///< [in] fq context
);
#endif
/// conversion of a factory element of F_q (for non-word size p) to a FLINT fq_t
void
convertFacCF2Fq_t (fq_t result, ///< [in,out] fq_t
const CanonicalForm& f, ///< [in] element of Fq
const fq_ctx_t ctx ///< [in] Fq context
);
/// conversion of a factory univariate poly over F_q (for non-word size p) to a
/// FLINT fq_poly_t
void
convertFacCF2Fq_poly_t (fq_poly_t result, ///< [in,out] fq_poly_t
const CanonicalForm& f,///< [in] univariate poly over Fq
const fq_ctx_t ctx ///< [in] Fq context
);
/// conversion of a factory univariate poly over F_q to a FLINT fq_nmod_poly_t
void
convertFacCF2Fq_nmod_poly_t (fq_nmod_poly_t result, ///< [in,out] fq_nmod_poly_t
const CanonicalForm& f,///< [in] univariate poly
///< over Fq
const fq_nmod_ctx_t ctx///< [in] Fq context
);
/// conversion of a FLINT poly over Fq (for non-word size p) to a CanonicalForm
/// with alg. variable alpha and polynomial variable x
CanonicalForm
convertFq_poly_t2FacCF (const fq_poly_t p, ///< [in] fq_poly_t
const Variable& x, ///< [in] polynomial variable
const Variable& alpha, ///< [in] algebraic variable
const fq_ctx_t ctx ///< [in] Fq context
);
/// conversion of a FLINT poly over Fq to a CanonicalForm with alg. variable
/// alpha and polynomial variable x
CanonicalForm
convertFq_nmod_poly_t2FacCF (const fq_nmod_poly_t p, ///< [in] fq_nmod_poly_t
const Variable& x, ///< [in] polynomial var.
const Variable& alpha, ///< [in] algebraic var.
const fq_nmod_ctx_t ctx ///< [in] Fq context
);
#endif
/// conversion of a factory matrix over Z to a fmpz_mat_t
void convertFacCFMatrix2Fmpz_mat_t (fmpz_mat_t M, ///<[in,out] fmpz_mat_t
const CFMatrix &m ///<[in] matrix over Z
);
/// conversion of a FLINT matrix over Z to a factory matrix
CFMatrix* convertFmpz_mat_t2FacCFMatrix(const fmpz_mat_t m ///<[in] fmpz_mat_t
);
/// conversion of a factory matrix over Z/p to a nmod_mat_t
void convertFacCFMatrix2nmod_mat_t (nmod_mat_t M, ///<[in,out] nmod_mat_t
const CFMatrix &m ///<[in] matrix over Z/p
);
/// conversion of a FLINT matrix over Z/p to a factory matrix
CFMatrix* convertNmod_mat_t2FacCFMatrix(const nmod_mat_t m ///<[in] nmod_mat_t
);
#if __FLINT_RELEASE >= 20400
/// conversion of a FLINT matrix over F_q to a factory matrix
CFMatrix*
convertFq_nmod_mat_t2FacCFMatrix(const fq_nmod_mat_t m, ///< [in] fq_nmod_mat_t
const fq_nmod_ctx_t& fq_con, ///< [in] Fq context
const Variable& alpha ///< [in] algebraic variable
);
/// conversion of a factory matrix over F_q to a fq_nmod_mat_t
void
convertFacCFMatrix2Fq_nmod_mat_t (fq_nmod_mat_t M, ///< [in, out] fq_nmod_mat_t
const fq_nmod_ctx_t fq_con, ///< [in] Fq context
const CFMatrix &m ///< [in] matrix over Fq
);
/// conversion of a FLINT factorization over Fq (for word size p) to a
/// CFFList
CFFList
convertFLINTFq_nmod_poly_factor2FacCFFList (const fq_nmod_poly_factor_t fac, ///< [in] fq_nmod_poly_factor_t
const Variable& x, ///< [in] polynomial variable
const Variable& alpha, ///< [in] algebraic variable
const fq_nmod_ctx_t fq_con ///< [in] Fq context
);
#endif
#if __FLINT_RELEASE >= 20503
CanonicalForm mulFlintMP_Zp(const CanonicalForm& F,int lF, const CanonicalForm& Gi, int lG, int m);
CanonicalForm mulFlintMP_QQ(const CanonicalForm& F,int lF, const CanonicalForm& Gi, int lG, int m);
CanonicalForm gcdFlintMP_Zp(const CanonicalForm& F, const CanonicalForm& G);
CanonicalForm gcdFlintMP_QQ(const CanonicalForm& F, const CanonicalForm& G);
void convFactoryPFlintMP ( const CanonicalForm & f, nmod_mpoly_t res, nmod_mpoly_ctx_t ctx, int N );
void convFactoryPFlintMP ( const CanonicalForm & f, fmpq_mpoly_t res, fmpq_mpoly_ctx_t ctx, int N );
void convFactoryPFlintMP ( const CanonicalForm & f, fmpz_mpoly_t res, fmpz_mpoly_ctx_t ctx, int N );
CanonicalForm convFlintMPFactoryP(nmod_mpoly_t f, nmod_mpoly_ctx_t ctx, int N);
CanonicalForm convFlintMPFactoryP(fmpq_mpoly_t f, fmpq_mpoly_ctx_t ctx, int N);
CanonicalForm convFlintMPFactoryP(fmpz_mpoly_t f, fmpz_mpoly_ctx_t ctx, int N);
#endif // FLINT 2.5.3
#if __FLINT_RELEASE >= 20700
CanonicalForm
convertFq_nmod_mpoly_t2FacCF (const fq_nmod_mpoly_t poly, ///< [in]
const fq_nmod_mpoly_ctx_t& ctx,///< [in] context
const int N, ///< [in] #vars
const fq_nmod_ctx_t& fq_ctx, ///< [in] fq context
const Variable alpha ///< [in] alpha
);
#endif // FLINT2.7.0
#endif // FLINT
#endif
convertFacCFMatrix2Fmpz_mat_t
void convertFacCFMatrix2Fmpz_mat_t(fmpz_mat_t M, const CFMatrix &m)
conversion of a factory matrix over Z to a fmpz_mat_t
Definition FLINTconvert.cc:585
convertFq_poly_t2FacCF
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....
Definition FLINTconvert.cc:543
convertFmpz_mat_t2FacCFMatrix
CFMatrix * convertFmpz_mat_t2FacCFMatrix(const fmpz_mat_t m)
conversion of a FLINT matrix over Z to a factory matrix
Definition FLINTconvert.cc:598
convertFq_nmod_t2FacCF
CanonicalForm convertFq_nmod_t2FacCF(const fq_nmod_t poly, const Variable &alpha, const fq_nmod_ctx_t ctx)
conversion of a FLINT element of F_q to a CanonicalForm with alg. variable alpha
Definition FLINTconvert.cc:479
convertFacCF2Fq_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
Definition FLINTconvert.cc:485
convertNmod_mat_t2FacCFMatrix
CFMatrix * convertNmod_mat_t2FacCFMatrix(const nmod_mat_t m)
conversion of a FLINT matrix over Z/p to a factory matrix
Definition FLINTconvert.cc:630
convertFacCFMatrix2nmod_mat_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
Definition FLINTconvert.cc:612
convertFq_nmod_poly_t2FacCF
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...
Definition FLINTconvert.cc:564
convertFLINTfmpz_poly_factor2FacCFFList
CFFList convertFLINTfmpz_poly_factor2FacCFFList(const fmpz_poly_factor_t fac, const Variable &x)
conversion of a FLINT factorization over Z to a CFFList
convertFmpz2CF
CanonicalForm convertFmpz2CF(const fmpz_t coefficient)
conversion of a FLINT integer to CanonicalForm
Definition FLINTconvert.cc:154
convertFq_t2FacCF
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....
Definition FLINTconvert.cc:503
convertFacCF2Fq_nmod_t
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...
Definition FLINTconvert.cc:442
convertFmpq_poly_t2FacCF
CanonicalForm convertFmpq_poly_t2FacCF(const fmpq_poly_t p, const Variable &x)
conversion of a FLINT poly over Q to CanonicalForm
Definition FLINTconvert.cc:294
convertFacCFMatrix2Fq_nmod_mat_t
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
Definition FLINTconvert.cc:646
convertFmpz_mod_poly_t2FacCF
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
Definition FLINTconvert.cc:419
convertFacCF2nmod_poly_t
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
Definition FLINTconvert.cc:186
convertFLINTFq_nmod_poly_factor2FacCFFList
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
Definition FLINTconvert.cc:379
convertCF2Fmpz
void convertCF2Fmpz(fmpz_t result, const CanonicalForm &f)
conversion of a factory integer to fmpz_t
Definition FLINTconvert.cc:120
convertCF2Fmpq
void convertCF2Fmpq(fmpq_t result, const CanonicalForm &f)
conversion of a factory rationals to fmpq_t
Definition FLINTconvert.cc:220
convertnmod_poly_t2FacCF
CanonicalForm convertnmod_poly_t2FacCF(const nmod_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z/p to CanonicalForm
Definition FLINTconvert.cc:208
convertFacCF2Fmpz_mod_poly_t
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)
Definition FLINTconvert.cc:397
convertFacCF2Fq_nmod_poly_t
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
Definition FLINTconvert.cc:526
convertFmpz_poly_t2FacCF
CanonicalForm convertFmpz_poly_t2FacCF(const fmpz_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z to CanonicalForm
Definition FLINTconvert.cc:172
convertFLINTnmod_poly_factor2FacCFFList
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
Definition FLINTconvert.cc:337
convertFmpq2CF
CanonicalForm convertFmpq2CF(const fmpq_t q)
conversion of a FLINT rational to CanonicalForm
Definition FLINTconvert.cc:260
convertFacCF2Fmpq_poly_t
void convertFacCF2Fmpq_poly_t(fmpq_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomials over Q to fmpq_poly_t
Definition FLINTconvert.cc:320
convertFacCF2Fmpz_poly_t
void convertFacCF2Fmpz_poly_t(fmpz_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomial over Z to a fmpz_poly_t
Definition FLINTconvert.cc:146
convertCF2initFmpz
void convertCF2initFmpz(fmpz_t result, const CanonicalForm &f)
conversion of a factory integer to fmpz_t(init.)
Definition FLINTconvert.cc:133
convertFq_nmod_mat_t2FacCFMatrix
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
Definition FLINTconvert.cc:661
convertFacCF2Fq_poly_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
Definition FLINTconvert.cc:509
canonicalform.h
Header for factory's main class CanonicalForm.
CFMatrix
Matrix< CanonicalForm > CFMatrix
Definition canonicalform.h:398
CFFList
List< CFFactor > CFFList
Definition canonicalform.h:393
N
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
m
int m
Definition cfEzgcd.cc:128
x
Variable x
Definition cfModGcd.cc:4090
p
int p
Definition cfModGcd.cc:4086
b
CanonicalForm b
Definition cfModGcd.cc:4111
cf_gmp.h
FLINTrandom
GLOBAL_VAR flint_rand_t FLINTrandom
Definition cf_random.cc:23
f
FILE * f
Definition checklibs.c:9
CanonicalForm
factory's main class
Definition canonicalform.h:86
Variable
factory's class for variables
Definition factory.h:127
modpk
class to do operations mod p^k for int's p and k
Definition fac_util.h:23
alpha
Variable alpha
Definition facAbsBiFact.cc:52
result
return result
Definition facAbsBiFact.cc:76
res
CanonicalForm res
Definition facAbsFact.cc:60
fq_con
fq_nmod_ctx_t fq_con
Definition facHensel.cc:99
fac_util.h
operations mod p^k and some other useful functions for factorization
EXTERN_VAR
#define EXTERN_VAR
Definition globaldefs.h:6
G
STATIC_VAR TreeM * G
Definition janet.cc:31
M
#define M
Definition sirandom.c:25