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