[7bf145] | 1 | /*****************************************************************************\ |
---|
[806c18] | 2 | * Computer Algebra System SINGULAR |
---|
[7bf145] | 3 | \*****************************************************************************/ |
---|
| 4 | /** @file facFqFactorize.h |
---|
[806c18] | 5 | * |
---|
[7bf145] | 6 | * This file provides functions for factorizing a multivariate polynomial over |
---|
[806c18] | 7 | * \f$ F_{p} \f$ , \f$ F_{p}(\alpha ) \f$ or GF. |
---|
[7bf145] | 8 | * |
---|
| 9 | * @author Martin Lee |
---|
| 10 | * |
---|
| 11 | **/ |
---|
| 12 | /*****************************************************************************/ |
---|
| 13 | |
---|
| 14 | #ifndef FAC_FQ_FACTORIZE_H |
---|
| 15 | #define FAC_FQ_FACTORIZE_H |
---|
| 16 | |
---|
[e4fe2b] | 17 | // #include "config.h" |
---|
[7bf145] | 18 | |
---|
| 19 | #include "facFqBivar.h" |
---|
| 20 | #include "DegreePattern.h" |
---|
| 21 | #include "ExtensionInfo.h" |
---|
| 22 | #include "cf_util.h" |
---|
| 23 | #include "facFqSquarefree.h" |
---|
| 24 | #include "facFqBivarUtil.h" |
---|
| 25 | |
---|
| 26 | /// Factorization over a finite field |
---|
[806c18] | 27 | /// |
---|
[7bf145] | 28 | /// @return @a multiFactorize returns a factorization of F |
---|
| 29 | /// @sa biFactorize(), extFactorize() |
---|
[806c18] | 30 | CFList |
---|
[7bf145] | 31 | multiFactorize (const CanonicalForm& F, ///< [in] poly to be factored |
---|
| 32 | const ExtensionInfo& info ///< [in] info about extension |
---|
| 33 | ); |
---|
| 34 | |
---|
| 35 | /// factorize a squarefree multivariate polynomial over \f$ F_{p} \f$ |
---|
| 36 | /// |
---|
[806c18] | 37 | /// @return @a FpSqrfFactorize returns a list of monic factors, the first |
---|
| 38 | /// element is the leading coefficient. |
---|
[7bf145] | 39 | /// @sa FqSqrfFactorize(), GFSqrfFactorize() |
---|
[d990001] | 40 | #ifdef HAVE_NTL |
---|
[7bf145] | 41 | inline |
---|
| 42 | CFList FpSqrfFactorize (const CanonicalForm & F ///< [in] a multivariate poly |
---|
[806c18] | 43 | ) |
---|
[7bf145] | 44 | { |
---|
[f09105] | 45 | if (getNumVars (F) == 2) |
---|
| 46 | return FpBiSqrfFactorize (F); |
---|
[7bf145] | 47 | ExtensionInfo info= ExtensionInfo (false); |
---|
| 48 | CFList result= multiFactorize (F, info); |
---|
| 49 | result.insert (Lc(F)); |
---|
| 50 | return result; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | /// factorize a squarefree multivariate polynomial over \f$ F_{p} (\alpha ) \f$ |
---|
| 54 | /// |
---|
[806c18] | 55 | /// @return @a FqSqrfFactorize returns a list of monic factors, the first |
---|
| 56 | /// element is the leading coefficient. |
---|
| 57 | /// @sa FpSqrfFactorize(), GFSqrfFactorize() |
---|
[7bf145] | 58 | inline |
---|
| 59 | CFList FqSqrfFactorize (const CanonicalForm & F, ///< [in] a multivariate poly |
---|
| 60 | const Variable& alpha ///< [in] algebraic variable |
---|
[806c18] | 61 | ) |
---|
[7bf145] | 62 | { |
---|
[f09105] | 63 | if (getNumVars (F) == 2) |
---|
| 64 | return FqBiSqrfFactorize (F, alpha); |
---|
[7bf145] | 65 | ExtensionInfo info= ExtensionInfo (alpha, false); |
---|
| 66 | CFList result= multiFactorize (F, info); |
---|
| 67 | result.insert (Lc(F)); |
---|
| 68 | return result; |
---|
| 69 | } |
---|
| 70 | |
---|
[806c18] | 71 | /// factorize a squarefree multivariate polynomial over GF |
---|
[7bf145] | 72 | /// |
---|
[806c18] | 73 | /// @return @a GFSqrfFactorize returns a list of monic factors, the first |
---|
| 74 | /// element is the leading coefficient. |
---|
[7bf145] | 75 | /// @sa FpSqrfFactorize(), FqSqrfFactorize() |
---|
| 76 | inline |
---|
| 77 | CFList GFSqrfFactorize (const CanonicalForm & F ///< [in] a multivariate poly |
---|
[806c18] | 78 | ) |
---|
[7bf145] | 79 | { |
---|
[806c18] | 80 | ASSERT (CFFactory::gettype() == GaloisFieldDomain, |
---|
[7bf145] | 81 | "GF as base field expected"); |
---|
[f09105] | 82 | if (getNumVars (F) == 2) |
---|
| 83 | return GFBiSqrfFactorize (F); |
---|
[7bf145] | 84 | ExtensionInfo info= ExtensionInfo (getGFDegree(), gf_name, false); |
---|
| 85 | CFList result= multiFactorize (F, info); |
---|
| 86 | result.insert (Lc(F)); |
---|
| 87 | return result; |
---|
| 88 | } |
---|
| 89 | |
---|
[806c18] | 90 | /// factorize a multivariate polynomial over \f$ F_{p} \f$ |
---|
[7bf145] | 91 | /// |
---|
[806c18] | 92 | /// @return @a FpFactorize returns a list of monic factors with |
---|
| 93 | /// multiplicity, the first element is the leading coefficient. |
---|
[7bf145] | 94 | /// @sa FqFactorize(), GFFactorize() |
---|
| 95 | inline |
---|
[f9b796e] | 96 | CFFList FpFactorize (const CanonicalForm& G,///< [in] a multivariate poly |
---|
| 97 | bool substCheck= true ///< [in] enables substitute check |
---|
[806c18] | 98 | ) |
---|
[7bf145] | 99 | { |
---|
[f9b796e] | 100 | if (getNumVars (G) == 2) |
---|
| 101 | return FpBiFactorize (G, substCheck); |
---|
| 102 | |
---|
| 103 | CanonicalForm F= G; |
---|
| 104 | if (substCheck) |
---|
| 105 | { |
---|
| 106 | bool foundOne= false; |
---|
| 107 | int * substDegree= new int [F.level()]; |
---|
| 108 | for (int i= 1; i <= F.level(); i++) |
---|
| 109 | { |
---|
| 110 | if (degree (F, i) > 0) |
---|
| 111 | { |
---|
| 112 | substDegree[i-1]= substituteCheck (F, Variable (i)); |
---|
| 113 | if (substDegree [i-1] > 1) |
---|
| 114 | { |
---|
| 115 | foundOne= true; |
---|
| 116 | subst (F, F, substDegree[i-1], Variable (i)); |
---|
| 117 | } |
---|
| 118 | } |
---|
| 119 | else |
---|
| 120 | substDegree[i-1]= -1; |
---|
| 121 | } |
---|
| 122 | if (foundOne) |
---|
| 123 | { |
---|
| 124 | CFFList result= FpFactorize (F, false); |
---|
| 125 | CFFList newResult, tmp; |
---|
| 126 | CanonicalForm tmp2; |
---|
| 127 | newResult.insert (result.getFirst()); |
---|
| 128 | result.removeFirst(); |
---|
| 129 | for (CFFListIterator i= result; i.hasItem(); i++) |
---|
| 130 | { |
---|
| 131 | tmp2= i.getItem().factor(); |
---|
| 132 | for (int j= 1; j <= G.level(); j++) |
---|
| 133 | { |
---|
| 134 | if (substDegree[j-1] > 1) |
---|
| 135 | tmp2= reverseSubst (tmp2, substDegree[j-1], Variable (j)); |
---|
| 136 | } |
---|
| 137 | tmp= FpFactorize (tmp2, false); |
---|
| 138 | tmp.removeFirst(); |
---|
| 139 | for (CFFListIterator j= tmp; j.hasItem(); j++) |
---|
| 140 | newResult.append (CFFactor (j.getItem().factor(), |
---|
| 141 | j.getItem().exp()*i.getItem().exp())); |
---|
| 142 | } |
---|
| 143 | delete [] substDegree; |
---|
| 144 | return newResult; |
---|
| 145 | } |
---|
| 146 | delete [] substDegree; |
---|
| 147 | } |
---|
| 148 | |
---|
[7bf145] | 149 | ExtensionInfo info= ExtensionInfo (false); |
---|
| 150 | Variable a= Variable (1); |
---|
[806c18] | 151 | CanonicalForm LcF= Lc (F); |
---|
[8baf483] | 152 | CFFList sqrf= FpSqrf (F, false); |
---|
| 153 | CFFList result; |
---|
| 154 | CFList bufResult; |
---|
| 155 | sqrf.removeFirst(); |
---|
| 156 | CFListIterator i; |
---|
| 157 | for (CFFListIterator iter= sqrf; iter.hasItem(); iter++) |
---|
[7bf145] | 158 | { |
---|
[8baf483] | 159 | bufResult= multiFactorize (iter.getItem().factor(), info); |
---|
| 160 | for (i= bufResult; i.hasItem(); i++) |
---|
| 161 | result.append (CFFactor (i.getItem(), iter.getItem().exp())); |
---|
[7bf145] | 162 | } |
---|
| 163 | result.insert (CFFactor (LcF, 1)); |
---|
| 164 | return result; |
---|
| 165 | } |
---|
| 166 | |
---|
| 167 | /// factorize a multivariate polynomial over \f$ F_{p} (\alpha ) \f$ |
---|
| 168 | /// |
---|
[806c18] | 169 | /// @return @a FqFactorize returns a list of monic factors with |
---|
| 170 | /// multiplicity, the first element is the leading coefficient. |
---|
[7bf145] | 171 | /// @sa FpFactorize(), GFFactorize() |
---|
| 172 | inline |
---|
[f9b796e] | 173 | CFFList FqFactorize (const CanonicalForm& G, ///< [in] a multivariate poly |
---|
| 174 | const Variable& alpha, ///< [in] algebraic variable |
---|
| 175 | bool substCheck= true ///< [in] enables substitute check |
---|
[806c18] | 176 | ) |
---|
[7bf145] | 177 | { |
---|
[f9b796e] | 178 | if (getNumVars (G) == 2) |
---|
| 179 | return FqBiFactorize (G, alpha, substCheck); |
---|
| 180 | |
---|
| 181 | CanonicalForm F= G; |
---|
| 182 | if (substCheck) |
---|
| 183 | { |
---|
| 184 | bool foundOne= false; |
---|
| 185 | int * substDegree= new int [F.level()]; |
---|
| 186 | for (int i= 1; i <= F.level(); i++) |
---|
| 187 | { |
---|
| 188 | if (degree (F, i) > 0) |
---|
| 189 | { |
---|
| 190 | substDegree[i-1]= substituteCheck (F, Variable (i)); |
---|
| 191 | if (substDegree [i-1] > 1) |
---|
| 192 | { |
---|
| 193 | foundOne= true; |
---|
| 194 | subst (F, F, substDegree[i-1], Variable (i)); |
---|
| 195 | } |
---|
| 196 | } |
---|
| 197 | else |
---|
| 198 | substDegree[i-1]= -1; |
---|
| 199 | } |
---|
| 200 | if (foundOne) |
---|
| 201 | { |
---|
| 202 | CFFList result= FqFactorize (F, alpha, false); |
---|
| 203 | CFFList newResult, tmp; |
---|
| 204 | CanonicalForm tmp2; |
---|
| 205 | newResult.insert (result.getFirst()); |
---|
| 206 | result.removeFirst(); |
---|
| 207 | for (CFFListIterator i= result; i.hasItem(); i++) |
---|
| 208 | { |
---|
| 209 | tmp2= i.getItem().factor(); |
---|
| 210 | for (int j= 1; j <= G.level(); j++) |
---|
| 211 | { |
---|
| 212 | if (substDegree[j-1] > 1) |
---|
| 213 | tmp2= reverseSubst (tmp2, substDegree[j-1], Variable (j)); |
---|
| 214 | } |
---|
| 215 | tmp= FqFactorize (tmp2, alpha, false); |
---|
| 216 | tmp.removeFirst(); |
---|
| 217 | for (CFFListIterator j= tmp; j.hasItem(); j++) |
---|
| 218 | newResult.append (CFFactor (j.getItem().factor(), |
---|
| 219 | j.getItem().exp()*i.getItem().exp())); |
---|
| 220 | } |
---|
| 221 | delete [] substDegree; |
---|
| 222 | return newResult; |
---|
| 223 | } |
---|
| 224 | delete [] substDegree; |
---|
| 225 | } |
---|
| 226 | |
---|
[806c18] | 227 | ExtensionInfo info= ExtensionInfo (alpha, false); |
---|
| 228 | CanonicalForm LcF= Lc (F); |
---|
[8baf483] | 229 | CFFList sqrf= FqSqrf (F, alpha, false); |
---|
| 230 | CFFList result; |
---|
| 231 | CFList bufResult; |
---|
| 232 | sqrf.removeFirst(); |
---|
| 233 | CFListIterator i; |
---|
| 234 | for (CFFListIterator iter= sqrf; iter.hasItem(); iter++) |
---|
[806c18] | 235 | { |
---|
[8baf483] | 236 | bufResult= multiFactorize (iter.getItem().factor(), info); |
---|
| 237 | for (i= bufResult; i.hasItem(); i++) |
---|
| 238 | result.append (CFFactor (i.getItem(), iter.getItem().exp())); |
---|
[7bf145] | 239 | } |
---|
| 240 | result.insert (CFFactor (LcF, 1)); |
---|
| 241 | return result; |
---|
| 242 | } |
---|
| 243 | |
---|
| 244 | /// factorize a multivariate polynomial over GF |
---|
| 245 | /// |
---|
[806c18] | 246 | /// @return @a GFFactorize returns a list of monic factors with |
---|
| 247 | /// multiplicity, the first element is the leading coefficient. |
---|
[7bf145] | 248 | /// @sa FpFactorize(), FqFactorize() |
---|
| 249 | inline |
---|
[f9b796e] | 250 | CFFList GFFactorize (const CanonicalForm& G, ///< [in] a multivariate poly |
---|
| 251 | bool substCheck= true ///< [in] enables substitute check |
---|
[806c18] | 252 | ) |
---|
[7bf145] | 253 | { |
---|
[806c18] | 254 | ASSERT (CFFactory::gettype() == GaloisFieldDomain, |
---|
[7bf145] | 255 | "GF as base field expected"); |
---|
[f9b796e] | 256 | if (getNumVars (G) == 2) |
---|
| 257 | return GFBiFactorize (G, substCheck); |
---|
| 258 | |
---|
| 259 | CanonicalForm F= G; |
---|
| 260 | if (substCheck) |
---|
| 261 | { |
---|
| 262 | bool foundOne= false; |
---|
| 263 | int * substDegree= new int [F.level()]; |
---|
| 264 | for (int i= 1; i <= F.level(); i++) |
---|
| 265 | { |
---|
| 266 | if (degree (F, i) > 0) |
---|
| 267 | { |
---|
| 268 | substDegree[i-1]= substituteCheck (F, Variable (i)); |
---|
| 269 | if (substDegree [i-1] > 1) |
---|
| 270 | { |
---|
| 271 | foundOne= true; |
---|
| 272 | subst (F, F, substDegree[i-1], Variable (i)); |
---|
| 273 | } |
---|
| 274 | } |
---|
| 275 | else |
---|
| 276 | substDegree[i-1]= -1; |
---|
| 277 | } |
---|
| 278 | if (foundOne) |
---|
| 279 | { |
---|
| 280 | CFFList result= GFFactorize (F, false); |
---|
| 281 | CFFList newResult, tmp; |
---|
| 282 | CanonicalForm tmp2; |
---|
| 283 | newResult.insert (result.getFirst()); |
---|
| 284 | result.removeFirst(); |
---|
| 285 | for (CFFListIterator i= result; i.hasItem(); i++) |
---|
| 286 | { |
---|
| 287 | tmp2= i.getItem().factor(); |
---|
| 288 | for (int j= 1; j <= G.level(); j++) |
---|
| 289 | { |
---|
| 290 | if (substDegree[j-1] > 1) |
---|
| 291 | tmp2= reverseSubst (tmp2, substDegree[j-1], Variable (j)); |
---|
| 292 | } |
---|
| 293 | tmp= GFFactorize (tmp2, false); |
---|
| 294 | tmp.removeFirst(); |
---|
| 295 | for (CFFListIterator j= tmp; j.hasItem(); j++) |
---|
| 296 | newResult.append (CFFactor (j.getItem().factor(), |
---|
| 297 | j.getItem().exp()*i.getItem().exp())); |
---|
| 298 | } |
---|
| 299 | delete [] substDegree; |
---|
| 300 | return newResult; |
---|
| 301 | } |
---|
| 302 | delete [] substDegree; |
---|
| 303 | } |
---|
| 304 | |
---|
[7bf145] | 305 | Variable a= Variable (1); |
---|
[806c18] | 306 | ExtensionInfo info= ExtensionInfo (getGFDegree(), gf_name, false); |
---|
[7bf145] | 307 | CanonicalForm LcF= Lc (F); |
---|
[8baf483] | 308 | CFFList sqrf= GFSqrf (F, false); |
---|
| 309 | CFFList result; |
---|
| 310 | CFList bufResult; |
---|
| 311 | sqrf.removeFirst(); |
---|
| 312 | CFListIterator i; |
---|
| 313 | for (CFFListIterator iter= sqrf; iter.hasItem(); iter++) |
---|
[7bf145] | 314 | { |
---|
[8baf483] | 315 | bufResult= multiFactorize (iter.getItem().factor(), info); |
---|
| 316 | for (i= bufResult; i.hasItem(); i++) |
---|
| 317 | result.append (CFFactor (i.getItem(), iter.getItem().exp())); |
---|
[7bf145] | 318 | } |
---|
| 319 | result.insert (CFFactor (LcF, 1)); |
---|
| 320 | return result; |
---|
| 321 | } |
---|
| 322 | |
---|
[d990001] | 323 | #endif |
---|
| 324 | |
---|
[806c18] | 325 | /// Naive factor recombination for multivariate factorization over an extension |
---|
| 326 | /// of the initial field. No precomputed is used to exclude combinations. |
---|
[7bf145] | 327 | /// |
---|
| 328 | /// @return @a extFactorRecombination returns a list of factors of @a F, whose |
---|
| 329 | /// shift to zero is reversed. |
---|
[806c18] | 330 | /// @sa factorRecombination() |
---|
| 331 | CFList |
---|
[7bf145] | 332 | extFactorRecombination ( |
---|
| 333 | const CFList& factors, ///< [in] list of lifted factors |
---|
[806c18] | 334 | ///< that are monic wrt Variable (1) |
---|
[7bf145] | 335 | const CanonicalForm& F, ///< [in] poly to be factored |
---|
| 336 | const CFList& M, ///< [in] a list of powers of |
---|
[806c18] | 337 | ///< Variables |
---|
| 338 | const ExtensionInfo& info, ///< [in] info about extension |
---|
[7bf145] | 339 | const CFList& evaluation ///< [in] evaluation point |
---|
| 340 | ); |
---|
| 341 | |
---|
| 342 | /// Naive factor recombination for multivariate factorization. |
---|
| 343 | /// No precomputed is used to exclude combinations. |
---|
| 344 | /// |
---|
[806c18] | 345 | /// @return @a factorRecombination returns a list of factors of @a F |
---|
| 346 | /// @sa extFactorRecombination() |
---|
| 347 | CFList |
---|
[7bf145] | 348 | factorRecombination (const CanonicalForm& F,///< [in] poly to be factored |
---|
| 349 | const CFList& factors, ///< [in] list of lifted factors |
---|
| 350 | ///< that are monic wrt Variable (1) |
---|
| 351 | const CFList& M ///< [in] a list of powers of |
---|
| 352 | ///< Variables |
---|
| 353 | ); |
---|
| 354 | |
---|
[91788c0] | 355 | /// recombination of bivariate factors @a factors1 s. t. the result evaluated |
---|
| 356 | /// at @a evalPoint coincides with @a factors2 |
---|
| 357 | CFList |
---|
| 358 | recombination (const CFList& factors1, ///<[in] list of bivariate factors |
---|
| 359 | const CFList& factors2, ///<[in] list univariate factors |
---|
| 360 | int s, ///<[in] algorithm starts checking |
---|
| 361 | ///< subsets of size s |
---|
| 362 | int thres, ///<[in] threshold for the size of |
---|
| 363 | ///< subsets which are checked |
---|
| 364 | const CanonicalForm& evalPoint,///<[in] evaluation point |
---|
| 365 | const Variable& x ///<[in] second variable of |
---|
| 366 | ///< bivariate factors |
---|
| 367 | ); |
---|
| 368 | |
---|
[7bf145] | 369 | /// Lift bound adaption. Essentially an early factor detection but only the lift |
---|
| 370 | /// bound is adapted. |
---|
| 371 | /// |
---|
| 372 | /// @return @a liftBoundAdaption returns an adapted lift bound. |
---|
[806c18] | 373 | /// @sa earlyFactorDetect(), earlyFactorDetection() |
---|
[7bf145] | 374 | int |
---|
| 375 | liftBoundAdaption (const CanonicalForm& F, ///< [in] a poly |
---|
[806c18] | 376 | const CFList& factors, ///< [in] list of list of lifted |
---|
| 377 | ///< factors that are monic wrt |
---|
[7bf145] | 378 | ///< Variable (1) |
---|
| 379 | bool& success, ///< [in,out] indicates that no |
---|
| 380 | ///< further lifting is necessary |
---|
| 381 | const int deg, ///< [in] stage of Hensel lifting |
---|
| 382 | const CFList& MOD, ///< [in] a list of powers of |
---|
| 383 | ///< Variables |
---|
| 384 | const int bound ///< [in] initial lift bound |
---|
| 385 | ); |
---|
| 386 | |
---|
| 387 | /// Lift bound adaption over an extension of the initial field. Essentially an |
---|
| 388 | ///early factor detection but only the lift bound is adapted. |
---|
| 389 | /// |
---|
| 390 | /// @return @a liftBoundAdaption returns an adapted lift bound. |
---|
[806c18] | 391 | /// @sa earlyFactorDetect(), earlyFactorDetection() |
---|
| 392 | int |
---|
[7bf145] | 393 | extLiftBoundAdaption ( |
---|
[806c18] | 394 | const CanonicalForm& F, ///< [in] a poly |
---|
| 395 | const CFList& factors, ///< [in] list of list of lifted |
---|
| 396 | ///< factors that are monic wrt |
---|
| 397 | bool& success, ///< [in,out] indicates that no further |
---|
[7bf145] | 398 | ///< lifting is necessary |
---|
[806c18] | 399 | const ExtensionInfo& info, ///< [in] info about extension |
---|
| 400 | const CFList& eval, ///< [in] evaluation point |
---|
| 401 | const int deg, ///< [in] stage of Hensel lifting |
---|
| 402 | const CFList& MOD, ///< [in] a list of powers of |
---|
| 403 | ///< Variables |
---|
| 404 | const int bound ///< [in] initial lift bound |
---|
[7bf145] | 405 | ); |
---|
| 406 | |
---|
| 407 | /// detects factors of @a F at stage @a deg of Hensel lifting. |
---|
[806c18] | 408 | /// No combinations of more than one factor are tested. Lift bound is adapted. |
---|
| 409 | /// |
---|
| 410 | /// @return @a earlyFactorDetect returns a list of factors of F (possibly |
---|
[7bf145] | 411 | /// incomplete), in case of success. Otherwise an empty list. |
---|
| 412 | /// @sa factorRecombination(), extEarlyFactorDetect() |
---|
[806c18] | 413 | CFList |
---|
[7bf145] | 414 | earlyFactorDetect ( |
---|
[806c18] | 415 | CanonicalForm& F, ///< [in,out] poly to be factored, |
---|
[7bf145] | 416 | ///< returns poly divided by detected |
---|
| 417 | ///< factors in case of success |
---|
[806c18] | 418 | CFList& factors, ///< [in,out] list of factors lifted up |
---|
[7bf145] | 419 | ///< to @a deg, returns a list of factors |
---|
| 420 | ///< without detected factors |
---|
[806c18] | 421 | int& adaptedLiftBound, ///< [in,out] adapted lift bound |
---|
| 422 | bool& success, ///< [in,out] indicating success |
---|
| 423 | const int deg, ///< [in] stage of Hensel lifting |
---|
| 424 | const CFList& MOD, ///< [in] a list of powers of |
---|
[7bf145] | 425 | ///< Variables |
---|
[806c18] | 426 | const int bound ///< [in] initial lift bound |
---|
[7bf145] | 427 | ); |
---|
| 428 | |
---|
| 429 | /// detects factors of @a F at stage @a deg of Hensel lifting. |
---|
[806c18] | 430 | /// No combinations of more than one factor are tested. Lift bound is adapted. |
---|
| 431 | /// |
---|
| 432 | /// @return @a extEarlyFactorDetect returns a list of factors of F (possibly |
---|
[7bf145] | 433 | /// incomplete), whose shift to zero is reversed, in case of success. |
---|
[806c18] | 434 | /// Otherwise an empty list. |
---|
[7bf145] | 435 | /// @sa factorRecombination(), earlyFactorDetection() |
---|
[806c18] | 436 | CFList |
---|
[7bf145] | 437 | extEarlyFactorDetect ( |
---|
[806c18] | 438 | CanonicalForm& F, ///< [in,out] poly to be factored, |
---|
[7bf145] | 439 | ///< returns poly divided by detected |
---|
| 440 | ///< factors in case of success |
---|
[806c18] | 441 | CFList& factors, ///< [in,out] list of factors lifted up |
---|
[7bf145] | 442 | ///< to @a deg, returns a list of factors |
---|
| 443 | ///< without detected factors |
---|
[806c18] | 444 | int& adaptedLiftBound, ///< [in,out] adapted lift bound |
---|
| 445 | bool& success, ///< [in,out] indicating succes |
---|
| 446 | const ExtensionInfo& info, ///< [in] info about extension |
---|
| 447 | const CFList& eval, ///< [in] evaluation point |
---|
| 448 | const int deg, ///< [in] stage of Hensel lifting |
---|
| 449 | const CFList& MOD, ///< [in] a list of powers of Variables |
---|
| 450 | const int bound ///< [in] initial lift bound |
---|
[7bf145] | 451 | ); |
---|
| 452 | |
---|
[806c18] | 453 | /// evaluation point search for multivariate factorization, |
---|
[7bf145] | 454 | /// looks for a (F.level() - 1)-tuple such that the resulting univariate |
---|
[8c1a84] | 455 | /// polynomial has main variable Variable (1), is squarefree and its degree |
---|
[806c18] | 456 | /// coincides with degree(F) and the bivariate one is primitive wrt. |
---|
[8c1a84] | 457 | /// Variable(1), and successively evaluated polynomials have the same degree in |
---|
| 458 | /// their main variable as F has, fails if there are no valid evaluation points, |
---|
| 459 | /// eval contains the intermediate evaluated polynomials. |
---|
[7bf145] | 460 | /// |
---|
| 461 | /// @return @a evalPoints returns an evaluation point, which is valid if and |
---|
[806c18] | 462 | /// only if fail == false. |
---|
| 463 | CFList |
---|
| 464 | evalPoints (const CanonicalForm& F, ///< [in] a compressed poly |
---|
[7bf145] | 465 | CFList & eval, ///< [in,out] an empty list, returns @a F |
---|
| 466 | ///< successive evaluated |
---|
| 467 | const Variable& alpha, ///< [in] algebraic variable |
---|
| 468 | CFList& list, ///< [in,out] a list of points already |
---|
| 469 | ///< considered, a point is encoded as a |
---|
| 470 | ///< poly of degree F.level()-1 in |
---|
[806c18] | 471 | ///< Variable(1) |
---|
[7bf145] | 472 | const bool& GF, ///< [in] GF? |
---|
| 473 | bool& fail ///< [in,out] indicates failure |
---|
| 474 | ); |
---|
| 475 | |
---|
[806c18] | 476 | /// hensel Lifting and early factor detection |
---|
[7bf145] | 477 | /// |
---|
[806c18] | 478 | /// @return @a henselLiftAndEarly returns monic (wrt Variable (1)) lifted |
---|
[7bf145] | 479 | /// factors without factors which have been detected at an early stage |
---|
| 480 | /// of Hensel lifting |
---|
| 481 | /// @sa earlyFactorDetectn(), extEarlyFactorDetect() |
---|
| 482 | CFList |
---|
| 483 | henselLiftAndEarly ( |
---|
[806c18] | 484 | CanonicalForm& A, ///< [in,out] poly to be factored, |
---|
[7bf145] | 485 | ///< returns poly divided by detected |
---|
[806c18] | 486 | ///< factors, in case of success |
---|
| 487 | CFList& MOD, ///< [in,out] a list of powers of |
---|
[7bf145] | 488 | ///< Variables |
---|
[806c18] | 489 | int*& liftBounds, ///< [in,out] initial lift bounds, returns |
---|
[7bf145] | 490 | ///< adapted lift bounds |
---|
[806c18] | 491 | bool& earlySuccess, ///< [in,out] indicating success |
---|
| 492 | CFList& earlyFactors, ///< [in,out] early factors |
---|
| 493 | const CFList& Aeval, ///< [in] @a A successively evaluated at |
---|
[7bf145] | 494 | ///< elements of @a evaluation |
---|
[806c18] | 495 | const CFList& biFactors, ///< [in] bivariate factors |
---|
| 496 | const CFList& evaluation, ///< [in] evaluation point |
---|
| 497 | const ExtensionInfo& info ///< [in] info about extension |
---|
[7bf145] | 498 | ); |
---|
| 499 | |
---|
| 500 | /// Factorization over an extension of initial field |
---|
| 501 | /// |
---|
| 502 | /// @return @a extFactorize returns factorization of F over initial field |
---|
| 503 | /// @sa extBiFactorize(), multiFactorize() |
---|
[806c18] | 504 | CFList |
---|
| 505 | extFactorize (const CanonicalForm& F, ///< [in] poly to be factored |
---|
| 506 | const ExtensionInfo& info ///< [in] info about extension |
---|
| 507 | ); |
---|
[7bf145] | 508 | |
---|
[8c1a84] | 509 | /// compute the LCM of the contents of @a A wrt to each variable occuring in @a |
---|
| 510 | /// A. |
---|
| 511 | /// |
---|
| 512 | /// @return @a lcmContent returns the LCM of the contents of @a A wrt to each |
---|
| 513 | /// variable occuring in @a A. |
---|
| 514 | CanonicalForm |
---|
| 515 | lcmContent (const CanonicalForm& A, ///< [in] a compressed multivariate poly |
---|
| 516 | CFList& contentAi ///< [in,out] an empty list, returns a list |
---|
| 517 | ///< of the contents of @a A wrt to each |
---|
| 518 | ///< variable occuring in @a A starting from |
---|
| 519 | ///< @a A.mvar(). |
---|
| 520 | ); |
---|
| 521 | |
---|
| 522 | /// compress a polynomial s.t. \f$ deg_{x_{i}} (F) >= deg_{x_{i+1}} (F) \f$ and |
---|
| 523 | /// no gaps between the variables occur |
---|
| 524 | /// |
---|
| 525 | /// @return a compressed poly with the above properties |
---|
| 526 | CanonicalForm myCompress (const CanonicalForm& F, ///< [in] a poly |
---|
| 527 | CFMap& N ///< [in,out] a map to |
---|
| 528 | ///< decompress |
---|
| 529 | ); |
---|
| 530 | |
---|
| 531 | /// evaluate a poly A with main variable at level 1 at an evaluation point in |
---|
| 532 | /// K^(n-1) wrt different second variables. If this evaluation is valid (see |
---|
| 533 | /// evalPoints) then Aeval contains A successively evaluated at this point, |
---|
| 534 | /// otherwise this entry is empty |
---|
| 535 | void |
---|
| 536 | evaluationWRTDifferentSecondVars ( |
---|
| 537 | CFList*& Aeval, ///<[in,out] an array of length n-2 |
---|
| 538 | ///< if variable at level i > 2 |
---|
| 539 | ///< admits a valid evaluation |
---|
| 540 | ///< this entry contains A |
---|
| 541 | ///< successively evaluated at this |
---|
| 542 | ///< point otherwise an empty list |
---|
| 543 | const CFList& evaluation,///<[in] a valid evaluation point |
---|
| 544 | ///< for main variable at level 1 |
---|
| 545 | ///< and second variable at level 2 |
---|
| 546 | const CanonicalForm& A ///<[in] some poly |
---|
| 547 | ); |
---|
| 548 | |
---|
| 549 | /// evaluate F successively n-2 at 0 |
---|
| 550 | /// |
---|
| 551 | /// @return returns a list of successive evaluations of F, ending with F |
---|
| 552 | CFList evaluateAtZero (const CanonicalForm& F ///< [in] some poly |
---|
| 553 | ); |
---|
| 554 | |
---|
| 555 | /// divides factors by their content wrt. Variable(1) and checks if these polys |
---|
| 556 | /// divide F |
---|
| 557 | /// |
---|
| 558 | /// @return returns factors of F |
---|
| 559 | CFList recoverFactors (const CanonicalForm& F, ///< [in] some poly F |
---|
| 560 | const CFList& factors ///< [in] some list of |
---|
| 561 | ///< factor candidates |
---|
| 562 | ); |
---|
| 563 | |
---|
[c79a9d] | 564 | /// divides factors shifted by evaluation by their content wrt. Variable(1) and |
---|
| 565 | /// checks if these polys divide F |
---|
| 566 | /// |
---|
| 567 | /// @return returns factors of F |
---|
| 568 | CFList recoverFactors (const CanonicalForm& F, ///< [in] some poly F |
---|
| 569 | const CFList& factors, ///< [in] some list of |
---|
| 570 | ///< factor candidates |
---|
[8267b8] | 571 | const CFList& evaluation ///< [in] evaluation point |
---|
| 572 | ); |
---|
| 573 | |
---|
| 574 | /// checks if factors divide F, if so F is divided by this factor and the factor |
---|
| 575 | /// is divided by its content wrt. Variable(1) and the entry in index at the |
---|
| 576 | /// position of the factor is set to 1, otherwise the entry in index is set to 0 |
---|
| 577 | /// |
---|
| 578 | /// @return returns factors of F |
---|
| 579 | CFList recoverFactors (CanonicalForm& F, ///< [in,out] some poly F |
---|
| 580 | const CFList& factors,///< [in] some list of |
---|
| 581 | ///< factor candidates |
---|
| 582 | int* index ///< [in] position of real factors |
---|
[c79a9d] | 583 | ); |
---|
| 584 | |
---|
[8c1a84] | 585 | /// refine a bivariate factorization of A with l factors to one with |
---|
| 586 | /// minFactorsLength |
---|
| 587 | void |
---|
| 588 | refineBiFactors (const CanonicalForm& A, ///< [in] some poly |
---|
| 589 | CFList& biFactors, ///< [in,out] list of bivariate to be |
---|
| 590 | ///< refined, returns refined factors |
---|
| 591 | CFList* const& factors, ///< [in] list of bivariate |
---|
| 592 | ///< factorizations of A wrt different |
---|
| 593 | ///< second variables |
---|
| 594 | const CFList& evaluation,///< [in] the evaluation point |
---|
| 595 | int minFactorsLength ///< [in] the minimal number of factors |
---|
| 596 | ); |
---|
| 597 | |
---|
| 598 | /// plug in evalPoint for y in a list of polys |
---|
| 599 | /// |
---|
| 600 | /// @return returns a list of the evaluated polys, these evaluated polys are |
---|
| 601 | /// made monic |
---|
| 602 | CFList |
---|
| 603 | buildUniFactors (const CFList& biFactors, ///< [in] a list of polys |
---|
| 604 | const CanonicalForm& evalPoint,///< [in] some evaluation point |
---|
| 605 | const Variable& y ///< [in] some variable |
---|
| 606 | ); |
---|
| 607 | |
---|
[772056] | 608 | |
---|
| 609 | /// sort bivariate factors in Aeval such that their corresponding univariate |
---|
| 610 | /// factors coincide with uniFactors |
---|
| 611 | void sortByUniFactors (CFList*& Aeval, ///< [in,out] array of bivariate |
---|
| 612 | ///< factors |
---|
| 613 | int AevalLength, ///< [in] length of Aeval |
---|
| 614 | const CFList& uniFactors,///< [in] univariate factors |
---|
| 615 | const CFList& evaluation ///< [in] evaluation point |
---|
| 616 | ); |
---|
| 617 | |
---|
[8c1a84] | 618 | /// extract leading coefficients wrt Variable(1) from bivariate factors obtained |
---|
| 619 | /// from factorizations of A wrt different second variables |
---|
| 620 | void |
---|
| 621 | getLeadingCoeffs (const CanonicalForm& A, ///< [in] some poly |
---|
| 622 | CFList*& Aeval, ///< [in,out] array of bivariate |
---|
| 623 | ///< factors, returns the leading |
---|
| 624 | ///< coefficients of these factors |
---|
| 625 | const CFList& uniFactors,///< [in] univariate factors of A |
---|
| 626 | const CFList& evaluation ///< [in] evaluation point |
---|
| 627 | ); |
---|
| 628 | |
---|
| 629 | /// normalize precomputed leading coefficients such that leading coefficients |
---|
[eefc3a] | 630 | /// evaluated at @a evaluation in K^(n-2) equal the leading coeffs wrt |
---|
| 631 | /// Variable(1) of bivariate factors |
---|
[8c1a84] | 632 | void |
---|
| 633 | prepareLeadingCoeffs (CFList*& LCs, ///<[in,out] |
---|
| 634 | int n, ///<[in] level of poly to be |
---|
| 635 | ///< factored |
---|
| 636 | const CFList& leadingCoeffs,///<[in] precomputed leading |
---|
| 637 | ///< coeffs |
---|
[eefc3a] | 638 | const CFList& biFactors, ///<[in] bivariate factors |
---|
| 639 | const CFList& evaluation ///<[in] evaluation point |
---|
[8c1a84] | 640 | ); |
---|
| 641 | |
---|
| 642 | /// obtain factors of F by reconstructing their leading coeffs |
---|
| 643 | /// |
---|
| 644 | /// @return returns the reconstructed factors |
---|
| 645 | /// @sa factorRecombination() |
---|
| 646 | CFList |
---|
| 647 | leadingCoeffReconstruction (const CanonicalForm& F,///<[in] poly to be factored |
---|
| 648 | const CFList& factors, ///<[in] factors of f monic |
---|
| 649 | ///< wrt Variable (1) |
---|
| 650 | const CFList& M ///<[in] a list of powers of |
---|
| 651 | ///< Variables |
---|
| 652 | ); |
---|
| 653 | |
---|
| 654 | /// distribute content |
---|
| 655 | /// |
---|
| 656 | /// @return returns a list result of polys such that prod (result)= prod (L) |
---|
| 657 | /// but the first entry of L may be (partially) factorized and these factors |
---|
| 658 | /// are distributed onto other entries in L |
---|
| 659 | CFList |
---|
| 660 | distributeContent ( |
---|
| 661 | const CFList& L, ///<[in] list of polys, first |
---|
| 662 | ///< entry the content to be |
---|
| 663 | ///< distributed |
---|
| 664 | const CFList* differentSecondVarFactors,///<[in] factorization wrt |
---|
| 665 | ///< different second vars |
---|
| 666 | int length ///<[in] length of |
---|
| 667 | ///<differentSecondVarFactors |
---|
| 668 | ); |
---|
| 669 | |
---|
| 670 | /// gcd free basis of two lists of factors |
---|
| 671 | void |
---|
| 672 | gcdFreeBasis (CFFList& factors1, ///< [in,out] list of factors, returns gcd free |
---|
| 673 | ///< factors |
---|
| 674 | CFFList& factors2 ///< [in,out] list of factors, returns gcd free |
---|
| 675 | ///< factors |
---|
| 676 | ); |
---|
| 677 | |
---|
[eefc3a] | 678 | /// evaluate @a F at @a evaluation |
---|
| 679 | /// |
---|
| 680 | /// @return @a evaluateAtEval returns a list containing the successive |
---|
| 681 | /// evaluations of @a F, last entry is @a F again |
---|
| 682 | CFList |
---|
| 683 | evaluateAtEval (const CanonicalForm& F, ///<[in] some poly |
---|
| 684 | const CFArray& evaluation ///<[in] some evaluation point |
---|
| 685 | ); |
---|
| 686 | |
---|
| 687 | /// evaluate @a F at @a evaluation |
---|
| 688 | /// |
---|
| 689 | /// @return @a evaluateAtEval returns a list containing the successive |
---|
| 690 | /// evaluations of @a F starting at level @a l, last entry is @a F again |
---|
| 691 | CFList |
---|
| 692 | evaluateAtEval (const CanonicalForm& F, ///<[in] some poly |
---|
| 693 | const CFList& evaluation,///<[in] some evaluation point |
---|
| 694 | int l ///<[in] level to start at |
---|
| 695 | ); |
---|
| 696 | |
---|
[7bf145] | 697 | #endif |
---|
| 698 | /* FAC_FQ_FACTORIZE_H */ |
---|
| 699 | |
---|