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
23 extern "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 #endif
44 #ifdef __cplusplus
45 }
46 #endif
47 
48 #include <factory/cf_gmp.h>
49 
50 /// conversion of a factory integer to fmpz_t
51 void
52 convertCF2Fmpz (fmpz_t result, ///< [in,out] an fmpz_t
53  const CanonicalForm& f ///< [in] a CanonicalForm wrapping an
54  ///< integer
55  );
56 
57 /// conversion of a factory univariate polynomial over Z to a fmpz_poly_t
58 void
59 convertFacCF2Fmpz_poly_t (fmpz_poly_t result, ///< [in,out] an fmpz_poly_t
60  const CanonicalForm& f ///< [in] univariate poly over
61  ///< Z
62  );
63 
64 /// conversion of a FLINT integer to CanonicalForm
66 convertFmpz2CF (const fmpz_t coefficient ///< [in] a FLINT integer
67  );
68 
69 /// conversion of a FLINT poly over Z to CanonicalForm
71 convertFmpz_poly_t2FacCF (const fmpz_poly_t poly, ///< [in] an fmpz_poly_t
72  const Variable& x ///< [in] variable the result should
73  ///< have
74  );
75 
76 /// conversion of a factory univariate polynomials over Z/p (for word size p)
77 /// to nmod_poly_t
78 void
79 convertFacCF2nmod_poly_t (nmod_poly_t result, ///< [in, out] a nmod_poly_t
80  const CanonicalForm& f ///< [in] univariate poly over
81  ///< Z/p
82  );
83 
84 /// conversion of a FLINT poly over Z/p to CanonicalForm
86 convertnmod_poly_t2FacCF (const nmod_poly_t poly, ///< [in] a nmod_poly_t
87  const Variable& x ///< [in] variable the result should
88  ///< have
89  );
90 
91 /// conversion of a factory rationals to fmpq_t
92 void
93 convertCF2Fmpq (fmpq_t result, ///< [in,out] an fmpq_t
94  const CanonicalForm& f ///< [in] a CanonicalForm wrapping a
95  ///< rational
96  );
97 
98 /// conversion of a factory univariate polynomials over Q to fmpq_poly_t
99 void
100 convertFacCF2Fmpq_poly_t (fmpq_poly_t result, ///< [in,out] an fmpq_poly_t
101  const CanonicalForm& f ///< [in] univariate poly over
102  ///< Q
103  );
104 
105 /// conversion of a FLINT poly over Q to CanonicalForm
107 convertFmpq_poly_t2FacCF (const fmpq_poly_t p, ///< [in] an fmpq_poly_t
108  const Variable& x ///< [in] variable the result should
109  ///< have
110  );
111 
112 /// conversion of a FLINT factorization over Z/p (for word size p) to a
113 /// CFFList
114 CFFList
116  const nmod_poly_factor_t fac, ///< [in] a nmod_poly_factor_t
117  const mp_limb_t leadingCoeff, ///< [in] leading coefficient
118  const Variable& x ///< [in] variable the result should
119  ///< have
120  );
121 
122 /// conversion of a factory univariate poly over Z to a FLINT poly over
123 /// Z/p (for non word size p)
124 void
126  fmpz_mod_poly_t result, ///< [in,out] fmpz_mod_poly_t
127  const CanonicalForm& f, ///< [in] univariate poly over
128  ///< Z
129  const fmpz_t p ///< [in] some integer p
130  );
131 
132 /// conversion of a FLINT poly over Z/p (for non word size p) to a CanonicalForm
133 /// over Z
136  const fmpz_mod_poly_t poly, ///< [in] fmpz_mod_poly_t
137  const Variable& x, ///< [in] variable the result
138  ///< should have
139  const modpk& b ///< [in] coeff bound to map
140  ///< coeffs in (-p/2,p/2)
141  );
142 
143 #if __FLINT_RELEASE >= 20400
144 /// conversion of a FLINT element of F_q to a CanonicalForm with alg. variable
145 /// alpha
147 convertFq_nmod_t2FacCF (const fq_nmod_t poly, ///< [in] fq_nmod_t
148  const Variable& alpha ///< [in] algebraic variable
149  );
150 
151 /// conversion of a FLINT element of F_q with non-word size p to a CanonicalForm
152 /// with alg. variable alpha
154 convertFq_t2FacCF (const fq_t poly, ///< [in] fq_t
155  const Variable& alpha ///< [in] algebraic variable
156  );
157 
158 /// conversion of a factory element of F_q to a FLINT fq_nmod_t, does not do any
159 /// memory allocation for poly
160 void
161 convertFacCF2Fq_nmod_t (fq_nmod_t result, ///< [in,out] fq_nmod_t
162  const CanonicalForm& f, ///< [in] element of Fq
163  const fq_nmod_ctx_t ctx ///< [in] Fq context
164  );
165 
166 /// conversion of a factory element of F_q (for non-word size p) to a FLINT fq_t
167 void
168 convertFacCF2Fq_t (fq_t result, ///< [in,out] fq_t
169  const CanonicalForm& f, ///< [in] element of Fq
170  const fq_ctx_t ctx ///< [in] Fq context
171  );
172 
173 /// conversion of a factory univariate poly over F_q (for non-word size p) to a
174 /// FLINT fq_poly_t
175 void
176 convertFacCF2Fq_poly_t (fq_poly_t result, ///< [in,out] fq_poly_t
177  const CanonicalForm& f,///< [in] univariate poly over Fq
178  const fq_ctx_t ctx ///< [in] Fq context
179  );
180 
181 /// conversion of a factory univariate poly over F_q to a FLINT fq_nmod_poly_t
182 void
183 convertFacCF2Fq_nmod_poly_t (fq_nmod_poly_t result, ///< [in,out] fq_nmod_poly_t
184  const CanonicalForm& f,///< [in] univariate poly
185  ///< over Fq
186  const fq_nmod_ctx_t ctx///< [in] Fq context
187  );
188 
189 /// conversion of a FLINT poly over Fq (for non-word size p) to a CanonicalForm
190 /// with alg. variable alpha and polynomial variable x
192 convertFq_poly_t2FacCF (const fq_poly_t p, ///< [in] fq_poly_t
193  const Variable& x, ///< [in] polynomial variable
194  const Variable& alpha, ///< [in] algebraic variable
195  const fq_ctx_t ctx ///< [in] Fq context
196  );
197 
198 /// conversion of a FLINT poly over Fq to a CanonicalForm with alg. variable
199 /// alpha and polynomial variable x
201 convertFq_nmod_poly_t2FacCF (const fq_nmod_poly_t p, ///< [in] fq_nmod_poly_t
202  const Variable& x, ///< [in] polynomial var.
203  const Variable& alpha, ///< [in] algebraic var.
204  const fq_nmod_ctx_t ctx ///< [in] Fq context
205  );
206 #endif
207 
208 /// conversion of a factory matrix over Z to a fmpz_mat_t
209 void convertFacCFMatrix2Fmpz_mat_t (fmpz_mat_t M, ///<[in,out] fmpz_mat_t
210  const CFMatrix &m ///<[in] matrix over Z
211  );
212 
213 /// conversion of a FLINT matrix over Z to a factory matrix
214 CFMatrix* convertFmpz_mat_t2FacCFMatrix(const fmpz_mat_t m ///<[in] fmpz_mat_t
215  );
216 
217 /// conversion of a factory matrix over Z/p to a nmod_mat_t
218 void convertFacCFMatrix2nmod_mat_t (nmod_mat_t M, ///<[in,out] nmod_mat_t
219  const CFMatrix &m ///<[in] matrix over Z/p
220  );
221 
222 /// conversion of a FLINT matrix over Z/p to a factory matrix
223 CFMatrix* convertNmod_mat_t2FacCFMatrix(const nmod_mat_t m ///<[in] nmod_mat_t
224  );
225 
226 #if __FLINT_RELEASE >= 20400
227 /// conversion of a FLINT matrix over F_q to a factory matrix
228 CFMatrix*
229 convertFq_nmod_mat_t2FacCFMatrix(const fq_nmod_mat_t m, ///< [in] fq_nmod_mat_t
230  const fq_nmod_ctx_t& fq_con, ///< [in] Fq context
231  const Variable& alpha ///< [in] algebraic variable
232  );
233 
234 /// conversion of a factory matrix over F_q to a fq_nmod_mat_t
235 void
236 convertFacCFMatrix2Fq_nmod_mat_t (fq_nmod_mat_t M, ///< [in, out] fq_nmod_mat_t
237  const fq_nmod_ctx_t fq_con, ///< [in] Fq context
238  const CFMatrix &m ///< [in] matrix over Fq
239  );
240 
241 /// conversion of a FLINT factorization over Fq (for word size p) to a
242 /// CFFList
243 CFFList
244 convertFLINTFq_nmod_poly_factor2FacCFFList (const fq_nmod_poly_factor_t fac, ///< [in] fq_nmod_poly_factor_t
245  const Variable& x, ///< [in] polynomial variable
246  const Variable& alpha, ///< [in] algebraic variable
247  const fq_nmod_ctx_t fq_con ///< [in] Fq context
248  );
249 #endif
250 
251 
252 #endif
253 #endif
void convertFacCF2Fmpq_poly_t(fmpq_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomials over Q to fmpq_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 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
void convertFacCFMatrix2nmod_mat_t(nmod_mat_t M, const CFMatrix &m)
conversion of a factory matrix over Z/p to a nmod_mat_t
return P p
Definition: myNF.cc:203
factory&#39;s class for variables
Definition: variable.h:32
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 convertCF2Fmpz(fmpz_t result, const CanonicalForm &f)
conversion of a factory integer to fmpz_t
Definition: FLINTconvert.cc:61
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 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...
CanonicalForm convertFmpz2CF(const fmpz_t coefficient)
conversion of a FLINT integer to CanonicalForm
Definition: FLINTconvert.cc:82
factory&#39;s main class
Definition: canonicalform.h:75
fq_nmod_ctx_t fq_con
Definition: facHensel.cc:94
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
Variable alpha
Definition: facAbsBiFact.cc:52
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 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) ...
#define M
Definition: sirandom.c:24
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 convertnmod_poly_t2FacCF(const nmod_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z/p to CanonicalForm
int m
Definition: cfEzgcd.cc:119
FILE * f
Definition: checklibs.c:7
void convertCF2Fmpq(fmpq_t result, const CanonicalForm &f)
conversion of a factory rationals to fmpq_t
CanonicalForm convertFmpq_poly_t2FacCF(const fmpq_poly_t p, const Variable &x)
conversion of a FLINT poly over Q to CanonicalForm
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...
CFMatrix * convertFmpz_mat_t2FacCFMatrix(const fmpz_mat_t m)
conversion of a FLINT matrix over Z to a factory matrix
Variable x
Definition: cfModGcd.cc:4023
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
operations mod p^k and some other useful functions for factorization
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
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 ...
polyrec * poly
Definition: hilb.h:10
CanonicalForm convertFmpz_poly_t2FacCF(const fmpz_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z to CanonicalForm
const poly b
Definition: syzextra.cc:213
class to do operations mod p^k for int&#39;s p and k
Definition: fac_util.h:22
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
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:74
return result
Definition: facAbsBiFact.cc:76
void convertFacCFMatrix2Fmpz_mat_t(fmpz_mat_t M, const CFMatrix &m)
conversion of a factory matrix over Z to a fmpz_mat_t
Header for factory&#39;s main class CanonicalForm.
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 ...