| 146 | #endif |
| 147 | |
| 148 | CFList AlgExtSqrfFactorize (const CanonicalForm& F, const Variable& alpha) |
| 149 | { |
| 150 | ASSERT (F.isUnivariate(), "univariate input expected"); |
| 151 | ASSERT (getCharacteristic() == 0, "characteristic 0 expected"); |
| 152 | |
| 153 | bool save_rat=!isOn (SW_RATIONAL); |
| 154 | On (SW_RATIONAL); |
| 155 | CanonicalForm f= F*bCommonDen (F); |
| 156 | Variable y= f.mvar(); |
| 157 | int shift= 0, k= 0, count= 0; |
| 158 | CanonicalForm norm, buf, factor, oldF; |
| 159 | CFFList normFactors; |
| 160 | bool save_sort= !isOn (SW_USE_NTL_SORT); |
| 161 | CFList factors, tmp, tmp2; |
| 162 | CFFListIterator i; |
| 163 | CFListIterator iter; |
| 164 | bool shiftBuf= false; |
| 165 | |
| 166 | tmp.append (f); |
| 167 | do |
| 168 | { |
| 169 | tmp2= CFList(); |
| 170 | for (iter= tmp; iter.hasItem(); iter++) |
| 171 | { |
| 172 | oldF= iter.getItem()*bCommonDen (iter.getItem()); |
| 173 | if (shift == 0) |
| 174 | f= oldF; |
| 175 | else |
| 176 | { |
| 177 | f= oldF (y - shift*alpha, y); |
| 178 | f *= bCommonDen (f); |
| 179 | } |
| 180 | TIMING_START (fac_alg_norm); |
| 181 | norm= Norm (f, alpha); |
| 182 | TIMING_END_AND_PRINT (fac_alg_norm, "time to compute sqrf norm: "); |
| 183 | ASSERT (degree (norm, alpha) <= 0, "wrong norm computed"); |
| 184 | |
| 185 | TIMING_START (fac_alg_factor_norm); |
| 186 | On (SW_USE_NTL_SORT); |
| 187 | normFactors= factorize (norm); |
| 188 | if (save_sort) |
| 189 | Off (SW_USE_NTL_SORT); |
| 190 | TIMING_END_AND_PRINT (fac_alg_factor_norm, "time to factor norm: "); |
| 191 | |
| 192 | if (normFactors.getFirst().factor().inCoeffDomain()) |
| 193 | normFactors.removeFirst(); |
| 194 | if (normFactors.length() < 2 && normFactors.getLast().exp() == 1) |
| 195 | { |
| 196 | factors.append (oldF); |
| 197 | continue; |
| 198 | } |
| 199 | |
| 200 | i= normFactors; |
| 201 | shiftBuf= false; |
| 202 | if (!(normFactors.length() == 2 && |
| 203 | degree (i.getItem().factor()) <= degree (f))) |
| 204 | { |
| 205 | TIMING_START (fac_alg_time_shift); |
no test coverage detected