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 <fmpz.h> |
---|
30 | #include <fmpq.h> |
---|
31 | #include <fmpz_poly.h> |
---|
32 | #include <fmpz_mod_poly.h> |
---|
33 | #include <fmpq_poly.h> |
---|
34 | #include <nmod_poly.h> |
---|
35 | #ifdef __cplusplus |
---|
36 | } |
---|
37 | #endif |
---|
38 | |
---|
39 | #include <factory/cf_gmp.h> |
---|
40 | |
---|
41 | /// conversion of a factory integer to fmpz_t |
---|
42 | void |
---|
43 | convertCF2Fmpz (fmpz_t result, ///< [in,out] an fmpz_t |
---|
44 | const CanonicalForm& f ///< [in] a CanonicalForm wrapping an |
---|
45 | ///< integer |
---|
46 | ); |
---|
47 | |
---|
48 | /// conversion of a factory univariate polynomial over Z to a fmpz_poly_t |
---|
49 | void |
---|
50 | convertFacCF2Fmpz_poly_t (fmpz_poly_t result, ///< [in,out] an fmpz_poly_t |
---|
51 | const CanonicalForm& f ///< [in] univariate poly over |
---|
52 | ///< Z |
---|
53 | ); |
---|
54 | |
---|
55 | /// conversion of a FLINT integer to CanonicalForm |
---|
56 | CanonicalForm |
---|
57 | convertFmpz2CF (fmpz_t coefficient ///< [in] a FLINT integer |
---|
58 | ); |
---|
59 | |
---|
60 | /// conversion of a FLINT poly over Z to CanonicalForm |
---|
61 | CanonicalForm |
---|
62 | convertFmpz_poly_t2FacCF (fmpz_poly_t poly, ///< [in] an fmpz_poly_t |
---|
63 | const Variable& x ///< [in] variable the result should |
---|
64 | ///< have |
---|
65 | ); |
---|
66 | |
---|
67 | /// conversion of a factory univariate polynomials over Z/p (for word size p) |
---|
68 | /// to nmod_poly_t |
---|
69 | void |
---|
70 | convertFacCF2nmod_poly_t (nmod_poly_t result, ///< [in, out] a nmod_poly_t |
---|
71 | const CanonicalForm& f ///< [in] univariate poly over |
---|
72 | ///< Z/p |
---|
73 | ); |
---|
74 | |
---|
75 | /// conversion of a FLINT poly over Z/p to CanonicalForm |
---|
76 | CanonicalForm |
---|
77 | convertnmod_poly_t2FacCF (nmod_poly_t poly, ///< [in] a nmod_poly_t |
---|
78 | const Variable& x ///< [in] variable the result should |
---|
79 | ///< have |
---|
80 | ); |
---|
81 | |
---|
82 | /// conversion of a factory rationals to fmpq_t |
---|
83 | void |
---|
84 | convertCF2Fmpq (fmpq_t result, ///< [in,out] an fmpq_t |
---|
85 | const CanonicalForm& f ///< [in] a CanonicalForm wrapping a |
---|
86 | ///< rational |
---|
87 | ); |
---|
88 | |
---|
89 | /// conversion of a factory univariate polynomials over Q to fmpq_poly_t |
---|
90 | void |
---|
91 | convertFacCF2Fmpq_poly_t (fmpq_poly_t result, ///< [in,out] an fmpq_poly_t |
---|
92 | const CanonicalForm& f ///< [in] univariate poly over |
---|
93 | ///< Q |
---|
94 | ); |
---|
95 | |
---|
96 | /// conversion of a FLINT poly over Q to CanonicalForm |
---|
97 | CanonicalForm |
---|
98 | convertFmpq_poly_t2FacCF (fmpq_poly_t p, ///< [in] an fmpq_poly_t |
---|
99 | const Variable& x ///< [in] variable the result should |
---|
100 | ///< have |
---|
101 | ); |
---|
102 | |
---|
103 | /// conversion of a FLINT factorization over Z/p (for word size p) to a |
---|
104 | /// CFFList |
---|
105 | CFFList |
---|
106 | convertFLINTnmod_poly_factor2FacCFFList ( |
---|
107 | nmod_poly_factor_t fac, ///< [in] a nmod_poly_factor_t |
---|
108 | mp_limb_t leadingCoeff, ///< [in] leading coefficient |
---|
109 | const Variable& x ///< [in] variable the result should |
---|
110 | ///< have |
---|
111 | ); |
---|
112 | |
---|
113 | /// conversion of a factory univariate poly over Z to a FLINT poly over |
---|
114 | /// Z/p (for non word size p) |
---|
115 | void |
---|
116 | convertFacCF2Fmpz_mod_poly_t ( |
---|
117 | fmpz_mod_poly_t result, ///< [in,out] fmpz_mod_poly_t |
---|
118 | const CanonicalForm& f, ///< [in] univariate poly over |
---|
119 | ///< Z |
---|
120 | const fmpz_t p ///< [in] some integer p |
---|
121 | ); |
---|
122 | |
---|
123 | /// conversion of a FLINT poly over Z/p (for non word size p) to a CanonicalForm |
---|
124 | /// over Z |
---|
125 | CanonicalForm |
---|
126 | convertFmpz_mod_poly_t2FacCF ( |
---|
127 | fmpz_mod_poly_t poly, ///< [in] fmpz_mod_poly_t |
---|
128 | const Variable& x, ///< [in] variable the result |
---|
129 | ///< should have |
---|
130 | const modpk& b ///< [in] coeff bound to map |
---|
131 | ///< coeffs in (-p/2,p/2) |
---|
132 | ); |
---|
133 | |
---|
134 | #endif |
---|
135 | #endif |
---|