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#endif
51
53
54#ifdef __cplusplus
55}
56#endif
57
58#include "factory/cf_gmp.h"
59
60/// conversion of a factory integer to fmpz_t
61void
62convertCF2Fmpz (fmpz_t result, ///< [out] an fmpz_t
63 const CanonicalForm& f ///< [in] a CanonicalForm wrapping an
64 ///< integer
65 );
66
67/// conversion of a factory integer to fmpz_t(init.)
68void
69convertCF2initFmpz (fmpz_t result, ///< [in,out] an fmpz_t
70 const CanonicalForm& f ///< [in] a CanonicalForm wrapping an
71 ///< integer
72 );
73
74/// conversion of a factory univariate polynomial over Z to a fmpz_poly_t
75void
76convertFacCF2Fmpz_poly_t (fmpz_poly_t result, ///< [in,out] an fmpz_poly_t
77 const CanonicalForm& f ///< [in] univariate poly over
78 ///< Z
79 );
80
81/// conversion of a FLINT integer to CanonicalForm
83convertFmpz2CF (const fmpz_t coefficient ///< [in] a FLINT integer
84 );
85
86/// conversion of a FLINT poly over Z to CanonicalForm
88convertFmpz_poly_t2FacCF (const fmpz_poly_t poly, ///< [in] an fmpz_poly_t
89 const Variable& x ///< [in] variable the result should
90 ///< have
91 );
92
93/// conversion of a factory univariate polynomials over Z/p (for word size p)
94/// to nmod_poly_t
95void
96convertFacCF2nmod_poly_t (nmod_poly_t result, ///< [in, out] a nmod_poly_t
97 const CanonicalForm& f ///< [in] univariate poly over
98 ///< Z/p
99 );
100
101/// conversion of a FLINT poly over Z/p to CanonicalForm
103convertnmod_poly_t2FacCF (const nmod_poly_t poly, ///< [in] a nmod_poly_t
104 const Variable& x ///< [in] variable the result should
105 ///< have
106 );
107
108/// conversion of a factory rationals to fmpq_t
109void
110convertCF2Fmpq (fmpq_t result, ///< [in,out] an fmpq_t
111 const CanonicalForm& f ///< [in] a CanonicalForm wrapping a
112 ///< rational
113 );
114
115/// conversion of a FLINT rational to CanonicalForm
117
118/// conversion of a factory univariate polynomials over Q to fmpq_poly_t
119void
120convertFacCF2Fmpq_poly_t (fmpq_poly_t result, ///< [in,out] an fmpq_poly_t
121 const CanonicalForm& f ///< [in] univariate poly over
122 ///< Q
123 );
124
125/// conversion of a FLINT poly over Q to CanonicalForm
127convertFmpq_poly_t2FacCF (const fmpq_poly_t p, ///< [in] an fmpq_poly_t
128 const Variable& x ///< [in] variable the result should
129 ///< have
130 );
131
132/// conversion of a FLINT factorization over Z/p (for word size p) to a
133/// CFFList
136 const nmod_poly_factor_t fac, ///< [in] a nmod_poly_factor_t
137 const mp_limb_t leadingCoeff, ///< [in] leading coefficient
138 const Variable& x ///< [in] variable the result should
139 ///< have
140 );
141
142/// conversion of a FLINT factorization over Z to a CFFList
145 const fmpz_poly_factor_t fac, ///< [in] a fmpz_poly_factor_t
146 const Variable& x ///< [in] variable the result should
147 ///< have
148 );
149
150
151#if ( __FLINT_RELEASE >= 20700)
152/// conversion of a FLINT factorization over Zp(a) to a CFFList
155 fq_nmod_mpoly_factor_t fac, ///< [in] a fq_nmod_mpoly_factor_t
156 const fq_nmod_mpoly_ctx_t& ctx,///< [in] context
157 const int N, ///< [in] #vars
158 const fq_nmod_ctx_t& fq_ctx, ///< [in] fq context
159 const Variable alpha ///< [in] alpha
160 );
161#endif
162
163/// conversion of a factory univariate poly over Z to a FLINT poly over
164/// Z/p (for non word size p)
165void
167 fmpz_mod_poly_t result, ///< [in,out] fmpz_mod_poly_t
168 const CanonicalForm& f, ///< [in] univariate poly over
169 ///< Z
170 const fmpz_t p ///< [in] some integer p
171 );
172
173/// conversion of a FLINT poly over Z/p (for non word size p) to a CanonicalForm
174/// over Z
177 const fmpz_mod_poly_t poly, ///< [in] fmpz_mod_poly_t
178 const Variable& x, ///< [in] variable the result
179 ///< should have
180 const modpk& b ///< [in] coeff bound to map
181 ///< coeffs in (-p/2,p/2)
182 );
183
184#if __FLINT_RELEASE >= 20400
185/// conversion of a FLINT element of F_q to a CanonicalForm with alg. variable
186/// alpha
188convertFq_nmod_t2FacCF (const fq_nmod_t poly, ///< [in] fq_nmod_t
189 const Variable& alpha, ///< [in] algebraic variable
190 const fq_nmod_ctx_t ctx ///<[in] context
191 );
192
193/// conversion of a FLINT element of F_q with non-word size p to a CanonicalForm
194/// with alg. variable alpha
196convertFq_t2FacCF (const fq_t poly, ///< [in] fq_t
197 const Variable& alpha ///< [in] algebraic variable
198 );
199
200/// conversion of a factory element of F_q to a FLINT fq_nmod_t, does not do any
201/// memory allocation for poly
202void
203convertFacCF2Fq_nmod_t (fq_nmod_t result, ///< [in,out] fq_nmod_t
204 const CanonicalForm& f, ///< [in] element of Fq
205 const fq_nmod_ctx_t ctx ///< [in] Fq context
206 );
207
208#if ( __FLINT_RELEASE >= 20700)
209/// conversion of a factory polynomial over of F_q to a FLINT fq_nmod_mpoly_t, does not do any
210/// memory allocation for poly
211void
212convertFacCF2Fq_nmod_mpoly_t (fq_nmod_mpoly_t result, ///< [in,out] fq_nmod_mpoly__t
213 const CanonicalForm& f, ///< [in] poly over Fq
214 const fq_nmod_mpoly_ctx_t ctx,///< [in] context
215 const int N, ///< [in] #vars
216 const fq_nmod_ctx_t fq_ctx ///< [in] fq context
217 );
218#endif
219
220/// conversion of a factory element of F_q (for non-word size p) to a FLINT fq_t
221void
222convertFacCF2Fq_t (fq_t result, ///< [in,out] fq_t
223 const CanonicalForm& f, ///< [in] element of Fq
224 const fq_ctx_t ctx ///< [in] Fq context
225 );
226
227/// conversion of a factory univariate poly over F_q (for non-word size p) to a
228/// FLINT fq_poly_t
229void
230convertFacCF2Fq_poly_t (fq_poly_t result, ///< [in,out] fq_poly_t
231 const CanonicalForm& f,///< [in] univariate poly over Fq
232 const fq_ctx_t ctx ///< [in] Fq context
233 );
234
235/// conversion of a factory univariate poly over F_q to a FLINT fq_nmod_poly_t
236void
237convertFacCF2Fq_nmod_poly_t (fq_nmod_poly_t result, ///< [in,out] fq_nmod_poly_t
238 const CanonicalForm& f,///< [in] univariate poly
239 ///< over Fq
240 const fq_nmod_ctx_t ctx///< [in] Fq context
241 );
242
243/// conversion of a FLINT poly over Fq (for non-word size p) to a CanonicalForm
244/// with alg. variable alpha and polynomial variable x
246convertFq_poly_t2FacCF (const fq_poly_t p, ///< [in] fq_poly_t
247 const Variable& x, ///< [in] polynomial variable
248 const Variable& alpha, ///< [in] algebraic variable
249 const fq_ctx_t ctx ///< [in] Fq context
250 );
251
252/// conversion of a FLINT poly over Fq to a CanonicalForm with alg. variable
253/// alpha and polynomial variable x
255convertFq_nmod_poly_t2FacCF (const fq_nmod_poly_t p, ///< [in] fq_nmod_poly_t
256 const Variable& x, ///< [in] polynomial var.
257 const Variable& alpha, ///< [in] algebraic var.
258 const fq_nmod_ctx_t ctx ///< [in] Fq context
259 );
260#endif
261
262/// conversion of a factory matrix over Z to a fmpz_mat_t
263void convertFacCFMatrix2Fmpz_mat_t (fmpz_mat_t M, ///<[in,out] fmpz_mat_t
264 const CFMatrix &m ///<[in] matrix over Z
265 );
266
267/// conversion of a FLINT matrix over Z to a factory matrix
268CFMatrix* convertFmpz_mat_t2FacCFMatrix(const fmpz_mat_t m ///<[in] fmpz_mat_t
269 );
270
271/// conversion of a factory matrix over Z/p to a nmod_mat_t
272void convertFacCFMatrix2nmod_mat_t (nmod_mat_t M, ///<[in,out] nmod_mat_t
273 const CFMatrix &m ///<[in] matrix over Z/p
274 );
275
276/// conversion of a FLINT matrix over Z/p to a factory matrix
277CFMatrix* convertNmod_mat_t2FacCFMatrix(const nmod_mat_t m ///<[in] nmod_mat_t
278 );
279
280#if __FLINT_RELEASE >= 20400
281/// conversion of a FLINT matrix over F_q to a factory matrix
283convertFq_nmod_mat_t2FacCFMatrix(const fq_nmod_mat_t m, ///< [in] fq_nmod_mat_t
284 const fq_nmod_ctx_t& fq_con, ///< [in] Fq context
285 const Variable& alpha ///< [in] algebraic variable
286 );
287
288/// conversion of a factory matrix over F_q to a fq_nmod_mat_t
289void
290convertFacCFMatrix2Fq_nmod_mat_t (fq_nmod_mat_t M, ///< [in, out] fq_nmod_mat_t
291 const fq_nmod_ctx_t fq_con, ///< [in] Fq context
292 const CFMatrix &m ///< [in] matrix over Fq
293 );
294
295/// conversion of a FLINT factorization over Fq (for word size p) to a
296/// CFFList
298convertFLINTFq_nmod_poly_factor2FacCFFList (const fq_nmod_poly_factor_t fac, ///< [in] fq_nmod_poly_factor_t
299 const Variable& x, ///< [in] polynomial variable
300 const Variable& alpha, ///< [in] algebraic variable
301 const fq_nmod_ctx_t fq_con ///< [in] Fq context
302 );
303#endif
304
305
306#if __FLINT_RELEASE >= 20503
307CanonicalForm mulFlintMP_Zp(const CanonicalForm& F,int lF, const CanonicalForm& Gi, int lG, int m);
308CanonicalForm mulFlintMP_QQ(const CanonicalForm& F,int lF, const CanonicalForm& Gi, int lG, int m);
317#endif // FLINT 2.5.3
318#if __FLINT_RELEASE >= 20700
321 const fq_nmod_mpoly_ctx_t& ctx,///< [in] context
322 const int N, ///< [in] #vars
323 const fq_nmod_ctx_t& fq_ctx, ///< [in] fq context
324 const Variable alpha ///< [in] alpha
325 );
326#endif // FLINT2.7.0
327#endif // FLINT
328#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
EXTERN_VAR flint_rand_t FLINTrandom
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.
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
int m
Definition cfEzgcd.cc:128
Variable x
Definition cfModGcd.cc:4083
int p
Definition cfModGcd.cc:4079
CanonicalForm b
Definition cfModGcd.cc:4104
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