[d3d3168] | 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 | |
---|
[97a059] | 14 | #ifndef FLINT_CONVERT_H |
---|
| 15 | #define FLINT_CONVERT_H |
---|
| 16 | |
---|
| 17 | #include <config.h> |
---|
| 18 | #include "canonicalform.h" |
---|
[9c98c2] | 19 | #include "fac_util.h" |
---|
[97a059] | 20 | |
---|
| 21 | #ifdef HAVE_FLINT |
---|
| 22 | #ifdef __cplusplus |
---|
| 23 | extern "C" |
---|
| 24 | { |
---|
| 25 | #endif |
---|
[a03496] | 26 | #ifndef __GMP_BITS_PER_MP_LIMB |
---|
| 27 | #define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS |
---|
| 28 | #endif |
---|
[139f6f] | 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> |
---|
[692aed] | 35 | #include <flint/nmod_mat.h> |
---|
| 36 | #include <flint/fmpz_mat.h> |
---|
[97a059] | 37 | #ifdef __cplusplus |
---|
| 38 | } |
---|
| 39 | #endif |
---|
| 40 | |
---|
[a03496] | 41 | #include <factory/cf_gmp.h> |
---|
| 42 | |
---|
[d3d3168] | 43 | /// conversion of a factory integer to fmpz_t |
---|
| 44 | void |
---|
| 45 | convertCF2Fmpz (fmpz_t result, ///< [in,out] an fmpz_t |
---|
| 46 | const CanonicalForm& f ///< [in] a CanonicalForm wrapping an |
---|
| 47 | ///< integer |
---|
| 48 | ); |
---|
| 49 | |
---|
| 50 | /// conversion of a factory univariate polynomial over Z to a fmpz_poly_t |
---|
| 51 | void |
---|
| 52 | convertFacCF2Fmpz_poly_t (fmpz_poly_t result, ///< [in,out] an fmpz_poly_t |
---|
| 53 | const CanonicalForm& f ///< [in] univariate poly over |
---|
| 54 | ///< Z |
---|
| 55 | ); |
---|
| 56 | |
---|
| 57 | /// conversion of a FLINT integer to CanonicalForm |
---|
| 58 | CanonicalForm |
---|
| 59 | convertFmpz2CF (fmpz_t coefficient ///< [in] a FLINT integer |
---|
| 60 | ); |
---|
| 61 | |
---|
| 62 | /// conversion of a FLINT poly over Z to CanonicalForm |
---|
| 63 | CanonicalForm |
---|
| 64 | convertFmpz_poly_t2FacCF (fmpz_poly_t poly, ///< [in] an fmpz_poly_t |
---|
| 65 | const Variable& x ///< [in] variable the result should |
---|
| 66 | ///< have |
---|
| 67 | ); |
---|
| 68 | |
---|
| 69 | /// conversion of a factory univariate polynomials over Z/p (for word size p) |
---|
| 70 | /// to nmod_poly_t |
---|
| 71 | void |
---|
| 72 | convertFacCF2nmod_poly_t (nmod_poly_t result, ///< [in, out] a nmod_poly_t |
---|
| 73 | const CanonicalForm& f ///< [in] univariate poly over |
---|
| 74 | ///< Z/p |
---|
| 75 | ); |
---|
| 76 | |
---|
| 77 | /// conversion of a FLINT poly over Z/p to CanonicalForm |
---|
| 78 | CanonicalForm |
---|
| 79 | convertnmod_poly_t2FacCF (nmod_poly_t poly, ///< [in] a nmod_poly_t |
---|
| 80 | const Variable& x ///< [in] variable the result should |
---|
| 81 | ///< have |
---|
| 82 | ); |
---|
| 83 | |
---|
| 84 | /// conversion of a factory rationals to fmpq_t |
---|
| 85 | void |
---|
| 86 | convertCF2Fmpq (fmpq_t result, ///< [in,out] an fmpq_t |
---|
| 87 | const CanonicalForm& f ///< [in] a CanonicalForm wrapping a |
---|
| 88 | ///< rational |
---|
| 89 | ); |
---|
| 90 | |
---|
| 91 | /// conversion of a factory univariate polynomials over Q to fmpq_poly_t |
---|
| 92 | void |
---|
| 93 | convertFacCF2Fmpq_poly_t (fmpq_poly_t result, ///< [in,out] an fmpq_poly_t |
---|
| 94 | const CanonicalForm& f ///< [in] univariate poly over |
---|
| 95 | ///< Q |
---|
| 96 | ); |
---|
| 97 | |
---|
| 98 | /// conversion of a FLINT poly over Q to CanonicalForm |
---|
| 99 | CanonicalForm |
---|
| 100 | convertFmpq_poly_t2FacCF (fmpq_poly_t p, ///< [in] an fmpq_poly_t |
---|
| 101 | const Variable& x ///< [in] variable the result should |
---|
| 102 | ///< have |
---|
| 103 | ); |
---|
| 104 | |
---|
| 105 | /// conversion of a FLINT factorization over Z/p (for word size p) to a |
---|
| 106 | /// CFFList |
---|
| 107 | CFFList |
---|
| 108 | convertFLINTnmod_poly_factor2FacCFFList ( |
---|
| 109 | nmod_poly_factor_t fac, ///< [in] a nmod_poly_factor_t |
---|
| 110 | mp_limb_t leadingCoeff, ///< [in] leading coefficient |
---|
| 111 | const Variable& x ///< [in] variable the result should |
---|
| 112 | ///< have |
---|
| 113 | ); |
---|
[97a059] | 114 | |
---|
[9c98c2] | 115 | /// conversion of a factory univariate poly over Z to a FLINT poly over |
---|
| 116 | /// Z/p (for non word size p) |
---|
| 117 | void |
---|
| 118 | convertFacCF2Fmpz_mod_poly_t ( |
---|
| 119 | fmpz_mod_poly_t result, ///< [in,out] fmpz_mod_poly_t |
---|
| 120 | const CanonicalForm& f, ///< [in] univariate poly over |
---|
| 121 | ///< Z |
---|
| 122 | const fmpz_t p ///< [in] some integer p |
---|
| 123 | ); |
---|
| 124 | |
---|
| 125 | /// conversion of a FLINT poly over Z/p (for non word size p) to a CanonicalForm |
---|
| 126 | /// over Z |
---|
| 127 | CanonicalForm |
---|
| 128 | convertFmpz_mod_poly_t2FacCF ( |
---|
| 129 | fmpz_mod_poly_t poly, ///< [in] fmpz_mod_poly_t |
---|
| 130 | const Variable& x, ///< [in] variable the result |
---|
| 131 | ///< should have |
---|
| 132 | const modpk& b ///< [in] coeff bound to map |
---|
| 133 | ///< coeffs in (-p/2,p/2) |
---|
| 134 | ); |
---|
| 135 | |
---|
[692aed] | 136 | /// conversion of a factory matrix over Z to a fmpz_mat_t |
---|
| 137 | void convertFacCFMatrix2Fmpz_mat_t (fmpz_mat_t M, ///<[in,out] fmpz_mat_t |
---|
| 138 | CFMatrix &m ///<[in] matrix over Z |
---|
| 139 | ); |
---|
| 140 | |
---|
| 141 | /// conversion of a FLINT matrix over Z to a factory matrix |
---|
| 142 | CFMatrix* convertFmpz_mat_t2FacCFMatrix(fmpz_mat_t m ///<[in] fmpz_mat_t |
---|
| 143 | ); |
---|
| 144 | |
---|
| 145 | /// conversion of a factory matrix over Z/p to a nmod_mat_t |
---|
| 146 | void convertFacCFMatrix2nmod_mat_t (nmod_mat_t M, ///<[in,out] nmod_mat_t |
---|
| 147 | CFMatrix &m ///<[in] matrix over Z/p |
---|
| 148 | ); |
---|
| 149 | |
---|
| 150 | /// conversion of a FLINT matrix over Z/p to a factory matrix |
---|
| 151 | CFMatrix* convertNmod_mat_t2FacCFMatrix(nmod_mat_t m ///<[in] nmod_mat_t |
---|
| 152 | ); |
---|
| 153 | |
---|
[97a059] | 154 | #endif |
---|
| 155 | #endif |
---|