[ad3c3ff] | 1 | /*****************************************************************************\ |
---|
[806c18] | 2 | * Computer Algebra System SINGULAR |
---|
[ad3c3ff] | 3 | \*****************************************************************************/ |
---|
| 4 | /** @file facHensel.h |
---|
| 5 | * |
---|
[0e2e23] | 6 | * This file defines functions for Hensel lifting. |
---|
[806c18] | 7 | * |
---|
| 8 | * ABSTRACT: function are used for bi- and multivariate factorization over |
---|
[ad3c3ff] | 9 | * finite fields |
---|
| 10 | * |
---|
| 11 | * @author Martin Lee |
---|
| 12 | * |
---|
| 13 | * @internal @version \$Id$ |
---|
| 14 | * |
---|
| 15 | **/ |
---|
| 16 | /*****************************************************************************/ |
---|
| 17 | |
---|
| 18 | #ifndef FAC_HENSEL_H |
---|
| 19 | #define FAC_HENSEL_H |
---|
| 20 | |
---|
[e4fe2b] | 21 | // #include "config.h" |
---|
[650f2d8] | 22 | #include "cf_assert.h" |
---|
[ad3c3ff] | 23 | #include "debug.h" |
---|
| 24 | #include "timing.h" |
---|
| 25 | |
---|
| 26 | #include "canonicalform.h" |
---|
[d9357b] | 27 | #include "fac_util.h" |
---|
[ad3c3ff] | 28 | |
---|
[615ca8] | 29 | #ifdef HAVE_NTL |
---|
[ad3c3ff] | 30 | /// sort a list of polynomials by their degree in @a x. |
---|
| 31 | /// |
---|
[806c18] | 32 | void sortList (CFList& list, ///< [in, out] list of polys, sorted list |
---|
| 33 | const Variable& x ///< [in] some Variable |
---|
[ad3c3ff] | 34 | ); |
---|
| 35 | |
---|
| 36 | /// Hensel lift from univariate to bivariate. |
---|
[806c18] | 37 | /// |
---|
[ad3c3ff] | 38 | /// @sa henselLiftResume12(), henselLift23(), henselLiftResume(), henselLift() |
---|
[806c18] | 39 | void |
---|
[ad3c3ff] | 40 | henselLift12 (const CanonicalForm& F, ///< [in] compressed, bivariate poly |
---|
[806c18] | 41 | CFList& factors, ///< [in, out] monic univariate factors of |
---|
[ad3c3ff] | 42 | ///< F, including leading coefficient as |
---|
[806c18] | 43 | ///< first element. Returns monic lifted |
---|
| 44 | ///< factors without the leading |
---|
[ad3c3ff] | 45 | ///< coefficient |
---|
| 46 | int l, ///< [in] lifting precision |
---|
| 47 | CFArray& Pi, ///< [in,out] stores intermediate results |
---|
| 48 | CFList& diophant, ///< [in,out] result of diophantine() |
---|
[e368746] | 49 | CFMatrix& M, ///< [in,out] stores intermediate results |
---|
[69fdf90] | 50 | modpk& b, ///< [in] coeff bound |
---|
| 51 | bool sort= true ///< [in] sort factors by degree in |
---|
| 52 | ///< Variable(1) |
---|
| 53 | ); |
---|
| 54 | |
---|
| 55 | /// Hensel lift from univariate to bivariate. |
---|
| 56 | /// |
---|
| 57 | /// @sa henselLiftResume12(), henselLift23(), henselLiftResume(), henselLift() |
---|
| 58 | void |
---|
| 59 | henselLift12 (const CanonicalForm& F, ///< [in] compressed, bivariate poly |
---|
| 60 | CFList& factors, ///< [in, out] monic univariate factors of |
---|
| 61 | ///< F, including leading coefficient as |
---|
| 62 | ///< first element. Returns monic lifted |
---|
| 63 | ///< factors without the leading |
---|
| 64 | ///< coefficient |
---|
| 65 | int l, ///< [in] lifting precision |
---|
| 66 | CFArray& Pi, ///< [in,out] stores intermediate results |
---|
| 67 | CFList& diophant, ///< [in,out] result of diophantine() |
---|
| 68 | CFMatrix& M, ///< [in,out] stores intermediate results |
---|
| 69 | bool sort= true ///< [in] sort factors by degree in |
---|
[e368746] | 70 | ///< Variable(1) |
---|
[ad3c3ff] | 71 | ); |
---|
| 72 | |
---|
[806c18] | 73 | /// resume Hensel lift from univariate to bivariate. Assumes factors are lifted |
---|
[ad3c3ff] | 74 | /// to precision Variable (2)^start and lifts them to precision Variable (2)^end |
---|
[806c18] | 75 | /// |
---|
[ad3c3ff] | 76 | /// @sa henselLift12(), henselLift23(), henselLiftResume(), henselLift() |
---|
[806c18] | 77 | void |
---|
[ad3c3ff] | 78 | henselLiftResume12 (const CanonicalForm& F, ///< [in] compressed, bivariate poly |
---|
[806c18] | 79 | CFList& factors, ///< [in,out] monic factors of F, |
---|
| 80 | ///< lifted to precision start, |
---|
| 81 | ///< including leading coefficient |
---|
| 82 | ///< as first element. Returns monic |
---|
| 83 | ///< lifted factors without the |
---|
[ad3c3ff] | 84 | ///< leading coefficient |
---|
| 85 | int start, ///< [in] starting precision |
---|
| 86 | int end, ///< [in] end precision |
---|
| 87 | CFArray& Pi, ///< [in,out] stores intermediate |
---|
| 88 | ///< results |
---|
| 89 | const CFList& diophant, ///< [in] result of diophantine |
---|
[d9357b] | 90 | CFMatrix& M, ///< [in,out] stores intermediate |
---|
[ad3c3ff] | 91 | ///< results |
---|
[d9357b] | 92 | const modpk& b= modpk() ///< [in] coeff bound |
---|
[ad3c3ff] | 93 | ); |
---|
| 94 | |
---|
| 95 | /// Hensel lifting from bivariate to trivariate. |
---|
| 96 | /// |
---|
| 97 | /// @return @a henselLift23 returns a list of polynomials lifted to precision |
---|
| 98 | /// Variable (3)^l[1] |
---|
| 99 | /// @sa henselLift12(), henselLiftResume12(), henselLiftResume(), henselLift() |
---|
[806c18] | 100 | CFList |
---|
[ad3c3ff] | 101 | henselLift23 (const CFList& eval, ///< [in] contains compressed, bivariate |
---|
| 102 | ///< as first element and trivariate one as |
---|
[806c18] | 103 | ///< second element |
---|
| 104 | const CFList& factors, ///< [in] monic bivariate factors, |
---|
| 105 | ///< including leading coefficient |
---|
[ad3c3ff] | 106 | ///< as first element. |
---|
[81d96c] | 107 | int* l, ///< [in] l[0]: precision of bivariate |
---|
[ad3c3ff] | 108 | ///< lifting, l[1] as above |
---|
| 109 | CFList& diophant, ///< [in,out] returns the result of |
---|
| 110 | ///< biDiophantine() |
---|
| 111 | CFArray& Pi, ///< [in,out] stores intermediate results |
---|
| 112 | CFMatrix& M ///< [in,out] stores intermediate results |
---|
| 113 | ); |
---|
| 114 | |
---|
| 115 | /// resume Hensel lifting. |
---|
| 116 | /// |
---|
| 117 | /// @sa henselLift12(), henselLiftResume12(), henselLift23(), henselLift() |
---|
[806c18] | 118 | void |
---|
[ad3c3ff] | 119 | henselLiftResume ( |
---|
[806c18] | 120 | const CanonicalForm& F, ///< [in] compressed, multivariate poly |
---|
[ad3c3ff] | 121 | CFList& factors, ///< [in,out] monic multivariate factors |
---|
[806c18] | 122 | ///< lifted to precision F.mvar()^start, |
---|
| 123 | ///< including leading coefficient |
---|
[ad3c3ff] | 124 | ///< as first element. Returns factors |
---|
| 125 | ///< lifted to precision F.mvar()^end |
---|
[806c18] | 126 | int start, ///< [in] starting precision |
---|
[ad3c3ff] | 127 | int end, ///< [in] end precision |
---|
| 128 | CFArray& Pi, ///< [in,out] stores intermediate results |
---|
| 129 | const CFList& diophant, ///< [in] result of multiRecDiophantine() |
---|
| 130 | CFMatrix& M, ///< [in, out] stores intermediate results |
---|
| 131 | const CFList& MOD ///< [in] a list of powers of Variables |
---|
| 132 | ///< of level higher than 1 |
---|
| 133 | ); |
---|
| 134 | |
---|
| 135 | /// Hensel lifting |
---|
| 136 | /// |
---|
[806c18] | 137 | /// @return @a henselLift returns a list of polynomials lifted to |
---|
[ad3c3ff] | 138 | /// precision F.getLast().mvar()^l_new |
---|
| 139 | /// @sa henselLift12(), henselLiftResume12(), henselLift23(), henselLiftResume() |
---|
| 140 | CFList |
---|
| 141 | henselLift (const CFList& F, ///< [in] two compressed, multivariate |
---|
| 142 | ///< polys F and G |
---|
[806c18] | 143 | const CFList& factors, ///< [in] monic multivariate factors |
---|
| 144 | ///< including leading coefficient |
---|
| 145 | ///< as first element. |
---|
[ad3c3ff] | 146 | const CFList& MOD, ///< [in] a list of powers of Variables |
---|
| 147 | ///< of level higher than 1 |
---|
| 148 | CFList& diophant, ///< [in,out] result of multiRecDiophantine() |
---|
| 149 | CFArray& Pi, ///< [in,out] stores intermediate results |
---|
| 150 | CFMatrix& M, ///< [in,out] stores intermediate results |
---|
[81d96c] | 151 | int lOld, ///< [in] lifting precision of F.mvar() |
---|
| 152 | int lNew ///< [in] lifting precision of G.mvar() |
---|
[ad3c3ff] | 153 | ); |
---|
| 154 | |
---|
[806c18] | 155 | /// Hensel lifting from bivariate to multivariate |
---|
[ad3c3ff] | 156 | /// |
---|
[806c18] | 157 | /// @return @a henselLift returns a list of lifted factors |
---|
| 158 | /// @sa henselLift12(), henselLiftResume12(), henselLift23(), henselLiftResume() |
---|
[ad3c3ff] | 159 | CFList |
---|
[806c18] | 160 | henselLift (const CFList& eval, ///< [in] a list of polynomials the last |
---|
| 161 | ///< element is a compressed multivariate |
---|
| 162 | ///< poly, last but one element equals the |
---|
[ad3c3ff] | 163 | ///< last elements modulo its main variable |
---|
[806c18] | 164 | ///< and so on. The first element is a |
---|
[ad3c3ff] | 165 | ///< compressed bivariate poly. |
---|
[806c18] | 166 | const CFList& factors, ///< [in] bivariate factors, including |
---|
[ad3c3ff] | 167 | ///< leading coefficient |
---|
[81d96c] | 168 | int* l, ///< [in] lifting bounds |
---|
| 169 | int lLength, ///< [in] length of l |
---|
[e368746] | 170 | bool sort= true ///< [in] sort factors by degree in |
---|
| 171 | ///< Variable(1) |
---|
[ad3c3ff] | 172 | ); |
---|
| 173 | |
---|
[81d96c] | 174 | /// Hensel lifting from univariate to bivariate, factors need not to be monic |
---|
[08daea] | 175 | void |
---|
[81d96c] | 176 | nonMonicHenselLift12 (const CanonicalForm& F,///< [in] a bivariate poly |
---|
[08daea] | 177 | CFList& factors, ///< [in, out] a list of univariate polys |
---|
| 178 | ///< lifted factors |
---|
| 179 | int l, ///< [in] lift bound |
---|
| 180 | CFArray& Pi, ///< [in, out] stores intermediate results |
---|
| 181 | CFList& diophant, ///< [in, out] result of diophantine |
---|
| 182 | CFMatrix& M, ///< [in, out] stores intermediate results |
---|
| 183 | const CFArray& LCs, ///< [in] leading coefficients |
---|
| 184 | bool sort ///< [in] if true factors are sorted by |
---|
| 185 | ///< their degree |
---|
| 186 | ); |
---|
| 187 | |
---|
| 188 | /// two factor Hensel lifting from bivariate to multivariate, factors need not |
---|
| 189 | /// to be monic |
---|
| 190 | /// |
---|
| 191 | /// @return @a henselLift122 returns a list of lifted factors |
---|
| 192 | CFList |
---|
[81d96c] | 193 | nonMonicHenselLift2 (const CFList& eval,///< [in] a list of polynomials the last |
---|
[08daea] | 194 | ///< element is a compressed multivariate |
---|
| 195 | ///< poly, last but one element equals the |
---|
| 196 | ///< last elements modulo its main variable |
---|
| 197 | ///< and so on. The first element is a |
---|
| 198 | ///< compressed bivariate poly. |
---|
| 199 | const CFList& factors,///< [in] bivariate factors |
---|
| 200 | int* l, ///< [in] lift bounds |
---|
[81d96c] | 201 | int lLength, ///< [in] length of l |
---|
[08daea] | 202 | bool sort, ///< [in] if true factors are sorted by |
---|
| 203 | ///< their degree in Variable(1) |
---|
| 204 | const CFList& LCs1, ///< [in] a list of evaluated LC of first |
---|
| 205 | ///< factor |
---|
| 206 | const CFList& LCs2, ///< [in] a list of evaluated LC of second |
---|
| 207 | ///< factor |
---|
| 208 | const CFArray& Pi, ///< [in] intermediate result |
---|
[e368746] | 209 | const CFList& diophant,///< [in] result of diophantine |
---|
| 210 | bool& noOneToOne ///< [in,out] check for one to one |
---|
| 211 | ///< correspondence |
---|
[08daea] | 212 | ); |
---|
| 213 | |
---|
[c1b9927] | 214 | /// Hensel lifting of non monic factors, needs correct leading coefficients of |
---|
[e368746] | 215 | /// factors and a one to one corresponds between bivariate and multivariate |
---|
| 216 | /// factors to succeed |
---|
| 217 | /// |
---|
| 218 | /// @return @a nonMonicHenselLift returns a list of lifted factors |
---|
[c1b9927] | 219 | /// such that prod (factors) == eval.getLast() if there is a one to one |
---|
[e368746] | 220 | /// correspondence |
---|
| 221 | CFList |
---|
| 222 | nonMonicHenselLift (const CFList& eval, ///< [in] a list of polys the last |
---|
[c1b9927] | 223 | ///< element is a compressed |
---|
[e368746] | 224 | ///< multivariate poly, last but one |
---|
| 225 | ///< element equals the last elements |
---|
[c1b9927] | 226 | ///< modulo its main variable and so |
---|
| 227 | ///< on. The first element is a |
---|
[e368746] | 228 | ///< compressed poly in 3 variables |
---|
| 229 | const CFList& factors, ///< [in] a list of bivariate factors |
---|
| 230 | CFList* const& LCs, ///< [in] leading coefficients, |
---|
[c1b9927] | 231 | ///< evaluated in the same way as |
---|
[e368746] | 232 | ///< eval |
---|
| 233 | CFList& diophant, ///< [in, out] solution of univariate |
---|
[c1b9927] | 234 | ///< diophantine equation |
---|
[e368746] | 235 | CFArray& Pi, ///< [in, out] buffer intermediate |
---|
| 236 | ///< results |
---|
| 237 | int* liftBound, ///< [in] lifting bounds |
---|
| 238 | int length, ///< [in] length of lifting bounds |
---|
| 239 | bool& noOneToOne ///< [in, out] check for one to one |
---|
| 240 | ///< correspondence |
---|
| 241 | ); |
---|
[615ca8] | 242 | #endif /* HAVE_NTL */ |
---|
[ad3c3ff] | 243 | #endif |
---|
| 244 | /* FAC_HENSEL_H */ |
---|
| 245 | |
---|