source: git/factory/FLINTconvert.h @ cac0f8

fieker-DuValspielwiese
Last change on this file since cac0f8 was 6e12a45, checked in by Hans Schoenemann <hannes@…>, 4 years ago
univariate factorization over Z via FLINT
  • Property mode set to 100644
File size: 10.8 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#endif
44#ifdef __cplusplus
45}
46#endif
47
48#include "factory/cf_gmp.h"
49
50/// conversion of a factory integer to fmpz_t
51void
52convertCF2Fmpz (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
58void
59convertFacCF2Fmpz_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
65CanonicalForm
66convertFmpz2CF (const fmpz_t coefficient ///< [in] a FLINT integer
67               );
68
69/// conversion of a FLINT poly over Z to CanonicalForm
70CanonicalForm
71convertFmpz_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
78void
79convertFacCF2nmod_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
85CanonicalForm
86convertnmod_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
92void
93convertCF2Fmpq (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
99void
100convertFacCF2Fmpq_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
106CanonicalForm
107convertFmpq_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
114CFFList
115convertFLINTnmod_poly_factor2FacCFFList (
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 FLINT factorization over Z to a CFFList
123CFFList
124convertFLINTfmpz_poly_factor2FacCFFList (
125                   const fmpz_poly_factor_t fac, ///< [in] a fmpz_poly_factor_t
126                   const Variable& x       ///< [in] variable the result should
127                                           ///< have
128                                        );
129
130/// conversion of a factory univariate poly over Z to a FLINT poly over
131/// Z/p (for non word size p)
132void
133convertFacCF2Fmpz_mod_poly_t (
134                          fmpz_mod_poly_t result, ///< [in,out] fmpz_mod_poly_t
135                          const CanonicalForm& f, ///< [in] univariate poly over
136                                                  ///< Z
137                          const fmpz_t p          ///< [in] some integer p
138                             );
139
140/// conversion of a FLINT poly over Z/p (for non word size p) to a CanonicalForm
141/// over Z
142CanonicalForm
143convertFmpz_mod_poly_t2FacCF (
144                          const fmpz_mod_poly_t poly, ///< [in] fmpz_mod_poly_t
145                          const Variable& x,    ///< [in] variable the result
146                                                ///< should have
147                          const modpk& b        ///< [in] coeff bound to map
148                                                ///< coeffs in (-p/2,p/2)
149                             );
150
151#if __FLINT_RELEASE >= 20400
152/// conversion of a FLINT element of F_q to a CanonicalForm with alg. variable
153/// alpha
154CanonicalForm
155convertFq_nmod_t2FacCF (const fq_nmod_t poly, ///< [in] fq_nmod_t
156                        const Variable& alpha ///< [in] algebraic variable
157                       );
158
159/// conversion of a FLINT element of F_q with non-word size p to a CanonicalForm
160/// with alg. variable alpha
161CanonicalForm
162convertFq_t2FacCF (const fq_t poly,      ///< [in] fq_t
163                   const Variable& alpha ///< [in] algebraic variable
164                  );
165
166/// conversion of a factory element of F_q to a FLINT fq_nmod_t, does not do any
167/// memory allocation for poly
168void
169convertFacCF2Fq_nmod_t (fq_nmod_t result,       ///< [in,out] fq_nmod_t
170                        const CanonicalForm& f, ///< [in] element of Fq
171                        const fq_nmod_ctx_t ctx ///< [in] Fq context
172                       );
173
174/// conversion of a factory element of F_q (for non-word size p) to a FLINT fq_t
175void
176convertFacCF2Fq_t (fq_t result,            ///< [in,out] fq_t
177                   const CanonicalForm& f, ///< [in] element of Fq
178                   const fq_ctx_t ctx      ///< [in] Fq context
179                  );
180
181/// conversion of a factory univariate poly over F_q (for non-word size p) to a
182/// FLINT fq_poly_t
183void
184convertFacCF2Fq_poly_t (fq_poly_t result,      ///< [in,out] fq_poly_t
185                        const CanonicalForm& f,///< [in] univariate poly over Fq
186                        const fq_ctx_t ctx     ///< [in] Fq context
187                       );
188
189/// conversion of a factory univariate poly over F_q to a FLINT fq_nmod_poly_t
190void
191convertFacCF2Fq_nmod_poly_t (fq_nmod_poly_t result, ///< [in,out] fq_nmod_poly_t
192                             const CanonicalForm& f,///< [in] univariate poly
193                                                    ///< over Fq
194                             const fq_nmod_ctx_t ctx///< [in] Fq context
195                            );
196
197/// conversion of a FLINT poly over Fq (for non-word size p) to a CanonicalForm
198/// with alg. variable alpha and polynomial variable x
199CanonicalForm
200convertFq_poly_t2FacCF (const fq_poly_t p,     ///< [in] fq_poly_t
201                        const Variable& x,     ///< [in] polynomial variable
202                        const Variable& alpha, ///< [in] algebraic variable
203                        const fq_ctx_t ctx     ///< [in] Fq context
204                       );
205
206/// conversion of a FLINT poly over Fq to a CanonicalForm with alg. variable
207/// alpha and polynomial variable x
208CanonicalForm
209convertFq_nmod_poly_t2FacCF (const fq_nmod_poly_t p, ///< [in] fq_nmod_poly_t
210                             const Variable& x,      ///< [in] polynomial var.
211                             const Variable& alpha,  ///< [in] algebraic var.
212                             const fq_nmod_ctx_t ctx ///< [in] Fq context
213                            );
214#endif
215
216/// conversion of a factory matrix over Z to a fmpz_mat_t
217void convertFacCFMatrix2Fmpz_mat_t (fmpz_mat_t M,      ///<[in,out] fmpz_mat_t
218                                    const CFMatrix &///<[in] matrix over Z
219                                   );
220
221/// conversion of a FLINT matrix over Z to a factory matrix
222CFMatrix* convertFmpz_mat_t2FacCFMatrix(const fmpz_mat_t m ///<[in] fmpz_mat_t
223                                       );
224
225/// conversion of a factory matrix over Z/p to a nmod_mat_t
226void convertFacCFMatrix2nmod_mat_t (nmod_mat_t M,     ///<[in,out] nmod_mat_t
227                                    const CFMatrix &m ///<[in] matrix over Z/p
228                                   );
229
230/// conversion of a FLINT matrix over Z/p to a factory matrix
231CFMatrix* convertNmod_mat_t2FacCFMatrix(const nmod_mat_t m ///<[in] nmod_mat_t
232                                       );
233
234#if __FLINT_RELEASE >= 20400
235/// conversion of a FLINT matrix over F_q to a factory matrix
236CFMatrix*
237convertFq_nmod_mat_t2FacCFMatrix(const fq_nmod_mat_t m,       ///< [in] fq_nmod_mat_t
238                                 const fq_nmod_ctx_t& fq_con, ///< [in] Fq context
239                                 const Variable& alpha ///< [in] algebraic variable
240                                );
241
242/// conversion of a factory matrix over F_q to a fq_nmod_mat_t
243void
244convertFacCFMatrix2Fq_nmod_mat_t (fq_nmod_mat_t M,            ///< [in, out] fq_nmod_mat_t
245                                  const fq_nmod_ctx_t fq_con, ///< [in] Fq context
246                                  const CFMatrix &m           ///< [in] matrix over Fq
247                                 );
248
249/// conversion of a FLINT factorization over Fq (for word size p) to a
250/// CFFList
251CFFList
252convertFLINTFq_nmod_poly_factor2FacCFFList (const fq_nmod_poly_factor_t fac, ///< [in] fq_nmod_poly_factor_t
253                                          const Variable& x,     ///< [in] polynomial variable
254                                          const Variable& alpha, ///< [in] algebraic variable
255                                          const fq_nmod_ctx_t fq_con ///< [in] Fq context
256                                           );
257#endif
258
259
260#if __FLINT_RELEASE >= 20503
261CanonicalForm mulFlintMP_Zp(const CanonicalForm& F,int lF, const CanonicalForm& Gi, int lG, int m);
262CanonicalForm mulFlintMP_QQ(const CanonicalForm& F,int lF, const CanonicalForm& Gi, int lG, int m);
263CanonicalForm gcdFlintMP_Zp(const CanonicalForm& F, const CanonicalForm& G);
264CanonicalForm gcdFlintMP_QQ(const CanonicalForm& F, const CanonicalForm& G);
265#endif
266#endif
267#endif
Note: See TracBrowser for help on using the repository browser.