[7bf145] | 1 | /*****************************************************************************\ |
---|
[806c18] | 2 | * Computer Algebra System SINGULAR |
---|
[7bf145] | 3 | \*****************************************************************************/ |
---|
| 4 | /** @file facFqFactorizeUtil.h |
---|
[806c18] | 5 | * |
---|
| 6 | * This file provides utility functions for multivariate factorization |
---|
[7bf145] | 7 | * |
---|
| 8 | * @author Martin Lee |
---|
| 9 | * |
---|
| 10 | **/ |
---|
| 11 | /*****************************************************************************/ |
---|
| 12 | |
---|
| 13 | #ifndef FAC_FQ_FACTORIZE_UTIL_H |
---|
| 14 | #define FAC_FQ_FACTORIZE_UTIL_H |
---|
| 15 | |
---|
[e4fe2b] | 16 | // #include "config.h" |
---|
[7bf145] | 17 | #include "canonicalform.h" |
---|
[19b3c7] | 18 | #include "cf_map.h" |
---|
[7bf145] | 19 | |
---|
| 20 | /// append @a factors2 to @a factors1 and decompress |
---|
| 21 | /// |
---|
[806c18] | 22 | static inline |
---|
[7bf145] | 23 | void decompressAppend (CFList& factors1, ///< [in,out] a list of polys, |
---|
| 24 | ///< returns @a factors2 appended |
---|
[806c18] | 25 | ///< to it and everything is |
---|
[7bf145] | 26 | ///< decompressed |
---|
| 27 | const CFList& factors2, ///< [in] a list of polys |
---|
| 28 | const CFMap& N ///< [in] a map |
---|
[d52c12] | 29 | ) |
---|
| 30 | { |
---|
[806c18] | 31 | for (CFListIterator i= factors1; i.hasItem(); i++) |
---|
[d52c12] | 32 | i.getItem()= N (i.getItem()); |
---|
| 33 | for (CFListIterator i= factors2; i.hasItem(); i++) |
---|
| 34 | factors1.append (N (i.getItem())); |
---|
| 35 | } |
---|
| 36 | |
---|
[7bf145] | 37 | |
---|
| 38 | /// swap elements in @a factors2 and append them to @a factors1 |
---|
[806c18] | 39 | /// |
---|
[7bf145] | 40 | void appendSwap (CFList& factors1, ///< [in,out] a list of polys, |
---|
[806c18] | 41 | ///< returns swapped elements of @a |
---|
[7bf145] | 42 | ///< factors2 appended to it |
---|
| 43 | const CFList& factors2, ///< [in] a list of polys |
---|
[806c18] | 44 | const int swapLevel1, ///< [in] level of variable to be |
---|
[7bf145] | 45 | ///< swapped with x, 0 if no swapping |
---|
[806c18] | 46 | const int swapLevel2, ///< [in] level of variable to be |
---|
[7bf145] | 47 | ///< swapped with x, 0 if no swapping |
---|
| 48 | const Variable& x ///< [in] a variable |
---|
| 49 | ); |
---|
| 50 | |
---|
| 51 | /// swap elements in @a factors |
---|
[806c18] | 52 | void swap (CFList& factors, ///< [in] a list of polys, returns swapped |
---|
[7bf145] | 53 | ///< elements of factors |
---|
[806c18] | 54 | const int swapLevel1, ///< [in] level of variable to be |
---|
[7bf145] | 55 | ///< swapped with x, 0 if no swapping |
---|
[806c18] | 56 | const int swapLevel2, ///< [in] level of variable to be |
---|
[7bf145] | 57 | ///< swapped with x, 0 if no swapping |
---|
| 58 | const Variable& x ///< [in] a variable |
---|
| 59 | ); |
---|
| 60 | |
---|
| 61 | /// swap elements of @a factors2, append them to @a factors1 and decompress |
---|
[806c18] | 62 | void appendSwapDecompress ( |
---|
[7bf145] | 63 | CFList& factors1, ///< [in,out] a list of polys, |
---|
[806c18] | 64 | ///< returns swapped elements of @a |
---|
| 65 | ///< factors2 appended to it and |
---|
[7bf145] | 66 | ///< everything is decompressed |
---|
| 67 | const CFList& factors2, ///< [in] a list of polys |
---|
| 68 | const CFMap& N, ///< [in] a map |
---|
[806c18] | 69 | const int swapLevel, ///< [in] level of variable to be |
---|
[7bf145] | 70 | ///< swapped with x, 0 if no swapping |
---|
| 71 | const Variable& x ///< [in] a variable |
---|
| 72 | ); |
---|
| 73 | |
---|
| 74 | /// swap elements of @a factors2, append them to @a factors1 and decompress |
---|
| 75 | void appendSwapDecompress ( |
---|
| 76 | CFList& factors1, ///< [in,out] a list of polys, |
---|
[806c18] | 77 | ///< returns swapped elements of @a |
---|
| 78 | ///< factors2 appended to it and |
---|
[7bf145] | 79 | ///< everything is decompressed |
---|
| 80 | const CFList& factors2, ///< [in] a list of polys |
---|
| 81 | const CFMap& N, ///< [in] a map |
---|
[806c18] | 82 | const int swapLevel1, ///< [in] level of variable to be |
---|
[7bf145] | 83 | ///< swapped with x, 0 if no swapping |
---|
[806c18] | 84 | const int swapLevel2, ///< [in] level of variable to be |
---|
[7bf145] | 85 | ///< swapped with x, 0 if no swapping |
---|
| 86 | const Variable& x ///< [in] a variable |
---|
[806c18] | 87 | ); |
---|
[7bf145] | 88 | |
---|
| 89 | |
---|
| 90 | /// compute lifting bounds |
---|
| 91 | /// |
---|
[806c18] | 92 | /// @return @a liftingBounds returns an array containing the lift bounds for A |
---|
| 93 | int* liftingBounds (const CanonicalForm& A, ///< [in] a compressed poly |
---|
| 94 | const int& bivarLiftBound ///< [in] lift bound for |
---|
[7bf145] | 95 | ///< @a biFactorizer() |
---|
| 96 | ); |
---|
| 97 | |
---|
| 98 | /// shift evaluation point to zero |
---|
[806c18] | 99 | /// @return @a shift2Zero returns @a F shifted by @a evaluation s.t. 0 is a |
---|
[7bf145] | 100 | /// valid evaluation point |
---|
[806c18] | 101 | /// @sa evalPoints(), reverseShift() |
---|
[7bf145] | 102 | CanonicalForm |
---|
| 103 | shift2Zero (const CanonicalForm& F, ///< [in] a compressed poly |
---|
| 104 | CFList& Feval, ///< [in,out] an empty list, returns |
---|
| 105 | ///< @a F successively evaluated |
---|
| 106 | ///< at 0 |
---|
[6deedd] | 107 | const CFList& evaluation,///< [in] a valid evaluation point |
---|
| 108 | int l= 2 ///< [in] level at which the evaluation |
---|
| 109 | ///< starts |
---|
[7bf145] | 110 | ); |
---|
| 111 | |
---|
| 112 | /// reverse shifting the evaluation point to zero |
---|
| 113 | /// |
---|
| 114 | /// @return @a reverseShift returns a poly whose shift to zero is reversed |
---|
| 115 | /// @sa shift2Zero(), evalPoints() |
---|
| 116 | CanonicalForm reverseShift (const CanonicalForm& F, ///< [in] a compressed poly |
---|
[6deedd] | 117 | const CFList& evaluation,///< [in] a valid |
---|
[7bf145] | 118 | ///< evaluation point |
---|
[6deedd] | 119 | int l= 2 ///< [in] level at which |
---|
| 120 | ///< the evaluation starts |
---|
[7bf145] | 121 | ); |
---|
| 122 | |
---|
[086f3e] | 123 | /// check if @a F consists of more than just the leading coeff wrt. Variable (1) |
---|
[79592ac] | 124 | /// |
---|
| 125 | /// @return as described above |
---|
| 126 | bool isOnlyLeadingCoeff (const CanonicalForm& F ///< [in] some poly |
---|
| 127 | ); |
---|
| 128 | |
---|
[8d2c11] | 129 | /// sort CFFList by the number variables in a factor |
---|
| 130 | CFFList sortCFFListByNumOfVars (CFFList & F ///< [in,out] a list of factors |
---|
| 131 | ); |
---|
| 132 | |
---|
[086f3e] | 133 | /// like getVars but each variable x occuring in @a F is raised to x^degree (F,x) |
---|
[8d2c11] | 134 | CanonicalForm myGetVars (const CanonicalForm& F ///< [in] a polynomial |
---|
| 135 | ); |
---|
| 136 | |
---|
[8336c9] | 137 | /// evaluate @a F at @a evaluation |
---|
| 138 | /// |
---|
[fea494] | 139 | /// @return @a evaluateAtEval returns a list containing the successive |
---|
[8336c9] | 140 | /// evaluations of @a F, last entry is @a F again |
---|
| 141 | CFList |
---|
| 142 | evaluateAtEval (const CanonicalForm& F, ///<[in] some poly |
---|
| 143 | const CFArray& evaluation ///<[in] some evaluation point |
---|
| 144 | ); |
---|
| 145 | |
---|
| 146 | /// evaluate @a F at @a evaluation |
---|
| 147 | /// |
---|
| 148 | /// @return @a evaluateAtEval returns a list containing the successive |
---|
| 149 | /// evaluations of @a F starting at level @a l, last entry is @a F again |
---|
| 150 | CFList |
---|
| 151 | evaluateAtEval (const CanonicalForm& F, ///<[in] some poly |
---|
| 152 | const CFList& evaluation,///<[in] some evaluation point |
---|
| 153 | int l ///<[in] level to start at |
---|
| 154 | ); |
---|
| 155 | |
---|
| 156 | /// evaluate F successively n-2 at 0 |
---|
| 157 | /// |
---|
| 158 | /// @return returns a list of successive evaluations of F, ending with F |
---|
| 159 | CFList evaluateAtZero (const CanonicalForm& F ///< [in] some poly |
---|
| 160 | ); |
---|
| 161 | |
---|
| 162 | /// divides factors by their content wrt. Variable(1) and checks if these polys |
---|
| 163 | /// divide F |
---|
| 164 | /// |
---|
| 165 | /// @return returns factors of F |
---|
| 166 | CFList recoverFactors (const CanonicalForm& F, ///< [in] some poly F |
---|
| 167 | const CFList& factors ///< [in] some list of |
---|
| 168 | ///< factor candidates |
---|
| 169 | ); |
---|
| 170 | |
---|
[fea494] | 171 | /// divides factors shifted by evaluation by their content wrt. Variable(1) and |
---|
[8336c9] | 172 | /// checks if these polys divide F |
---|
| 173 | /// |
---|
| 174 | /// @return returns factors of F |
---|
| 175 | CFList recoverFactors (const CanonicalForm& F, ///< [in] some poly F |
---|
| 176 | const CFList& factors, ///< [in] some list of |
---|
| 177 | ///< factor candidates |
---|
| 178 | const CFList& evaluation ///< [in] evaluation point |
---|
| 179 | ); |
---|
| 180 | |
---|
| 181 | /// checks if factors divide F, if so F is divided by this factor and the factor |
---|
| 182 | /// is divided by its content wrt. Variable(1) and the entry in index at the |
---|
| 183 | /// position of the factor is set to 1, otherwise the entry in index is set to 0 |
---|
| 184 | /// |
---|
| 185 | /// @return returns factors of F |
---|
| 186 | CFList recoverFactors (CanonicalForm& F, ///< [in,out] some poly F |
---|
| 187 | const CFList& factors,///< [in] some list of |
---|
| 188 | ///< factor candidates |
---|
| 189 | int* index ///< [in] position of real factors |
---|
| 190 | ); |
---|
| 191 | |
---|
[7bf145] | 192 | #endif |
---|
| 193 | /* FAC_FQ_FACTORIZE_UTIL_H */ |
---|
| 194 | |
---|