My Project
Loading...
Searching...
No Matches
FLINTconvert.h
Go to the documentation of this file.
1/*****************************************************************************\
2 * Computer Algebra System SINGULAR
3\*****************************************************************************/
4/** @file FLINTconvert.h
5 *
6 * This file defines functions for conversion to FLINT (www.flintlib.org)
7 * and back.
8 *
9 * @author Martin Lee
10 *
11 **/
12/*****************************************************************************/
13
14#ifndef FLINT_CONVERT_H
15#define FLINT_CONVERT_H
16
17// #include "config.h"
18#include "canonicalform.h"
19#include "fac_util.h"
20
21#ifdef HAVE_FLINT
22#ifdef __cplusplus
23extern "C"
24{
25#endif
26#ifndef __GMP_BITS_PER_MP_LIMB
27#define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS
28#endif
29#include <flint/fmpz.h>
30#include <flint/fmpq.h>
31#include <flint/fmpz_poly.h>
32#include <flint/fmpz_mod_poly.h>
33#include <flint/fmpq_poly.h>
34#include <flint/nmod_poly.h>
35#include <flint/nmod_mat.h>
36#include <flint/fmpz_mat.h>
37#if ( __FLINT_RELEASE >= 20400)
38#include <flint/fq.h>
39#include <flint/fq_poly.h>
40#include <flint/fq_nmod.h>
41#include <flint/fq_nmod_poly.h>
42#include <flint/fq_nmod_mat.h>
43#if ( __FLINT_RELEASE >= 20503)
44#include <flint/fmpq_mpoly.h>
45#endif
46#if ( __FLINT_RELEASE >= 20700)
47#include <flint/fq_nmod_mpoly_factor.h>
48#include <flint/fmpz_mod.h>
49#endif
50#if ( __FLINT_RELEASE >= 30000)
51#include <flint/nmod.h>
52#include <flint/nmod_mpoly.h>
53#include <flint/fmpz_vec.h>
54#endif
55#endif
56
58
59#ifdef __cplusplus
60}
61#endif
62
63#include "factory/cf_gmp.h"
64
65/// conversion of a factory integer to fmpz_t
66void
67convertCF2Fmpz (fmpz_t result, ///< [out] an fmpz_t
68 const CanonicalForm& f ///< [in] a CanonicalForm wrapping an
69 ///< integer
70 );
71
72/// conversion of a factory integer to fmpz_t(init.)
73void
74convertCF2initFmpz (fmpz_t result, ///< [in,out] an fmpz_t
75 const CanonicalForm& f ///< [in] a CanonicalForm wrapping an
76 ///< integer
77 );
78
79/// conversion of a factory univariate polynomial over Z to a fmpz_poly_t
80void
81convertFacCF2Fmpz_poly_t (fmpz_poly_t result, ///< [in,out] an fmpz_poly_t
82 const CanonicalForm& f ///< [in] univariate poly over
83 ///< Z
84 );
85
86/// conversion of a FLINT integer to CanonicalForm
88convertFmpz2CF (const fmpz_t coefficient ///< [in] a FLINT integer
89 );
90
91/// conversion of a FLINT poly over Z to CanonicalForm
93convertFmpz_poly_t2FacCF (const fmpz_poly_t poly, ///< [in] an fmpz_poly_t
94 const Variable& x ///< [in] variable the result should
95 ///< have
96 );
97
98/// conversion of a factory univariate polynomials over Z/p (for word size p)
99/// to nmod_poly_t
100void
101convertFacCF2nmod_poly_t (nmod_poly_t result, ///< [in, out] a nmod_poly_t
102 const CanonicalForm& f ///< [in] univariate poly over
103 ///< Z/p
104 );
105
106/// conversion of a FLINT poly over Z/p to CanonicalForm
108convertnmod_poly_t2FacCF (const nmod_poly_t poly, ///< [in] a nmod_poly_t
109 const Variable& x ///< [in] variable the result should
110 ///< have
111 );
112
113/// conversion of a factory rationals to fmpq_t
114void
115convertCF2Fmpq (fmpq_t result, ///< [in,out] an fmpq_t
116 const CanonicalForm& f ///< [in] a CanonicalForm wrapping a
117 ///< rational
118 );
119
120/// conversion of a FLINT rational to CanonicalForm
121CanonicalForm convertFmpq2CF (const fmpq_t q);
122
123/// conversion of a factory univariate polynomials over Q to fmpq_poly_t
124void
125convertFacCF2Fmpq_poly_t (fmpq_poly_t result, ///< [in,out] an fmpq_poly_t
126 const CanonicalForm& f ///< [in] univariate poly over
127 ///< Q
128 );
129
130/// conversion of a FLINT poly over Q to CanonicalForm
132convertFmpq_poly_t2FacCF (const fmpq_poly_t p, ///< [in] an fmpq_poly_t
133 const Variable& x ///< [in] variable the result should
134 ///< have
135 );
136
137/// conversion of a FLINT factorization over Z/p (for word size p) to a
138/// CFFList
141 const nmod_poly_factor_t fac, ///< [in] a nmod_poly_factor_t
142 const mp_limb_t leadingCoeff, ///< [in] leading coefficient
143 const Variable& x ///< [in] variable the result should
144 ///< have
145 );
146
147/// conversion of a FLINT factorization over Z to a CFFList
150 const fmpz_poly_factor_t fac, ///< [in] a fmpz_poly_factor_t
151 const Variable& x ///< [in] variable the result should
152 ///< have
153 );
154
155
156#if ( __FLINT_RELEASE >= 20700)
157/// conversion of a FLINT factorization over Zp(a) to a CFFList
159convertFLINTFq_nmod_mpoly_factor2FacCFFList (
160 fq_nmod_mpoly_factor_t fac, ///< [in] a fq_nmod_mpoly_factor_t
161 const fq_nmod_mpoly_ctx_t& ctx,///< [in] context
162 const int N, ///< [in] #vars
163 const fq_nmod_ctx_t& fq_ctx, ///< [in] fq context
164 const Variable alpha ///< [in] alpha
165 );
166#endif
167
168/// conversion of a factory univariate poly over Z to a FLINT poly over
169/// Z/p (for non word size p)
170void
172 fmpz_mod_poly_t result, ///< [in,out] fmpz_mod_poly_t
173 const CanonicalForm& f, ///< [in] univariate poly over
174 ///< Z
175 const fmpz_t p ///< [in] some integer p
176 );
177
178/// conversion of a FLINT poly over Z/p (for non word size p) to a CanonicalForm
179/// over Z
182 const fmpz_mod_poly_t poly, ///< [in] fmpz_mod_poly_t
183 const Variable& x, ///< [in] variable the result
184 ///< should have
185 const modpk& b ///< [in] coeff bound to map
186 ///< coeffs in (-p/2,p/2)
187 );
188
189#if __FLINT_RELEASE >= 20400
190/// conversion of a FLINT element of F_q to a CanonicalForm with alg. variable
191/// alpha
193convertFq_nmod_t2FacCF (const fq_nmod_t poly, ///< [in] fq_nmod_t
194 const Variable& alpha, ///< [in] algebraic variable
195 const fq_nmod_ctx_t ctx ///<[in] context
196 );
197
198/// conversion of a FLINT element of F_q with non-word size p to a CanonicalForm
199/// with alg. variable alpha
201convertFq_t2FacCF (const fq_t poly, ///< [in] fq_t
202 const Variable& alpha ///< [in] algebraic variable
203 );
204
205/// conversion of a factory element of F_q to a FLINT fq_nmod_t, does not do any
206/// memory allocation for poly
207void
208convertFacCF2Fq_nmod_t (fq_nmod_t result, ///< [in,out] fq_nmod_t
209 const CanonicalForm& f, ///< [in] element of Fq
210 const fq_nmod_ctx_t ctx ///< [in] Fq context
211 );
212
213#if ( __FLINT_RELEASE >= 20700)
214/// conversion of a factory polynomial over of F_q to a FLINT fq_nmod_mpoly_t, does not do any
215/// memory allocation for poly
216void
217convertFacCF2Fq_nmod_mpoly_t (fq_nmod_mpoly_t result, ///< [in,out] fq_nmod_mpoly__t
218 const CanonicalForm& f, ///< [in] poly over Fq
219 const fq_nmod_mpoly_ctx_t ctx,///< [in] context
220 const int N, ///< [in] #vars
221 const fq_nmod_ctx_t fq_ctx ///< [in] fq context
222 );
223#endif
224
225/// conversion of a factory element of F_q (for non-word size p) to a FLINT fq_t
226void
227convertFacCF2Fq_t (fq_t result, ///< [in,out] fq_t
228 const CanonicalForm& f, ///< [in] element of Fq
229 const fq_ctx_t ctx ///< [in] Fq context
230 );
231
232/// conversion of a factory univariate poly over F_q (for non-word size p) to a
233/// FLINT fq_poly_t
234void
235convertFacCF2Fq_poly_t (fq_poly_t result, ///< [in,out] fq_poly_t
236 const CanonicalForm& f,///< [in] univariate poly over Fq
237 const fq_ctx_t ctx ///< [in] Fq context
238 );
239
240/// conversion of a factory univariate poly over F_q to a FLINT fq_nmod_poly_t
241void
242convertFacCF2Fq_nmod_poly_t (fq_nmod_poly_t result, ///< [in,out] fq_nmod_poly_t
243 const CanonicalForm& f,///< [in] univariate poly
244 ///< over Fq
245 const fq_nmod_ctx_t ctx///< [in] Fq context
246 );
247
248/// conversion of a FLINT poly over Fq (for non-word size p) to a CanonicalForm
249/// with alg. variable alpha and polynomial variable x
251convertFq_poly_t2FacCF (const fq_poly_t p, ///< [in] fq_poly_t
252 const Variable& x, ///< [in] polynomial variable
253 const Variable& alpha, ///< [in] algebraic variable
254 const fq_ctx_t ctx ///< [in] Fq context
255 );
256
257/// conversion of a FLINT poly over Fq to a CanonicalForm with alg. variable
258/// alpha and polynomial variable x
260convertFq_nmod_poly_t2FacCF (const fq_nmod_poly_t p, ///< [in] fq_nmod_poly_t
261 const Variable& x, ///< [in] polynomial var.
262 const Variable& alpha, ///< [in] algebraic var.
263 const fq_nmod_ctx_t ctx ///< [in] Fq context
264 );
265#endif
266
267/// conversion of a factory matrix over Z to a fmpz_mat_t
268void convertFacCFMatrix2Fmpz_mat_t (fmpz_mat_t M, ///<[in,out] fmpz_mat_t
269 const CFMatrix &m ///<[in] matrix over Z
270 );
271
272/// conversion of a FLINT matrix over Z to a factory matrix
273CFMatrix* convertFmpz_mat_t2FacCFMatrix(const fmpz_mat_t m ///<[in] fmpz_mat_t
274 );
275
276/// conversion of a factory matrix over Z/p to a nmod_mat_t
277void convertFacCFMatrix2nmod_mat_t (nmod_mat_t M, ///<[in,out] nmod_mat_t
278 const CFMatrix &m ///<[in] matrix over Z/p
279 );
280
281/// conversion of a FLINT matrix over Z/p to a factory matrix
282CFMatrix* convertNmod_mat_t2FacCFMatrix(const nmod_mat_t m ///<[in] nmod_mat_t
283 );
284
285#if __FLINT_RELEASE >= 20400
286/// conversion of a FLINT matrix over F_q to a factory matrix
288convertFq_nmod_mat_t2FacCFMatrix(const fq_nmod_mat_t m, ///< [in] fq_nmod_mat_t
289 const fq_nmod_ctx_t& fq_con, ///< [in] Fq context
290 const Variable& alpha ///< [in] algebraic variable
291 );
292
293/// conversion of a factory matrix over F_q to a fq_nmod_mat_t
294void
295convertFacCFMatrix2Fq_nmod_mat_t (fq_nmod_mat_t M, ///< [in, out] fq_nmod_mat_t
296 const fq_nmod_ctx_t fq_con, ///< [in] Fq context
297 const CFMatrix &m ///< [in] matrix over Fq
298 );
299
300/// conversion of a FLINT factorization over Fq (for word size p) to a
301/// CFFList
303convertFLINTFq_nmod_poly_factor2FacCFFList (const fq_nmod_poly_factor_t fac, ///< [in] fq_nmod_poly_factor_t
304 const Variable& x, ///< [in] polynomial variable
305 const Variable& alpha, ///< [in] algebraic variable
306 const fq_nmod_ctx_t fq_con ///< [in] Fq context
307 );
308#endif
309
310
311#if __FLINT_RELEASE >= 20503
312CanonicalForm mulFlintMP_Zp(const CanonicalForm& F,int lF, const CanonicalForm& Gi, int lG, int m);
313CanonicalForm mulFlintMP_QQ(const CanonicalForm& F,int lF, const CanonicalForm& Gi, int lG, int m);
314CanonicalForm gcdFlintMP_Zp(const CanonicalForm& F, const CanonicalForm& G);
315CanonicalForm gcdFlintMP_QQ(const CanonicalForm& F, const CanonicalForm& G);
316void convFactoryPFlintMP ( const CanonicalForm & f, nmod_mpoly_t res, nmod_mpoly_ctx_t ctx, int N );
317void convFactoryPFlintMP ( const CanonicalForm & f, fmpq_mpoly_t res, fmpq_mpoly_ctx_t ctx, int N );
318void convFactoryPFlintMP ( const CanonicalForm & f, fmpz_mpoly_t res, fmpz_mpoly_ctx_t ctx, int N );
319CanonicalForm convFlintMPFactoryP(nmod_mpoly_t f, nmod_mpoly_ctx_t ctx, int N);
320CanonicalForm convFlintMPFactoryP(fmpq_mpoly_t f, fmpq_mpoly_ctx_t ctx, int N);
321CanonicalForm convFlintMPFactoryP(fmpz_mpoly_t f, fmpz_mpoly_ctx_t ctx, int N);
322#endif // FLINT 2.5.3
323#if __FLINT_RELEASE >= 20700
325convertFq_nmod_mpoly_t2FacCF (const fq_nmod_mpoly_t poly, ///< [in]
326 const fq_nmod_mpoly_ctx_t& ctx,///< [in] context
327 const int N, ///< [in] #vars
328 const fq_nmod_ctx_t& fq_ctx, ///< [in] fq context
329 const Variable alpha ///< [in] alpha
330 );
331#endif // FLINT2.7.0
332#endif // FLINT
333#endif
void convertFacCFMatrix2Fmpz_mat_t(fmpz_mat_t M, const CFMatrix &m)
conversion of a factory matrix over Z to a fmpz_mat_t
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....
CFMatrix * convertFmpz_mat_t2FacCFMatrix(const fmpz_mat_t m)
conversion of a FLINT matrix over Z to a factory matrix
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
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
CFMatrix * convertNmod_mat_t2FacCFMatrix(const nmod_mat_t m)
conversion of a FLINT matrix over Z/p to a factory matrix
void convertFacCFMatrix2nmod_mat_t(nmod_mat_t M, const CFMatrix &m)
conversion of a factory matrix over Z/p to a nmod_mat_t
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...
CFFList convertFLINTfmpz_poly_factor2FacCFFList(const fmpz_poly_factor_t fac, const Variable &x)
conversion of a FLINT factorization over Z to a CFFList
CanonicalForm convertFmpz2CF(const fmpz_t coefficient)
conversion of a FLINT integer to CanonicalForm
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 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...
CanonicalForm convertFmpq_poly_t2FacCF(const fmpq_poly_t p, const Variable &x)
conversion of a FLINT poly over Q to CanonicalForm
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
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
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 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
void convertCF2Fmpz(fmpz_t result, const CanonicalForm &f)
conversion of a factory integer to fmpz_t
void convertCF2Fmpq(fmpq_t result, const CanonicalForm &f)
conversion of a factory rationals to fmpq_t
CanonicalForm convertnmod_poly_t2FacCF(const nmod_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z/p to CanonicalForm
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)
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
CanonicalForm convertFmpz_poly_t2FacCF(const fmpz_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z to CanonicalForm
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
CanonicalForm convertFmpq2CF(const fmpq_t q)
conversion of a FLINT rational to CanonicalForm
void convertFacCF2Fmpq_poly_t(fmpq_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomials over Q to fmpq_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
void convertCF2initFmpz(fmpz_t result, const CanonicalForm &f)
conversion of a factory integer to fmpz_t(init.)
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
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
Header for factory's main class CanonicalForm.
Matrix< CanonicalForm > CFMatrix
List< CFFactor > CFFList
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
int m
Definition cfEzgcd.cc:128
Variable x
Definition cfModGcd.cc:4090
int p
Definition cfModGcd.cc:4086
CanonicalForm b
Definition cfModGcd.cc:4111
GLOBAL_VAR flint_rand_t FLINTrandom
Definition cf_random.cc:25
FILE * f
Definition checklibs.c:9
factory's main class
factory's class for variables
Definition factory.h:127
class to do operations mod p^k for int's p and k
Definition fac_util.h:23
Variable alpha
return result
CanonicalForm res
Definition facAbsFact.cc:60
fq_nmod_ctx_t fq_con
Definition facHensel.cc:99
operations mod p^k and some other useful functions for factorization
#define EXTERN_VAR
Definition globaldefs.h:6
STATIC_VAR TreeM * G
Definition janet.cc:31
#define M
Definition sirandom.c:25