source: git/factory/FLINTconvert.h @ 2234726

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