[24b338] | 1 | /*****************************************************************************\ |
---|
[806c18] | 2 | * Computer Algebra System SINGULAR |
---|
[24b338] | 3 | \*****************************************************************************/ |
---|
| 4 | /** @file facFqSquarefree.h |
---|
[806c18] | 5 | * |
---|
[24b338] | 6 | * This file provides functions for squarefrees factorizing over |
---|
[806c18] | 7 | * \f$ F_{p} \f$ , \f$ F_{p}(\alpha ) \f$ or GF. |
---|
[24b338] | 8 | * |
---|
| 9 | * @author Martin Lee |
---|
| 10 | * |
---|
| 11 | * @internal @version \$Id$ |
---|
| 12 | * |
---|
| 13 | **/ |
---|
| 14 | /*****************************************************************************/ |
---|
| 15 | |
---|
| 16 | #ifndef FAC_FQ_SQUAREFREE_H |
---|
| 17 | #define FAC_FQ_SQUAREFREE_H |
---|
| 18 | |
---|
[650f2d8] | 19 | #include "cf_assert.h" |
---|
[eacb7aa] | 20 | #include "cf_factory.h" |
---|
[6caa2a6] | 21 | #include "fac_sqrfree.h" |
---|
[24b338] | 22 | |
---|
| 23 | /// squarefree factorization over a finite field |
---|
| 24 | /// @a return a list of squarefree factors with multiplicity |
---|
[806c18] | 25 | CFFList |
---|
| 26 | squarefreeFactorization |
---|
[24b338] | 27 | (const CanonicalForm & F, ///<[in] a poly |
---|
[806c18] | 28 | const Variable & alpha ///<[in] either an algebraic variable, |
---|
[24b338] | 29 | ///< i.e. we are over some F_p (alpha) |
---|
| 30 | ///< or a variable of level 1, i.e. |
---|
[806c18] | 31 | ///< we are F_p or GF |
---|
[24b338] | 32 | ); |
---|
| 33 | |
---|
| 34 | /// squarefree factorization over \f$ F_{p} \f$. |
---|
| 35 | /// If input is not monic, the leading coefficient is dropped |
---|
| 36 | /// |
---|
| 37 | /// @return a list of squarefree factors with multiplicity |
---|
| 38 | inline |
---|
[6caa2a6] | 39 | CFFList FpSqrf (const CanonicalForm& F, ///< [in] a poly |
---|
| 40 | bool sort= true ///< [in] sort factors by exponent? |
---|
[806c18] | 41 | ) |
---|
[24b338] | 42 | { |
---|
| 43 | Variable a= 1; |
---|
[6caa2a6] | 44 | int n= F.level(); |
---|
| 45 | CanonicalForm cont, bufF= F; |
---|
| 46 | CFFList bufResult; |
---|
| 47 | |
---|
| 48 | CFFList result; |
---|
| 49 | for (int i= n; i >= 1; i++) |
---|
| 50 | { |
---|
| 51 | cont= content (bufF, i); |
---|
| 52 | bufResult= squarefreeFactorization (cont, a); |
---|
| 53 | if (bufResult.getFirst().factor().inCoeffDomain()) |
---|
| 54 | bufResult.removeFirst(); |
---|
| 55 | result= Union (result, bufResult); |
---|
| 56 | bufF /= cont; |
---|
| 57 | if (bufF.inCoeffDomain()) |
---|
| 58 | break; |
---|
| 59 | } |
---|
| 60 | if (!bufF.inCoeffDomain()) |
---|
| 61 | { |
---|
| 62 | bufResult= squarefreeFactorization (bufF, a); |
---|
| 63 | if (bufResult.getFirst().factor().inCoeffDomain()) |
---|
| 64 | bufResult.removeFirst(); |
---|
| 65 | result= Union (result, bufResult); |
---|
| 66 | } |
---|
| 67 | if (sort) |
---|
| 68 | result= sortCFFList (result); |
---|
[24b338] | 69 | result.insert (CFFactor (Lc(F), 1)); |
---|
| 70 | return result; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | /// squarefree factorization over \f$ F_{p}(\alpha ) \f$. |
---|
| 74 | /// If input is not monic, the leading coefficient is dropped |
---|
| 75 | /// |
---|
| 76 | /// @return a list of squarefree factors with multiplicity |
---|
| 77 | inline |
---|
| 78 | CFFList FqSqrf (const CanonicalForm& F, ///< [in] a poly |
---|
[6caa2a6] | 79 | const Variable& alpha, ///< [in] algebraic variable |
---|
| 80 | bool sort= true ///< [in] sort factors by exponent? |
---|
[24b338] | 81 | ) |
---|
| 82 | { |
---|
[6caa2a6] | 83 | int n= F.level(); |
---|
| 84 | CanonicalForm cont, bufF= F; |
---|
| 85 | CFFList bufResult; |
---|
| 86 | |
---|
| 87 | CFFList result; |
---|
| 88 | for (int i= n; i >= 1; i++) |
---|
| 89 | { |
---|
| 90 | cont= content (bufF, i); |
---|
| 91 | bufResult= squarefreeFactorization (cont, alpha); |
---|
| 92 | if (bufResult.getFirst().factor().inCoeffDomain()) |
---|
| 93 | bufResult.removeFirst(); |
---|
| 94 | result= Union (result, bufResult); |
---|
| 95 | bufF /= cont; |
---|
| 96 | if (bufF.inCoeffDomain()) |
---|
| 97 | break; |
---|
| 98 | } |
---|
| 99 | if (!bufF.inCoeffDomain()) |
---|
| 100 | { |
---|
| 101 | bufResult= squarefreeFactorization (bufF, alpha); |
---|
| 102 | if (bufResult.getFirst().factor().inCoeffDomain()) |
---|
| 103 | bufResult.removeFirst(); |
---|
| 104 | result= Union (result, bufResult); |
---|
| 105 | } |
---|
| 106 | if (sort) |
---|
| 107 | result= sortCFFList (result); |
---|
[24b338] | 108 | result.insert (CFFactor (Lc(F), 1)); |
---|
| 109 | return result; |
---|
[806c18] | 110 | } |
---|
[24b338] | 111 | |
---|
[806c18] | 112 | /// squarefree factorization over GF. |
---|
[24b338] | 113 | /// If input is not monic, the leading coefficient is dropped |
---|
| 114 | /// |
---|
| 115 | /// @return a list of squarefree factors with multiplicity |
---|
| 116 | inline |
---|
[6caa2a6] | 117 | CFFList GFSqrf (const CanonicalForm& F, ///< [in] a poly |
---|
| 118 | bool sort= true ///< [in] sort factors by exponent? |
---|
[806c18] | 119 | ) |
---|
[24b338] | 120 | { |
---|
[806c18] | 121 | ASSERT (CFFactory::gettype() == GaloisFieldDomain, |
---|
[24b338] | 122 | "GF as base field expected"); |
---|
[6caa2a6] | 123 | return FpSqrf (F, sort); |
---|
[24b338] | 124 | } |
---|
| 125 | |
---|
[806c18] | 126 | /// squarefree part of @a F/g, where g is the product of those squarefree |
---|
| 127 | /// factors whose multiplicity is 0 mod p, if @a F a pth power pthPower= F. |
---|
[24b338] | 128 | /// |
---|
[806c18] | 129 | /// @return @a sqrfPart returns 1, if F is a pthPower, else it returns the |
---|
| 130 | /// squarefree part of @a F/g, where g is the product of those |
---|
| 131 | /// squarefree factors whose multiplicity is 0 mod p |
---|
| 132 | CanonicalForm |
---|
| 133 | sqrfPart (const CanonicalForm& F, ///< [in] a poly |
---|
| 134 | CanonicalForm& pthPower, ///< [in,out] returns F is F is a pthPower |
---|
[24b338] | 135 | const Variable& alpha ///< [in] algebraic variable |
---|
| 136 | ); |
---|
| 137 | |
---|
| 138 | /// p^l-th root extraction, where l is maximal |
---|
| 139 | /// |
---|
| 140 | /// @return @a maxpthRoot returns a p^l-th root of @a F, where @a l is maximal |
---|
[806c18] | 141 | /// @sa pthRoot() |
---|
[24b338] | 142 | CanonicalForm |
---|
| 143 | maxpthRoot (const CanonicalForm & F, ///< [in] a poly which is a pth power |
---|
| 144 | const int & q, ///< [in] size of the field |
---|
| 145 | int& l ///< [in,out] @a l maximal, s.t. @a F is |
---|
[806c18] | 146 | ///< a p^l-th power |
---|
[24b338] | 147 | ); |
---|
| 148 | |
---|
| 149 | #endif |
---|
| 150 | /* FAC_FQ_SQUAREFREE_H */ |
---|
| 151 | |
---|