1 | /*****************************************************************************\ |
---|
2 | Â * Computer Algebra System SINGULAR |
---|
3 | \*****************************************************************************/ |
---|
4 | /** @file facFqBivar.cc |
---|
5 | Â * |
---|
6 | Â * This file provides functions for factorizing a bivariate polynomial over |
---|
7 | Â * \f$ F_{p} \f$ , \f$ F_{p}(\alpha ) \f$ or GF, based on "Modern Computer |
---|
8 | Â * Algebra, Chapter 15" by J. von zur Gathen & J. Gerhard and "Factoring |
---|
9 | Â * multivariate polynomials over a finite field" by L. Bernardin. |
---|
10 | Â * Factor Recombination is described in "Factoring polynomials over global |
---|
11 | Â * fields" by K. Belabas, M. van Hoeij, J. Klueners, A. Steel |
---|
12 | Â * |
---|
13 | Â * |
---|
14 | Â * @author Martin Lee |
---|
15 | Â * |
---|
16 | Â **/ |
---|
17 | /*****************************************************************************/ |
---|
18 | |
---|
19 | #include "config.h" |
---|
20 | |
---|
21 | #include "cf_assert.h" |
---|
22 | #include "debug.h" |
---|
23 | #include "timing.h" |
---|
24 | |
---|
25 | #include "canonicalform.h" |
---|
26 | #include "cf_defs.h" |
---|
27 | #include "cf_map_ext.h" |
---|
28 | #include "cf_random.h" |
---|
29 | #include "facHensel.h" |
---|
30 | #include "facMul.h" |
---|
31 | #include "cf_map.h" |
---|
32 | #include "cf_gcd_smallp.h" |
---|
33 | #include "facFqBivarUtil.h" |
---|
34 | #include "facFqBivar.h" |
---|
35 | #include "cfNewtonPolygon.h" |
---|
36 | #include "algext.h" |
---|
37 | |
---|
38 | #ifdef HAVE_NTL |
---|
39 | #include "NTLconvert.h" |
---|
40 | |
---|
41 | #ifdef HAVE_FLINT |
---|
42 | #include "FLINTconvert.h" |
---|
43 | #endif |
---|
44 | |
---|
45 | TIMING_DEFINE_PRINT(fac_fq_uni_factorizer) |
---|
46 | TIMING_DEFINE_PRINT(fac_fq_bi_hensel_lift) |
---|
47 | TIMING_DEFINE_PRINT(fac_fq_bi_factor_recombination) |
---|
48 | TIMING_DEFINE_PRINT(fac_fq_bi_evaluation) |
---|
49 | TIMING_DEFINE_PRINT(fac_fq_bi_shift_to_zero) |
---|
50 | |
---|
51 | CanonicalForm prodMod0 (const CFList& L, const CanonicalForm& M, const modpk& b) |
---|
52 | { |
---|
53 |  if (L.isEmpty()) |
---|
54 |   return 1; |
---|
55 |  else if (L.length() == 1) |
---|
56 |   return mod (L.getFirst()(0, 1) , M); |
---|
57 |  else if (L.length() == 2) |
---|
58 |   return mod (mulNTL (L.getFirst()(0, 1),L.getLast()(0, 1), b), M); |
---|
59 | Â else |
---|
60 | Â { |
---|
61 |   int l= L.length()/2; |
---|
62 | Â Â CFListIterator i=Â L; |
---|
63 |   CFList tmp1, tmp2; |
---|
64 |   CanonicalForm buf1, buf2; |
---|
65 |   for (int j= 1; j <= l; j++, i++) |
---|
66 | Â Â Â tmp1.append (i.getItem()); |
---|
67 |   tmp2= Difference (L, tmp1); |
---|
68 |   buf1= prodMod0 (tmp1, M, b); |
---|
69 |   buf2= prodMod0 (tmp2, M, b); |
---|
70 |   return mod (mulNTL (buf1,buf2, b), M); |
---|
71 | Â } |
---|
72 | } |
---|
73 | |
---|
74 | CanonicalForm evalPoint (const CanonicalForm& F, CanonicalForm & eval, |
---|
75 |              const Variable& alpha, CFList& list, const bool& GF, |
---|
76 | Â Â Â Â Â Â Â Â Â Â Â Â Â bool&Â fail) |
---|
77 | { |
---|
78 | Â fail=Â false; |
---|
79 | Â Variable x=Â Variable(2); |
---|
80 | Â Variable y=Â Variable(1); |
---|
81 | Â FFRandom genFF; |
---|
82 | Â GFRandom genGF; |
---|
83 |  CanonicalForm random, mipo; |
---|
84 |  double bound; |
---|
85 |  int p= getCharacteristic (); |
---|
86 |  if (alpha.level() != 1) |
---|
87 | Â { |
---|
88 | Â Â mipo=Â getMipo (alpha); |
---|
89 |   int d= degree (mipo); |
---|
90 |   bound= ipower (p, d); |
---|
91 | Â } |
---|
92 |  else if (GF) |
---|
93 | Â { |
---|
94 |   int d= getGFDegree(); |
---|
95 |   bound= ipower (p, d); |
---|
96 | Â } |
---|
97 | Â else |
---|
98 | Â Â bound=Â p; |
---|
99 | |
---|
100 | Â random=Â 0; |
---|
101 | Â do |
---|
102 | Â { |
---|
103 |   if (list.length() >= bound) |
---|
104 | Â Â { |
---|
105 | Â Â Â fail=Â true; |
---|
106 | Â Â Â break; |
---|
107 | Â Â } |
---|
108 |   if (list.isEmpty()) |
---|
109 | Â Â Â random=Â 0; |
---|
110 |   else if (GF) |
---|
111 | Â Â { |
---|
112 |    if (list.length() == 1) |
---|
113 | Â Â Â Â random=Â getGFGenerator(); |
---|
114 | Â Â Â else |
---|
115 | Â Â Â Â random=Â genGF.generate(); |
---|
116 | Â Â } |
---|
117 |   else if (list.length() < p || alpha.level() == 1) |
---|
118 | Â Â Â random=Â genFF.generate(); |
---|
119 |   else if (alpha != x && list.length() >= p) |
---|
120 | Â Â { |
---|
121 |    if (list.length() == p) |
---|
122 | Â Â Â Â random=Â alpha; |
---|
123 | Â Â Â else |
---|
124 | Â Â Â { |
---|
125 | Â Â Â Â AlgExtRandomF genAlgExt (alpha); |
---|
126 | Â Â Â Â random=Â genAlgExt.generate(); |
---|
127 | Â Â Â } |
---|
128 | Â Â } |
---|
129 |   if (find (list, random)) continue; |
---|
130 |   eval= F (random, x); |
---|
131 |   if (degree (eval) != degree (F, y)) |
---|
132 | Â Â {Â //leading coeff vanishes |
---|
133 |    if (!find (list, random)) |
---|
134 | Â Â Â Â list.append (random); |
---|
135 | Â Â Â continue; |
---|
136 | Â Â } |
---|
137 |   if (degree (gcd (deriv (eval, eval.mvar()), eval), eval.mvar()) > 0) |
---|
138 | Â Â {Â //evaluated polynomial is not squarefree |
---|
139 |    if (!find (list, random)) |
---|
140 | Â Â Â Â list.append (random); |
---|
141 | Â Â Â continue; |
---|
142 | Â Â } |
---|
143 |  } while (find (list, random)); |
---|
144 | |
---|
145 |  return random; |
---|
146 | } |
---|
147 | |
---|
148 | CFList |
---|
149 | uniFactorizer (const CanonicalForm& A, const Variable& alpha, const bool& GF) |
---|
150 | { |
---|
151 | Â Variable x=Â A.mvar(); |
---|
152 |  if (A.inCoeffDomain()) |
---|
153 |   return CFList(); |
---|
154 | Â ASSERT (A.isUnivariate(), |
---|
155 | Â Â Â Â Â "univariate polynomial expected or constant expected"); |
---|
156 | Â CFFList factorsA; |
---|
157 | Â zz_p::init (getCharacteristic()); |
---|
158 |  if (GF) |
---|
159 | Â { |
---|
160 |   int k= getGFDegree(); |
---|
161 |   char cGFName= gf_name; |
---|
162 | Â Â CanonicalForm mipo=Â gf_mipo; |
---|
163 | Â Â setCharacteristic (getCharacteristic()); |
---|
164 | Â Â Variable beta=Â rootOf (mipo.mapinto()); |
---|
165 |   CanonicalForm buf= GF2FalphaRep (A, beta); |
---|
166 |   if (getCharacteristic() > 2) |
---|
167 | Â Â { |
---|
168 | Â Â Â zz_pX NTLMipo=Â convertFacCF2NTLzzpX (mipo.mapinto()); |
---|
169 | Â Â Â zz_pE::init (NTLMipo); |
---|
170 |    zz_pEX NTLA= convertFacCF2NTLzz_pEX (buf, NTLMipo); |
---|
171 | Â Â Â MakeMonic (NTLA); |
---|
172 | Â Â Â vec_pair_zz_pEX_long NTLFactorsA=Â CanZass (NTLA); |
---|
173 | Â Â Â zz_pE multi=Â to_zz_pE (1); |
---|
174 |    factorsA= convertNTLvec_pair_zzpEX_long2FacCFFList (NTLFactorsA, multi, |
---|
175 |                              x, beta); |
---|
176 | Â Â } |
---|
177 | Â Â else |
---|
178 | Â Â { |
---|
179 | Â Â Â GF2X NTLMipo=Â convertFacCF2NTLGF2X (mipo.mapinto()); |
---|
180 | Â Â Â GF2E::init (NTLMipo); |
---|
181 |    GF2EX NTLA= convertFacCF2NTLGF2EX (buf, NTLMipo); |
---|
182 | Â Â Â MakeMonic (NTLA); |
---|
183 | Â Â Â vec_pair_GF2EX_long NTLFactorsA=Â CanZass (NTLA); |
---|
184 | Â Â Â GF2E multi=Â to_GF2E (1); |
---|
185 |    factorsA= convertNTLvec_pair_GF2EX_long2FacCFFList (NTLFactorsA, multi, |
---|
186 |                               x, beta); |
---|
187 | Â Â } |
---|
188 |   setCharacteristic (getCharacteristic(), k, cGFName); |
---|
189 |   for (CFFListIterator i= factorsA; i.hasItem(); i++) |
---|
190 | Â Â { |
---|
191 | Â Â Â buf=Â i.getItem().factor(); |
---|
192 | Â Â Â buf=Â Falpha2GFRep (buf); |
---|
193 |    i.getItem()= CFFactor (buf, i.getItem().exp()); |
---|
194 | Â Â } |
---|
195 | Â } |
---|
196 |  else if (alpha.level() != 1) |
---|
197 | Â { |
---|
198 |   if (getCharacteristic() > 2) |
---|
199 | Â Â { |
---|
200 | Â Â Â zz_pX NTLMipo=Â convertFacCF2NTLzzpX (getMipo (alpha)); |
---|
201 | Â Â Â zz_pE::init (NTLMipo); |
---|
202 |    zz_pEX NTLA= convertFacCF2NTLzz_pEX (A, NTLMipo); |
---|
203 | Â Â Â MakeMonic (NTLA); |
---|
204 | Â Â Â vec_pair_zz_pEX_long NTLFactorsA=Â CanZass (NTLA); |
---|
205 | Â Â Â zz_pE multi=Â to_zz_pE (1); |
---|
206 |    factorsA= convertNTLvec_pair_zzpEX_long2FacCFFList (NTLFactorsA, multi, |
---|
207 |                               x, alpha); |
---|
208 | Â Â } |
---|
209 | Â Â else |
---|
210 | Â Â { |
---|
211 | Â Â Â GF2X NTLMipo=Â convertFacCF2NTLGF2X (getMipo (alpha)); |
---|
212 | Â Â Â GF2E::init (NTLMipo); |
---|
213 |    GF2EX NTLA= convertFacCF2NTLGF2EX (A, NTLMipo); |
---|
214 | Â Â Â MakeMonic (NTLA); |
---|
215 | Â Â Â vec_pair_GF2EX_long NTLFactorsA=Â CanZass (NTLA); |
---|
216 | Â Â Â GF2E multi=Â to_GF2E (1); |
---|
217 |    factorsA= convertNTLvec_pair_GF2EX_long2FacCFFList (NTLFactorsA, multi, |
---|
218 |                               x, alpha); |
---|
219 | Â Â } |
---|
220 | Â } |
---|
221 | Â else |
---|
222 | Â { |
---|
223 | #ifdef HAVE_FLINT |
---|
224 | Â Â nmod_poly_t FLINTA; |
---|
225 |   convertFacCF2nmod_poly_t (FLINTA, A); |
---|
226 | Â Â nmod_poly_factor_t result; |
---|
227 | Â Â nmod_poly_factor_init (result); |
---|
228 |   mp_limb_t leadingCoeff= nmod_poly_factor (result, FLINTA); |
---|
229 |   factorsA= convertFLINTnmod_poly_factor2FacCFFList (result, leadingCoeff, x); |
---|
230 |   if (factorsA.getFirst().factor().inCoeffDomain()) |
---|
231 | Â Â Â factorsA.removeFirst(); |
---|
232 | Â Â nmod_poly_factor_clear (result); |
---|
233 | Â Â nmod_poly_clear (FLINTA); |
---|
234 | #else |
---|
235 |   if (getCharacteristic() > 2) |
---|
236 | Â Â { |
---|
237 | Â Â Â zz_pX NTLA=Â convertFacCF2NTLzzpX (A); |
---|
238 | Â Â Â MakeMonic (NTLA); |
---|
239 | Â Â Â vec_pair_zz_pX_long NTLFactorsA=Â CanZass (NTLA); |
---|
240 | Â Â Â zz_p multi=Â to_zz_p (1); |
---|
241 |    factorsA= convertNTLvec_pair_zzpX_long2FacCFFList (NTLFactorsA, multi, |
---|
242 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â x); |
---|
243 | Â Â } |
---|
244 | Â Â else |
---|
245 | Â Â { |
---|
246 | Â Â Â GF2X NTLA=Â convertFacCF2NTLGF2X (A); |
---|
247 | Â Â Â vec_pair_GF2X_long NTLFactorsA=Â CanZass (NTLA); |
---|
248 | Â Â Â GF2 multi=Â to_GF2 (1); |
---|
249 |    factorsA= convertNTLvec_pair_GF2X_long2FacCFFList (NTLFactorsA, multi, |
---|
250 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â x); |
---|
251 | Â Â } |
---|
252 | #endif |
---|
253 | Â } |
---|
254 | Â CFList uniFactors; |
---|
255 |  for (CFFListIterator i= factorsA; i.hasItem(); i++) |
---|
256 | Â Â uniFactors.append (i.getItem().factor()); |
---|
257 |  return uniFactors; |
---|
258 | } |
---|
259 | |
---|
260 | /// naive factor recombination as decribed in "Factoring |
---|
261 | /// multivariate polynomials over a finite field" by L Bernardin. |
---|
262 | CFList |
---|
263 | extFactorRecombination (CFList& factors, CanonicalForm& F, |
---|
264 |             const CanonicalForm& N, const ExtensionInfo& info, |
---|
265 |             DegreePattern& degs, const CanonicalForm& eval, int s, |
---|
266 |             int thres) |
---|
267 | { |
---|
268 |  if (factors.length() == 0) |
---|
269 | Â { |
---|
270 | Â Â F=Â 1; |
---|
271 |   return CFList(); |
---|
272 | Â } |
---|
273 |  if (F.inCoeffDomain()) |
---|
274 |   return CFList(); |
---|
275 | |
---|
276 | Â Variable alpha=Â info.getAlpha(); |
---|
277 | Â Variable beta=Â info.getBeta(); |
---|
278 | Â CanonicalForm gamma=Â info.getGamma(); |
---|
279 | Â CanonicalForm delta=Â info.getDelta(); |
---|
280 |  int k= info.getGFDegree(); |
---|
281 | |
---|
282 | Â CanonicalForm M=Â N; |
---|
283 |  int l= degree (N); |
---|
284 | Â Variable y=Â F.mvar(); |
---|
285 | Â Variable x=Â Variable (1); |
---|
286 |  CFList source, dest; |
---|
287 |  if (degs.getLength() <= 1 || factors.length() == 1) |
---|
288 | Â { |
---|
289 |   CFList result= CFList(mapDown (F(y-eval, y), info, source, dest)); |
---|
290 | Â Â F=Â 1; |
---|
291 |   return result; |
---|
292 | Â } |
---|
293 | |
---|
294 |  DEBOUTLN (cerr, "LC (F, 1)*prodMod (factors, M) == F " << |
---|
295 |       (mod (LC (F, 1)*prodMod (factors, M), M)/Lc (mod (LC (F, 1)*prodMod (factors, M), M)) == F/Lc (F))); |
---|
296 |  int degMipoBeta= 1; |
---|
297 |  if (!k && beta.level() != 1) |
---|
298 | Â Â degMipoBeta=Â degree (getMipo (beta)); |
---|
299 | |
---|
300 |  CFList T, S, Diff; |
---|
301 | Â T=Â factors; |
---|
302 | |
---|
303 | Â CFList result; |
---|
304 |  CanonicalForm buf, buf2, quot; |
---|
305 | |
---|
306 | Â buf=Â F; |
---|
307 | |
---|
308 |  CanonicalForm g, LCBuf= LC (buf, x); |
---|
309 |  int * v= new int [T.length()]; |
---|
310 |  for (int i= 0; i < T.length(); i++) |
---|
311 | Â Â v[i]=Â 0; |
---|
312 | |
---|
313 | Â CFArray TT; |
---|
314 |  DegreePattern bufDegs1, bufDegs2; |
---|
315 | Â bufDegs1=Â degs; |
---|
316 |  int subsetDeg; |
---|
317 | Â TT=Â copy (factors); |
---|
318 |  bool nosubset= false; |
---|
319 |  bool recombination= false; |
---|
320 |  bool trueFactor= false; |
---|
321 | Â CanonicalForm test; |
---|
322 |  CanonicalForm buf0= buf (0, x)*LCBuf; |
---|
323 |  while (T.length() >= 2*s && s <= thres) |
---|
324 | Â { |
---|
325 |   while (nosubset == false) |
---|
326 | Â Â { |
---|
327 |    if (T.length() == s) |
---|
328 | Â Â Â { |
---|
329 |     delete [] v; |
---|
330 |     if (recombination) |
---|
331 | Â Â Â Â { |
---|
332 | Â Â Â Â Â T.insert (LCBuf); |
---|
333 |      g= prodMod (T, M); |
---|
334 | Â Â Â Â Â T.removeFirst(); |
---|
335 | Â Â Â Â Â g /=Â content(g); |
---|
336 |      g= g (y - eval, y); |
---|
337 | Â Â Â Â Â g /=Â Lc (g); |
---|
338 |      appendTestMapDown (result, g, info, source, dest); |
---|
339 | Â Â Â Â Â F=Â 1; |
---|
340 |      return result; |
---|
341 | Â Â Â Â } |
---|
342 | Â Â Â Â else |
---|
343 | Â Â Â Â { |
---|
344 |      appendMapDown (result, F (y - eval, y), info, source, dest); |
---|
345 | Â Â Â Â Â F=Â 1; |
---|
346 |      return result; |
---|
347 | Â Â Â Â } |
---|
348 | Â Â Â } |
---|
349 |    S= subset (v, s, TT, nosubset); |
---|
350 |    if (nosubset) break; |
---|
351 | Â Â Â subsetDeg=Â subsetDegree (S); |
---|
352 | Â Â Â // skip those combinations that are not possible |
---|
353 |    if (!degs.find (subsetDeg)) |
---|
354 | Â Â Â Â continue; |
---|
355 | Â Â Â else |
---|
356 | Â Â Â { |
---|
357 |     test= prodMod0 (S, M); |
---|
358 | Â Â Â Â test *=Â LCBuf; |
---|
359 |     test = mod (test, M); |
---|
360 |     if (fdivides (test, buf0)) |
---|
361 | Â Â Â Â { |
---|
362 | Â Â Â Â Â S.insert (LCBuf); |
---|
363 |      g= prodMod (S, M); |
---|
364 | Â Â Â Â Â S.removeFirst(); |
---|
365 |      g /= content (g, x); |
---|
366 |      if (fdivides (g, buf, quot)) |
---|
367 | Â Â Â Â Â { |
---|
368 |       buf2= g (y - eval, y); |
---|
369 | Â Â Â Â Â Â buf2 /=Â Lc (buf2); |
---|
370 | |
---|
371 |       if (!k && beta.level() == 1) |
---|
372 | Â Â Â Â Â Â { |
---|
373 |        if (degree (buf2, alpha) < degMipoBeta) |
---|
374 | Â Â Â Â Â Â Â { |
---|
375 | Â Â Â Â Â Â Â Â buf=Â quot; |
---|
376 |         LCBuf= LC (buf, x); |
---|
377 | Â Â Â Â Â Â Â Â recombination=Â true; |
---|
378 |         appendTestMapDown (result, buf2, info, source, dest); |
---|
379 | Â Â Â Â Â Â Â Â trueFactor=Â true; |
---|
380 | Â Â Â Â Â Â Â } |
---|
381 | Â Â Â Â Â Â } |
---|
382 | Â Â Â Â Â Â else |
---|
383 | Â Â Â Â Â Â { |
---|
384 |        if (!isInExtension (buf2, gamma, k, delta, source, dest)) |
---|
385 | Â Â Â Â Â Â Â { |
---|
386 | Â Â Â Â Â Â Â Â buf=Â quot; |
---|
387 |         LCBuf= LC (buf, x); |
---|
388 | Â Â Â Â Â Â Â Â recombination=Â true; |
---|
389 |         appendTestMapDown (result, buf2, info, source, dest); |
---|
390 | Â Â Â Â Â Â Â Â trueFactor=Â true; |
---|
391 | Â Â Â Â Â Â Â } |
---|
392 | Â Â Â Â Â Â } |
---|
393 |       if (trueFactor) |
---|
394 | Â Â Â Â Â Â { |
---|
395 |        T= Difference (T, S); |
---|
396 | Â Â Â Â Â Â Â l -=Â degree (g); |
---|
397 |        M= power (y, l); |
---|
398 |        buf0= buf (0, x)*LCBuf; |
---|
399 | |
---|
400 | Â Â Â Â Â Â Â // compute new possible degree pattern |
---|
401 | Â Â Â Â Â Â Â bufDegs2=Â DegreePattern (T); |
---|
402 | Â Â Â Â Â Â Â bufDegs1.intersect (bufDegs2); |
---|
403 | Â Â Â Â Â Â Â bufDegs1.refine (); |
---|
404 |        if (T.length() < 2*s || T.length() == s || |
---|
405 | Â Â Â Â Â Â Â Â Â bufDegs1.getLength()Â ==Â 1) |
---|
406 | Â Â Â Â Â Â Â { |
---|
407 |         delete [] v; |
---|
408 |         if (recombination) |
---|
409 | Â Â Â Â Â Â Â Â { |
---|
410 |          appendTestMapDown (result, buf (y - eval, y), info, source, |
---|
411 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dest); |
---|
412 | Â Â Â Â Â Â Â Â Â F=Â 1; |
---|
413 |          return result; |
---|
414 | Â Â Â Â Â Â Â Â } |
---|
415 | Â Â Â Â Â Â Â Â else |
---|
416 | Â Â Â Â Â Â Â Â { |
---|
417 |          appendMapDown (result, F (y - eval, y), info, source, dest); |
---|
418 | Â Â Â Â Â Â Â Â Â F=Â 1; |
---|
419 |          return result; |
---|
420 | Â Â Â Â Â Â Â Â } |
---|
421 | Â Â Â Â Â Â Â } |
---|
422 | Â Â Â Â Â Â Â trueFactor=Â false; |
---|
423 | Â Â Â Â Â Â Â TT=Â copy (T); |
---|
424 |        indexUpdate (v, s, T.length(), nosubset); |
---|
425 |        if (nosubset) break; |
---|
426 | Â Â Â Â Â Â } |
---|
427 | Â Â Â Â Â } |
---|
428 | Â Â Â Â } |
---|
429 | Â Â Â } |
---|
430 | Â Â } |
---|
431 | Â Â s++; |
---|
432 |   if (T.length() < 2*s || T.length() == s) |
---|
433 | Â Â { |
---|
434 |    delete [] v; |
---|
435 |    if (recombination) |
---|
436 | Â Â Â { |
---|
437 |     appendTestMapDown (result, buf (y - eval, y), info, source, dest); |
---|
438 | Â Â Â Â F=Â 1; |
---|
439 |     return result; |
---|
440 | Â Â Â } |
---|
441 | Â Â Â else |
---|
442 | Â Â Â { |
---|
443 |     appendMapDown (result, F (y - eval, y), info, source, dest); |
---|
444 | Â Â Â Â F=Â 1; |
---|
445 |     return result; |
---|
446 | Â Â Â } |
---|
447 | Â Â } |
---|
448 |   for (int i= 0; i < T.length(); i++) |
---|
449 | Â Â Â v[i]=Â 0; |
---|
450 | Â Â nosubset=Â false; |
---|
451 | Â } |
---|
452 |  if (T.length() < 2*s) |
---|
453 | Â { |
---|
454 |   appendMapDown (result, F (y - eval, y), info, source, dest); |
---|
455 | Â Â F=Â 1; |
---|
456 |   delete [] v; |
---|
457 |   return result; |
---|
458 | Â } |
---|
459 | |
---|
460 |  if (s > thres) |
---|
461 | Â { |
---|
462 | Â Â factors=Â T; |
---|
463 | Â Â F=Â buf; |
---|
464 | Â Â degs=Â bufDegs1; |
---|
465 | Â } |
---|
466 | |
---|
467 |  delete [] v; |
---|
468 |  return result; |
---|
469 | } |
---|
470 | |
---|
471 | /// naive factor recombination as decribed in "Factoring |
---|
472 | /// multivariate polynomials over a finite field" by L Bernardin. |
---|
473 | CFList |
---|
474 | factorRecombination (CFList& factors, CanonicalForm& F, |
---|
475 |            const CanonicalForm& N, DegreePattern& degs, int s, |
---|
476 |            int thres, const modpk& b |
---|
477 | Â Â Â Â Â Â Â Â Â Â ) |
---|
478 | { |
---|
479 |  if (factors.length() == 0) |
---|
480 | Â { |
---|
481 | Â Â F=Â 1; |
---|
482 |   return CFList (); |
---|
483 | Â } |
---|
484 |  if (F.inCoeffDomain()) |
---|
485 |   return CFList(); |
---|
486 |  if (degs.getLength() <= 1 || factors.length() == 1) |
---|
487 | Â { |
---|
488 | Â Â CFList result=Â CFList (F); |
---|
489 | Â Â F=Â 1; |
---|
490 |   return result; |
---|
491 | Â } |
---|
492 | #ifdef DEBUGOUTPUT |
---|
493 |  if (b.getp() == 0) |
---|
494 |   DEBOUTLN (cerr, "LC (F, 1)*prodMod (factors, N) == F " << |
---|
495 |        (mod (LC (F, 1)*prodMod (factors, N),N)/Lc (mod (LC (F, 1)*prodMod (factors, N),N)) == F/Lc(F))); |
---|
496 | Â else |
---|
497 |   DEBOUTLN (cerr, "LC (F, 1)*prodMod (factors, N) == F " << |
---|
498 |        (mod (b(LC (F, 1)*prodMod (factors, N)),N)/Lc (mod (b(LC (F, 1)*prodMod (factors, N)),N)) == F/Lc(F))); |
---|
499 | #endif |
---|
500 | |
---|
501 |  CFList T, S; |
---|
502 | |
---|
503 | Â CanonicalForm M=Â N; |
---|
504 |  int l= degree (N); |
---|
505 | Â T=Â factors; |
---|
506 | Â CFList result; |
---|
507 | Â Variable y=Â Variable (2); |
---|
508 | Â Variable x=Â Variable (1); |
---|
509 |  CanonicalForm LCBuf= LC (F, x); |
---|
510 |  CanonicalForm g, quot, buf= F; |
---|
511 |  int * v= new int [T.length()]; |
---|
512 |  for (int i= 0; i < T.length(); i++) |
---|
513 | Â Â v[i]=Â 0; |
---|
514 |  bool nosubset= false; |
---|
515 | Â CFArray TT; |
---|
516 |  DegreePattern bufDegs1, bufDegs2; |
---|
517 | Â bufDegs1=Â degs; |
---|
518 |  int subsetDeg; |
---|
519 | Â TT=Â copy (factors); |
---|
520 |  bool recombination= false; |
---|
521 | Â CanonicalForm test; |
---|
522 |  bool isRat= (isOn (SW_RATIONAL) && getCharacteristic() == 0) || |
---|
523 | Â Â Â Â Â Â Â Â getCharacteristic()Â >Â 0; |
---|
524 |  if (!isRat) |
---|
525 | Â Â On (SW_RATIONAL); |
---|
526 |  CanonicalForm buf0= mulNTL (buf (0, x), LCBuf); |
---|
527 |  if (!isRat) |
---|
528 | Â Â Off (SW_RATIONAL); |
---|
529 |  while (T.length() >= 2*s && s <= thres) |
---|
530 | Â { |
---|
531 |   while (nosubset == false) |
---|
532 | Â Â { |
---|
533 |    if (T.length() == s) |
---|
534 | Â Â Â { |
---|
535 |     delete [] v; |
---|
536 |     if (recombination) |
---|
537 | Â Â Â Â { |
---|
538 | Â Â Â Â Â T.insert (LCBuf); |
---|
539 |      g= prodMod (T, M); |
---|
540 |      if (b.getp() != 0) |
---|
541 | Â Â Â Â Â Â g=Â b(g); |
---|
542 | Â Â Â Â Â T.removeFirst(); |
---|
543 |      result.append (g/content (g, x)); |
---|
544 | Â Â Â Â Â F=Â 1; |
---|
545 |      return result; |
---|
546 | Â Â Â Â } |
---|
547 | Â Â Â Â else |
---|
548 | Â Â Â Â { |
---|
549 | Â Â Â Â Â result=Â CFList (F); |
---|
550 | Â Â Â Â Â F=Â 1; |
---|
551 |      return result; |
---|
552 | Â Â Â Â } |
---|
553 | Â Â Â } |
---|
554 |    S= subset (v, s, TT, nosubset); |
---|
555 |    if (nosubset) break; |
---|
556 | Â Â Â subsetDeg=Â subsetDegree (S); |
---|
557 | Â Â Â // skip those combinations that are not possible |
---|
558 |    if (!degs.find (subsetDeg)) |
---|
559 | Â Â Â Â continue; |
---|
560 | Â Â Â else |
---|
561 | Â Â Â { |
---|
562 |     if (!isRat) |
---|
563 | Â Â Â Â Â On (SW_RATIONAL); |
---|
564 |     test= prodMod0 (S, M); |
---|
565 |     if (!isRat) |
---|
566 | Â Â Â Â { |
---|
567 | Â Â Â Â Â test *=Â bCommonDen (test); |
---|
568 | Â Â Â Â Â Off (SW_RATIONAL); |
---|
569 | Â Â Â Â } |
---|
570 |     test= mulNTL (test, LCBuf, b); |
---|
571 |     test= mod (test, M); |
---|
572 |     if (uniFdivides (test, buf0)) |
---|
573 | Â Â Â Â { |
---|
574 |      if (!isRat) |
---|
575 | Â Â Â Â Â Â On (SW_RATIONAL); |
---|
576 | Â Â Â Â Â S.insert (LCBuf); |
---|
577 |      g= prodMod (S, M); |
---|
578 | Â Â Â Â Â S.removeFirst(); |
---|
579 |      if (!isRat) |
---|
580 | Â Â Â Â Â { |
---|
581 | Â Â Â Â Â Â g *=Â bCommonDen(g); |
---|
582 | Â Â Â Â Â Â Off (SW_RATIONAL); |
---|
583 | Â Â Â Â Â } |
---|
584 |      if (b.getp() != 0) |
---|
585 | Â Â Â Â Â Â g=Â b(g); |
---|
586 |      if (!isRat) |
---|
587 | Â Â Â Â Â Â On (SW_RATIONAL); |
---|
588 |      g /= content (g, x); |
---|
589 |      if (fdivides (g, buf, quot)) |
---|
590 | Â Â Â Â Â { |
---|
591 | Â Â Â Â Â Â recombination=Â true; |
---|
592 | Â Â Â Â Â Â result.append (g); |
---|
593 |       if (b.getp() != 0) |
---|
594 | Â Â Â Â Â Â Â buf=Â quot*bCommonDen (quot); |
---|
595 | Â Â Â Â Â Â else |
---|
596 | Â Â Â Â Â Â Â buf=Â quot; |
---|
597 |       LCBuf= LC (buf, x); |
---|
598 |       T= Difference (T, S); |
---|
599 | Â Â Â Â Â Â l -=Â degree (g); |
---|
600 |       M= power (y, l); |
---|
601 |       buf0= mulNTL (buf (0, x), LCBuf); |
---|
602 |       if (!isRat) |
---|
603 | Â Â Â Â Â Â Â Off (SW_RATIONAL); |
---|
604 | Â Â Â Â Â Â // compute new possible degree pattern |
---|
605 | Â Â Â Â Â Â bufDegs2=Â DegreePattern (T); |
---|
606 | Â Â Â Â Â Â bufDegs1.intersect (bufDegs2); |
---|
607 | Â Â Â Â Â Â bufDegs1.refine (); |
---|
608 |       if (T.length() < 2*s || T.length() == s || |
---|
609 | Â Â Â Â Â Â Â Â bufDegs1.getLength()Â ==Â 1) |
---|
610 | Â Â Â Â Â Â { |
---|
611 |        delete [] v; |
---|
612 |        if (recombination) |
---|
613 | Â Â Â Â Â Â Â { |
---|
614 | Â Â Â Â Â Â Â Â result.append (buf); |
---|
615 | Â Â Â Â Â Â Â Â F=Â 1; |
---|
616 |         return result; |
---|
617 | Â Â Â Â Â Â Â } |
---|
618 | Â Â Â Â Â Â Â else |
---|
619 | Â Â Â Â Â Â Â { |
---|
620 | Â Â Â Â Â Â Â Â result=Â CFList (F); |
---|
621 | Â Â Â Â Â Â Â Â F=Â 1; |
---|
622 |         return result; |
---|
623 | Â Â Â Â Â Â Â } |
---|
624 | Â Â Â Â Â Â } |
---|
625 | Â Â Â Â Â Â TT=Â copy (T); |
---|
626 |       indexUpdate (v, s, T.length(), nosubset); |
---|
627 |       if (nosubset) break; |
---|
628 | Â Â Â Â Â } |
---|
629 |      if (!isRat) |
---|
630 | Â Â Â Â Â Â Off (SW_RATIONAL); |
---|
631 | Â Â Â Â } |
---|
632 | Â Â Â } |
---|
633 | Â Â } |
---|
634 | Â Â s++; |
---|
635 |   if (T.length() < 2*s || T.length() == s) |
---|
636 | Â Â { |
---|
637 |    delete [] v; |
---|
638 |    if (recombination) |
---|
639 | Â Â Â { |
---|
640 | Â Â Â Â result.append (buf); |
---|
641 | Â Â Â Â F=Â 1; |
---|
642 |     return result; |
---|
643 | Â Â Â } |
---|
644 | Â Â Â else |
---|
645 | Â Â Â { |
---|
646 | Â Â Â Â result=Â CFList (F); |
---|
647 | Â Â Â Â F=Â 1; |
---|
648 |     return result; |
---|
649 | Â Â Â } |
---|
650 | Â Â } |
---|
651 |   for (int i= 0; i < T.length(); i++) |
---|
652 | Â Â Â v[i]=Â 0; |
---|
653 | Â Â nosubset=Â false; |
---|
654 | Â } |
---|
655 |  delete [] v; |
---|
656 |  if (T.length() < 2*s) |
---|
657 | Â { |
---|
658 | Â Â result.append (F); |
---|
659 | Â Â F=Â 1; |
---|
660 |   return result; |
---|
661 | Â } |
---|
662 | |
---|
663 |  if (s > thres) |
---|
664 | Â { |
---|
665 | Â Â factors=Â T; |
---|
666 | Â Â F=Â buf; |
---|
667 | Â Â degs=Â bufDegs1; |
---|
668 | Â } |
---|
669 | |
---|
670 |  return result; |
---|
671 | } |
---|
672 | |
---|
673 | Variable chooseExtension (const Variable & alpha, const Variable& beta, int k) |
---|
674 | { |
---|
675 | Â zz_p::init (getCharacteristic()); |
---|
676 | Â zz_pX NTLIrredpoly; |
---|
677 |  int i=1, m= 2; |
---|
678 | Â // extension of F_p needed |
---|
679 |  if (alpha.level() == 1 && beta.level() == 1 && k == 1) |
---|
680 | Â { |
---|
681 | Â Â i=Â 1; |
---|
682 | Â Â m=Â 2; |
---|
683 | Â }Â //extension of F_p(alpha) needed but want to factorize over F_p |
---|
684 |  else if (alpha.level() != 1 && beta.level() == 1 && k == 1) |
---|
685 | Â { |
---|
686 | Â Â i=Â 1; |
---|
687 | Â Â m=Â degree (getMipo (alpha))Â +Â 1; |
---|
688 | Â }Â //extension of F_p(alpha) needed for first time |
---|
689 |  else if (alpha.level() != 1 && beta.level() == 1 && k != 1) |
---|
690 | Â { |
---|
691 | Â Â i=Â 2; |
---|
692 | Â Â m=Â degree (getMipo (alpha)); |
---|
693 | Â } |
---|
694 |  else if (alpha.level() != 1 && beta.level() != 1 && k != 1) |
---|
695 | Â { |
---|
696 | Â Â m=Â degree (getMipo (beta)); |
---|
697 | Â Â i=Â degree (getMipo (alpha))/m +Â 1; |
---|
698 | Â } |
---|
699 |  BuildIrred (NTLIrredpoly, i*m); |
---|
700 |  CanonicalForm newMipo= convertNTLzzpX2CF (NTLIrredpoly, Variable (1)); |
---|
701 |  return rootOf (newMipo); |
---|
702 | } |
---|
703 | |
---|
704 | void |
---|
705 | earlyFactorDetection (CFList& reconstructedFactors, CanonicalForm& F, CFList& |
---|
706 |            factors, int& adaptedLiftBound, int*& factorsFoundIndex, |
---|
707 |            DegreePattern& degs, bool& success, int deg, |
---|
708 |            const modpk& b) |
---|
709 | { |
---|
710 | Â DegreePattern bufDegs1=Â degs; |
---|
711 | Â DegreePattern bufDegs2; |
---|
712 | Â CFList T=Â factors; |
---|
713 | Â CanonicalForm buf=Â F; |
---|
714 | Â Variable x=Â Variable (1); |
---|
715 |  CanonicalForm g, quot; |
---|
716 |  CanonicalForm M= power (F.mvar(), deg); |
---|
717 | Â adaptedLiftBound=Â 0; |
---|
718 |  int d= degree (F), l= 0; |
---|
719 |  bool isRat= (isOn (SW_RATIONAL) && getCharacteristic() == 0) || getCharacteristic() > 0; |
---|
720 |  if (!isRat) |
---|
721 | Â Â On (SW_RATIONAL); |
---|
722 |  if (b.getp() != 0) |
---|
723 | Â Â buf *=Â bCommonDen (buf); |
---|
724 |  CanonicalForm LCBuf= LC (buf, x); |
---|
725 |  CanonicalForm buf0= mulNTL (buf (0,x), LCBuf); |
---|
726 |  CanonicalForm buf1= mulNTL (buf (1,x), LCBuf); |
---|
727 |  if (!isRat) |
---|
728 | Â Â Off (SW_RATIONAL); |
---|
729 |  CanonicalForm test0, test1; |
---|
730 | |
---|
731 |  for (CFListIterator i= factors; i.hasItem(); i++, l++) |
---|
732 | Â { |
---|
733 |   if (!bufDegs1.find (degree (i.getItem(), 1)) || factorsFoundIndex[l] == 1) |
---|
734 | Â Â Â continue; |
---|
735 | Â Â else |
---|
736 | Â Â { |
---|
737 |    test1= mod (mulNTL (i.getItem() (1,x), LCBuf, b), M); |
---|
738 |    if (uniFdivides (test1, buf1)) |
---|
739 | Â Â Â { |
---|
740 |     test0= mod (mulNTL (i.getItem() (0,x), LCBuf, b), M); |
---|
741 |     if (uniFdivides (test0, buf0)) |
---|
742 | Â Â Â Â { |
---|
743 |      if (!isRat) |
---|
744 | Â Â Â Â Â Â On (SW_RATIONAL); |
---|
745 |      g= mulMod2 (i.getItem(), LCBuf, M); |
---|
746 |      if (!isRat) |
---|
747 | Â Â Â Â Â { |
---|
748 | Â Â Â Â Â Â g *=Â bCommonDen(g); |
---|
749 | Â Â Â Â Â Â Off (SW_RATIONAL); |
---|
750 | Â Â Â Â Â } |
---|
751 |      if (b.getp() != 0) |
---|
752 | Â Â Â Â Â Â g=Â b(g); |
---|
753 |      if (!isRat) |
---|
754 | Â Â Â Â Â Â On (SW_RATIONAL); |
---|
755 |      g /= content (g, x); |
---|
756 |      if (fdivides (g, buf, quot)) |
---|
757 | Â Â Â Â Â { |
---|
758 | Â Â Â Â Â Â reconstructedFactors.append (g); |
---|
759 | Â Â Â Â Â Â factorsFoundIndex[l]=Â 1; |
---|
760 |       if (b.getp() != 0) |
---|
761 | Â Â Â Â Â Â Â buf=Â quot*bCommonDen(quot); |
---|
762 | Â Â Â Â Â Â else |
---|
763 | Â Â Â Â Â Â Â buf=Â quot; |
---|
764 | Â Â Â Â Â Â d -=Â degree (g); |
---|
765 |       LCBuf= LC (buf, x); |
---|
766 |       buf0= mulNTL (buf (0,x), LCBuf); |
---|
767 |       buf1= mulNTL (buf (1,x), LCBuf); |
---|
768 |       if (!isRat) |
---|
769 | Â Â Â Â Â Â Â Off (SW_RATIONAL); |
---|
770 |       T= Difference (T, CFList (i.getItem())); |
---|
771 | Â Â Â Â Â Â F=Â buf; |
---|
772 | |
---|
773 | Â Â Â Â Â Â // compute new possible degree pattern |
---|
774 | Â Â Â Â Â Â bufDegs2=Â DegreePattern (T); |
---|
775 | Â Â Â Â Â Â bufDegs1.intersect (bufDegs2); |
---|
776 | Â Â Â Â Â Â bufDegs1.refine (); |
---|
777 |       if (bufDegs1.getLength() <= 1) |
---|
778 | Â Â Â Â Â Â { |
---|
779 |        if (!buf.inCoeffDomain()) |
---|
780 | Â Â Â Â Â Â Â { |
---|
781 | Â Â Â Â Â Â Â Â reconstructedFactors.append (buf); |
---|
782 | Â Â Â Â Â Â Â Â F=Â 1; |
---|
783 | Â Â Â Â Â Â Â } |
---|
784 | Â Â Â Â Â Â Â break; |
---|
785 | Â Â Â Â Â Â } |
---|
786 | Â Â Â Â Â } |
---|
787 |      if (!isRat) |
---|
788 | Â Â Â Â Â Â Off (SW_RATIONAL); |
---|
789 | Â Â Â Â } |
---|
790 | Â Â Â } |
---|
791 | Â Â } |
---|
792 | Â } |
---|
793 | Â adaptedLiftBound=Â d +Â 1; |
---|
794 |  if (adaptedLiftBound < deg) |
---|
795 | Â { |
---|
796 | Â Â degs=Â bufDegs1; |
---|
797 | Â Â success=Â true; |
---|
798 | Â } |
---|
799 |  if (bufDegs1.getLength() <= 1) |
---|
800 | Â Â degs=Â bufDegs1; |
---|
801 | } |
---|
802 | |
---|
803 | void |
---|
804 | extEarlyFactorDetection (CFList& reconstructedFactors, CanonicalForm& F, CFList& |
---|
805 |              factors,int& adaptedLiftBound, int*& factorsFoundIndex, |
---|
806 |              DegreePattern& degs, bool& success, const |
---|
807 |              ExtensionInfo& info, const CanonicalForm& eval, int deg |
---|
808 | Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
809 | { |
---|
810 | Â Variable alpha=Â info.getAlpha(); |
---|
811 | Â Variable beta=Â info.getBeta(); |
---|
812 | Â CanonicalForm gamma=Â info.getGamma(); |
---|
813 | Â CanonicalForm delta=Â info.getDelta(); |
---|
814 |  int k= info.getGFDegree(); |
---|
815 |  DegreePattern bufDegs1= degs, bufDegs2; |
---|
816 | Â CFList result; |
---|
817 | Â CFList T=Â factors; |
---|
818 | Â Variable y=Â F.mvar(); |
---|
819 | Â Variable x=Â Variable (1); |
---|
820 |  CanonicalForm buf= F, LCBuf= LC (buf, x), g, buf2; |
---|
821 |  CanonicalForm M= power (y, deg); |
---|
822 | Â adaptedLiftBound=Â 0; |
---|
823 |  bool trueFactor= false; |
---|
824 |  int d= degree (F), l= 0; |
---|
825 |  CFList source, dest; |
---|
826 |  int degMipoBeta= 1; |
---|
827 |  if (!k && beta.level() != 1) |
---|
828 | Â Â degMipoBeta=Â degree (getMipo (beta)); |
---|
829 | Â CanonicalForm quot; |
---|
830 |  for (CFListIterator i= factors; i.hasItem(); i++, l++) |
---|
831 | Â { |
---|
832 |   if (!bufDegs1.find (degree (i.getItem(), 1)) || factorsFoundIndex[l] == 1) |
---|
833 | Â Â Â continue; |
---|
834 | Â Â else |
---|
835 | Â Â { |
---|
836 |    g= mulMod2 (i.getItem(), LCBuf, M); |
---|
837 |    g /= content (g, x); |
---|
838 |    if (fdivides (g, buf, quot)) |
---|
839 | Â Â Â { |
---|
840 |     buf2= g (y - eval, y); |
---|
841 | Â Â Â Â buf2 /=Â Lc (buf2); |
---|
842 | |
---|
843 |     if (!k && beta == x) |
---|
844 | Â Â Â Â { |
---|
845 |      if (degree (buf2, alpha) < degMipoBeta) |
---|
846 | Â Â Â Â Â { |
---|
847 |       appendTestMapDown (reconstructedFactors, buf2, info, source, dest); |
---|
848 | Â Â Â Â Â Â factorsFoundIndex[l]=Â 1; |
---|
849 | Â Â Â Â Â Â buf=Â quot; |
---|
850 | Â Â Â Â Â Â d -=Â degree (g); |
---|
851 |       LCBuf= LC (buf, x); |
---|
852 | Â Â Â Â Â Â trueFactor=Â true; |
---|
853 | Â Â Â Â Â } |
---|
854 | Â Â Â Â } |
---|
855 | Â Â Â Â else |
---|
856 | Â Â Â Â { |
---|
857 |      if (!isInExtension (buf2, gamma, k, delta, source, dest)) |
---|
858 | Â Â Â Â Â { |
---|
859 |       appendTestMapDown (reconstructedFactors, buf2, info, source, dest); |
---|
860 | Â Â Â Â Â Â factorsFoundIndex[l]=Â 1; |
---|
861 | Â Â Â Â Â Â buf=Â quot; |
---|
862 | Â Â Â Â Â Â d -=Â degree (g); |
---|
863 |       LCBuf= LC (buf, x); |
---|
864 | Â Â Â Â Â Â trueFactor=Â true; |
---|
865 | Â Â Â Â Â } |
---|
866 | Â Â Â Â } |
---|
867 |     if (trueFactor) |
---|
868 | Â Â Â Â { |
---|
869 |      T= Difference (T, CFList (i.getItem())); |
---|
870 | Â Â Â Â Â F=Â buf; |
---|
871 | |
---|
872 | Â Â Â Â Â // compute new possible degree pattern |
---|
873 | Â Â Â Â Â bufDegs2=Â DegreePattern (T); |
---|
874 | Â Â Â Â Â bufDegs1.intersect (bufDegs2); |
---|
875 | Â Â Â Â Â bufDegs1.refine (); |
---|
876 | Â Â Â Â Â trueFactor=Â false; |
---|
877 |      if (bufDegs1.getLength() <= 1) |
---|
878 | Â Â Â Â Â { |
---|
879 |       if (!buf.inCoeffDomain()) |
---|
880 | Â Â Â Â Â Â { |
---|
881 |        buf= buf (y - eval, y); |
---|
882 | Â Â Â Â Â Â Â buf /=Â Lc (buf); |
---|
883 |        appendMapDown (reconstructedFactors, buf, info, source, dest); |
---|
884 | Â Â Â Â Â Â Â F=Â 1; |
---|
885 | Â Â Â Â Â Â } |
---|
886 | Â Â Â Â Â Â break; |
---|
887 | Â Â Â Â Â } |
---|
888 | Â Â Â Â } |
---|
889 | Â Â Â } |
---|
890 | Â Â } |
---|
891 | Â } |
---|
892 | Â adaptedLiftBound=Â d +Â 1; |
---|
893 |  if (adaptedLiftBound < deg) |
---|
894 | Â { |
---|
895 | Â Â degs=Â bufDegs1; |
---|
896 | Â Â success=Â true; |
---|
897 | Â } |
---|
898 |  if (bufDegs1.getLength() <= 1) |
---|
899 | Â Â degs=Â bufDegs1; |
---|
900 | } |
---|
901 | |
---|
902 | int* |
---|
903 | getCombinations (int * rightSide, int sizeOfRightSide, int& sizeOfOutput, |
---|
904 |          int degreeLC) |
---|
905 | { |
---|
906 | Â Variable x=Â Variable (1); |
---|
907 |  int p= getCharacteristic(); |
---|
908 |  int d= getGFDegree(); |
---|
909 |  char cGFName= gf_name; |
---|
910 | Â setCharacteristic(0); |
---|
911 | Â CanonicalForm buf=Â 1; |
---|
912 |  for (int i= 0; i < sizeOfRightSide; i++) |
---|
913 |   buf *= (power (x, rightSide [i]) + 1); |
---|
914 | |
---|
915 |  int j= 0; |
---|
916 |  for (CFIterator i= buf; i.hasTerms(); i++, j++) |
---|
917 | Â { |
---|
918 |   if (i.exp() < degreeLC) |
---|
919 | Â Â { |
---|
920 | Â Â Â j++; |
---|
921 | Â Â Â break; |
---|
922 | Â Â } |
---|
923 | Â } |
---|
924 | |
---|
925 |  ASSERT ( j > 1, "j > 1 expected" ); |
---|
926 | |
---|
927 |  int* result = new int [j - 1]; |
---|
928 | Â sizeOfOutput=Â j -Â 1; |
---|
929 | |
---|
930 |  int i= 0; |
---|
931 |  for (CFIterator m = buf; i < j - 1; i++, m++) |
---|
932 | Â Â result [i]=Â m.exp(); |
---|
933 | |
---|
934 |  if (d > 1) |
---|
935 |   setCharacteristic (p, d, cGFName); |
---|
936 | Â else |
---|
937 |   setCharacteristic (p); |
---|
938 |  return result; |
---|
939 | } |
---|
940 | |
---|
941 | int * |
---|
942 | getLiftPrecisions (const CanonicalForm& F, int& sizeOfOutput, int degreeLC) |
---|
943 | { |
---|
944 |  int sizeOfNewtonPoly; |
---|
945 |  int ** newtonPolyg= newtonPolygon (F, sizeOfNewtonPoly); |
---|
946 |  int sizeOfRightSide; |
---|
947 |  int * rightSide= getRightSide(newtonPolyg, sizeOfNewtonPoly, sizeOfRightSide); |
---|
948 |  int * result= getCombinations(rightSide, sizeOfRightSide, sizeOfOutput, |
---|
949 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â degreeLC); |
---|
950 |  delete [] rightSide; |
---|
951 |  for (int i= 0; i < sizeOfNewtonPoly; i++) |
---|
952 |   delete [] newtonPolyg[i]; |
---|
953 |  delete [] newtonPolyg; |
---|
954 |  return result; |
---|
955 | } |
---|
956 | |
---|
957 | void |
---|
958 | deleteFactors (CFList& factors, int* factorsFoundIndex) |
---|
959 | { |
---|
960 | Â CFList result; |
---|
961 |  int i= 0; |
---|
962 |  for (CFListIterator iter= factors; iter.hasItem(); iter++, i++) |
---|
963 | Â { |
---|
964 |   if (factorsFoundIndex[i] == 1) |
---|
965 | Â Â Â continue; |
---|
966 | Â Â else |
---|
967 | Â Â Â result.append (iter.getItem()); |
---|
968 | Â } |
---|
969 | Â factors=Â result; |
---|
970 | } |
---|
971 | |
---|
972 | CFList |
---|
973 | henselLiftAndEarly (CanonicalForm& A, bool& earlySuccess, CFList& |
---|
974 |           earlyFactors, DegreePattern& degs, int& liftBound, |
---|
975 |           const CFList& uniFactors, const ExtensionInfo& info, |
---|
976 |           const CanonicalForm& eval, modpk& b) |
---|
977 | { |
---|
978 | Â Variable alpha=Â info.getAlpha(); |
---|
979 | Â Variable beta=Â info.getBeta(); |
---|
980 | Â CanonicalForm gamma=Â info.getGamma(); |
---|
981 | Â CanonicalForm delta=Â info.getDelta(); |
---|
982 |  bool extension= info.isInExtension(); |
---|
983 | |
---|
984 |  int sizeOfLiftPre; |
---|
985 |  int * liftPre= getLiftPrecisions (A, sizeOfLiftPre, degree (LC (A, 1), 2)); |
---|
986 | |
---|
987 | Â Variable x=Â Variable (1); |
---|
988 | Â Variable y=Â Variable (2); |
---|
989 | Â CFArray Pi; |
---|
990 | Â CFList diophant; |
---|
991 | Â CFList bufUniFactors=Â uniFactors; |
---|
992 | Â CanonicalForm bufA=Â A; |
---|
993 | Â CanonicalForm lcA0=Â 0; |
---|
994 |  bool mipoHasDen= false; |
---|
995 |  if (getCharacteristic() == 0 && b.getp() != 0) |
---|
996 | Â { |
---|
997 |   if (alpha.level() == 1) |
---|
998 | Â Â { |
---|
999 |    lcA0= lc (A (0, 2)); |
---|
1000 | Â Â Â A *=Â b.inverse (lcA0); |
---|
1001 | Â Â Â A=Â b (A); |
---|
1002 |    for (CFListIterator i= bufUniFactors; i.hasItem(); i++) |
---|
1003 | Â Â Â Â i.getItem()=Â b (i.getItem()*b.inverse (lc (i.getItem()))); |
---|
1004 | Â Â } |
---|
1005 | Â Â else |
---|
1006 | Â Â { |
---|
1007 | Â Â Â lcA0=Â Lc (A (0,2)); |
---|
1008 | Â Â Â On (SW_RATIONAL); |
---|
1009 | Â Â Â mipoHasDen=Â !bCommonDen(getMipo(alpha)).isOne(); |
---|
1010 | Â Â Â Off (SW_RATIONAL); |
---|
1011 | Â Â Â CanonicalForm lcA0inverse=Â b.inverse (lcA0); |
---|
1012 | Â Â Â A *=Â lcA0inverse; |
---|
1013 | Â Â Â A=Â b (A); |
---|
1014 | Â Â Â // Lc of bufUniFactors is in Z |
---|
1015 |    for (CFListIterator i= bufUniFactors; i.hasItem(); i++) |
---|
1016 | Â Â Â Â i.getItem()=Â b (i.getItem()*b.inverse (lc (i.getItem()))); |
---|
1017 | Â Â } |
---|
1018 | Â } |
---|
1019 |  bufUniFactors.insert (LC (A, x)); |
---|
1020 |  CFMatrix M= CFMatrix (liftBound, bufUniFactors.length() - 1); |
---|
1021 | Â earlySuccess=Â false; |
---|
1022 |  int newLiftBound= 0; |
---|
1023 | |
---|
1024 |  int smallFactorDeg= tmin (11, liftPre [sizeOfLiftPre- 1] + 1);//this is a tunable parameter |
---|
1025 |  int dummy; |
---|
1026 |  int * factorsFoundIndex= new int [uniFactors.length()]; |
---|
1027 |  for (int i= 0; i < uniFactors.length(); i++) |
---|
1028 | Â Â factorsFoundIndex [i]=Â 0; |
---|
1029 | |
---|
1030 | Â CFList bufBufUniFactors; |
---|
1031 | Â Variable v=Â alpha; |
---|
1032 |  if (smallFactorDeg >= liftBound || degree (A,y) <= 4) |
---|
1033 |   henselLift12 (A, bufUniFactors, liftBound, Pi, diophant, M, b, true); |
---|
1034 |  else if (sizeOfLiftPre > 1 && sizeOfLiftPre < 30) |
---|
1035 | Â { |
---|
1036 |   henselLift12 (A, bufUniFactors, smallFactorDeg, Pi, diophant, M, b, true); |
---|
1037 |   if (mipoHasDen) |
---|
1038 | Â Â { |
---|
1039 |    for (CFListIterator iter= bufUniFactors; iter.hasItem(); iter++) |
---|
1040 |     if (hasFirstAlgVar (iter.getItem(), v)) |
---|
1041 | Â Â Â Â Â break; |
---|
1042 |    if (v != alpha) |
---|
1043 | Â Â Â { |
---|
1044 | Â Â Â Â bufBufUniFactors=Â bufUniFactors; |
---|
1045 |     for (CFListIterator iter= bufBufUniFactors; iter.hasItem(); iter++) |
---|
1046 |      iter.getItem()= replacevar (iter.getItem(), v, alpha); |
---|
1047 |     A= replacevar (A, alpha, v); |
---|
1048 | Â Â Â } |
---|
1049 | Â Â } |
---|
1050 | |
---|
1051 |   if (!extension) |
---|
1052 | Â Â { |
---|
1053 |    if (v==alpha) |
---|
1054 |     earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound, |
---|
1055 |                factorsFoundIndex, degs, earlySuccess, |
---|
1056 |                smallFactorDeg, b); |
---|
1057 | Â Â Â else |
---|
1058 |     earlyFactorDetection(earlyFactors, bufA, bufBufUniFactors, newLiftBound, |
---|
1059 |                factorsFoundIndex, degs, earlySuccess, |
---|
1060 |                smallFactorDeg, b); |
---|
1061 | Â Â } |
---|
1062 | Â Â else |
---|
1063 |    extEarlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound, |
---|
1064 |                 factorsFoundIndex, degs, earlySuccess, info, |
---|
1065 |                 eval, smallFactorDeg); |
---|
1066 |   if (degs.getLength() > 1 && !earlySuccess && |
---|
1067 | Â Â Â Â smallFactorDeg !=Â liftPre [sizeOfLiftPre-1]Â +Â 1) |
---|
1068 | Â Â { |
---|
1069 |    if (newLiftBound >= liftPre[sizeOfLiftPre-1]+1) |
---|
1070 | Â Â Â { |
---|
1071 |     bufUniFactors.insert (LC (A, x)); |
---|
1072 |     henselLiftResume12 (A, bufUniFactors, smallFactorDeg, |
---|
1073 |               liftPre[sizeOfLiftPre-1] + 1, Pi, diophant, M, b); |
---|
1074 |     if (v!=alpha) |
---|
1075 | Â Â Â Â { |
---|
1076 | Â Â Â Â Â bufBufUniFactors=Â bufUniFactors; |
---|
1077 |      for (CFListIterator iter= bufBufUniFactors; iter.hasItem(); iter++) |
---|
1078 |       iter.getItem()= replacevar (iter.getItem(), v, alpha); |
---|
1079 | Â Â Â Â } |
---|
1080 |     if (!extension) |
---|
1081 | Â Â Â Â { |
---|
1082 |      if (v==alpha) |
---|
1083 |      earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound, |
---|
1084 |                 factorsFoundIndex, degs, earlySuccess, |
---|
1085 |                 liftPre[sizeOfLiftPre-1] + 1, b); |
---|
1086 | Â Â Â Â Â else |
---|
1087 | Â Â Â Â Â earlyFactorDetection (earlyFactors,bufA,bufBufUniFactors,newLiftBound, |
---|
1088 |                 factorsFoundIndex, degs, earlySuccess, |
---|
1089 |                 liftPre[sizeOfLiftPre-1] + 1, b); |
---|
1090 | Â Â Â Â } |
---|
1091 | Â Â Â Â else |
---|
1092 | Â Â Â Â Â extEarlyFactorDetection (earlyFactors,bufA,bufUniFactors,newLiftBound, |
---|
1093 |                   factorsFoundIndex, degs, earlySuccess, info, |
---|
1094 |                   eval, liftPre[sizeOfLiftPre-1] + 1); |
---|
1095 | Â Â Â } |
---|
1096 | Â Â } |
---|
1097 |   else if (earlySuccess) |
---|
1098 | Â Â Â liftBound=Â newLiftBound; |
---|
1099 | |
---|
1100 |   int i= sizeOfLiftPre - 1; |
---|
1101 |   while (degs.getLength() > 1 && !earlySuccess && i - 1 >= 0) |
---|
1102 | Â Â { |
---|
1103 |    if (newLiftBound >= liftPre[i] + 1) |
---|
1104 | Â Â Â { |
---|
1105 |     bufUniFactors.insert (LC (A, x)); |
---|
1106 |     henselLiftResume12 (A, bufUniFactors, liftPre[i] + 1, |
---|
1107 |               liftPre[i-1] + 1, Pi, diophant, M, b); |
---|
1108 |     if (v!=alpha) |
---|
1109 | Â Â Â Â { |
---|
1110 | Â Â Â Â Â bufBufUniFactors=Â bufUniFactors; |
---|
1111 |      for (CFListIterator iter= bufBufUniFactors; iter.hasItem(); iter++) |
---|
1112 |       iter.getItem()= replacevar (iter.getItem(), v, alpha); |
---|
1113 | Â Â Â Â } |
---|
1114 |     if (!extension) |
---|
1115 | Â Â Â Â { |
---|
1116 |      if (v==alpha) |
---|
1117 |      earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound, |
---|
1118 |                 factorsFoundIndex, degs, earlySuccess, |
---|
1119 |                 liftPre[i-1] + 1, b); |
---|
1120 | Â Â Â Â Â else |
---|
1121 | Â Â Â Â Â earlyFactorDetection (earlyFactors,bufA,bufBufUniFactors,newLiftBound, |
---|
1122 |                 factorsFoundIndex, degs, earlySuccess, |
---|
1123 |                 liftPre[i-1] + 1, b); |
---|
1124 | Â Â Â Â } |
---|
1125 | Â Â Â Â else |
---|
1126 | Â Â Â Â Â extEarlyFactorDetection (earlyFactors,bufA,bufUniFactors,newLiftBound, |
---|
1127 |                   factorsFoundIndex, degs, earlySuccess, info, |
---|
1128 |                   eval, liftPre[i-1] + 1); |
---|
1129 | Â Â Â } |
---|
1130 | Â Â Â else |
---|
1131 | Â Â Â { |
---|
1132 | Â Â Â Â liftBound=Â newLiftBound; |
---|
1133 | Â Â Â Â break; |
---|
1134 | Â Â Â } |
---|
1135 | Â Â Â i--; |
---|
1136 | Â Â } |
---|
1137 |   if (earlySuccess) |
---|
1138 | Â Â Â liftBound=Â newLiftBound; |
---|
1139 | Â Â //after here all factors are lifted to liftPre[sizeOfLiftPre-1] |
---|
1140 | Â } |
---|
1141 | Â else |
---|
1142 | Â { |
---|
1143 |   henselLift12 (A, bufUniFactors, smallFactorDeg, Pi, diophant, M, b, true); |
---|
1144 |   if (mipoHasDen) |
---|
1145 | Â Â { |
---|
1146 |    for (CFListIterator iter= bufUniFactors; iter.hasItem(); iter++) |
---|
1147 |     if (hasFirstAlgVar (iter.getItem(), v)) |
---|
1148 | Â Â Â Â Â break; |
---|
1149 |    if (v != alpha) |
---|
1150 | Â Â Â { |
---|
1151 | Â Â Â Â bufBufUniFactors=Â bufUniFactors; |
---|
1152 |     for (CFListIterator iter= bufBufUniFactors; iter.hasItem(); iter++) |
---|
1153 |      iter.getItem()= replacevar (iter.getItem(), v, alpha); |
---|
1154 |     A= replacevar (A, alpha, v); |
---|
1155 | Â Â Â } |
---|
1156 | Â Â } |
---|
1157 |   if (!extension) |
---|
1158 | Â Â { |
---|
1159 |    if (v==alpha) |
---|
1160 |    earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound, |
---|
1161 |               factorsFoundIndex, degs, earlySuccess, |
---|
1162 |               smallFactorDeg, b); |
---|
1163 | Â Â Â else |
---|
1164 |    earlyFactorDetection (earlyFactors, bufA, bufBufUniFactors, newLiftBound, |
---|
1165 |               factorsFoundIndex, degs, earlySuccess, |
---|
1166 |               smallFactorDeg, b); |
---|
1167 | Â Â } |
---|
1168 | Â Â else |
---|
1169 |    extEarlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound, |
---|
1170 |                 factorsFoundIndex, degs, earlySuccess, info, |
---|
1171 |                 eval, smallFactorDeg); |
---|
1172 |   int i= 1; |
---|
1173 |   while ((degree (A,y)/4)*i + 4 <= smallFactorDeg) |
---|
1174 | Â Â Â i++; |
---|
1175 |   dummy= tmin (degree (A,y)+1, (degree (A,y)/4)*i+4); |
---|
1176 |   if (degs.getLength() > 1 && !earlySuccess && dummy > smallFactorDeg) |
---|
1177 | Â Â { |
---|
1178 |    bufUniFactors.insert (LC (A, x)); |
---|
1179 |    henselLiftResume12 (A, bufUniFactors, smallFactorDeg, |
---|
1180 |              dummy, Pi, diophant, M, b); |
---|
1181 |    if (v!=alpha) |
---|
1182 | Â Â Â { |
---|
1183 | Â Â Â Â bufBufUniFactors=Â bufUniFactors; |
---|
1184 |     for (CFListIterator iter= bufBufUniFactors; iter.hasItem(); iter++) |
---|
1185 |      iter.getItem()= replacevar (iter.getItem(), v, alpha); |
---|
1186 | Â Â Â } |
---|
1187 |    if (!extension) |
---|
1188 | Â Â Â { |
---|
1189 |     if (v==alpha) |
---|
1190 |     earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound, |
---|
1191 |                factorsFoundIndex, degs, earlySuccess, dummy, b); |
---|
1192 | Â Â Â Â else |
---|
1193 |     earlyFactorDetection (earlyFactors, bufA,bufBufUniFactors, newLiftBound, |
---|
1194 |                factorsFoundIndex, degs, earlySuccess, dummy, b); |
---|
1195 | Â Â Â } |
---|
1196 | Â Â Â else |
---|
1197 |     extEarlyFactorDetection (earlyFactors, bufA,bufUniFactors, newLiftBound, |
---|
1198 |                  factorsFoundIndex, degs, earlySuccess, info, |
---|
1199 |                  eval, dummy); |
---|
1200 | Â Â } |
---|
1201 |   while (degs.getLength() > 1 && !earlySuccess && i < 4) |
---|
1202 | Â Â { |
---|
1203 |    if (newLiftBound >= dummy) |
---|
1204 | Â Â Â { |
---|
1205 |     bufUniFactors.insert (LC (A, x)); |
---|
1206 |     dummy= tmin (degree (A,y)+1, (degree (A,y)/4)*(i+1)+4); |
---|
1207 |     henselLiftResume12 (A, bufUniFactors, (degree (A,y)/4)*i + 4, |
---|
1208 |               dummy, Pi, diophant, M, b); |
---|
1209 |     if (v!=alpha) |
---|
1210 | Â Â Â Â { |
---|
1211 | Â Â Â Â Â bufBufUniFactors=Â bufUniFactors; |
---|
1212 |      for (CFListIterator iter= bufBufUniFactors; iter.hasItem(); iter++) |
---|
1213 |       iter.getItem()= replacevar (iter.getItem(), v, alpha); |
---|
1214 | Â Â Â Â } |
---|
1215 |     if (!extension) |
---|
1216 | Â Â Â Â { |
---|
1217 |      if (v==alpha) |
---|
1218 |      earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound, |
---|
1219 |                 factorsFoundIndex, degs, earlySuccess, dummy,b); |
---|
1220 | Â Â Â Â Â else |
---|
1221 |      earlyFactorDetection (earlyFactors,bufA,bufBufUniFactors,newLiftBound, |
---|
1222 |                 factorsFoundIndex, degs, earlySuccess, dummy,b); |
---|
1223 | Â Â Â Â } |
---|
1224 | Â Â Â Â else |
---|
1225 | Â Â Â Â Â extEarlyFactorDetection (earlyFactors,bufA,bufUniFactors,newLiftBound, |
---|
1226 |                   factorsFoundIndex, degs, earlySuccess, info, |
---|
1227 |                   eval, dummy); |
---|
1228 | Â Â Â } |
---|
1229 | Â Â Â else |
---|
1230 | Â Â Â { |
---|
1231 | Â Â Â Â liftBound=Â newLiftBound; |
---|
1232 | Â Â Â Â break; |
---|
1233 | Â Â Â } |
---|
1234 | Â Â Â i++; |
---|
1235 | Â Â } |
---|
1236 |   if (earlySuccess) |
---|
1237 | Â Â Â liftBound=Â newLiftBound; |
---|
1238 | Â } |
---|
1239 | |
---|
1240 | Â A=Â bufA; |
---|
1241 |  if (earlyFactors.length() > 0 && degs.getLength() > 1) |
---|
1242 | Â { |
---|
1243 | Â Â liftBound=Â degree (A,y)Â +Â 1; |
---|
1244 | Â Â earlySuccess=Â true; |
---|
1245 |   deleteFactors (bufUniFactors, factorsFoundIndex); |
---|
1246 | Â } |
---|
1247 | |
---|
1248 |  delete [] factorsFoundIndex; |
---|
1249 |  delete [] liftPre; |
---|
1250 | |
---|
1251 |  return bufUniFactors; |
---|
1252 | } |
---|
1253 | |
---|
1254 | CFList |
---|
1255 | henselLiftAndEarly (CanonicalForm& A, bool& earlySuccess, CFList& |
---|
1256 |           earlyFactors, DegreePattern& degs, int& liftBound, |
---|
1257 |           const CFList& uniFactors, const ExtensionInfo& info, |
---|
1258 |           const CanonicalForm& eval) |
---|
1259 | { |
---|
1260 | Â modpk dummy=Â modpk(); |
---|
1261 |  return henselLiftAndEarly (A, earlySuccess, earlyFactors, degs, liftBound, |
---|
1262 |                uniFactors, info, eval, dummy); |
---|
1263 | } |
---|
1264 | |
---|
1265 | long isReduced (const mat_zz_p& M) |
---|
1266 | { |
---|
1267 |  long i, j, nonZero; |
---|
1268 |  for (i = 1; i <= M.NumRows(); i++) |
---|
1269 | Â { |
---|
1270 | Â Â nonZero=Â 0; |
---|
1271 |   for (j = 1; j <= M.NumCols(); j++) |
---|
1272 | Â Â { |
---|
1273 |    if (!IsZero (M (i,j))) |
---|
1274 | Â Â Â Â nonZero++; |
---|
1275 | Â Â } |
---|
1276 |   if (nonZero != 1) |
---|
1277 |    return 0; |
---|
1278 | Â } |
---|
1279 |  return 1; |
---|
1280 | } |
---|
1281 | |
---|
1282 | #ifdef HAVE_FLINT |
---|
1283 | long isReduced (const nmod_mat_t M) |
---|
1284 | { |
---|
1285 |  long i, j, nonZero; |
---|
1286 |  for (i = 1; i <= nmod_mat_nrows(M); i++) |
---|
1287 | Â { |
---|
1288 | Â Â nonZero=Â 0; |
---|
1289 |   for (j = 1; j <= nmod_mat_ncols (M); j++) |
---|
1290 | Â Â { |
---|
1291 |    if (!(nmod_mat_entry (M, i-1, j-1)==0)) |
---|
1292 | Â Â Â Â nonZero++; |
---|
1293 | Â Â } |
---|
1294 |   if (nonZero != 1) |
---|
1295 |    return 0; |
---|
1296 | Â } |
---|
1297 |  return 1; |
---|
1298 | } |
---|
1299 | #endif |
---|
1300 | |
---|
1301 | long isReduced (const mat_zz_pE& M) |
---|
1302 | { |
---|
1303 |  long i, j, nonZero; |
---|
1304 |  for (i = 1; i <= M.NumRows(); i++) |
---|
1305 | Â { |
---|
1306 | Â Â nonZero=Â 0; |
---|
1307 |   for (j = 1; j <= M.NumCols(); j++) |
---|
1308 | Â Â { |
---|
1309 |    if (!IsZero (M (i,j))) |
---|
1310 | Â Â Â Â nonZero++; |
---|
1311 | Â Â } |
---|
1312 |   if (nonZero != 1) |
---|
1313 |    return 0; |
---|
1314 | Â } |
---|
1315 |  return 1; |
---|
1316 | } |
---|
1317 | |
---|
1318 | int * extractZeroOneVecs (const mat_zz_p& M) |
---|
1319 | { |
---|
1320 |  long i, j; |
---|
1321 |  bool nonZeroOne= false; |
---|
1322 |  int * result= new int [M.NumCols()]; |
---|
1323 |  for (i = 1; i <= M.NumCols(); i++) |
---|
1324 | Â { |
---|
1325 |   for (j = 1; j <= M.NumRows(); j++) |
---|
1326 | Â Â { |
---|
1327 |    if (!(IsOne (M (j,i)) || IsZero (M (j,i)))) |
---|
1328 | Â Â Â { |
---|
1329 | Â Â Â Â nonZeroOne=Â true; |
---|
1330 | Â Â Â Â break; |
---|
1331 | Â Â Â } |
---|
1332 | Â Â } |
---|
1333 |   if (!nonZeroOne) |
---|
1334 | Â Â Â result [i -Â 1]=Â 1; |
---|
1335 | Â Â else |
---|
1336 | Â Â Â result [i -Â 1]=Â 0; |
---|
1337 | Â Â nonZeroOne=Â false; |
---|
1338 | Â } |
---|
1339 |  return result; |
---|
1340 | } |
---|
1341 | |
---|
1342 | #ifdef HAVE_FLINT |
---|
1343 | int * extractZeroOneVecs (const nmod_mat_t M) |
---|
1344 | { |
---|
1345 |  long i, j; |
---|
1346 |  bool nonZeroOne= false; |
---|
1347 |  int * result= new int [nmod_mat_ncols (M)]; |
---|
1348 |  for (i = 0; i < nmod_mat_ncols (M); i++) |
---|
1349 | Â { |
---|
1350 |   for (j = 0; j < nmod_mat_nrows (M); j++) |
---|
1351 | Â Â { |
---|
1352 |    if (!((nmod_mat_entry (M, j, i) == 1) || (nmod_mat_entry (M, j,i) == 0))) |
---|
1353 | Â Â Â { |
---|
1354 | Â Â Â Â nonZeroOne=Â true; |
---|
1355 | Â Â Â Â break; |
---|
1356 | Â Â Â } |
---|
1357 | Â Â } |
---|
1358 |   if (!nonZeroOne) |
---|
1359 | Â Â Â result [i]=Â 1; |
---|
1360 | Â Â else |
---|
1361 | Â Â Â result [i]=Â 0; |
---|
1362 | Â Â nonZeroOne=Â false; |
---|
1363 | Â } |
---|
1364 |  return result; |
---|
1365 | } |
---|
1366 | #endif |
---|
1367 | |
---|
1368 | int * extractZeroOneVecs (const mat_zz_pE& M) |
---|
1369 | { |
---|
1370 |  long i, j; |
---|
1371 |  bool nonZeroOne= false; |
---|
1372 |  int * result= new int [M.NumCols()]; |
---|
1373 |  for (i = 1; i <= M.NumCols(); i++) |
---|
1374 | Â { |
---|
1375 |   for (j = 1; j <= M.NumRows(); j++) |
---|
1376 | Â Â { |
---|
1377 |    if (!(IsOne (M (j,i)) || IsZero (M (j,i)))) |
---|
1378 | Â Â Â { |
---|
1379 | Â Â Â Â nonZeroOne=Â true; |
---|
1380 | Â Â Â Â break; |
---|
1381 | Â Â Â } |
---|
1382 | Â Â } |
---|
1383 |   if (!nonZeroOne) |
---|
1384 | Â Â Â result [i -Â 1]=Â 1; |
---|
1385 | Â Â else |
---|
1386 | Â Â Â result [i -Â 1]=Â 0; |
---|
1387 | Â Â nonZeroOne=Â false; |
---|
1388 | Â } |
---|
1389 |  return result; |
---|
1390 | } |
---|
1391 | |
---|
1392 | void |
---|
1393 | reconstructionTry (CFList& reconstructedFactors, CanonicalForm& F, const CFList& |
---|
1394 |           factors, const int liftBound, int& factorsFound, int*& |
---|
1395 |           factorsFoundIndex, mat_zz_pE& N, bool beenInThres |
---|
1396 | Â Â Â Â Â Â Â Â Â ) |
---|
1397 | { |
---|
1398 | Â Variable y=Â Variable (2); |
---|
1399 | Â Variable x=Â Variable (1); |
---|
1400 |  CanonicalForm yToL= power (y, liftBound); |
---|
1401 |  if (factors.length() == 2) |
---|
1402 | Â { |
---|
1403 |   CanonicalForm tmp1, tmp2, tmp3; |
---|
1404 | Â Â tmp1=Â factors.getFirst(); |
---|
1405 | Â Â tmp2=Â factors.getLast(); |
---|
1406 |   tmp1 *= LC (F, x); |
---|
1407 |   tmp1= mod (tmp1, yToL); |
---|
1408 |   tmp1 /= content (tmp1, x); |
---|
1409 |   tmp2 *= LC (F, x); |
---|
1410 |   tmp2= mod (tmp2, yToL); |
---|
1411 |   tmp2 /= content (tmp2, x); |
---|
1412 | Â Â tmp3 =Â tmp1*tmp2; |
---|
1413 |   if (tmp3/Lc (tmp3) == F/Lc (F)) |
---|
1414 | Â Â { |
---|
1415 | Â Â Â factorsFound++; |
---|
1416 | Â Â Â F=Â 1; |
---|
1417 | Â Â Â reconstructedFactors.append (tmp1); |
---|
1418 | Â Â Â reconstructedFactors.append (tmp2); |
---|
1419 | Â Â Â return; |
---|
1420 | Â Â } |
---|
1421 | Â } |
---|
1422 |  CanonicalForm quot, buf; |
---|
1423 | Â CFListIterator iter; |
---|
1424 |  for (long i= 1; i <= N.NumCols(); i++) |
---|
1425 | Â { |
---|
1426 |   if (factorsFoundIndex [i - 1] == 1) |
---|
1427 | Â Â Â continue; |
---|
1428 | Â Â iter=Â factors; |
---|
1429 |   if (beenInThres) |
---|
1430 | Â Â { |
---|
1431 |    int count= 1; |
---|
1432 |    while (count < i) |
---|
1433 | Â Â Â { |
---|
1434 | Â Â Â Â count++; |
---|
1435 | Â Â Â Â iter++; |
---|
1436 | Â Â Â } |
---|
1437 | Â Â Â buf=Â iter.getItem(); |
---|
1438 | Â Â } |
---|
1439 | Â Â else |
---|
1440 | Â Â { |
---|
1441 | Â Â Â buf=Â 1; |
---|
1442 |    for (long j= 1; j <= N.NumRows(); j++, iter++) |
---|
1443 | Â Â Â { |
---|
1444 |     if (!IsZero (N (j,i))) |
---|
1445 |      buf= mulMod2 (buf, iter.getItem(), yToL); |
---|
1446 | Â Â Â } |
---|
1447 | Â Â } |
---|
1448 |   buf *= LC (F, x); |
---|
1449 |   buf= mod (buf, yToL); |
---|
1450 |   buf /= content (buf, x); |
---|
1451 |   if (fdivides (buf, F, quot)) |
---|
1452 | Â Â { |
---|
1453 | Â Â Â factorsFoundIndex[i -Â 1]=Â 1; |
---|
1454 | Â Â Â factorsFound++; |
---|
1455 | Â Â Â F=Â quot; |
---|
1456 | Â Â Â F /=Â Lc (F); |
---|
1457 | Â Â Â reconstructedFactors.append (buf); |
---|
1458 | Â Â } |
---|
1459 |   if (degree (F) <= 0) |
---|
1460 | Â Â Â return; |
---|
1461 |   if (factorsFound + 1 == N.NumCols()) |
---|
1462 | Â Â { |
---|
1463 | Â Â Â reconstructedFactors.append (F); |
---|
1464 | Â Â Â return; |
---|
1465 | Â Â } |
---|
1466 | Â } |
---|
1467 | } |
---|
1468 | |
---|
1469 | void |
---|
1470 | reconstructionTry (CFList& reconstructedFactors, CanonicalForm& F, const CFList& |
---|
1471 |           factors, const int liftBound, int& factorsFound, int*& |
---|
1472 |           factorsFoundIndex, mat_zz_p& N, bool beenInThres |
---|
1473 | Â Â Â Â Â Â Â Â Â ) |
---|
1474 | { |
---|
1475 | Â Variable y=Â Variable (2); |
---|
1476 | Â Variable x=Â Variable (1); |
---|
1477 |  CanonicalForm yToL= power (y, liftBound); |
---|
1478 |  if (factors.length() == 2) |
---|
1479 | Â { |
---|
1480 |   CanonicalForm tmp1, tmp2, tmp3; |
---|
1481 | Â Â tmp1=Â factors.getFirst(); |
---|
1482 | Â Â tmp2=Â factors.getLast(); |
---|
1483 |   tmp1 *= LC (F, x); |
---|
1484 |   tmp1= mod (tmp1, yToL); |
---|
1485 |   tmp1 /= content (tmp1, x); |
---|
1486 |   tmp2 *= LC (F, x); |
---|
1487 |   tmp2= mod (tmp2, yToL); |
---|
1488 |   tmp2 /= content (tmp2, x); |
---|
1489 | Â Â tmp3 =Â tmp1*tmp2; |
---|
1490 |   if (tmp3/Lc (tmp3) == F/Lc (F)) |
---|
1491 | Â Â { |
---|
1492 | Â Â Â factorsFound++; |
---|
1493 | Â Â Â F=Â 1; |
---|
1494 | Â Â Â reconstructedFactors.append (tmp1); |
---|
1495 | Â Â Â reconstructedFactors.append (tmp2); |
---|
1496 | Â Â Â return; |
---|
1497 | Â Â } |
---|
1498 | Â } |
---|
1499 |  CanonicalForm quot, buf; |
---|
1500 | Â CFListIterator iter; |
---|
1501 |  for (long i= 1; i <= N.NumCols(); i++) |
---|
1502 | Â { |
---|
1503 |   if (factorsFoundIndex [i - 1] == 1) |
---|
1504 | Â Â Â continue; |
---|
1505 | Â Â iter=Â factors; |
---|
1506 |   if (beenInThres) |
---|
1507 | Â Â { |
---|
1508 |    int count= 1; |
---|
1509 |    while (count < i) |
---|
1510 | Â Â Â { |
---|
1511 | Â Â Â Â count++; |
---|
1512 | Â Â Â Â iter++; |
---|
1513 | Â Â Â } |
---|
1514 | Â Â Â buf=Â iter.getItem(); |
---|
1515 | Â Â } |
---|
1516 | Â Â else |
---|
1517 | Â Â { |
---|
1518 | Â Â Â buf=Â 1; |
---|
1519 |    for (long j= 1; j <= N.NumRows(); j++, iter++) |
---|
1520 | Â Â Â { |
---|
1521 |     if (!IsZero (N (j,i))) |
---|
1522 |      buf= mulMod2 (buf, iter.getItem(), yToL); |
---|
1523 | Â Â Â } |
---|
1524 | Â Â } |
---|
1525 |   buf *= LC (F, x); |
---|
1526 |   buf= mod (buf, yToL); |
---|
1527 |   buf /= content (buf, x); |
---|
1528 |   if (fdivides (buf, F, quot)) |
---|
1529 | Â Â { |
---|
1530 | Â Â Â factorsFoundIndex[i -Â 1]=Â 1; |
---|
1531 | Â Â Â factorsFound++; |
---|
1532 | Â Â Â F=Â quot; |
---|
1533 | Â Â Â F /=Â Lc (F); |
---|
1534 | Â Â Â reconstructedFactors.append (buf); |
---|
1535 | Â Â } |
---|
1536 |   if (degree (F) <= 0) |
---|
1537 | Â Â Â return; |
---|
1538 |   if (factorsFound + 1 == N.NumCols()) |
---|
1539 | Â Â { |
---|
1540 | Â Â Â reconstructedFactors.append (F); |
---|
1541 | Â Â Â return; |
---|
1542 | Â Â } |
---|
1543 | Â } |
---|
1544 | } |
---|
1545 | |
---|
1546 | #ifdef HAVE_FLINT |
---|
1547 | void |
---|
1548 | reconstructionTry (CFList& reconstructedFactors, CanonicalForm& F, const CFList& |
---|
1549 |           factors, const int liftBound, int& factorsFound, int*& |
---|
1550 |           factorsFoundIndex, nmod_mat_t N, bool beenInThres |
---|
1551 | Â Â Â Â Â Â Â Â Â ) |
---|
1552 | { |
---|
1553 | Â Variable y=Â Variable (2); |
---|
1554 | Â Variable x=Â Variable (1); |
---|
1555 |  CanonicalForm yToL= power (y, liftBound); |
---|
1556 |  if (factors.length() == 2) |
---|
1557 | Â { |
---|
1558 |   CanonicalForm tmp1, tmp2, tmp3; |
---|
1559 | Â Â tmp1=Â factors.getFirst(); |
---|
1560 | Â Â tmp2=Â factors.getLast(); |
---|
1561 |   tmp1 *= LC (F, x); |
---|
1562 |   tmp1= mod (tmp1, yToL); |
---|
1563 |   tmp1 /= content (tmp1, x); |
---|
1564 |   tmp2 *= LC (F, x); |
---|
1565 |   tmp2= mod (tmp2, yToL); |
---|
1566 |   tmp2 /= content (tmp2, x); |
---|
1567 | Â Â tmp3 =Â tmp1*tmp2; |
---|
1568 |   if (tmp3/Lc (tmp3) == F/Lc (F)) |
---|
1569 | Â Â { |
---|
1570 | Â Â Â factorsFound++; |
---|
1571 | Â Â Â F=Â 1; |
---|
1572 | Â Â Â reconstructedFactors.append (tmp1); |
---|
1573 | Â Â Â reconstructedFactors.append (tmp2); |
---|
1574 | Â Â Â return; |
---|
1575 | Â Â } |
---|
1576 | Â } |
---|
1577 |  CanonicalForm quot, buf; |
---|
1578 | Â CFListIterator iter; |
---|
1579 |  for (long i= 0; i < nmod_mat_ncols (N); i++) |
---|
1580 | Â { |
---|
1581 |   if (factorsFoundIndex [i] == 1) |
---|
1582 | Â Â Â continue; |
---|
1583 | Â Â iter=Â factors; |
---|
1584 |   if (beenInThres) |
---|
1585 | Â Â { |
---|
1586 |    int count= 0; |
---|
1587 |    while (count < i) |
---|
1588 | Â Â Â { |
---|
1589 | Â Â Â Â count++; |
---|
1590 | Â Â Â Â iter++; |
---|
1591 | Â Â Â } |
---|
1592 | Â Â Â buf=Â iter.getItem(); |
---|
1593 | Â Â } |
---|
1594 | Â Â else |
---|
1595 | Â Â { |
---|
1596 | Â Â Â buf=Â 1; |
---|
1597 |    for (long j= 0; j < nmod_mat_nrows (N); j++, iter++) |
---|
1598 | Â Â Â { |
---|
1599 |     if (!(nmod_mat_entry (N, j, i) == 0)) |
---|
1600 |      buf= mulMod2 (buf, iter.getItem(), yToL); |
---|
1601 | Â Â Â } |
---|
1602 | Â Â } |
---|
1603 |   buf *= LC (F, x); |
---|
1604 |   buf= mod (buf, yToL); |
---|
1605 |   buf /= content (buf, x); |
---|
1606 |   if (fdivides (buf, F, quot)) |
---|
1607 | Â Â { |
---|
1608 | Â Â Â factorsFoundIndex[i]=Â 1; |
---|
1609 | Â Â Â factorsFound++; |
---|
1610 | Â Â Â F=Â quot; |
---|
1611 | Â Â Â F /=Â Lc (F); |
---|
1612 | Â Â Â reconstructedFactors.append (buf); |
---|
1613 | Â Â } |
---|
1614 |   if (degree (F) <= 0) |
---|
1615 | Â Â Â return; |
---|
1616 |   if (factorsFound + 1 == nmod_mat_ncols (N)) |
---|
1617 | Â Â { |
---|
1618 | Â Â Â reconstructedFactors.append (F); |
---|
1619 | Â Â Â return; |
---|
1620 | Â Â } |
---|
1621 | Â } |
---|
1622 | } |
---|
1623 | #endif |
---|
1624 | |
---|
1625 | CFList |
---|
1626 | reconstruction (CanonicalForm& G, CFList& factors, int* zeroOneVecs, int |
---|
1627 |         precision, const mat_zz_pE& N |
---|
1628 | Â Â Â Â Â Â Â Â ) |
---|
1629 | { |
---|
1630 | Â Variable y=Â Variable (2); |
---|
1631 | Â Variable x=Â Variable (1); |
---|
1632 | Â CanonicalForm F=Â G; |
---|
1633 |  CanonicalForm yToL= power (y, precision); |
---|
1634 |  CanonicalForm quot, buf; |
---|
1635 |  CFList result, factorsConsidered; |
---|
1636 | Â CFList bufFactors=Â factors; |
---|
1637 | Â CFListIterator iter; |
---|
1638 |  for (long i= 1; i <= N.NumCols(); i++) |
---|
1639 | Â { |
---|
1640 |   if (zeroOneVecs [i - 1] == 0) |
---|
1641 | Â Â Â continue; |
---|
1642 | Â Â iter=Â factors; |
---|
1643 | Â Â buf=Â 1; |
---|
1644 | Â Â factorsConsidered=Â CFList(); |
---|
1645 |   for (long j= 1; j <= N.NumRows(); j++, iter++) |
---|
1646 | Â Â { |
---|
1647 |    if (!IsZero (N (j,i))) |
---|
1648 | Â Â Â { |
---|
1649 | Â Â Â Â factorsConsidered.append (iter.getItem()); |
---|
1650 |     buf= mulMod2 (buf, iter.getItem(), yToL); |
---|
1651 | Â Â Â } |
---|
1652 | Â Â } |
---|
1653 |   buf *= LC (F, x); |
---|
1654 |   buf= mod (buf, yToL); |
---|
1655 |   buf /= content (buf, x); |
---|
1656 |   if (fdivides (buf, F, quot)) |
---|
1657 | Â Â { |
---|
1658 | Â Â Â F=Â quot; |
---|
1659 | Â Â Â F /=Â Lc (F); |
---|
1660 | Â Â Â result.append (buf); |
---|
1661 |    bufFactors= Difference (bufFactors, factorsConsidered); |
---|
1662 | Â Â } |
---|
1663 |   if (degree (F) <= 0) |
---|
1664 | Â Â { |
---|
1665 | Â Â Â G=Â F; |
---|
1666 | Â Â Â factors=Â bufFactors; |
---|
1667 |    return result; |
---|
1668 | Â Â } |
---|
1669 | Â } |
---|
1670 | Â G=Â F; |
---|
1671 | Â factors=Â bufFactors; |
---|
1672 |  return result; |
---|
1673 | } |
---|
1674 | |
---|
1675 | CFList |
---|
1676 | monicReconstruction (CanonicalForm& G, CFList& factors, int* zeroOneVecs, |
---|
1677 |            int precision, const mat_zz_pE& N |
---|
1678 | Â Â Â Â Â Â Â Â Â Â ) |
---|
1679 | { |
---|
1680 | Â Variable y=Â Variable (2); |
---|
1681 | Â Variable x=Â Variable (1); |
---|
1682 | Â CanonicalForm F=Â G; |
---|
1683 |  CanonicalForm yToL= power (y, precision); |
---|
1684 |  CanonicalForm quot, buf, buf2; |
---|
1685 | Â CFList result; |
---|
1686 | Â CFList bufFactors=Â factors; |
---|
1687 | Â CFList factorsConsidered; |
---|
1688 | Â CFListIterator iter; |
---|
1689 |  for (long i= 1; i <= N.NumCols(); i++) |
---|
1690 | Â { |
---|
1691 |   if (zeroOneVecs [i - 1] == 0) |
---|
1692 | Â Â Â continue; |
---|
1693 | Â Â iter=Â factors; |
---|
1694 | Â Â buf=Â 1; |
---|
1695 | Â Â factorsConsidered=Â CFList(); |
---|
1696 |   for (long j= 1; j <= N.NumRows(); j++, iter++) |
---|
1697 | Â Â { |
---|
1698 |    if (!IsZero (N (j,i))) |
---|
1699 | Â Â Â { |
---|
1700 | Â Â Â Â factorsConsidered.append (iter.getItem()); |
---|
1701 |     buf= mulMod2 (buf, iter.getItem(), yToL); |
---|
1702 | Â Â Â } |
---|
1703 | Â Â } |
---|
1704 | Â Â buf2=Â buf; |
---|
1705 |   buf *= LC (F, x); |
---|
1706 |   buf= mod (buf, yToL); |
---|
1707 |   buf /= content (buf, x); |
---|
1708 |   if (fdivides (buf, F, quot)) |
---|
1709 | Â Â { |
---|
1710 | Â Â Â F=Â quot; |
---|
1711 | Â Â Â F /=Â Lc (F); |
---|
1712 | Â Â Â result.append (buf2); |
---|
1713 |    bufFactors= Difference (bufFactors, factorsConsidered); |
---|
1714 | Â Â } |
---|
1715 |   if (degree (F) <= 0) |
---|
1716 | Â Â { |
---|
1717 | Â Â Â G=Â F; |
---|
1718 | Â Â Â factors=Â bufFactors; |
---|
1719 |    return result; |
---|
1720 | Â Â } |
---|
1721 | Â } |
---|
1722 | Â G=Â F; |
---|
1723 | Â factors=Â bufFactors; |
---|
1724 |  return result; |
---|
1725 | } |
---|
1726 | |
---|
1727 | CFList |
---|
1728 | extReconstruction (CanonicalForm& G, CFList& factors, int* zeroOneVecs, int |
---|
1729 |           precision, const mat_zz_p& N, const ExtensionInfo& info, |
---|
1730 |           const CanonicalForm& evaluation |
---|
1731 | Â Â Â Â Â Â Â Â Â ) |
---|
1732 | { |
---|
1733 | Â Variable y=Â Variable (2); |
---|
1734 | Â Variable x=Â Variable (1); |
---|
1735 | Â Variable alpha=Â info.getAlpha(); |
---|
1736 | Â Variable beta=Â info.getBeta(); |
---|
1737 |  int k= info.getGFDegree(); |
---|
1738 | Â CanonicalForm gamma=Â info.getGamma(); |
---|
1739 | Â CanonicalForm delta=Â info.getDelta(); |
---|
1740 | Â CanonicalForm F=Â G; |
---|
1741 |  CanonicalForm yToL= power (y, precision); |
---|
1742 | Â CFList result; |
---|
1743 | Â CFList bufFactors=Â factors; |
---|
1744 | Â CFList factorsConsidered; |
---|
1745 |  CanonicalForm buf2, quot, buf; |
---|
1746 | Â CFListIterator iter; |
---|
1747 |  for (long i= 1; i <= N.NumCols(); i++) |
---|
1748 | Â { |
---|
1749 |   if (zeroOneVecs [i - 1] == 0) |
---|
1750 | Â Â Â continue; |
---|
1751 | Â Â iter=Â factors; |
---|
1752 | Â Â buf=Â 1; |
---|
1753 | Â Â factorsConsidered=Â CFList(); |
---|
1754 |   for (long j= 1; j <= N.NumRows(); j++, iter++) |
---|
1755 | Â Â { |
---|
1756 |    if (!IsZero (N (j,i))) |
---|
1757 | Â Â Â { |
---|
1758 | Â Â Â Â factorsConsidered.append (iter.getItem()); |
---|
1759 |     buf= mulMod2 (buf, iter.getItem(), yToL); |
---|
1760 | Â Â Â } |
---|
1761 | Â Â } |
---|
1762 |   buf *= LC (F, x); |
---|
1763 |   buf= mod (buf, yToL); |
---|
1764 |   buf /= content (buf, x); |
---|
1765 |   buf2= buf (y-evaluation, y); |
---|
1766 |   if (!k && beta == x) |
---|
1767 | Â Â { |
---|
1768 |    if (degree (buf2, alpha) < 1) |
---|
1769 | Â Â Â { |
---|
1770 |     if (fdivides (buf, F, quot)) |
---|
1771 | Â Â Â Â { |
---|
1772 | Â Â Â Â Â F=Â quot; |
---|
1773 | Â Â Â Â Â F /=Â Lc (F); |
---|
1774 | Â Â Â Â Â result.append (buf2); |
---|
1775 |      bufFactors= Difference (bufFactors, factorsConsidered); |
---|
1776 | Â Â Â Â } |
---|
1777 | Â Â Â } |
---|
1778 | Â Â } |
---|
1779 | Â Â else |
---|
1780 | Â Â { |
---|
1781 |    CFList source, dest; |
---|
1782 | |
---|
1783 |    if (!isInExtension (buf2, gamma, k, delta, source, dest)) |
---|
1784 | Â Â Â { |
---|
1785 |     if (fdivides (buf, F, quot)) |
---|
1786 | Â Â Â Â { |
---|
1787 | Â Â Â Â Â F=Â quot; |
---|
1788 | Â Â Â Â Â F /=Â Lc (F); |
---|
1789 | Â Â Â Â Â result.append (buf2); |
---|
1790 |      bufFactors= Difference (bufFactors, factorsConsidered); |
---|
1791 | Â Â Â Â } |
---|
1792 | Â Â Â } |
---|
1793 | Â Â } |
---|
1794 |   if (degree (F) <= 0) |
---|
1795 | Â Â { |
---|
1796 | Â Â Â G=Â F; |
---|
1797 | Â Â Â factors=Â bufFactors; |
---|
1798 |    return result; |
---|
1799 | Â Â } |
---|
1800 | Â } |
---|
1801 | Â G=Â F; |
---|
1802 | Â factors=Â bufFactors; |
---|
1803 |  return result; |
---|
1804 | } |
---|
1805 | |
---|
1806 | #ifdef HAVE_FLINT |
---|
1807 | CFList |
---|
1808 | extReconstruction (CanonicalForm& G, CFList& factors, int* zeroOneVecs, int |
---|
1809 |           precision, const nmod_mat_t N, const ExtensionInfo& info, |
---|
1810 |           const CanonicalForm& evaluation |
---|
1811 | Â Â Â Â Â Â Â Â Â ) |
---|
1812 | { |
---|
1813 | Â Variable y=Â Variable (2); |
---|
1814 | Â Variable x=Â Variable (1); |
---|
1815 | Â Variable alpha=Â info.getAlpha(); |
---|
1816 | Â Variable beta=Â info.getBeta(); |
---|
1817 |  int k= info.getGFDegree(); |
---|
1818 | Â CanonicalForm gamma=Â info.getGamma(); |
---|
1819 | Â CanonicalForm delta=Â info.getDelta(); |
---|
1820 | Â CanonicalForm F=Â G; |
---|
1821 |  CanonicalForm yToL= power (y, precision); |
---|
1822 | Â CFList result; |
---|
1823 | Â CFList bufFactors=Â factors; |
---|
1824 | Â CFList factorsConsidered; |
---|
1825 |  CanonicalForm buf2, quot, buf; |
---|
1826 | Â CFListIterator iter; |
---|
1827 |  for (long i= 0; i < nmod_mat_ncols(N); i++) |
---|
1828 | Â { |
---|
1829 |   if (zeroOneVecs [i] == 0) |
---|
1830 | Â Â Â continue; |
---|
1831 | Â Â iter=Â factors; |
---|
1832 | Â Â buf=Â 1; |
---|
1833 | Â Â factorsConsidered=Â CFList(); |
---|
1834 |   for (long j= 0; j < nmod_mat_ncols(N); j++, iter++) |
---|
1835 | Â Â { |
---|
1836 |    if (!(nmod_mat_entry (N, j, i) == 0)) |
---|
1837 | Â Â Â { |
---|
1838 | Â Â Â Â factorsConsidered.append (iter.getItem()); |
---|
1839 |     buf= mulMod2 (buf, iter.getItem(), yToL); |
---|
1840 | Â Â Â } |
---|
1841 | Â Â } |
---|
1842 |   buf *= LC (F, x); |
---|
1843 |   buf= mod (buf, yToL); |
---|
1844 |   buf /= content (buf, x); |
---|
1845 |   buf2= buf (y-evaluation, y); |
---|
1846 |   if (!k && beta == x) |
---|
1847 | Â Â { |
---|
1848 |    if (degree (buf2, alpha) < 1) |
---|
1849 | Â Â Â { |
---|
1850 |     if (fdivides (buf, F, quot)) |
---|
1851 | Â Â Â Â { |
---|
1852 | Â Â Â Â Â F=Â quot; |
---|
1853 | Â Â Â Â Â F /=Â Lc (F); |
---|
1854 | Â Â Â Â Â result.append (buf2); |
---|
1855 |      bufFactors= Difference (bufFactors, factorsConsidered); |
---|
1856 | Â Â Â Â } |
---|
1857 | Â Â Â } |
---|
1858 | Â Â } |
---|
1859 | Â Â else |
---|
1860 | Â Â { |
---|
1861 |    CFList source, dest; |
---|
1862 | |
---|
1863 |    if (!isInExtension (buf2, gamma, k, delta, source, dest)) |
---|
1864 | Â Â Â { |
---|
1865 |     if (fdivides (buf, F, quot)) |
---|
1866 | Â Â Â Â { |
---|
1867 | Â Â Â Â Â F=Â quot; |
---|
1868 | Â Â Â Â Â F /=Â Lc (F); |
---|
1869 | Â Â Â Â Â result.append (buf2); |
---|
1870 |      bufFactors= Difference (bufFactors, factorsConsidered); |
---|
1871 | Â Â Â Â } |
---|
1872 | Â Â Â } |
---|
1873 | Â Â } |
---|
1874 |   if (degree (F) <= 0) |
---|
1875 | Â Â { |
---|
1876 | Â Â Â G=Â F; |
---|
1877 | Â Â Â factors=Â bufFactors; |
---|
1878 |    return result; |
---|
1879 | Â Â } |
---|
1880 | Â } |
---|
1881 | Â G=Â F; |
---|
1882 | Â factors=Â bufFactors; |
---|
1883 |  return result; |
---|
1884 | } |
---|
1885 | #endif |
---|
1886 | |
---|
1887 | CFList |
---|
1888 | reconstruction (CanonicalForm& G, CFList& factors, int* zeroOneVecs, |
---|
1889 |         int precision, const mat_zz_p& N) |
---|
1890 | { |
---|
1891 | Â Variable y=Â Variable (2); |
---|
1892 | Â Variable x=Â Variable (1); |
---|
1893 | Â CanonicalForm F=Â G; |
---|
1894 |  CanonicalForm yToL= power (y, precision); |
---|
1895 |  CanonicalForm quot, buf; |
---|
1896 | Â CFList result; |
---|
1897 | Â CFList bufFactors=Â factors; |
---|
1898 | Â CFList factorsConsidered; |
---|
1899 | Â CFListIterator iter; |
---|
1900 |  for (long i= 1; i <= N.NumCols(); i++) |
---|
1901 | Â { |
---|
1902 |   if (zeroOneVecs [i - 1] == 0) |
---|
1903 | Â Â Â continue; |
---|
1904 | Â Â iter=Â factors; |
---|
1905 | Â Â buf=Â 1; |
---|
1906 | Â Â factorsConsidered=Â CFList(); |
---|
1907 |   for (long j= 1; j <= N.NumRows(); j++, iter++) |
---|
1908 | Â Â { |
---|
1909 |    if (!IsZero (N (j,i))) |
---|
1910 | Â Â Â { |
---|
1911 | Â Â Â Â factorsConsidered.append (iter.getItem()); |
---|
1912 |     buf= mulMod2 (buf, iter.getItem(), yToL); |
---|
1913 | Â Â Â } |
---|
1914 | Â Â } |
---|
1915 |   buf *= LC (F, x); |
---|
1916 |   buf= mod (buf, yToL); |
---|
1917 |   buf /= content (buf, x); |
---|
1918 |   if (fdivides (buf, F, quot)) |
---|
1919 | Â Â { |
---|
1920 | Â Â Â F=Â quot; |
---|
1921 | Â Â Â F /=Â Lc (F); |
---|
1922 | Â Â Â result.append (buf); |
---|
1923 |    bufFactors= Difference (bufFactors, factorsConsidered); |
---|
1924 | Â Â } |
---|
1925 |   if (degree (F) <= 0) |
---|
1926 | Â Â { |
---|
1927 | Â Â Â G=Â F; |
---|
1928 | Â Â Â factors=Â bufFactors; |
---|
1929 |    return result; |
---|
1930 | Â Â } |
---|
1931 | Â } |
---|
1932 | Â G=Â F; |
---|
1933 | Â factors=Â bufFactors; |
---|
1934 |  return result; |
---|
1935 | } |
---|
1936 | |
---|
1937 | #ifdef HAVE_FLINT |
---|
1938 | CFList |
---|
1939 | reconstruction (CanonicalForm& G, CFList& factors, int* zeroOneVecs, |
---|
1940 |         int precision, const nmod_mat_t N) |
---|
1941 | { |
---|
1942 | Â Variable y=Â Variable (2); |
---|
1943 | Â Variable x=Â Variable (1); |
---|
1944 | Â CanonicalForm F=Â G; |
---|
1945 |  CanonicalForm yToL= power (y, precision); |
---|
1946 |  CanonicalForm quot, buf; |
---|
1947 | Â CFList result; |
---|
1948 | Â CFList bufFactors=Â factors; |
---|
1949 | Â CFList factorsConsidered; |
---|
1950 | Â CFListIterator iter; |
---|
1951 |  for (long i= 0; i < nmod_mat_ncols (N); i++) |
---|
1952 | Â { |
---|
1953 |   if (zeroOneVecs [i] == 0) |
---|
1954 | Â Â Â continue; |
---|
1955 | Â Â iter=Â factors; |
---|
1956 | Â Â buf=Â 1; |
---|
1957 | Â Â factorsConsidered=Â CFList(); |
---|
1958 |   for (long j= 0; j < nmod_mat_nrows (N); j++, iter++) |
---|
1959 | Â Â { |
---|
1960 |    if (!(nmod_mat_entry (N, j, i) == 0)) |
---|
1961 | Â Â Â { |
---|
1962 | Â Â Â Â factorsConsidered.append (iter.getItem()); |
---|
1963 |     buf= mulMod2 (buf, iter.getItem(), yToL); |
---|
1964 | Â Â Â } |
---|
1965 | Â Â } |
---|
1966 |   buf *= LC (F, x); |
---|
1967 |   buf= mod (buf, yToL); |
---|
1968 |   buf /= content (buf, x); |
---|
1969 |   if (fdivides (buf, F, quot)) |
---|
1970 | Â Â { |
---|
1971 | Â Â Â F=Â quot; |
---|
1972 | Â Â Â F /=Â Lc (F); |
---|
1973 | Â Â Â result.append (buf); |
---|
1974 |    bufFactors= Difference (bufFactors, factorsConsidered); |
---|
1975 | Â Â } |
---|
1976 |   if (degree (F) <= 0) |
---|
1977 | Â Â { |
---|
1978 | Â Â Â G=Â F; |
---|
1979 | Â Â Â factors=Â bufFactors; |
---|
1980 |    return result; |
---|
1981 | Â Â } |
---|
1982 | Â } |
---|
1983 | Â G=Â F; |
---|
1984 | Â factors=Â bufFactors; |
---|
1985 |  return result; |
---|
1986 | } |
---|
1987 | #endif |
---|
1988 | |
---|
1989 | void |
---|
1990 | extReconstructionTry (CFList& reconstructedFactors, CanonicalForm& F, const |
---|
1991 |            CFList& factors, const int liftBound, int& factorsFound, |
---|
1992 |            int*& factorsFoundIndex, mat_zz_p& N, bool beenInThres, |
---|
1993 |            const ExtensionInfo& info, const CanonicalForm& evaluation |
---|
1994 | Â Â Â Â Â Â Â Â Â Â Â ) |
---|
1995 | { |
---|
1996 | Â Variable y=Â Variable (2); |
---|
1997 | Â Variable x=Â Variable (1); |
---|
1998 | Â Variable alpha=Â info.getAlpha(); |
---|
1999 | Â Variable beta=Â info.getBeta(); |
---|
2000 |  int k= info.getGFDegree(); |
---|
2001 | Â CanonicalForm gamma=Â info.getGamma(); |
---|
2002 | Â CanonicalForm delta=Â info.getDelta(); |
---|
2003 |  CanonicalForm yToL= power (y, liftBound); |
---|
2004 |  CFList source, dest; |
---|
2005 |  if (factors.length() == 2) |
---|
2006 | Â { |
---|
2007 |   CanonicalForm tmp1, tmp2, tmp3; |
---|
2008 | Â Â tmp1=Â factors.getFirst(); |
---|
2009 | Â Â tmp2=Â factors.getLast(); |
---|
2010 |   tmp1 *= LC (F, x); |
---|
2011 |   tmp1= mod (tmp1, yToL); |
---|
2012 |   tmp1 /= content (tmp1, x); |
---|
2013 |   tmp2 *= LC (F, x); |
---|
2014 |   tmp2= mod (tmp2, yToL); |
---|
2015 |   tmp2 /= content (tmp2, x); |
---|
2016 | Â Â tmp3 =Â tmp1*tmp2; |
---|
2017 |   if (tmp3/Lc (tmp3) == F/Lc (F)) |
---|
2018 | Â Â { |
---|
2019 |    tmp1= tmp1 (y - evaluation, y); |
---|
2020 |    tmp2= tmp2 (y - evaluation, y); |
---|
2021 |    if (!k && beta == x && degree (tmp2, alpha) < 1 && |
---|
2022 |      degree (tmp1, alpha) < 1) |
---|
2023 | Â Â Â { |
---|
2024 | Â Â Â Â factorsFound++; |
---|
2025 | Â Â Â Â F=Â 1; |
---|
2026 |     tmp1= mapDown (tmp1, info, source, dest); |
---|
2027 |     tmp2= mapDown (tmp2, info, source, dest); |
---|
2028 | Â Â Â Â reconstructedFactors.append (tmp1); |
---|
2029 | Â Â Â Â reconstructedFactors.append (tmp2); |
---|
2030 | Â Â Â Â return; |
---|
2031 | Â Â Â } |
---|
2032 |    else if (!isInExtension (tmp2, gamma, k, delta, source, dest) && |
---|
2033 |         !isInExtension (tmp1, gamma, k, delta, source, dest)) |
---|
2034 | Â Â Â { |
---|
2035 | Â Â Â Â factorsFound++; |
---|
2036 | Â Â Â Â F=Â 1; |
---|
2037 |     tmp1= mapDown (tmp1, info, source, dest); |
---|
2038 |     tmp2= mapDown (tmp2, info, source, dest); |
---|
2039 | Â Â Â Â reconstructedFactors.append (tmp1); |
---|
2040 | Â Â Â Â reconstructedFactors.append (tmp2); |
---|
2041 | Â Â Â Â return; |
---|
2042 | Â Â Â } |
---|
2043 | Â Â } |
---|
2044 | Â } |
---|
2045 |  CanonicalForm quot, buf, buf2; |
---|
2046 | Â CFListIterator iter; |
---|
2047 |  for (long i= 1; i <= N.NumCols(); i++) |
---|
2048 | Â { |
---|
2049 |   if (factorsFoundIndex [i - 1] == 1) |
---|
2050 | Â Â Â continue; |
---|
2051 | Â Â iter=Â factors; |
---|
2052 |   if (beenInThres) |
---|
2053 | Â Â { |
---|
2054 |    int count= 1; |
---|
2055 |    while (count < i) |
---|
2056 | Â Â Â { |
---|
2057 | Â Â Â Â count++; |
---|
2058 | Â Â Â Â iter++; |
---|
2059 | Â Â Â } |
---|
2060 | Â Â Â buf=Â iter.getItem(); |
---|
2061 | Â Â } |
---|
2062 | Â Â else |
---|
2063 | Â Â { |
---|
2064 | Â Â Â buf=Â 1; |
---|
2065 |    for (long j= 1; j <= N.NumRows(); j++, iter++) |
---|
2066 | Â Â Â { |
---|
2067 |     if (!IsZero (N (j,i))) |
---|
2068 |      buf= mulMod2 (buf, iter.getItem(), yToL); |
---|
2069 | Â Â Â } |
---|
2070 | Â Â } |
---|
2071 |   buf *= LC (F, x); |
---|
2072 |   buf= mod (buf, yToL); |
---|
2073 |   buf /= content (buf, x); |
---|
2074 |   buf2= buf (y - evaluation, y); |
---|
2075 |   if (!k && beta == x) |
---|
2076 | Â Â { |
---|
2077 |    if (degree (buf2, alpha) < 1) |
---|
2078 | Â Â Â { |
---|
2079 |     if (fdivides (buf, F, quot)) |
---|
2080 | Â Â Â Â { |
---|
2081 | Â Â Â Â Â factorsFoundIndex[i -Â 1]=Â 1; |
---|
2082 | Â Â Â Â Â factorsFound++; |
---|
2083 | Â Â Â Â Â F=Â quot; |
---|
2084 | Â Â Â Â Â F /=Â Lc (F); |
---|
2085 |      buf2= mapDown (buf2, info, source, dest); |
---|
2086 | Â Â Â Â Â reconstructedFactors.append (buf2); |
---|
2087 | Â Â Â Â } |
---|
2088 | Â Â Â } |
---|
2089 | Â Â } |
---|
2090 | Â Â else |
---|
2091 | Â Â { |
---|
2092 |    if (!isInExtension (buf2, gamma, k, delta, source, dest)) |
---|
2093 | Â Â Â { |
---|
2094 |     if (fdivides (buf, F, quot)) |
---|
2095 | Â Â Â Â { |
---|
2096 | Â Â Â Â Â factorsFoundIndex[i -Â 1]=Â 1; |
---|
2097 | Â Â Â Â Â factorsFound++; |
---|
2098 | Â Â Â Â Â F=Â quot; |
---|
2099 | Â Â Â Â Â F /=Â Lc (F); |
---|
2100 |      buf2= mapDown (buf2, info, source, dest); |
---|
2101 | Â Â Â Â Â reconstructedFactors.append (buf2); |
---|
2102 | Â Â Â Â } |
---|
2103 | Â Â Â } |
---|
2104 | Â Â } |
---|
2105 |   if (degree (F) <= 0) |
---|
2106 | Â Â Â return; |
---|
2107 |   if (factorsFound + 1 == N.NumCols()) |
---|
2108 | Â Â { |
---|
2109 |    CanonicalForm tmp= F (y - evaluation, y); |
---|
2110 |    tmp= mapDown (tmp, info, source, dest); |
---|
2111 | Â Â Â reconstructedFactors.append (tmp); |
---|
2112 | Â Â Â return; |
---|
2113 | Â Â } |
---|
2114 | Â } |
---|
2115 | } |
---|
2116 | |
---|
2117 | #ifdef HAVE_FLINT |
---|
2118 | void |
---|
2119 | extReconstructionTry (CFList& reconstructedFactors, CanonicalForm& F, const |
---|
2120 |            CFList& factors, const int liftBound, int& factorsFound, |
---|
2121 |            int*& factorsFoundIndex, nmod_mat_t N, bool beenInThres, |
---|
2122 |            const ExtensionInfo& info, const CanonicalForm& evaluation |
---|
2123 | Â Â Â Â Â Â Â Â Â Â Â ) |
---|
2124 | { |
---|
2125 | Â Variable y=Â Variable (2); |
---|
2126 | Â Variable x=Â Variable (1); |
---|
2127 | Â Variable alpha=Â info.getAlpha(); |
---|
2128 | Â Variable beta=Â info.getBeta(); |
---|
2129 |  int k= info.getGFDegree(); |
---|
2130 | Â CanonicalForm gamma=Â info.getGamma(); |
---|
2131 | Â CanonicalForm delta=Â info.getDelta(); |
---|
2132 |  CanonicalForm yToL= power (y, liftBound); |
---|
2133 |  CFList source, dest; |
---|
2134 |  if (factors.length() == 2) |
---|
2135 | Â { |
---|
2136 |   CanonicalForm tmp1, tmp2, tmp3; |
---|
2137 | Â Â tmp1=Â factors.getFirst(); |
---|
2138 | Â Â tmp2=Â factors.getLast(); |
---|
2139 |   tmp1 *= LC (F, x); |
---|
2140 |   tmp1= mod (tmp1, yToL); |
---|
2141 |   tmp1 /= content (tmp1, x); |
---|
2142 |   tmp2 *= LC (F, x); |
---|
2143 |   tmp2= mod (tmp2, yToL); |
---|
2144 |   tmp2 /= content (tmp2, x); |
---|
2145 | Â Â tmp3 =Â tmp1*tmp2; |
---|
2146 |   if (tmp3/Lc (tmp3) == F/Lc (F)) |
---|
2147 | Â Â { |
---|
2148 |    tmp1= tmp1 (y - evaluation, y); |
---|
2149 |    tmp2= tmp2 (y - evaluation, y); |
---|
2150 |    if (!k && beta == x && degree (tmp2, alpha) < 1 && |
---|
2151 |      degree (tmp1, alpha) < 1) |
---|
2152 | Â Â Â { |
---|
2153 | Â Â Â Â factorsFound++; |
---|
2154 | Â Â Â Â F=Â 1; |
---|
2155 |     tmp1= mapDown (tmp1, info, source, dest); |
---|
2156 |     tmp2= mapDown (tmp2, info, source, dest); |
---|
2157 | Â Â Â Â reconstructedFactors.append (tmp1); |
---|
2158 | Â Â Â Â reconstructedFactors.append (tmp2); |
---|
2159 | Â Â Â Â return; |
---|
2160 | Â Â Â } |
---|
2161 |    else if (!isInExtension (tmp2, gamma, k, delta, source, dest) && |
---|
2162 |         !isInExtension (tmp1, gamma, k, delta, source, dest)) |
---|
2163 | Â Â Â { |
---|
2164 | Â Â Â Â factorsFound++; |
---|
2165 | Â Â Â Â F=Â 1; |
---|
2166 |     tmp1= mapDown (tmp1, info, source, dest); |
---|
2167 |     tmp2= mapDown (tmp2, info, source, dest); |
---|
2168 | Â Â Â Â reconstructedFactors.append (tmp1); |
---|
2169 | Â Â Â Â reconstructedFactors.append (tmp2); |
---|
2170 | Â Â Â Â return; |
---|
2171 | Â Â Â } |
---|
2172 | Â Â } |
---|
2173 | Â } |
---|
2174 |  CanonicalForm quot, buf, buf2; |
---|
2175 | Â CFListIterator iter; |
---|
2176 |  for (long i= 0; i < nmod_mat_ncols (N); i++) |
---|
2177 | Â { |
---|
2178 |   if (factorsFoundIndex [i] == 1) |
---|
2179 | Â Â Â continue; |
---|
2180 | Â Â iter=Â factors; |
---|
2181 |   if (beenInThres) |
---|
2182 | Â Â { |
---|
2183 |    int count= 0; |
---|
2184 |    while (count < i) |
---|
2185 | Â Â Â { |
---|
2186 | Â Â Â Â count++; |
---|
2187 | Â Â Â Â iter++; |
---|
2188 | Â Â Â } |
---|
2189 | Â Â Â buf=Â iter.getItem(); |
---|
2190 | Â Â } |
---|
2191 | Â Â else |
---|
2192 | Â Â { |
---|
2193 | Â Â Â buf=Â 1; |
---|
2194 |    for (long j= 0; j < nmod_mat_nrows (N); j++, iter++) |
---|
2195 | Â Â Â { |
---|
2196 |     if (!(nmod_mat_entry (N, j, i) == 0)) |
---|
2197 |      buf= mulMod2 (buf, iter.getItem(), yToL); |
---|
2198 | Â Â Â } |
---|
2199 | Â Â } |
---|
2200 |   buf *= LC (F, x); |
---|
2201 |   buf= mod (buf, yToL); |
---|
2202 |   buf /= content (buf, x); |
---|
2203 |   buf2= buf (y - evaluation, y); |
---|
2204 |   if (!k && beta == x) |
---|
2205 | Â Â { |
---|
2206 |    if (degree (buf2, alpha) < 1) |
---|
2207 | Â Â Â { |
---|
2208 |     if (fdivides (buf, F, quot)) |
---|
2209 | Â Â Â Â { |
---|
2210 | Â Â Â Â Â factorsFoundIndex[i]=Â 1; |
---|
2211 | Â Â Â Â Â factorsFound++; |
---|
2212 | Â Â Â Â Â F=Â quot; |
---|
2213 | Â Â Â Â Â F /=Â Lc (F); |
---|
2214 |      buf2= mapDown (buf2, info, source, dest); |
---|
2215 | Â Â Â Â Â reconstructedFactors.append (buf2); |
---|
2216 | Â Â Â Â } |
---|
2217 | Â Â Â } |
---|
2218 | Â Â } |
---|
2219 | Â Â else |
---|
2220 | Â Â { |
---|
2221 |    if (!isInExtension (buf2, gamma, k, delta, source, dest)) |
---|
2222 | Â Â Â { |
---|
2223 |     if (fdivides (buf, F, quot)) |
---|
2224 | Â Â Â Â { |
---|
2225 | Â Â Â Â Â factorsFoundIndex[i]=Â 1; |
---|
2226 | Â Â Â Â Â factorsFound++; |
---|
2227 | Â Â Â Â Â F=Â quot; |
---|
2228 | Â Â Â Â Â F /=Â Lc (F); |
---|
2229 |      buf2= mapDown (buf2, info, source, dest); |
---|
2230 | Â Â Â Â Â reconstructedFactors.append (buf2); |
---|
2231 | Â Â Â Â } |
---|
2232 | Â Â Â } |
---|
2233 | Â Â } |
---|
2234 |   if (degree (F) <= 0) |
---|
2235 | Â Â Â return; |
---|
2236 |   if (factorsFound + 1 == nmod_mat_nrows (N)) |
---|
2237 | Â Â { |
---|
2238 |    CanonicalForm tmp= F (y - evaluation, y); |
---|
2239 |    tmp= mapDown (tmp, info, source, dest); |
---|
2240 | Â Â Â reconstructedFactors.append (tmp); |
---|
2241 | Â Â Â return; |
---|
2242 | Â Â } |
---|
2243 | Â } |
---|
2244 | } |
---|
2245 | #endif |
---|
2246 | |
---|
2247 | //over Fp |
---|
2248 | int |
---|
2249 | liftAndComputeLattice (const CanonicalForm& F, int* bounds, int sizeBounds, int |
---|
2250 |             start, int liftBound, int minBound, CFList& factors, |
---|
2251 |             mat_zz_p& NTLN, CFList& diophant, CFMatrix& M, CFArray& |
---|
2252 |             Pi, CFArray& bufQ, bool& irreducible |
---|
2253 | Â Â Â Â Â Â Â Â Â Â Â ) |
---|
2254 | { |
---|
2255 |  CanonicalForm LCF= LC (F, 1); |
---|
2256 |  CFArray *A= new CFArray [factors.length() - 1]; |
---|
2257 |  bool wasInBounds= false; |
---|
2258 |  bool hitBound= false; |
---|
2259 |  int l= (minBound+1)*2; |
---|
2260 |  int stepSize= 2; |
---|
2261 |  int oldL= l/2; |
---|
2262 |  bool reduced= false; |
---|
2263 |  mat_zz_p NTLK, *NTLC; |
---|
2264 | Â CFMatrix C; |
---|
2265 | Â CFArray buf; |
---|
2266 | Â CFListIterator j; |
---|
2267 | Â CanonicalForm truncF; |
---|
2268 | Â Variable y=Â F.mvar(); |
---|
2269 |  while (l <= liftBound) |
---|
2270 | Â { |
---|
2271 |   if (start) |
---|
2272 | Â Â { |
---|
2273 |    henselLiftResume12 (F, factors, start, l, Pi, diophant, M); |
---|
2274 | Â Â Â start=Â 0; |
---|
2275 | Â Â } |
---|
2276 | Â Â else |
---|
2277 | Â Â { |
---|
2278 |    if (wasInBounds) |
---|
2279 |     henselLiftResume12 (F, factors, oldL, l, Pi, diophant, M); |
---|
2280 | Â Â Â else |
---|
2281 |     henselLift12 (F, factors, l, Pi, diophant, M); |
---|
2282 | Â Â } |
---|
2283 | |
---|
2284 | Â Â factors.insert (LCF); |
---|
2285 | Â Â j=Â factors; |
---|
2286 | Â Â j++; |
---|
2287 | |
---|
2288 |   truncF= mod (F, power (y, l)); |
---|
2289 |   for (int i= 0; i < factors.length() - 1; i++, j++) |
---|
2290 | Â Â { |
---|
2291 |    if (!wasInBounds) |
---|
2292 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ[i]); |
---|
2293 | Â Â Â else |
---|
2294 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL, bufQ[i], |
---|
2295 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i]); |
---|
2296 | Â Â } |
---|
2297 | |
---|
2298 |   for (int i= 0; i < sizeBounds; i++) |
---|
2299 | Â Â { |
---|
2300 |    if (bounds [i] + 1 <= l/2) |
---|
2301 | Â Â Â { |
---|
2302 | Â Â Â Â wasInBounds=Â true; |
---|
2303 |     int k= tmin (bounds [i] + 1, l/2); |
---|
2304 |     C= CFMatrix (l - k, factors.length() - 1); |
---|
2305 |     for (int ii= 0; ii < factors.length() - 1; ii++) |
---|
2306 | Â Â Â Â { |
---|
2307 |      if (A[ii].size() - 1 >= i) |
---|
2308 | Â Â Â Â Â { |
---|
2309 |       buf= getCoeffs (A[ii] [i], k); |
---|
2310 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
2311 | Â Â Â Â Â } |
---|
2312 | Â Â Â Â } |
---|
2313 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_p(C); |
---|
2314 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
2315 |     transpose (NTLK, NTLK); |
---|
2316 |     kernel (NTLK, NTLK); |
---|
2317 |     transpose (NTLK, NTLK); |
---|
2318 | Â Â Â Â NTLN *=Â NTLK; |
---|
2319 | |
---|
2320 |     if (NTLN.NumCols() == 1) |
---|
2321 | Â Â Â Â { |
---|
2322 | Â Â Â Â Â irreducible=Â true; |
---|
2323 | Â Â Â Â Â break; |
---|
2324 | Â Â Â Â } |
---|
2325 |     if (isReduced (NTLN) && l > (minBound+1)*2) |
---|
2326 | Â Â Â Â { |
---|
2327 | Â Â Â Â Â reduced=Â true; |
---|
2328 | Â Â Â Â Â break; |
---|
2329 | Â Â Â Â } |
---|
2330 | Â Â Â } |
---|
2331 | Â Â } |
---|
2332 | |
---|
2333 |   if (irreducible) |
---|
2334 | Â Â Â break; |
---|
2335 |   if (reduced) |
---|
2336 | Â Â Â break; |
---|
2337 | Â Â oldL=Â l; |
---|
2338 | Â Â l +=Â stepSize; |
---|
2339 | Â Â stepSize *=Â 2; |
---|
2340 |   if (l > liftBound) |
---|
2341 | Â Â { |
---|
2342 |    if (!hitBound) |
---|
2343 | Â Â Â { |
---|
2344 | Â Â Â Â l=Â liftBound; |
---|
2345 | Â Â Â Â hitBound=Â true; |
---|
2346 | Â Â Â } |
---|
2347 | Â Â Â else |
---|
2348 | Â Â Â Â break; |
---|
2349 | Â Â } |
---|
2350 | Â } |
---|
2351 |  delete [] A; |
---|
2352 |  if (!wasInBounds) |
---|
2353 | Â { |
---|
2354 |   if (start) |
---|
2355 |    henselLiftResume12 (F, factors, start, degree (F) + 1, Pi, diophant, M); |
---|
2356 | Â Â else |
---|
2357 |    henselLift12 (F, factors, degree (F) + 1, Pi, diophant, M); |
---|
2358 | Â Â factors.insert (LCF); |
---|
2359 | Â } |
---|
2360 |  return l; |
---|
2361 | } |
---|
2362 | |
---|
2363 | #ifdef HAVE_FLINT |
---|
2364 | int |
---|
2365 | liftAndComputeLattice (const CanonicalForm& F, int* bounds, int sizeBounds, int |
---|
2366 |             start, int liftBound, int minBound, CFList& factors, |
---|
2367 |             nmod_mat_t FLINTN, CFList& diophant, CFMatrix& M,CFArray& |
---|
2368 |             Pi, CFArray& bufQ, bool& irreducible |
---|
2369 | Â Â Â Â Â Â Â Â Â Â Â ) |
---|
2370 | { |
---|
2371 |  CanonicalForm LCF= LC (F, 1); |
---|
2372 |  CFArray *A= new CFArray [factors.length() - 1]; |
---|
2373 |  bool wasInBounds= false; |
---|
2374 |  bool hitBound= false; |
---|
2375 |  int l= (minBound+1)*2; |
---|
2376 |  int stepSize= 2; |
---|
2377 |  int oldL= l/2; |
---|
2378 |  bool reduced= false; |
---|
2379 |  long rank; |
---|
2380 |  nmod_mat_t FLINTK, FLINTC, null; |
---|
2381 | Â CFMatrix C; |
---|
2382 | Â CFArray buf; |
---|
2383 | Â CFListIterator j; |
---|
2384 | Â CanonicalForm truncF; |
---|
2385 | Â Variable y=Â F.mvar(); |
---|
2386 |  while (l <= liftBound) |
---|
2387 | Â { |
---|
2388 |   if (start) |
---|
2389 | Â Â { |
---|
2390 |    henselLiftResume12 (F, factors, start, l, Pi, diophant, M); |
---|
2391 | Â Â Â start=Â 0; |
---|
2392 | Â Â } |
---|
2393 | Â Â else |
---|
2394 | Â Â { |
---|
2395 |    if (wasInBounds) |
---|
2396 |     henselLiftResume12 (F, factors, oldL, l, Pi, diophant, M); |
---|
2397 | Â Â Â else |
---|
2398 |     henselLift12 (F, factors, l, Pi, diophant, M); |
---|
2399 | Â Â } |
---|
2400 | |
---|
2401 | Â Â factors.insert (LCF); |
---|
2402 | Â Â j=Â factors; |
---|
2403 | Â Â j++; |
---|
2404 | |
---|
2405 |   truncF= mod (F, power (y, l)); |
---|
2406 |   for (int i= 0; i < factors.length() - 1; i++, j++) |
---|
2407 | Â Â { |
---|
2408 |    if (!wasInBounds) |
---|
2409 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ[i]); |
---|
2410 | Â Â Â else |
---|
2411 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL, bufQ[i], |
---|
2412 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i]); |
---|
2413 | Â Â } |
---|
2414 | |
---|
2415 |   for (int i= 0; i < sizeBounds; i++) |
---|
2416 | Â Â { |
---|
2417 |    if (bounds [i] + 1 <= l/2) |
---|
2418 | Â Â Â { |
---|
2419 | Â Â Â Â wasInBounds=Â true; |
---|
2420 |     int k= tmin (bounds [i] + 1, l/2); |
---|
2421 |     C= CFMatrix (l - k, factors.length() - 1); |
---|
2422 |     for (int ii= 0; ii < factors.length() - 1; ii++) |
---|
2423 | Â Â Â Â { |
---|
2424 |      if (A[ii].size() - 1 >= i) |
---|
2425 | Â Â Â Â Â { |
---|
2426 |       buf= getCoeffs (A[ii] [i], k); |
---|
2427 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
2428 | Â Â Â Â Â } |
---|
2429 | Â Â Â Â } |
---|
2430 | |
---|
2431 |     convertFacCFMatrix2nmod_mat_t (FLINTC, C); |
---|
2432 |     nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), |
---|
2433 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
2434 |     nmod_mat_mul (FLINTK, FLINTC, FLINTN); |
---|
2435 |     nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), |
---|
2436 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
2437 |     rank= nmod_mat_nullspace (null, FLINTK); |
---|
2438 | Â Â Â Â nmod_mat_clear (FLINTK); |
---|
2439 |     nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); |
---|
2440 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
2441 |     nmod_mat_init_set (FLINTC, FLINTN); |
---|
2442 | Â Â Â Â nmod_mat_clear (FLINTN); |
---|
2443 |     nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), |
---|
2444 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
2445 |     nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! |
---|
2446 | |
---|
2447 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
2448 | Â Â Â Â nmod_mat_window_clear (FLINTK); |
---|
2449 | Â Â Â Â nmod_mat_clear (null); |
---|
2450 |     if (nmod_mat_ncols (FLINTN) == 1) |
---|
2451 | Â Â Â Â { |
---|
2452 | Â Â Â Â Â irreducible=Â true; |
---|
2453 | Â Â Â Â Â break; |
---|
2454 | Â Â Â Â } |
---|
2455 |     if (isReduced (FLINTN) && l > (minBound+1)*2) |
---|
2456 | Â Â Â Â { |
---|
2457 | Â Â Â Â Â reduced=Â true; |
---|
2458 | Â Â Â Â Â break; |
---|
2459 | Â Â Â Â } |
---|
2460 | Â Â Â } |
---|
2461 | Â Â } |
---|
2462 | |
---|
2463 |   if (irreducible) |
---|
2464 | Â Â Â break; |
---|
2465 |   if (reduced) |
---|
2466 | Â Â Â break; |
---|
2467 | Â Â oldL=Â l; |
---|
2468 | Â Â l +=Â stepSize; |
---|
2469 | Â Â stepSize *=Â 2; |
---|
2470 |   if (l > liftBound) |
---|
2471 | Â Â { |
---|
2472 |    if (!hitBound) |
---|
2473 | Â Â Â { |
---|
2474 | Â Â Â Â l=Â liftBound; |
---|
2475 | Â Â Â Â hitBound=Â true; |
---|
2476 | Â Â Â } |
---|
2477 | Â Â Â else |
---|
2478 | Â Â Â Â break; |
---|
2479 | Â Â } |
---|
2480 | Â } |
---|
2481 |  delete [] A; |
---|
2482 |  if (!wasInBounds) |
---|
2483 | Â { |
---|
2484 |   if (start) |
---|
2485 |    henselLiftResume12 (F, factors, start, degree (F) + 1, Pi, diophant, M); |
---|
2486 | Â Â else |
---|
2487 |    henselLift12 (F, factors, degree (F) + 1, Pi, diophant, M); |
---|
2488 | Â Â factors.insert (LCF); |
---|
2489 | Â } |
---|
2490 |  return l; |
---|
2491 | } |
---|
2492 | #endif |
---|
2493 | |
---|
2494 | //over field extension |
---|
2495 | int |
---|
2496 | extLiftAndComputeLattice (const CanonicalForm& F, int* bounds, int sizeBounds, |
---|
2497 |              int liftBound, int minBound, int start, CFList& |
---|
2498 |              factors, mat_zz_p& NTLN, CFList& diophant, |
---|
2499 |              CFMatrix& M, CFArray& Pi, CFArray& bufQ, bool& |
---|
2500 |              irreducible, const CanonicalForm& evaluation, const |
---|
2501 |              ExtensionInfo& info, CFList& source, CFList& dest |
---|
2502 | Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
2503 | { |
---|
2504 |  bool GF= (CFFactory::gettype()==GaloisFieldDomain); |
---|
2505 |  CanonicalForm LCF= LC (F, 1); |
---|
2506 |  CFArray *A= new CFArray [factors.length() - 1]; |
---|
2507 |  bool wasInBounds= false; |
---|
2508 |  bool hitBound= false; |
---|
2509 |  int degMipo; |
---|
2510 | Â Variable alpha; |
---|
2511 | Â alpha=Â info.getAlpha(); |
---|
2512 | Â degMipo=Â degree (getMipo (alpha)); |
---|
2513 | |
---|
2514 | Â Variable gamma=Â info.getBeta(); |
---|
2515 | Â CanonicalForm primElemAlpha=Â info.getGamma(); |
---|
2516 | Â CanonicalForm imPrimElemAlpha=Â info.getDelta(); |
---|
2517 | |
---|
2518 |  int stepSize= 2; |
---|
2519 |  int l= ((minBound+1)/degMipo+1)*2; |
---|
2520 |  l= tmax (l, 2); |
---|
2521 |  if (start > l) |
---|
2522 | Â Â l=Â start; |
---|
2523 |  int oldL= l/2; |
---|
2524 |  bool reduced= false; |
---|
2525 | Â Variable y=Â F.mvar(); |
---|
2526 | Â Variable x=Â Variable (1); |
---|
2527 |  CanonicalForm powX, imBasis, truncF; |
---|
2528 |  CFMatrix Mat, C; |
---|
2529 | Â CFArray buf; |
---|
2530 | Â CFIterator iter; |
---|
2531 |  mat_zz_p* NTLMat, *NTLC, NTLK; |
---|
2532 | Â CFListIterator j; |
---|
2533 |  while (l <= liftBound) |
---|
2534 | Â { |
---|
2535 |   if (start) |
---|
2536 | Â Â { |
---|
2537 |    henselLiftResume12 (F, factors, start, l, Pi, diophant, M); |
---|
2538 | Â Â Â start=Â 0; |
---|
2539 | Â Â } |
---|
2540 | Â Â else |
---|
2541 | Â Â { |
---|
2542 |    if (wasInBounds) |
---|
2543 |     henselLiftResume12 (F, factors, oldL, l, Pi, diophant, M); |
---|
2544 | Â Â Â else |
---|
2545 |     henselLift12 (F, factors, l, Pi, diophant, M); |
---|
2546 | Â Â } |
---|
2547 | |
---|
2548 | Â Â factors.insert (LCF); |
---|
2549 | |
---|
2550 |   if (GF) |
---|
2551 | Â Â Â setCharacteristic (getCharacteristic()); |
---|
2552 | |
---|
2553 |   powX= power (y-gamma, l); |
---|
2554 |   Mat= CFMatrix (l*degMipo, l*degMipo); |
---|
2555 |   for (int i= 0; i < l*degMipo; i++) |
---|
2556 | Â Â { |
---|
2557 |    imBasis= mod (power (y, i), powX); |
---|
2558 |    imBasis= imBasis (power (y, degMipo), y); |
---|
2559 |    imBasis= imBasis (y, gamma); |
---|
2560 | Â Â Â iter=Â imBasis; |
---|
2561 |    for (; iter.hasTerms(); iter++) |
---|
2562 |     Mat (iter.exp()+ 1, i+1)= iter.coeff(); |
---|
2563 | Â Â } |
---|
2564 | |
---|
2565 | Â Â NTLMat=Â convertFacCFMatrix2NTLmat_zz_p (Mat); |
---|
2566 | Â Â *NTLMat=Â inv (*NTLMat); |
---|
2567 | |
---|
2568 |   if (GF) |
---|
2569 |    setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); |
---|
2570 | |
---|
2571 | Â Â j=Â factors; |
---|
2572 | Â Â j++; |
---|
2573 | |
---|
2574 |   truncF= mod (F, power (y, l)); |
---|
2575 |   for (int i= 0; i < factors.length() - 1; i++, j++) |
---|
2576 | Â Â { |
---|
2577 |    if (!wasInBounds) |
---|
2578 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ[i]); |
---|
2579 | Â Â Â else |
---|
2580 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL, bufQ[i], |
---|
2581 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i]); |
---|
2582 | Â Â } |
---|
2583 | |
---|
2584 |   for (int i= 0; i < sizeBounds; i++) |
---|
2585 | Â Â { |
---|
2586 |    if (bounds [i] + 1 <= (l/2)*degMipo) |
---|
2587 | Â Â Â { |
---|
2588 | Â Â Â Â wasInBounds=Â true; |
---|
2589 |     int k= tmin (bounds [i] + 1, (l/2)*degMipo); |
---|
2590 |     C= CFMatrix (l*degMipo - k, factors.length() - 1); |
---|
2591 | |
---|
2592 |     for (int ii= 0; ii < factors.length() - 1; ii++) |
---|
2593 | Â Â Â Â { |
---|
2594 |      if (A[ii].size() - 1 >= i) |
---|
2595 | Â Â Â Â Â { |
---|
2596 |       if (GF) |
---|
2597 | Â Â Â Â Â Â { |
---|
2598 |        A [ii] [i]= A [ii] [i] (y-evaluation, y); |
---|
2599 | Â Â Â Â Â Â Â setCharacteristic (getCharacteristic()); |
---|
2600 |        A[ii] [i]= GF2FalphaRep (A[ii] [i], alpha); |
---|
2601 |        if (alpha != gamma) |
---|
2602 |         A [ii] [i]= mapDown (A[ii] [i], imPrimElemAlpha, primElemAlpha, |
---|
2603 |                    gamma, source, dest |
---|
2604 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
2605 |        buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, *NTLMat); |
---|
2606 | Â Â Â Â Â Â } |
---|
2607 | Â Â Â Â Â Â else |
---|
2608 | Â Â Â Â Â Â { |
---|
2609 |        A [ii] [i]= A [ii] [i] (y-evaluation, y); |
---|
2610 |        if (alpha != gamma) |
---|
2611 |         A[ii] [i]= mapDown (A[ii] [i], imPrimElemAlpha, primElemAlpha, |
---|
2612 |                   gamma, source, dest |
---|
2613 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
2614 |        buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, *NTLMat); |
---|
2615 | Â Â Â Â Â Â } |
---|
2616 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
2617 | Â Â Â Â Â } |
---|
2618 |      if (GF) |
---|
2619 |       setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); |
---|
2620 | Â Â Â Â } |
---|
2621 | |
---|
2622 |     if (GF) |
---|
2623 | Â Â Â Â Â setCharacteristic(getCharacteristic()); |
---|
2624 | |
---|
2625 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_p(C); |
---|
2626 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
2627 |     transpose (NTLK, NTLK); |
---|
2628 |     kernel (NTLK, NTLK); |
---|
2629 |     transpose (NTLK, NTLK); |
---|
2630 | Â Â Â Â NTLN *=Â NTLK; |
---|
2631 | |
---|
2632 |     if (GF) |
---|
2633 |      setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); |
---|
2634 | |
---|
2635 |     if (NTLN.NumCols() == 1) |
---|
2636 | Â Â Â Â { |
---|
2637 | Â Â Â Â Â irreducible=Â true; |
---|
2638 | Â Â Â Â Â break; |
---|
2639 | Â Â Â Â } |
---|
2640 |     if (isReduced (NTLN)) |
---|
2641 | Â Â Â Â { |
---|
2642 | Â Â Â Â Â reduced=Â true; |
---|
2643 | Â Â Â Â Â break; |
---|
2644 | Â Â Â Â } |
---|
2645 | Â Â Â } |
---|
2646 | Â Â } |
---|
2647 | |
---|
2648 |   if (NTLN.NumCols() == 1) |
---|
2649 | Â Â { |
---|
2650 | Â Â Â irreducible=Â true; |
---|
2651 | Â Â Â break; |
---|
2652 | Â Â } |
---|
2653 |   if (reduced) |
---|
2654 | Â Â Â break; |
---|
2655 | Â Â oldL=Â l; |
---|
2656 | Â Â l +=Â stepSize; |
---|
2657 | Â Â stepSize *=Â 2; |
---|
2658 |   if (l > liftBound) |
---|
2659 | Â Â { |
---|
2660 |    if (!hitBound) |
---|
2661 | Â Â Â { |
---|
2662 | Â Â Â Â l=Â liftBound; |
---|
2663 | Â Â Â Â hitBound=Â true; |
---|
2664 | Â Â Â } |
---|
2665 | Â Â Â else |
---|
2666 | Â Â Â Â break; |
---|
2667 | Â Â } |
---|
2668 | Â } |
---|
2669 |  delete [] A; |
---|
2670 |  if (!wasInBounds) |
---|
2671 | Â { |
---|
2672 |   if (start) |
---|
2673 |    henselLiftResume12 (F, factors, start, degree (F) + 1, Pi, diophant, M); |
---|
2674 | Â Â else |
---|
2675 |    henselLift12 (F, factors, degree (F) + 1, Pi, diophant, M); |
---|
2676 | Â Â factors.insert (LCF); |
---|
2677 | Â } |
---|
2678 |  return l; |
---|
2679 | } |
---|
2680 | |
---|
2681 | /*#ifdef HAVE_FLINT |
---|
2682 | //over field extension |
---|
2683 | int |
---|
2684 | extLiftAndComputeLattice (const CanonicalForm& F, int* bounds, int sizeBounds, |
---|
2685 | Â Â Â Â Â Â Â Â Â Â Â Â Â int liftBound, int minBound, int start, CFList& |
---|
2686 | Â Â Â Â Â Â Â Â Â Â Â Â Â factors, nmod_mat_t FLINTN, CFList& diophant, |
---|
2687 | Â Â Â Â Â Â Â Â Â Â Â Â Â CFMatrix& M, CFArray& Pi, CFArray& bufQ, bool& |
---|
2688 | Â Â Â Â Â Â Â Â Â Â Â Â Â irreducible, const CanonicalForm& evaluation, const |
---|
2689 | Â Â Â Â Â Â Â Â Â Â Â Â Â ExtensionInfo& info, CFList& source, CFList& dest |
---|
2690 | Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
2691 | { |
---|
2692 | Â bool GF= (CFFactory::gettype()==GaloisFieldDomain); |
---|
2693 | Â CanonicalForm LCF= LC (F, 1); |
---|
2694 | Â CFArray *A= new CFArray [factors.length() - 1]; |
---|
2695 | Â bool wasInBounds= false; |
---|
2696 | Â bool hitBound= false; |
---|
2697 | Â int degMipo; |
---|
2698 | Â Variable alpha; |
---|
2699 | Â alpha= info.getAlpha(); |
---|
2700 | Â degMipo= degree (getMipo (alpha)); |
---|
2701 | |
---|
2702 | Â Variable gamma= info.getBeta(); |
---|
2703 | Â CanonicalForm primElemAlpha= info.getGamma(); |
---|
2704 | Â CanonicalForm imPrimElemAlpha= info.getDelta(); |
---|
2705 | |
---|
2706 | Â int stepSize= 2; |
---|
2707 | Â int l= ((minBound+1)/degMipo+1)*2; |
---|
2708 | Â l= tmax (l, 2); |
---|
2709 | Â if (start > l) |
---|
2710 | Â Â l= start; |
---|
2711 | Â int oldL= l/2; |
---|
2712 | Â bool reduced= false; |
---|
2713 | Â Variable y= F.mvar(); |
---|
2714 | Â Variable x= Variable (1); |
---|
2715 | Â CanonicalForm powX, imBasis, truncF; |
---|
2716 | Â CFMatrix Mat, C; |
---|
2717 | Â CFArray buf; |
---|
2718 | Â CFIterator iter; |
---|
2719 | Â long rank; |
---|
2720 | Â nmod_mat_t FLINTMat, FLINTMatInv, FLINTC, FLINTK, null; |
---|
2721 | Â CFListIterator j; |
---|
2722 | Â while (l <= liftBound) |
---|
2723 | Â { |
---|
2724 | Â Â if (start) |
---|
2725 | Â Â { |
---|
2726 | Â Â Â henselLiftResume12 (F, factors, start, l, Pi, diophant, M); |
---|
2727 | Â Â Â start= 0; |
---|
2728 | Â Â } |
---|
2729 | Â Â else |
---|
2730 | Â Â { |
---|
2731 | Â Â Â if (wasInBounds) |
---|
2732 | Â Â Â Â henselLiftResume12 (F, factors, oldL, l, Pi, diophant, M); |
---|
2733 | Â Â Â else |
---|
2734 | Â Â Â Â henselLift12 (F, factors, l, Pi, diophant, M); |
---|
2735 | Â Â } |
---|
2736 | |
---|
2737 | Â Â factors.insert (LCF); |
---|
2738 | |
---|
2739 | Â Â if (GF) |
---|
2740 | Â Â Â setCharacteristic (getCharacteristic()); |
---|
2741 | |
---|
2742 | Â Â powX= power (y-gamma, l); |
---|
2743 | Â Â Mat= CFMatrix (l*degMipo, l*degMipo); |
---|
2744 | Â Â for (int i= 0; i < l*degMipo; i++) |
---|
2745 | Â Â { |
---|
2746 | Â Â Â imBasis= mod (power (y, i), powX); |
---|
2747 | Â Â Â imBasis= imBasis (power (y, degMipo), y); |
---|
2748 | Â Â Â imBasis= imBasis (y, gamma); |
---|
2749 | Â Â Â iter= imBasis; |
---|
2750 | Â Â Â for (; iter.hasTerms(); iter++) |
---|
2751 | Â Â Â Â Mat (iter.exp()+ 1, i+1)= iter.coeff(); |
---|
2752 | Â Â } |
---|
2753 | |
---|
2754 | Â Â convertFacCFMatrix2nmod_mat_t (FLINTMat, Mat); |
---|
2755 | Â Â nmod_mat_init (FLINTMatInv, nmod_mat_nrows (FLINTMat), |
---|
2756 | Â Â Â Â Â Â Â Â Â Â nmod_mat_nrows (FLINTMat), getCharacteristic()); |
---|
2757 | Â Â nmod_mat_inv (FLINTMatInv, FLINTMat); |
---|
2758 | |
---|
2759 | Â Â if (GF) |
---|
2760 | Â Â Â setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); |
---|
2761 | |
---|
2762 | Â Â j= factors; |
---|
2763 | Â Â j++; |
---|
2764 | |
---|
2765 | Â Â truncF= mod (F, power (y, l)); |
---|
2766 | Â Â for (int i= 0; i < factors.length() - 1; i++, j++) |
---|
2767 | Â Â { |
---|
2768 | Â Â Â if (!wasInBounds) |
---|
2769 | Â Â Â Â A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ[i]); |
---|
2770 | Â Â Â else |
---|
2771 | Â Â Â Â A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL, bufQ[i], |
---|
2772 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i]); |
---|
2773 | Â Â } |
---|
2774 | |
---|
2775 | Â Â for (int i= 0; i < sizeBounds; i++) |
---|
2776 | Â Â { |
---|
2777 | Â Â Â if (bounds [i] + 1 <= (l/2)*degMipo) |
---|
2778 | Â Â Â { |
---|
2779 | Â Â Â Â wasInBounds= true; |
---|
2780 | Â Â Â Â int k= tmin (bounds [i] + 1, (l/2)*degMipo); |
---|
2781 | Â Â Â Â C= CFMatrix (l*degMipo - k, factors.length() - 1); |
---|
2782 | |
---|
2783 | Â Â Â Â for (int ii= 0; ii < factors.length() - 1; ii++) |
---|
2784 | Â Â Â Â { |
---|
2785 | Â Â Â Â Â if (A[ii].size() - 1 >= i) |
---|
2786 | Â Â Â Â Â { |
---|
2787 | Â Â Â Â Â Â if (GF) |
---|
2788 | Â Â Â Â Â Â { |
---|
2789 | Â Â Â Â Â Â Â A [ii] [i]= A [ii] [i] (y-evaluation, y); |
---|
2790 | Â Â Â Â Â Â Â setCharacteristic (getCharacteristic()); |
---|
2791 | Â Â Â Â Â Â Â A[ii] [i]= GF2FalphaRep (A[ii] [i], alpha); |
---|
2792 | Â Â Â Â Â Â Â if (alpha != gamma) |
---|
2793 | Â Â Â Â Â Â Â Â A [ii] [i]= mapDown (A[ii] [i], imPrimElemAlpha, primElemAlpha, |
---|
2794 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gamma, source, dest |
---|
2795 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
2796 | Â Â Â Â Â Â Â buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv); //TODO |
---|
2797 | Â Â Â Â Â Â } |
---|
2798 | Â Â Â Â Â Â else |
---|
2799 | Â Â Â Â Â Â { |
---|
2800 | Â Â Â Â Â Â Â A [ii] [i]= A [ii] [i] (y-evaluation, y); |
---|
2801 | Â Â Â Â Â Â Â if (alpha != gamma) |
---|
2802 | Â Â Â Â Â Â Â Â A[ii] [i]= mapDown (A[ii] [i], imPrimElemAlpha, primElemAlpha, |
---|
2803 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gamma, source, dest |
---|
2804 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
2805 | Â Â Â Â Â Â Â buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, FLINTMatInv); //TODO |
---|
2806 | Â Â Â Â Â Â } |
---|
2807 | Â Â Â Â Â Â writeInMatrix (C, buf, ii + 1, 0); |
---|
2808 | Â Â Â Â Â } |
---|
2809 | Â Â Â Â Â if (GF) |
---|
2810 | Â Â Â Â Â Â setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); |
---|
2811 | Â Â Â Â } |
---|
2812 | |
---|
2813 | Â Â Â Â if (GF) |
---|
2814 | Â Â Â Â Â setCharacteristic(getCharacteristic()); |
---|
2815 | |
---|
2816 | Â Â Â Â convertFacCFMatrix2nmod_mat_t (FLINTC, C); |
---|
2817 | Â Â Â Â nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), |
---|
2818 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
2819 | Â Â Â Â nmod_mat_mul (FLINTK, FLINTC, FLINTN); |
---|
2820 | Â Â Â Â nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), |
---|
2821 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
2822 | Â Â Â Â rank= nmod_mat_nullspace (null, FLINTK); |
---|
2823 | Â Â Â Â nmod_mat_clear (FLINTK); |
---|
2824 | Â Â Â Â nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); |
---|
2825 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
2826 | Â Â Â Â nmod_mat_init_set (FLINTC, FLINTN); |
---|
2827 | Â Â Â Â nmod_mat_clear (FLINTN); |
---|
2828 | Â Â Â Â nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), |
---|
2829 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
2830 | Â Â Â Â nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! |
---|
2831 | |
---|
2832 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
2833 | Â Â Â Â nmod_mat_window_clear (FLINTK); |
---|
2834 | Â Â Â Â nmod_mat_clear (null); |
---|
2835 | |
---|
2836 | Â Â Â Â if (GF) |
---|
2837 | Â Â Â Â Â setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); |
---|
2838 | |
---|
2839 | Â Â Â Â if (nmod_mat_ncols (FLINTN) == 1) |
---|
2840 | Â Â Â Â { |
---|
2841 | Â Â Â Â Â irreducible= true; |
---|
2842 | Â Â Â Â Â break; |
---|
2843 | Â Â Â Â } |
---|
2844 | Â Â Â Â if (isReduced (FLINTN)) |
---|
2845 | Â Â Â Â { |
---|
2846 | Â Â Â Â Â reduced= true; |
---|
2847 | Â Â Â Â Â break; |
---|
2848 | Â Â Â Â } |
---|
2849 | Â Â Â } |
---|
2850 | Â Â } |
---|
2851 | |
---|
2852 | Â Â nmod_mat_clear (FLINTMat); |
---|
2853 | Â Â nmod_mat_clear (FLINTMatInv); |
---|
2854 | |
---|
2855 | Â Â if (nmod_mat_ncols (FLINTN) == 1) |
---|
2856 | Â Â { |
---|
2857 | Â Â Â irreducible= true; |
---|
2858 | Â Â Â break; |
---|
2859 | Â Â } |
---|
2860 | Â Â if (reduced) |
---|
2861 | Â Â Â break; |
---|
2862 | Â Â oldL= l; |
---|
2863 | Â Â l += stepSize; |
---|
2864 | Â Â stepSize *= 2; |
---|
2865 | Â Â if (l > liftBound) |
---|
2866 | Â Â { |
---|
2867 | Â Â Â if (!hitBound) |
---|
2868 | Â Â Â { |
---|
2869 | Â Â Â Â l= liftBound; |
---|
2870 | Â Â Â Â hitBound= true; |
---|
2871 | Â Â Â } |
---|
2872 | Â Â Â else |
---|
2873 | Â Â Â Â break; |
---|
2874 | Â Â } |
---|
2875 | Â } |
---|
2876 | Â delete [] A; |
---|
2877 | Â if (!wasInBounds) |
---|
2878 | Â { |
---|
2879 | Â Â if (start) |
---|
2880 | Â Â Â henselLiftResume12 (F, factors, start, degree (F) + 1, Pi, diophant, M); |
---|
2881 | Â Â else |
---|
2882 | Â Â Â henselLift12 (F, factors, degree (F) + 1, Pi, diophant, M); |
---|
2883 | Â Â factors.insert (LCF); |
---|
2884 | Â } |
---|
2885 | Â return l; |
---|
2886 | } |
---|
2887 | #endif*/ |
---|
2888 | |
---|
2889 | // over Fq |
---|
2890 | int |
---|
2891 | liftAndComputeLattice (const CanonicalForm& F, int* bounds, int sizeBounds, |
---|
2892 |             int start, int liftBound, int minBound, CFList& factors, |
---|
2893 |             mat_zz_pE& NTLN, CFList& diophant, CFMatrix& M, CFArray& |
---|
2894 |             Pi, CFArray& bufQ, bool& irreducible |
---|
2895 | Â Â Â Â Â Â Â Â Â Â Â ) |
---|
2896 | { |
---|
2897 |  CanonicalForm LCF= LC (F, 1); |
---|
2898 |  CFArray *A= new CFArray [factors.length() - 1]; |
---|
2899 |  bool wasInBounds= false; |
---|
2900 |  bool hitBound= false; |
---|
2901 |  int l= (minBound+1)*2; |
---|
2902 |  int stepSize= 2; |
---|
2903 |  int oldL= l/2; |
---|
2904 |  bool reduced= false; |
---|
2905 | Â CFListIterator j; |
---|
2906 |  mat_zz_pE* NTLC, NTLK; |
---|
2907 | Â CFArray buf; |
---|
2908 | Â CFMatrix C; |
---|
2909 | Â Variable y=Â F.mvar(); |
---|
2910 | Â CanonicalForm truncF; |
---|
2911 |  while (l <= liftBound) |
---|
2912 | Â { |
---|
2913 |   if (start) |
---|
2914 | Â Â { |
---|
2915 |    henselLiftResume12 (F, factors, start, l, Pi, diophant, M); |
---|
2916 | Â Â Â start=Â 0; |
---|
2917 | Â Â } |
---|
2918 | Â Â else |
---|
2919 | Â Â { |
---|
2920 |    if (wasInBounds) |
---|
2921 |     henselLiftResume12 (F, factors, oldL, l, Pi, diophant, M); |
---|
2922 | Â Â Â else |
---|
2923 |     henselLift12 (F, factors, l, Pi, diophant, M); |
---|
2924 | Â Â } |
---|
2925 | |
---|
2926 | Â Â factors.insert (LCF); |
---|
2927 | Â Â j=Â factors; |
---|
2928 | Â Â j++; |
---|
2929 | |
---|
2930 |   truncF= mod (F, power (y,l)); |
---|
2931 |   for (int i= 0; i < factors.length() - 1; i++, j++) |
---|
2932 | Â Â { |
---|
2933 |    if (l == (minBound+1)*2) |
---|
2934 | Â Â Â { |
---|
2935 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ[i]); |
---|
2936 | Â Â Â } |
---|
2937 | Â Â Â else |
---|
2938 | Â Â Â { |
---|
2939 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL, bufQ[i], |
---|
2940 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i] |
---|
2941 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
2942 | Â Â Â } |
---|
2943 | Â Â } |
---|
2944 | |
---|
2945 |   for (int i= 0; i < sizeBounds; i++) |
---|
2946 | Â Â { |
---|
2947 |    if (bounds [i] + 1 <= l/2) |
---|
2948 | Â Â Â { |
---|
2949 | Â Â Â Â wasInBounds=Â true; |
---|
2950 |     int k= tmin (bounds [i] + 1, l/2); |
---|
2951 |     C= CFMatrix (l - k, factors.length() - 1); |
---|
2952 |     for (int ii= 0; ii < factors.length() - 1; ii++) |
---|
2953 | Â Â Â Â { |
---|
2954 | |
---|
2955 |      if (A[ii].size() - 1 >= i) |
---|
2956 | Â Â Â Â Â { |
---|
2957 |       buf= getCoeffs (A[ii] [i], k); |
---|
2958 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
2959 | Â Â Â Â Â } |
---|
2960 | Â Â Â Â } |
---|
2961 | |
---|
2962 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_pE(C); |
---|
2963 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
2964 |     transpose (NTLK, NTLK); |
---|
2965 |     kernel (NTLK, NTLK); |
---|
2966 |     transpose (NTLK, NTLK); |
---|
2967 | Â Â Â Â NTLN *=Â NTLK; |
---|
2968 | |
---|
2969 |     if (NTLN.NumCols() == 1) |
---|
2970 | Â Â Â Â { |
---|
2971 | Â Â Â Â Â irreducible=Â true; |
---|
2972 | Â Â Â Â Â break; |
---|
2973 | Â Â Â Â } |
---|
2974 |     if (isReduced (NTLN) && l > (minBound+1)*2) |
---|
2975 | Â Â Â Â { |
---|
2976 | Â Â Â Â Â reduced=Â true; |
---|
2977 | Â Â Â Â Â break; |
---|
2978 | Â Â Â Â } |
---|
2979 | Â Â Â } |
---|
2980 | Â Â } |
---|
2981 | |
---|
2982 |   if (NTLN.NumCols() == 1) |
---|
2983 | Â Â { |
---|
2984 | Â Â Â irreducible=Â true; |
---|
2985 | Â Â Â break; |
---|
2986 | Â Â } |
---|
2987 |   if (reduced) |
---|
2988 | Â Â Â break; |
---|
2989 | Â Â oldL=Â l; |
---|
2990 | Â Â l +=Â stepSize; |
---|
2991 | Â Â stepSize *=Â 2; |
---|
2992 |   if (l > liftBound) |
---|
2993 | Â Â { |
---|
2994 |    if (!hitBound) |
---|
2995 | Â Â Â { |
---|
2996 | Â Â Â Â l=Â liftBound; |
---|
2997 | Â Â Â Â hitBound=Â true; |
---|
2998 | Â Â Â } |
---|
2999 | Â Â Â else |
---|
3000 | Â Â Â Â break; |
---|
3001 | Â Â } |
---|
3002 | Â } |
---|
3003 |  delete [] A; |
---|
3004 |  if (!wasInBounds) |
---|
3005 | Â { |
---|
3006 |   if (start) |
---|
3007 |    henselLiftResume12 (F, factors, start, degree (F) + 1, Pi, diophant, M); |
---|
3008 | Â Â else |
---|
3009 |    henselLift12 (F, factors, degree (F) + 1, Pi, diophant, M); |
---|
3010 | Â Â factors.insert (LCF); |
---|
3011 | Â } |
---|
3012 |  return l; |
---|
3013 | } |
---|
3014 | |
---|
3015 | #ifdef HAVE_FLINT |
---|
3016 | int |
---|
3017 | liftAndComputeLatticeFq2Fp (const CanonicalForm& F, int* bounds, int sizeBounds, |
---|
3018 |               int start, int liftBound, int minBound, CFList& |
---|
3019 |               factors, nmod_mat_t FLINTN, CFList& diophant, |
---|
3020 |               CFMatrix& M, CFArray& Pi, CFArray& bufQ, bool& |
---|
3021 |               irreducible, const Variable& alpha |
---|
3022 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
3023 | #else |
---|
3024 | int |
---|
3025 | liftAndComputeLatticeFq2Fp (const CanonicalForm& F, int* bounds, int sizeBounds, |
---|
3026 |               int start, int liftBound, int minBound, CFList& |
---|
3027 |               factors, mat_zz_p& NTLN, CFList& diophant, CFMatrix& |
---|
3028 |               M, CFArray& Pi, CFArray& bufQ, bool& irreducible, |
---|
3029 |               const Variable& alpha |
---|
3030 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
3031 | #endif |
---|
3032 | { |
---|
3033 |  CanonicalForm LCF= LC (F, 1); |
---|
3034 |  CFArray *A= new CFArray [factors.length() - 1]; |
---|
3035 |  bool wasInBounds= false; |
---|
3036 |  int l= (minBound+1)*2; |
---|
3037 |  int oldL= l/2; |
---|
3038 |  int stepSize= 2; |
---|
3039 |  bool hitBound= false; |
---|
3040 |  int extensionDeg= degree (getMipo (alpha)); |
---|
3041 |  bool reduced= false; |
---|
3042 | Â CFListIterator j; |
---|
3043 | Â CFMatrix C; |
---|
3044 | Â CFArray buf; |
---|
3045 | #ifdef HAVE_FLINT |
---|
3046 |  long rank; |
---|
3047 |  nmod_mat_t FLINTC, FLINTK, null; |
---|
3048 | #else |
---|
3049 |  mat_zz_p* NTLC, NTLK; |
---|
3050 | #endif |
---|
3051 | Â Variable y=Â F.mvar(); |
---|
3052 | Â CanonicalForm truncF; |
---|
3053 |  while (l <= liftBound) |
---|
3054 | Â { |
---|
3055 |   if (start) |
---|
3056 | Â Â { |
---|
3057 |    henselLiftResume12 (F, factors, start, l, Pi, diophant, M); |
---|
3058 | Â Â Â start=Â 0; |
---|
3059 | Â Â } |
---|
3060 | Â Â else |
---|
3061 | Â Â { |
---|
3062 |    if (wasInBounds) |
---|
3063 |     henselLiftResume12 (F, factors, oldL, l, Pi, diophant, M); |
---|
3064 | Â Â Â else |
---|
3065 |     henselLift12 (F, factors, l, Pi, diophant, M); |
---|
3066 | Â Â } |
---|
3067 | |
---|
3068 | Â Â factors.insert (LCF); |
---|
3069 | Â Â j=Â factors; |
---|
3070 | Â Â j++; |
---|
3071 | |
---|
3072 |   truncF= mod (F, power (y,l)); |
---|
3073 |   for (int i= 0; i < factors.length() - 1; i++, j++) |
---|
3074 | Â Â { |
---|
3075 |    if (l == (minBound+1)*2) |
---|
3076 | Â Â Â { |
---|
3077 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ[i]); |
---|
3078 | Â Â Â } |
---|
3079 | Â Â Â else |
---|
3080 | Â Â Â { |
---|
3081 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL, bufQ[i], |
---|
3082 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i] |
---|
3083 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
3084 | Â Â Â } |
---|
3085 | Â Â } |
---|
3086 | |
---|
3087 |   for (int i= 0; i < sizeBounds; i++) |
---|
3088 | Â Â { |
---|
3089 |    if (bounds [i] + 1 <= l/2) |
---|
3090 | Â Â Â { |
---|
3091 | Â Â Â Â wasInBounds=Â true; |
---|
3092 |     int k= tmin (bounds [i] + 1, l/2); |
---|
3093 |     C= CFMatrix ((l - k)*extensionDeg, factors.length() - 1); |
---|
3094 |     for (int ii= 0; ii < factors.length() - 1; ii++) |
---|
3095 | Â Â Â Â { |
---|
3096 |      if (A[ii].size() - 1 >= i) |
---|
3097 | Â Â Â Â Â { |
---|
3098 |       buf= getCoeffs (A[ii] [i], k, alpha); |
---|
3099 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
3100 | Â Â Â Â Â } |
---|
3101 | Â Â Â Â } |
---|
3102 | |
---|
3103 | #ifdef HAVE_FLINT |
---|
3104 |     convertFacCFMatrix2nmod_mat_t (FLINTC, C); |
---|
3105 |     nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), |
---|
3106 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
3107 |     nmod_mat_mul (FLINTK, FLINTC, FLINTN); |
---|
3108 |     nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), |
---|
3109 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
3110 |     rank= nmod_mat_nullspace (null, FLINTK); |
---|
3111 | Â Â Â Â nmod_mat_clear (FLINTK); |
---|
3112 |     nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); |
---|
3113 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
3114 |     nmod_mat_init_set (FLINTC, FLINTN); |
---|
3115 | Â Â Â Â nmod_mat_clear (FLINTN); |
---|
3116 |     nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), |
---|
3117 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
3118 |     nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! |
---|
3119 | |
---|
3120 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
3121 | Â Â Â Â nmod_mat_window_clear (FLINTK); |
---|
3122 | Â Â Â Â nmod_mat_clear (null); |
---|
3123 | #else |
---|
3124 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_p(C); |
---|
3125 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
3126 |     transpose (NTLK, NTLK); |
---|
3127 |     kernel (NTLK, NTLK); |
---|
3128 |     transpose (NTLK, NTLK); |
---|
3129 | Â Â Â Â NTLN *=Â NTLK; |
---|
3130 | #endif |
---|
3131 | |
---|
3132 | #ifdef HAVE_FLINT |
---|
3133 |     if (nmod_mat_nrows (FLINTN) == 1) |
---|
3134 | #else |
---|
3135 |     if (NTLN.NumCols() == 1) |
---|
3136 | #endif |
---|
3137 | Â Â Â Â { |
---|
3138 | Â Â Â Â Â irreducible=Â true; |
---|
3139 | Â Â Â Â Â break; |
---|
3140 | Â Â Â Â } |
---|
3141 | #ifdef HAVE_FLINT |
---|
3142 |     if (isReduced (FLINTN) && l > (minBound+1)*2) |
---|
3143 | #else |
---|
3144 |     if (isReduced (NTLN) && l > (minBound+1)*2) |
---|
3145 | #endif |
---|
3146 | Â Â Â Â { |
---|
3147 | Â Â Â Â Â reduced=Â true; |
---|
3148 | Â Â Â Â Â break; |
---|
3149 | Â Â Â Â } |
---|
3150 | Â Â Â } |
---|
3151 | Â Â } |
---|
3152 | |
---|
3153 | #ifdef HAVE_FLINT |
---|
3154 |   if (nmod_mat_ncols (FLINTN) == 1) |
---|
3155 | #else |
---|
3156 |   if (NTLN.NumCols() == 1) |
---|
3157 | #endif |
---|
3158 | Â Â { |
---|
3159 | Â Â Â irreducible=Â true; |
---|
3160 | Â Â Â break; |
---|
3161 | Â Â } |
---|
3162 |   if (reduced) |
---|
3163 | Â Â Â break; |
---|
3164 | Â Â oldL=Â l; |
---|
3165 | Â Â l +=Â stepSize; |
---|
3166 | Â Â stepSize *=Â 2; |
---|
3167 |   if (l > liftBound) |
---|
3168 | Â Â { |
---|
3169 |    if (!hitBound) |
---|
3170 | Â Â Â { |
---|
3171 | Â Â Â Â l=Â liftBound; |
---|
3172 | Â Â Â Â hitBound=Â true; |
---|
3173 | Â Â Â } |
---|
3174 | Â Â Â else |
---|
3175 | Â Â Â Â break; |
---|
3176 | Â Â } |
---|
3177 | Â } |
---|
3178 |  delete [] A; |
---|
3179 |  if (!wasInBounds) |
---|
3180 | Â { |
---|
3181 |   if (start) |
---|
3182 |    henselLiftResume12 (F, factors, start, degree (F) + 1, Pi, diophant, M); |
---|
3183 | Â Â else |
---|
3184 |    henselLift12 (F, factors, degree (F) + 1, Pi, diophant, M); |
---|
3185 | Â Â factors.insert (LCF); |
---|
3186 | Â } |
---|
3187 |  return l; |
---|
3188 | } |
---|
3189 | |
---|
3190 | CFList |
---|
3191 | increasePrecision (CanonicalForm& F, CFList& factors, int factorsFound, |
---|
3192 |           int oldNumCols, int oldL, int precision |
---|
3193 | Â Â Â Â Â Â Â Â Â ) |
---|
3194 | { |
---|
3195 |  int d; |
---|
3196 |  bool isIrreducible= false; |
---|
3197 |  int* bounds= computeBounds (F, d, isIrreducible); |
---|
3198 |  if (isIrreducible) |
---|
3199 | Â { |
---|
3200 |   delete [] bounds; |
---|
3201 | Â Â CanonicalForm G=Â F; |
---|
3202 | Â Â F=Â 1; |
---|
3203 |   return CFList (G); |
---|
3204 | Â } |
---|
3205 |  CFArray * A= new CFArray [factors.length()]; |
---|
3206 | Â CFArray bufQ=Â CFArray (factors.length()); |
---|
3207 | #ifdef HAVE_FLINT |
---|
3208 | Â nmod_mat_t FLINTN; |
---|
3209 |  nmod_mat_init (FLINTN,factors.length(),factors.length(), getCharacteristic()); |
---|
3210 |  for (long i=factors.length()-1; i >= 0; i--) |
---|
3211 |   nmod_mat_entry (FLINTN, i, i)= 1; |
---|
3212 | #else |
---|
3213 | Â mat_zz_p NTLN; |
---|
3214 |  ident (NTLN, factors.length()); |
---|
3215 | #endif |
---|
3216 |  int minBound= bounds[0]; |
---|
3217 |  for (int i= 1; i < d; i++) |
---|
3218 | Â { |
---|
3219 |   if (bounds[i] != 0) |
---|
3220 |    minBound= tmin (minBound, bounds[i]); |
---|
3221 | Â } |
---|
3222 |  int l= tmax (2*(minBound + 1), oldL); |
---|
3223 |  int oldL2= l/2; |
---|
3224 |  int stepSize= 2; |
---|
3225 |  bool useOldQs= false; |
---|
3226 |  bool hitBound= false; |
---|
3227 | Â CFListIterator j; |
---|
3228 | Â CFMatrix C; |
---|
3229 | Â CFArray buf; |
---|
3230 | #ifdef HAVE_FLINT |
---|
3231 |  long rank; |
---|
3232 |  nmod_mat_t FLINTC, FLINTK, null; |
---|
3233 | #else |
---|
3234 |  mat_zz_p* NTLC, NTLK; |
---|
3235 | #endif |
---|
3236 | Â Variable y=Â F.mvar(); |
---|
3237 | Â CanonicalForm truncF; |
---|
3238 |  while (l <= precision) |
---|
3239 | Â { |
---|
3240 | Â Â j=Â factors; |
---|
3241 |   truncF= mod (F, power (y,l)); |
---|
3242 |   if (useOldQs) |
---|
3243 | Â Â { |
---|
3244 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
3245 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL2, bufQ[i], |
---|
3246 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i] |
---|
3247 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
3248 | Â Â } |
---|
3249 | Â Â else |
---|
3250 | Â Â { |
---|
3251 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
3252 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ [i]); |
---|
3253 | Â Â } |
---|
3254 | Â Â useOldQs=Â true; |
---|
3255 |   for (int i= 0; i < d; i++) |
---|
3256 | Â Â { |
---|
3257 |    if (bounds [i] + 1 <= l/2) |
---|
3258 | Â Â Â { |
---|
3259 |     int k= tmin (bounds [i] + 1, l/2); |
---|
3260 |     C= CFMatrix (l - k, factors.length()); |
---|
3261 |     for (int ii= 0; ii < factors.length(); ii++) |
---|
3262 | Â Â Â Â { |
---|
3263 |      if (A[ii].size() - 1 >= i) |
---|
3264 | Â Â Â Â Â { |
---|
3265 |       buf= getCoeffs (A[ii] [i], k); |
---|
3266 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
3267 | Â Â Â Â Â } |
---|
3268 | Â Â Â Â } |
---|
3269 | #ifdef HAVE_FLINT |
---|
3270 |     convertFacCFMatrix2nmod_mat_t (FLINTC, C); |
---|
3271 |     nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), |
---|
3272 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
3273 |     nmod_mat_mul (FLINTK, FLINTC, FLINTN); |
---|
3274 |     nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), |
---|
3275 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
3276 |     rank= nmod_mat_nullspace (null, FLINTK); |
---|
3277 | Â Â Â Â nmod_mat_clear (FLINTK); |
---|
3278 |     nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); |
---|
3279 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
3280 |     nmod_mat_init_set (FLINTC, FLINTN); |
---|
3281 | Â Â Â Â nmod_mat_clear (FLINTN); |
---|
3282 |     nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), |
---|
3283 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
3284 |     nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! |
---|
3285 | |
---|
3286 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
3287 | Â Â Â Â nmod_mat_window_clear (FLINTK); |
---|
3288 | Â Â Â Â nmod_mat_clear (null); |
---|
3289 | #else |
---|
3290 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_p(C); |
---|
3291 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
3292 |     transpose (NTLK, NTLK); |
---|
3293 |     kernel (NTLK, NTLK); |
---|
3294 |     transpose (NTLK, NTLK); |
---|
3295 | Â Â Â Â NTLN *=Â NTLK; |
---|
3296 | #endif |
---|
3297 | #ifdef HAVE_FLINT |
---|
3298 |     if (nmod_mat_ncols (FLINTN) == 1) |
---|
3299 | Â Â Â Â { |
---|
3300 | Â Â Â Â Â nmod_mat_clear (FLINTN); |
---|
3301 | #else |
---|
3302 |     if (NTLN.NumCols() == 1) |
---|
3303 | Â Â Â Â { |
---|
3304 | #endif |
---|
3305 |      delete [] A; |
---|
3306 |      delete [] bounds; |
---|
3307 | Â Â Â Â Â CanonicalForm G=Â F; |
---|
3308 | Â Â Â Â Â F=Â 1; |
---|
3309 |      return CFList (G); |
---|
3310 | Â Â Â Â } |
---|
3311 | Â Â Â } |
---|
3312 | Â Â } |
---|
3313 | |
---|
3314 | #ifdef HAVE_FLINT |
---|
3315 |   if (nmod_mat_ncols (FLINTN) < oldNumCols - factorsFound) |
---|
3316 | Â Â { |
---|
3317 |    if (isReduced (FLINTN)) |
---|
3318 | Â Â Â { |
---|
3319 |     int * factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; |
---|
3320 |     for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) |
---|
3321 | #else |
---|
3322 |   if (NTLN.NumCols() < oldNumCols - factorsFound) |
---|
3323 | Â Â { |
---|
3324 |    if (isReduced (NTLN)) |
---|
3325 | Â Â Â { |
---|
3326 |     int * factorsFoundIndex= new int [NTLN.NumCols()]; |
---|
3327 |     for (long i= 0; i < NTLN.NumCols(); i++) |
---|
3328 | #endif |
---|
3329 | Â Â Â Â Â factorsFoundIndex[i]=Â 0; |
---|
3330 |     int factorsFound2= 0; |
---|
3331 | Â Â Â Â CFList result; |
---|
3332 | Â Â Â Â CanonicalForm bufF=Â F; |
---|
3333 | #ifdef HAVE_FLINT |
---|
3334 |     reconstructionTry (result, bufF, factors, degree (F) + 1, factorsFound2, |
---|
3335 |               factorsFoundIndex, FLINTN, false |
---|
3336 | Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
3337 |     if (result.length() == nmod_mat_ncols (FLINTN)) |
---|
3338 | Â Â Â Â { |
---|
3339 | Â Â Â Â Â nmod_mat_clear (FLINTN); |
---|
3340 | #else |
---|
3341 |     reconstructionTry (result, bufF, factors, degree (F) + 1, factorsFound2, |
---|
3342 |               factorsFoundIndex, NTLN, false |
---|
3343 | Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
3344 |     if (result.length() == NTLN.NumCols()) |
---|
3345 | Â Â Â Â { |
---|
3346 | #endif |
---|
3347 |      delete [] factorsFoundIndex; |
---|
3348 |      delete [] A; |
---|
3349 |      delete [] bounds; |
---|
3350 | Â Â Â Â Â F=Â 1; |
---|
3351 |      return result; |
---|
3352 | Â Â Â Â } |
---|
3353 |     delete [] factorsFoundIndex; |
---|
3354 | Â Â Â } |
---|
3355 |    else if (l == precision) |
---|
3356 | Â Â Â { |
---|
3357 | Â Â Â Â CanonicalForm bufF=Â F; |
---|
3358 | #ifdef HAVE_FLINT |
---|
3359 |     int * zeroOne= extractZeroOneVecs (FLINTN); |
---|
3360 | Â Â Â Â CFList result=Â reconstruction (bufF,factors,zeroOne,precision,FLINTN); |
---|
3361 | Â Â Â Â nmod_mat_clear (FLINTN); |
---|
3362 | #else |
---|
3363 |     int * zeroOne= extractZeroOneVecs (NTLN); |
---|
3364 |     CFList result= reconstruction (bufF, factors, zeroOne, precision, NTLN); |
---|
3365 | #endif |
---|
3366 | Â Â Â Â F=Â bufF; |
---|
3367 |     delete [] zeroOne; |
---|
3368 |     delete [] A; |
---|
3369 |     delete [] bounds; |
---|
3370 |     return result; |
---|
3371 | Â Â Â } |
---|
3372 | Â Â } |
---|
3373 | Â Â oldL2=Â l; |
---|
3374 | Â Â l +=Â stepSize; |
---|
3375 | Â Â stepSize *=Â 2; |
---|
3376 |   if (l > precision) |
---|
3377 | Â Â { |
---|
3378 |    if (!hitBound) |
---|
3379 | Â Â Â { |
---|
3380 | Â Â Â Â l=Â precision; |
---|
3381 | Â Â Â Â hitBound=Â true; |
---|
3382 | Â Â Â } |
---|
3383 | Â Â Â else |
---|
3384 | Â Â Â Â break; |
---|
3385 | Â Â } |
---|
3386 | Â } |
---|
3387 | #ifdef HAVE_FLINT |
---|
3388 | Â nmod_mat_clear (FLINTN); |
---|
3389 | #endif |
---|
3390 |  delete [] bounds; |
---|
3391 |  delete [] A; |
---|
3392 |  return CFList(); |
---|
3393 | } |
---|
3394 | |
---|
3395 | CFList |
---|
3396 | increasePrecision (CanonicalForm& F, CFList& factors, int factorsFound, |
---|
3397 |           int oldNumCols, int oldL, const Variable&, |
---|
3398 |           int precision |
---|
3399 | Â Â Â Â Â Â Â Â Â ) |
---|
3400 | { |
---|
3401 |  int d; |
---|
3402 |  bool isIrreducible= false; |
---|
3403 |  int* bounds= computeBounds (F, d, isIrreducible); |
---|
3404 |  if (isIrreducible) |
---|
3405 | Â { |
---|
3406 |   delete [] bounds; |
---|
3407 | Â Â CanonicalForm G=Â F; |
---|
3408 | Â Â F=Â 1; |
---|
3409 |   return CFList (G); |
---|
3410 | Â } |
---|
3411 |  CFArray * A= new CFArray [factors.length()]; |
---|
3412 | Â CFArray bufQ=Â CFArray (factors.length()); |
---|
3413 | Â mat_zz_pE NTLN; |
---|
3414 |  ident (NTLN, factors.length()); |
---|
3415 |  int minBound= bounds[0]; |
---|
3416 |  for (int i= 1; i < d; i++) |
---|
3417 | Â { |
---|
3418 |   if (bounds[i] != 0) |
---|
3419 |    minBound= tmin (minBound, bounds[i]); |
---|
3420 | Â } |
---|
3421 |  int l= tmax (2*(minBound + 1), oldL); |
---|
3422 |  int oldL2= l/2; |
---|
3423 |  int stepSize= 2; |
---|
3424 |  bool useOldQs= false; |
---|
3425 |  bool hitBound= false; |
---|
3426 | Â CFListIterator j; |
---|
3427 | Â CFMatrix C; |
---|
3428 |  mat_zz_pE* NTLC, NTLK; |
---|
3429 | Â CFArray buf; |
---|
3430 | Â Variable y=Â F.mvar(); |
---|
3431 | Â CanonicalForm truncF; |
---|
3432 |  while (l <= precision) |
---|
3433 | Â { |
---|
3434 | Â Â j=Â factors; |
---|
3435 |   truncF= mod (F, power (y,l)); |
---|
3436 |   if (useOldQs) |
---|
3437 | Â Â { |
---|
3438 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
3439 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL2, bufQ[i], |
---|
3440 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i] |
---|
3441 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
3442 | Â Â } |
---|
3443 | Â Â else |
---|
3444 | Â Â { |
---|
3445 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
3446 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ [i]); |
---|
3447 | Â Â } |
---|
3448 | Â Â useOldQs=Â true; |
---|
3449 |   for (int i= 0; i < d; i++) |
---|
3450 | Â Â { |
---|
3451 |    if (bounds [i] + 1 <= l/2) |
---|
3452 | Â Â Â { |
---|
3453 |     int k= tmin (bounds [i] + 1, l/2); |
---|
3454 |     C= CFMatrix (l - k, factors.length()); |
---|
3455 |     for (int ii= 0; ii < factors.length(); ii++) |
---|
3456 | Â Â Â Â { |
---|
3457 |      if (A[ii].size() - 1 >= i) |
---|
3458 | Â Â Â Â Â { |
---|
3459 |       buf= getCoeffs (A[ii] [i], k); |
---|
3460 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
3461 | Â Â Â Â Â } |
---|
3462 | Â Â Â Â } |
---|
3463 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_pE(C); |
---|
3464 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
3465 |     transpose (NTLK, NTLK); |
---|
3466 |     kernel (NTLK, NTLK); |
---|
3467 |     transpose (NTLK, NTLK); |
---|
3468 | Â Â Â Â NTLN *=Â NTLK; |
---|
3469 |     if (NTLN.NumCols() == 1) |
---|
3470 | Â Â Â Â { |
---|
3471 |      delete [] A; |
---|
3472 |      delete [] bounds; |
---|
3473 | Â Â Â Â Â CanonicalForm G=Â F; |
---|
3474 | Â Â Â Â Â F=Â 1; |
---|
3475 |      return CFList (G); |
---|
3476 | Â Â Â Â } |
---|
3477 | Â Â Â } |
---|
3478 | Â Â } |
---|
3479 | |
---|
3480 |   if (NTLN.NumCols() < oldNumCols - factorsFound) |
---|
3481 | Â Â { |
---|
3482 |    if (isReduced (NTLN)) |
---|
3483 | Â Â Â { |
---|
3484 |     int * factorsFoundIndex= new int [NTLN.NumCols()]; |
---|
3485 |     for (long i= 0; i < NTLN.NumCols(); i++) |
---|
3486 | Â Â Â Â Â factorsFoundIndex[i]=Â 0; |
---|
3487 |     int factorsFound2= 0; |
---|
3488 | Â Â Â Â CFList result; |
---|
3489 | Â Â Â Â CanonicalForm bufF=Â F; |
---|
3490 |     reconstructionTry (result, bufF, factors, degree (F) + 1, factorsFound2, |
---|
3491 |               factorsFoundIndex, NTLN, false); |
---|
3492 |     if (result.length() == NTLN.NumCols()) |
---|
3493 | Â Â Â Â { |
---|
3494 |      delete [] factorsFoundIndex; |
---|
3495 |      delete [] A; |
---|
3496 |      delete [] bounds; |
---|
3497 | Â Â Â Â Â F=Â 1; |
---|
3498 |      return result; |
---|
3499 | Â Â Â Â } |
---|
3500 |     delete [] factorsFoundIndex; |
---|
3501 | Â Â Â } |
---|
3502 |    else if (l == precision) |
---|
3503 | Â Â Â { |
---|
3504 | Â Â Â Â CanonicalForm bufF=Â F; |
---|
3505 |     int * zeroOne= extractZeroOneVecs (NTLN); |
---|
3506 |     CFList result= reconstruction (bufF, factors, zeroOne, precision, NTLN); |
---|
3507 | Â Â Â Â F=Â bufF; |
---|
3508 |     delete [] zeroOne; |
---|
3509 |     delete [] A; |
---|
3510 |     delete [] bounds; |
---|
3511 |     return result; |
---|
3512 | Â Â Â } |
---|
3513 | Â Â } |
---|
3514 | Â Â oldL2=Â l; |
---|
3515 | Â Â l +=Â stepSize; |
---|
3516 | Â Â stepSize *=Â 2; |
---|
3517 |   if (l > precision) |
---|
3518 | Â Â { |
---|
3519 |    if (!hitBound) |
---|
3520 | Â Â Â { |
---|
3521 | Â Â Â Â l=Â precision; |
---|
3522 | Â Â Â Â hitBound=Â true; |
---|
3523 | Â Â Â } |
---|
3524 | Â Â Â else |
---|
3525 | Â Â Â Â break; |
---|
3526 | Â Â } |
---|
3527 | Â } |
---|
3528 |  delete [] bounds; |
---|
3529 |  delete [] A; |
---|
3530 |  return CFList(); |
---|
3531 | } |
---|
3532 | |
---|
3533 | //over field extension |
---|
3534 | CFList |
---|
3535 | extIncreasePrecision (CanonicalForm& F, CFList& factors, int factorsFound, |
---|
3536 |            int oldNumCols, int oldL, const CanonicalForm& evaluation, |
---|
3537 |            const ExtensionInfo& info, CFList& source, CFList& dest, |
---|
3538 |            int precision |
---|
3539 | Â Â Â Â Â Â Â Â Â Â Â ) |
---|
3540 | { |
---|
3541 |  bool GF= (CFFactory::gettype()==GaloisFieldDomain); |
---|
3542 |  int degMipo= degree (getMipo (info.getAlpha())); |
---|
3543 | Â Variable alpha=Â info.getAlpha(); |
---|
3544 |  int d; |
---|
3545 |  bool isIrreducible= false; |
---|
3546 |  int* bounds= computeBounds (F, d, isIrreducible); |
---|
3547 |  if (isIrreducible) |
---|
3548 | Â { |
---|
3549 |   delete [] bounds; |
---|
3550 | Â Â CanonicalForm G=Â F; |
---|
3551 | Â Â F=Â 1; |
---|
3552 |   return CFList (G); |
---|
3553 | Â } |
---|
3554 | |
---|
3555 |  CFArray * A= new CFArray [factors.length()]; |
---|
3556 | Â CFArray bufQ=Â CFArray (factors.length()); |
---|
3557 | Â zz_p::init (getCharacteristic()); |
---|
3558 | Â mat_zz_p NTLN; |
---|
3559 |  ident (NTLN, factors.length()); |
---|
3560 |  int minBound= bounds[0]; |
---|
3561 |  for (int i= 1; i < d; i++) |
---|
3562 | Â { |
---|
3563 |   if (bounds[i] != 0) |
---|
3564 |    minBound= tmin (minBound, bounds[i]); |
---|
3565 | Â } |
---|
3566 |  int l= tmax (oldL, 2*((minBound+1)/degMipo+1)); |
---|
3567 |  int oldL2= l/2; |
---|
3568 |  int stepSize= 2; |
---|
3569 |  bool useOldQs= false; |
---|
3570 |  bool hitBound= false; |
---|
3571 | Â Variable gamma=Â info.getBeta(); |
---|
3572 | Â CanonicalForm primElemAlpha=Â info.getGamma(); |
---|
3573 | Â CanonicalForm imPrimElemAlpha=Â info.getDelta(); |
---|
3574 | Â CFListIterator j; |
---|
3575 | Â Variable y=Â F.mvar(); |
---|
3576 |  CanonicalForm powX, imBasis, truncF; |
---|
3577 |  CFMatrix Mat, C; |
---|
3578 | Â CFIterator iter; |
---|
3579 |  mat_zz_p* NTLMat,*NTLC, NTLK; |
---|
3580 | Â CFArray buf; |
---|
3581 |  while (l <= precision) |
---|
3582 | Â { |
---|
3583 | Â Â j=Â factors; |
---|
3584 |   if (GF) |
---|
3585 | Â Â Â setCharacteristic (getCharacteristic()); |
---|
3586 |   powX= power (y-gamma, l); |
---|
3587 |   Mat= CFMatrix (l*degMipo, l*degMipo); |
---|
3588 |   for (int i= 0; i < l*degMipo; i++) |
---|
3589 | Â Â { |
---|
3590 |    imBasis= mod (power (y, i), powX); |
---|
3591 |    imBasis= imBasis (power (y, degMipo), y); |
---|
3592 |    imBasis= imBasis (y, gamma); |
---|
3593 | Â Â Â iter=Â imBasis; |
---|
3594 |    for (; iter.hasTerms(); iter++) |
---|
3595 |      Mat (iter.exp()+ 1, i+1)= iter.coeff(); |
---|
3596 | Â Â } |
---|
3597 | |
---|
3598 | Â Â NTLMat=Â convertFacCFMatrix2NTLmat_zz_p (Mat); |
---|
3599 | Â Â *NTLMat=Â inv (*NTLMat); |
---|
3600 |   if (GF) |
---|
3601 |    setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); |
---|
3602 | |
---|
3603 |   truncF= mod (F, power (y, l)); |
---|
3604 |   if (useOldQs) |
---|
3605 | Â Â { |
---|
3606 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
3607 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL2, bufQ[i], |
---|
3608 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i] |
---|
3609 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
3610 | Â Â } |
---|
3611 | Â Â else |
---|
3612 | Â Â { |
---|
3613 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
3614 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ [i]); |
---|
3615 | Â Â } |
---|
3616 | Â Â useOldQs=Â true; |
---|
3617 |   for (int i= 0; i < d; i++) |
---|
3618 | Â Â { |
---|
3619 |    if (bounds [i] + 1 <= (l/2)*degMipo) |
---|
3620 | Â Â Â { |
---|
3621 |     int k= tmin (bounds [i] + 1, (l/2)*degMipo); |
---|
3622 |     C= CFMatrix (l*degMipo - k, factors.length()); |
---|
3623 |     for (int ii= 0; ii < factors.length(); ii++) |
---|
3624 | Â Â Â Â { |
---|
3625 |      if (A[ii].size() - 1 >= i) |
---|
3626 | Â Â Â Â Â { |
---|
3627 |       if (GF) |
---|
3628 | Â Â Â Â Â Â { |
---|
3629 |        A[ii] [i]= A [ii] [i] (y-evaluation, y); |
---|
3630 | Â Â Â Â Â Â Â setCharacteristic (getCharacteristic()); |
---|
3631 |        A[ii] [i]= GF2FalphaRep (A[ii] [i], alpha); |
---|
3632 |        if (alpha != gamma) |
---|
3633 |         A [ii] [i]= mapDown (A[ii] [i], imPrimElemAlpha, primElemAlpha, |
---|
3634 |                    gamma, source, dest |
---|
3635 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
3636 |        buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, *NTLMat); |
---|
3637 | Â Â Â Â Â Â } |
---|
3638 | Â Â Â Â Â Â else |
---|
3639 | Â Â Â Â Â Â { |
---|
3640 |        A [ii] [i]= A [ii] [i] (y-evaluation, y); |
---|
3641 |        if (alpha != gamma) |
---|
3642 |         A[ii] [i]= mapDown (A[ii] [i], imPrimElemAlpha, primElemAlpha, |
---|
3643 |                   gamma, source, dest |
---|
3644 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
3645 |        buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, *NTLMat); |
---|
3646 | Â Â Â Â Â Â } |
---|
3647 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
3648 | Â Â Â Â Â } |
---|
3649 |      if (GF) |
---|
3650 |       setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); |
---|
3651 | Â Â Â Â } |
---|
3652 | |
---|
3653 |     if (GF) |
---|
3654 | Â Â Â Â Â setCharacteristic(getCharacteristic()); |
---|
3655 | |
---|
3656 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_p(C); |
---|
3657 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
3658 |     transpose (NTLK, NTLK); |
---|
3659 |     kernel (NTLK, NTLK); |
---|
3660 |     transpose (NTLK, NTLK); |
---|
3661 | Â Â Â Â NTLN *=Â NTLK; |
---|
3662 | |
---|
3663 |     if (GF) |
---|
3664 |      setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); |
---|
3665 | |
---|
3666 |     if (NTLN.NumCols() == 1) |
---|
3667 | Â Â Â Â { |
---|
3668 | Â Â Â Â Â Variable y=Â Variable (2); |
---|
3669 |      CanonicalForm tmp= F (y - evaluation, y); |
---|
3670 |      CFList source, dest; |
---|
3671 |      tmp= mapDown (tmp, info, source, dest); |
---|
3672 |      delete [] A; |
---|
3673 |      delete [] bounds; |
---|
3674 | Â Â Â Â Â F=Â 1; |
---|
3675 |      return CFList (tmp); |
---|
3676 | Â Â Â Â } |
---|
3677 | Â Â Â } |
---|
3678 | Â Â } |
---|
3679 | |
---|
3680 |   if (NTLN.NumCols() < oldNumCols - factorsFound) |
---|
3681 | Â Â { |
---|
3682 |    if (isReduced (NTLN)) |
---|
3683 | Â Â Â { |
---|
3684 |     int * factorsFoundIndex= new int [NTLN.NumCols()]; |
---|
3685 |     for (long i= 0; i < NTLN.NumCols(); i++) |
---|
3686 | Â Â Â Â Â factorsFoundIndex[i]=Â 0; |
---|
3687 |     int factorsFound2= 0; |
---|
3688 | Â Â Â Â CFList result; |
---|
3689 | Â Â Â Â CanonicalForm bufF=Â F; |
---|
3690 |     extReconstructionTry (result, bufF, factors,degree (F)+1, factorsFound2, |
---|
3691 |                factorsFoundIndex, NTLN, false, info, evaluation |
---|
3692 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
3693 |     if (result.length() == NTLN.NumCols()) |
---|
3694 | Â Â Â Â { |
---|
3695 |      delete [] factorsFoundIndex; |
---|
3696 |      delete [] A; |
---|
3697 |      delete [] bounds; |
---|
3698 | Â Â Â Â Â F=Â 1; |
---|
3699 |      return result; |
---|
3700 | Â Â Â Â } |
---|
3701 |     delete [] factorsFoundIndex; |
---|
3702 | Â Â Â } |
---|
3703 |    else if (l == precision) |
---|
3704 | Â Â Â { |
---|
3705 | Â Â Â Â CanonicalForm bufF=Â F; |
---|
3706 |     int * zeroOne= extractZeroOneVecs (NTLN); |
---|
3707 |     CFList result= extReconstruction (bufF, factors, zeroOne, precision, |
---|
3708 |                      NTLN, info, evaluation |
---|
3709 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
3710 | Â Â Â Â F=Â bufF; |
---|
3711 |     delete [] zeroOne; |
---|
3712 |     delete [] A; |
---|
3713 |     delete [] bounds; |
---|
3714 |     return result; |
---|
3715 | Â Â Â } |
---|
3716 | Â Â } |
---|
3717 | Â Â oldL2=Â l; |
---|
3718 | Â Â l +=Â stepSize; |
---|
3719 | Â Â stepSize *=Â 2; |
---|
3720 |   if (l > precision) |
---|
3721 | Â Â { |
---|
3722 |    if (!hitBound) |
---|
3723 | Â Â Â { |
---|
3724 | Â Â Â Â hitBound=Â true; |
---|
3725 | Â Â Â Â l=Â precision; |
---|
3726 | Â Â Â } |
---|
3727 | Â Â Â else |
---|
3728 | Â Â Â Â break; |
---|
3729 | Â Â } |
---|
3730 | Â } |
---|
3731 |  delete [] bounds; |
---|
3732 |  delete [] A; |
---|
3733 |  return CFList(); |
---|
3734 | } |
---|
3735 | |
---|
3736 | CFList |
---|
3737 | increasePrecision2 (const CanonicalForm& F, CFList& factors, |
---|
3738 |           const Variable& alpha, int precision) |
---|
3739 | { |
---|
3740 |  int d; |
---|
3741 |  bool isIrreducible= false; |
---|
3742 |  int* bounds= computeBounds (F, d, isIrreducible); |
---|
3743 |  if (isIrreducible) |
---|
3744 | Â { |
---|
3745 |   delete [] bounds; |
---|
3746 |   return CFList (F); |
---|
3747 | Â } |
---|
3748 |  CFArray * A= new CFArray [factors.length()]; |
---|
3749 | Â CFArray bufQ=Â CFArray (factors.length()); |
---|
3750 | Â zz_p::init (getCharacteristic()); |
---|
3751 | Â zz_pX NTLMipo=Â convertFacCF2NTLzzpX (getMipo (alpha)); |
---|
3752 | Â zz_pE::init (NTLMipo); |
---|
3753 | Â mat_zz_pE NTLN; |
---|
3754 |  ident (NTLN, factors.length()); |
---|
3755 |  int minBound= bounds[0]; |
---|
3756 |  for (int i= 1; i < d; i++) |
---|
3757 | Â { |
---|
3758 |   if (bounds[i] != 0) |
---|
3759 |    minBound= tmin (minBound, bounds[i]); |
---|
3760 | Â } |
---|
3761 |  int l= tmin (2*(minBound + 1), precision); |
---|
3762 |  int oldL= l/2; |
---|
3763 |  int stepSize= 2; |
---|
3764 |  bool useOldQs= false; |
---|
3765 |  bool hitBound= false; |
---|
3766 | Â CFListIterator j; |
---|
3767 | Â CFMatrix C; |
---|
3768 | Â CFArray buf; |
---|
3769 |  mat_zz_pE* NTLC, NTLK; |
---|
3770 | Â Variable y=Â F.mvar(); |
---|
3771 | Â CanonicalForm truncF; |
---|
3772 |  while (l <= precision) |
---|
3773 | Â { |
---|
3774 | Â Â j=Â factors; |
---|
3775 |   truncF= mod (F, power (y, l)); |
---|
3776 |   if (useOldQs) |
---|
3777 | Â Â { |
---|
3778 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
3779 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL, bufQ[i], bufQ[i]); |
---|
3780 | Â Â } |
---|
3781 | Â Â else |
---|
3782 | Â Â { |
---|
3783 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
3784 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ [i]); |
---|
3785 | Â Â } |
---|
3786 | Â Â useOldQs=Â true; |
---|
3787 |   for (int i= 0; i < d; i++) |
---|
3788 | Â Â { |
---|
3789 |    if (bounds [i] + 1 <= l/2) |
---|
3790 | Â Â Â { |
---|
3791 |     int k= tmin (bounds [i] + 1, l/2); |
---|
3792 |     C= CFMatrix (l - k, factors.length()); |
---|
3793 |     for (int ii= 0; ii < factors.length(); ii++) |
---|
3794 | Â Â Â Â { |
---|
3795 |      if (A[ii].size() - 1 >= i) |
---|
3796 | Â Â Â Â Â { |
---|
3797 |       buf= getCoeffs (A[ii] [i], k); |
---|
3798 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
3799 | Â Â Â Â Â } |
---|
3800 | Â Â Â Â } |
---|
3801 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_pE(C); |
---|
3802 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
3803 |     transpose (NTLK, NTLK); |
---|
3804 |     kernel (NTLK, NTLK); |
---|
3805 |     transpose (NTLK, NTLK); |
---|
3806 | Â Â Â Â NTLN *=Â NTLK; |
---|
3807 |     if (NTLN.NumCols() == 1) |
---|
3808 | Â Â Â Â { |
---|
3809 |      delete [] A; |
---|
3810 |      delete [] bounds; |
---|
3811 |      return CFList (F); |
---|
3812 | Â Â Â Â } |
---|
3813 | Â Â Â } |
---|
3814 | Â Â } |
---|
3815 | |
---|
3816 |   if (isReduced (NTLN) || l == precision) |
---|
3817 | Â Â { |
---|
3818 | Â Â Â CanonicalForm bufF=Â F; |
---|
3819 |    int * zeroOne= extractZeroOneVecs (NTLN); |
---|
3820 | Â Â Â CFList bufFactors=Â factors; |
---|
3821 |    CFList result= monicReconstruction (bufF, factors, zeroOne, precision, |
---|
3822 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â NTLN |
---|
3823 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
3824 |    if (result.length() != NTLN.NumCols() && l != precision) |
---|
3825 | Â Â Â Â factors=Â bufFactors; |
---|
3826 |    if (result.length() == NTLN.NumCols()) |
---|
3827 | Â Â Â { |
---|
3828 |     delete [] zeroOne; |
---|
3829 |     delete [] A; |
---|
3830 |     delete [] bounds; |
---|
3831 |     return result; |
---|
3832 | Â Â Â } |
---|
3833 |    if (l == precision) |
---|
3834 | Â Â Â { |
---|
3835 |     delete [] zeroOne; |
---|
3836 |     delete [] A; |
---|
3837 |     delete [] bounds; |
---|
3838 |     return Union (result, factors); |
---|
3839 | Â Â Â } |
---|
3840 | Â Â } |
---|
3841 | Â Â oldL=Â l; |
---|
3842 | Â Â l +=Â stepSize; |
---|
3843 | Â Â stepSize *=Â 2; |
---|
3844 |   if (l > precision) |
---|
3845 | Â Â { |
---|
3846 |    if (!hitBound) |
---|
3847 | Â Â Â { |
---|
3848 | Â Â Â Â l=Â precision; |
---|
3849 | Â Â Â Â hitBound=Â true; |
---|
3850 | Â Â Â } |
---|
3851 | Â Â Â else |
---|
3852 | Â Â Â Â break; |
---|
3853 | Â Â } |
---|
3854 | Â } |
---|
3855 |  delete [] bounds; |
---|
3856 |  delete [] A; |
---|
3857 |  return CFList(); |
---|
3858 | } |
---|
3859 | |
---|
3860 | CFList |
---|
3861 | increasePrecisionFq2Fp (CanonicalForm& F, CFList& factors, int factorsFound, |
---|
3862 |             int oldNumCols, int oldL, const Variable& alpha, |
---|
3863 |             int precision |
---|
3864 | Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
3865 | { |
---|
3866 |  int d; |
---|
3867 |  bool isIrreducible= false; |
---|
3868 |  int* bounds= computeBounds (F, d, isIrreducible); |
---|
3869 |  if (isIrreducible) |
---|
3870 | Â { |
---|
3871 |   delete [] bounds; |
---|
3872 | Â Â CanonicalForm G=Â F; |
---|
3873 | Â Â F=Â 1; |
---|
3874 |   return CFList (G); |
---|
3875 | Â } |
---|
3876 |  int extensionDeg= degree (getMipo (alpha)); |
---|
3877 |  CFArray * A= new CFArray [factors.length()]; |
---|
3878 | Â CFArray bufQ=Â CFArray (factors.length()); |
---|
3879 | #ifdef HAVE_FLINT |
---|
3880 | Â nmod_mat_t FLINTN; |
---|
3881 |  nmod_mat_init (FLINTN,factors.length(),factors.length(), getCharacteristic()); |
---|
3882 |  for (long i=factors.length()-1; i >= 0; i--) |
---|
3883 |   nmod_mat_entry (FLINTN, i, i)= 1; |
---|
3884 | #else |
---|
3885 | Â mat_zz_p NTLN; |
---|
3886 |  ident (NTLN, factors.length()); |
---|
3887 | #endif |
---|
3888 |  int minBound= bounds[0]; |
---|
3889 |  for (int i= 1; i < d; i++) |
---|
3890 | Â { |
---|
3891 |   if (bounds[i] != 0) |
---|
3892 |    minBound= tmin (minBound, bounds[i]); |
---|
3893 | Â } |
---|
3894 |  int l= tmax (2*(minBound + 1), oldL); |
---|
3895 |  int oldL2= l/2; |
---|
3896 |  int stepSize= 2; |
---|
3897 |  bool useOldQs= false; |
---|
3898 |  bool hitBound= false; |
---|
3899 | Â CFListIterator j; |
---|
3900 | Â CFMatrix C; |
---|
3901 | #ifdef HAVE_FLINT |
---|
3902 |  long rank; |
---|
3903 |  nmod_mat_t FLINTC, FLINTK, null; |
---|
3904 | #else |
---|
3905 |  mat_zz_p* NTLC, NTLK; |
---|
3906 | #endif |
---|
3907 | Â CFArray buf; |
---|
3908 | Â Variable y=Â F.mvar(); |
---|
3909 | Â CanonicalForm truncF; |
---|
3910 |  while (l <= precision) |
---|
3911 | Â { |
---|
3912 | Â Â j=Â factors; |
---|
3913 |   truncF= mod (F, power (y, l)); |
---|
3914 |   if (useOldQs) |
---|
3915 | Â Â { |
---|
3916 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
3917 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL2, bufQ[i], |
---|
3918 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i] |
---|
3919 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
3920 | Â Â } |
---|
3921 | Â Â else |
---|
3922 | Â Â { |
---|
3923 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
3924 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ [i]); |
---|
3925 | Â Â } |
---|
3926 | Â Â useOldQs=Â true; |
---|
3927 |   for (int i= 0; i < d; i++) |
---|
3928 | Â Â { |
---|
3929 |    if (bounds [i] + 1 <= l/2) |
---|
3930 | Â Â Â { |
---|
3931 |     int k= tmin (bounds [i] + 1, l/2); |
---|
3932 |     C= CFMatrix ((l - k)*extensionDeg, factors.length()); |
---|
3933 |     for (int ii= 0; ii < factors.length(); ii++) |
---|
3934 | Â Â Â Â { |
---|
3935 |      if (A[ii].size() - 1 >= i) |
---|
3936 | Â Â Â Â Â { |
---|
3937 |       buf= getCoeffs (A[ii] [i], k, alpha); |
---|
3938 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
3939 | Â Â Â Â Â } |
---|
3940 | Â Â Â Â } |
---|
3941 | #ifdef HAVE_FLINT |
---|
3942 |     convertFacCFMatrix2nmod_mat_t (FLINTC, C); |
---|
3943 |     nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), |
---|
3944 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
3945 |     nmod_mat_mul (FLINTK, FLINTC, FLINTN); |
---|
3946 |     nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), |
---|
3947 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
3948 |     rank= nmod_mat_nullspace (null, FLINTK); |
---|
3949 | Â Â Â Â nmod_mat_clear (FLINTK); |
---|
3950 |     nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); |
---|
3951 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
3952 |     nmod_mat_init_set (FLINTC, FLINTN); |
---|
3953 | Â Â Â Â nmod_mat_clear (FLINTN); |
---|
3954 |     nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), |
---|
3955 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
3956 |     nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! |
---|
3957 | |
---|
3958 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
3959 | Â Â Â Â nmod_mat_window_clear (FLINTK); |
---|
3960 | Â Â Â Â nmod_mat_clear (null); |
---|
3961 | #else |
---|
3962 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_p(C); |
---|
3963 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
3964 |     transpose (NTLK, NTLK); |
---|
3965 |     kernel (NTLK, NTLK); |
---|
3966 |     transpose (NTLK, NTLK); |
---|
3967 | Â Â Â Â NTLN *=Â NTLK; |
---|
3968 | #endif |
---|
3969 | #ifdef HAVE_FLINT |
---|
3970 |     if (nmod_mat_ncols (FLINTN) == 1) |
---|
3971 | Â Â Â Â { |
---|
3972 | Â Â Â Â Â nmod_mat_clear (FLINTN); |
---|
3973 | #else |
---|
3974 |     if (NTLN.NumCols() == 1) |
---|
3975 | Â Â Â Â { |
---|
3976 | #endif |
---|
3977 |      delete [] A; |
---|
3978 |      delete [] bounds; |
---|
3979 | Â Â Â Â Â CanonicalForm G=Â F; |
---|
3980 | Â Â Â Â Â F=Â 1; |
---|
3981 |      return CFList (G); |
---|
3982 | Â Â Â Â } |
---|
3983 | Â Â Â } |
---|
3984 | Â Â } |
---|
3985 | |
---|
3986 | #ifdef HAVE_FLINT |
---|
3987 |   if (nmod_mat_ncols (FLINTN) < oldNumCols - factorsFound) |
---|
3988 | Â Â { |
---|
3989 |    if (isReduced (FLINTN)) |
---|
3990 | Â Â Â { |
---|
3991 |     int * factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; |
---|
3992 |     for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) |
---|
3993 | #else |
---|
3994 |   if (NTLN.NumCols() < oldNumCols - factorsFound) |
---|
3995 | Â Â { |
---|
3996 |    if (isReduced (NTLN)) |
---|
3997 | Â Â Â { |
---|
3998 |     int * factorsFoundIndex= new int [NTLN.NumCols()]; |
---|
3999 |     for (long i= 0; i < NTLN.NumCols(); i++) |
---|
4000 | #endif |
---|
4001 | Â Â Â Â Â factorsFoundIndex[i]=Â 0; |
---|
4002 |     int factorsFound2= 0; |
---|
4003 | Â Â Â Â CFList result; |
---|
4004 | Â Â Â Â CanonicalForm bufF=Â F; |
---|
4005 | #ifdef HAVE_FLINT |
---|
4006 |     reconstructionTry (result, bufF, factors, degree (F) + 1, factorsFound2, |
---|
4007 |               factorsFoundIndex, FLINTN, false |
---|
4008 | Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
4009 |     if (result.length() == nmod_mat_ncols (FLINTN)) |
---|
4010 | Â Â Â Â { |
---|
4011 | Â Â Â Â Â nmod_mat_clear (FLINTN); |
---|
4012 | #else |
---|
4013 |     reconstructionTry (result, bufF, factors, degree (F) + 1, factorsFound2, |
---|
4014 |               factorsFoundIndex, NTLN, false |
---|
4015 | Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
4016 |     if (result.length() == NTLN.NumCols()) |
---|
4017 | Â Â Â Â { |
---|
4018 | #endif |
---|
4019 |      delete [] factorsFoundIndex; |
---|
4020 |      delete [] A; |
---|
4021 |      delete [] bounds; |
---|
4022 | Â Â Â Â Â F=Â 1; |
---|
4023 |      return result; |
---|
4024 | Â Â Â Â } |
---|
4025 |     delete [] factorsFoundIndex; |
---|
4026 | Â Â Â } |
---|
4027 |    else if (l == precision) |
---|
4028 | Â Â Â { |
---|
4029 | Â Â Â Â CanonicalForm bufF=Â F; |
---|
4030 | #ifdef HAVE_FLINT |
---|
4031 |     int * zeroOne= extractZeroOneVecs (FLINTN); |
---|
4032 | Â Â Â Â CFList result=Â reconstruction (bufF,factors,zeroOne,precision,FLINTN); |
---|
4033 | Â Â Â Â nmod_mat_clear (FLINTN); |
---|
4034 | #else |
---|
4035 |     int * zeroOne= extractZeroOneVecs (NTLN); |
---|
4036 |     CFList result= reconstruction (bufF, factors, zeroOne, precision, NTLN); |
---|
4037 | #endif |
---|
4038 | Â Â Â Â F=Â bufF; |
---|
4039 |     delete [] zeroOne; |
---|
4040 |     delete [] A; |
---|
4041 |     delete [] bounds; |
---|
4042 |     return result; |
---|
4043 | Â Â Â } |
---|
4044 | Â Â } |
---|
4045 | Â Â oldL2=Â l; |
---|
4046 | Â Â l +=Â stepSize; |
---|
4047 | Â Â stepSize *=Â 2; |
---|
4048 |   if (l > precision) |
---|
4049 | Â Â { |
---|
4050 |    if (!hitBound) |
---|
4051 | Â Â Â { |
---|
4052 | Â Â Â Â hitBound=Â true; |
---|
4053 | Â Â Â Â l=Â precision; |
---|
4054 | Â Â Â } |
---|
4055 | Â Â Â else |
---|
4056 | Â Â Â Â break; |
---|
4057 | Â Â } |
---|
4058 | Â } |
---|
4059 | #ifdef HAVE_FLINT |
---|
4060 | Â nmod_mat_clear (FLINTN); |
---|
4061 | #endif |
---|
4062 |  delete [] bounds; |
---|
4063 |  delete [] A; |
---|
4064 |  return CFList(); |
---|
4065 | } |
---|
4066 | |
---|
4067 | #ifdef HAVE_FLINT |
---|
4068 | CFList |
---|
4069 | increasePrecision (CanonicalForm& F, CFList& factors, int oldL, int |
---|
4070 |           l, int d, int* bounds, CFArray& bufQ, nmod_mat_t FLINTN |
---|
4071 | Â Â Â Â Â Â Â Â Â ) |
---|
4072 | #else |
---|
4073 | CFList |
---|
4074 | increasePrecision (CanonicalForm& F, CFList& factors, int oldL, int |
---|
4075 |           l, int d, int* bounds, CFArray& bufQ, mat_zz_p& NTLN |
---|
4076 | Â Â Â Â Â Â Â Â Â ) |
---|
4077 | #endif |
---|
4078 | { |
---|
4079 | Â CFList result=Â CFList(); |
---|
4080 |  CFArray * A= new CFArray [factors.length()]; |
---|
4081 |  int oldL2= oldL/2; |
---|
4082 |  bool hitBound= false; |
---|
4083 | #ifdef HAVE_FLINT |
---|
4084 |  if (nmod_mat_nrows (FLINTN) != factors.length()) //refined factors |
---|
4085 | Â { |
---|
4086 | Â Â nmod_mat_clear (FLINTN); |
---|
4087 | Â Â nmod_mat_init(FLINTN,factors.length(),factors.length(),getCharacteristic()); |
---|
4088 |   for (long i=factors.length()-1; i >= 0; i--) |
---|
4089 |    nmod_mat_entry (FLINTN, i, i)= 1; |
---|
4090 | Â Â bufQ=Â CFArray (factors.length()); |
---|
4091 | Â } |
---|
4092 | #else |
---|
4093 |  if (NTLN.NumRows() != factors.length()) //refined factors |
---|
4094 | Â { |
---|
4095 |   ident (NTLN, factors.length()); |
---|
4096 | Â Â bufQ=Â CFArray (factors.length()); |
---|
4097 | Â } |
---|
4098 | #endif |
---|
4099 |  bool useOldQs= false; |
---|
4100 | Â CFListIterator j; |
---|
4101 | Â CFMatrix C; |
---|
4102 | Â CFArray buf; |
---|
4103 | #ifdef HAVE_FLINT |
---|
4104 |  long rank; |
---|
4105 |  nmod_mat_t FLINTC, FLINTK, null; |
---|
4106 | #else |
---|
4107 |  mat_zz_p* NTLC, NTLK; |
---|
4108 | #endif |
---|
4109 |  CanonicalForm bufF, truncF; |
---|
4110 | Â CFList bufUniFactors; |
---|
4111 | Â Variable y=Â F.mvar(); |
---|
4112 |  while (oldL <= l) |
---|
4113 | Â { |
---|
4114 | Â Â j=Â factors; |
---|
4115 |   truncF= mod (F, power (y, oldL)); |
---|
4116 |   if (useOldQs) |
---|
4117 | Â Â { |
---|
4118 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
4119 |     A[i]= logarithmicDerivative (truncF, j.getItem(), oldL, oldL2, bufQ[i], |
---|
4120 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i] |
---|
4121 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
4122 | Â Â } |
---|
4123 | Â Â else |
---|
4124 | Â Â { |
---|
4125 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
4126 |     A[i]= logarithmicDerivative (truncF, j.getItem(), oldL, bufQ [i]); |
---|
4127 | Â Â } |
---|
4128 | Â Â useOldQs=Â true; |
---|
4129 | |
---|
4130 |   for (int i= 0; i < d; i++) |
---|
4131 | Â Â { |
---|
4132 |    if (bounds [i] + 1 <= oldL/2) |
---|
4133 | Â Â Â { |
---|
4134 |     int k= tmin (bounds [i] + 1, oldL/2); |
---|
4135 |     C= CFMatrix (oldL - k, factors.length()); |
---|
4136 |     for (int ii= 0; ii < factors.length(); ii++) |
---|
4137 | Â Â Â Â { |
---|
4138 |      if (A[ii].size() - 1 >= i) |
---|
4139 | Â Â Â Â Â { |
---|
4140 |       buf= getCoeffs (A[ii] [i], k); |
---|
4141 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
4142 | Â Â Â Â Â } |
---|
4143 | Â Â Â Â } |
---|
4144 | #ifdef HAVE_FLINT |
---|
4145 |     convertFacCFMatrix2nmod_mat_t (FLINTC, C); |
---|
4146 |     nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), |
---|
4147 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
4148 |     nmod_mat_mul (FLINTK, FLINTC, FLINTN); |
---|
4149 |     nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), |
---|
4150 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
4151 |     rank= nmod_mat_nullspace (null, FLINTK); |
---|
4152 | Â Â Â Â nmod_mat_clear (FLINTK); |
---|
4153 |     nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); |
---|
4154 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
4155 |     nmod_mat_init_set (FLINTC, FLINTN); |
---|
4156 | Â Â Â Â nmod_mat_clear (FLINTN); |
---|
4157 |     nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), |
---|
4158 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
4159 |     nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! |
---|
4160 | |
---|
4161 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
4162 | Â Â Â Â nmod_mat_window_clear (FLINTK); |
---|
4163 | Â Â Â Â nmod_mat_clear (null); |
---|
4164 | #else |
---|
4165 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_p(C); |
---|
4166 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
4167 |     transpose (NTLK, NTLK); |
---|
4168 |     kernel (NTLK, NTLK); |
---|
4169 |     transpose (NTLK, NTLK); |
---|
4170 | Â Â Â Â NTLN *=Â NTLK; |
---|
4171 | #endif |
---|
4172 | #ifdef HAVE_FLINT |
---|
4173 |     if (nmod_mat_ncols (FLINTN) == 1) |
---|
4174 | #else |
---|
4175 |     if (NTLN.NumCols() == 1) |
---|
4176 | #endif |
---|
4177 | Â Â Â Â { |
---|
4178 |      delete [] A; |
---|
4179 |      return CFList (F); |
---|
4180 | Â Â Â Â } |
---|
4181 | Â Â Â } |
---|
4182 | Â Â } |
---|
4183 | #ifdef HAVE_FLINT |
---|
4184 |   if (nmod_mat_ncols (FLINTN) == 1) |
---|
4185 | #else |
---|
4186 |   if (NTLN.NumCols() == 1) |
---|
4187 | #endif |
---|
4188 | Â Â { |
---|
4189 |    delete [] A; |
---|
4190 |    return CFList (F); |
---|
4191 | Â Â } |
---|
4192 |   int * zeroOneVecs; |
---|
4193 | #ifdef HAVE_FLINT |
---|
4194 | Â Â zeroOneVecs=Â extractZeroOneVecs (FLINTN); |
---|
4195 | #else |
---|
4196 | Â Â zeroOneVecs=Â extractZeroOneVecs (NTLN); |
---|
4197 | #endif |
---|
4198 | Â Â bufF=Â F; |
---|
4199 | Â Â bufUniFactors=Â factors; |
---|
4200 | #ifdef HAVE_FLINT |
---|
4201 |   result= reconstruction (bufF, bufUniFactors, zeroOneVecs, oldL, FLINTN); |
---|
4202 | #else |
---|
4203 |   result= reconstruction (bufF, bufUniFactors, zeroOneVecs, oldL, NTLN); |
---|
4204 | #endif |
---|
4205 |   delete [] zeroOneVecs; |
---|
4206 |   if (degree (bufF) + 1 + degree (LC (bufF, 1)) < oldL && result.length() > 0) |
---|
4207 | Â Â { |
---|
4208 | Â Â Â F=Â bufF; |
---|
4209 | Â Â Â factors=Â bufUniFactors; |
---|
4210 |    delete [] A; |
---|
4211 |    return result; |
---|
4212 | Â Â } |
---|
4213 | |
---|
4214 | Â Â result=Â CFList(); |
---|
4215 | Â Â oldL2=Â oldL; |
---|
4216 | Â Â oldL *=Â 2; |
---|
4217 |   if (oldL > l) |
---|
4218 | Â Â { |
---|
4219 |    if (!hitBound) |
---|
4220 | Â Â Â { |
---|
4221 | Â Â Â Â oldL=Â l; |
---|
4222 | Â Â Â Â hitBound=Â true; |
---|
4223 | Â Â Â } |
---|
4224 | Â Â Â else |
---|
4225 | Â Â Â Â break; |
---|
4226 | Â Â } |
---|
4227 | Â } |
---|
4228 |  delete [] A; |
---|
4229 |  return result; |
---|
4230 | } |
---|
4231 | |
---|
4232 | CFList |
---|
4233 | increasePrecision (CanonicalForm& F, CFList& factors, int oldL, int |
---|
4234 |           l, int d, int* bounds, CFArray& bufQ, mat_zz_pE& NTLN |
---|
4235 | Â Â Â Â Â Â Â Â Â ) |
---|
4236 | { |
---|
4237 | Â CFList result=Â CFList(); |
---|
4238 |  CFArray * A= new CFArray [factors.length()]; |
---|
4239 |  int oldL2= oldL/2; |
---|
4240 |  bool hitBound= false; |
---|
4241 |  bool useOldQs= false; |
---|
4242 |  if (NTLN.NumRows() != factors.length()) //refined factors |
---|
4243 |   ident (NTLN, factors.length()); |
---|
4244 | Â CFListIterator j; |
---|
4245 | Â CFMatrix C; |
---|
4246 | Â CFArray buf; |
---|
4247 |  mat_zz_pE* NTLC, NTLK; |
---|
4248 |  CanonicalForm bufF, truncF; |
---|
4249 | Â CFList bufUniFactors; |
---|
4250 | Â Variable y=Â F.mvar(); |
---|
4251 |  while (oldL <= l) |
---|
4252 | Â { |
---|
4253 | Â Â j=Â factors; |
---|
4254 |   truncF= mod (F, power (y, oldL)); |
---|
4255 |   if (useOldQs) |
---|
4256 | Â Â { |
---|
4257 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
4258 |     A[i]= logarithmicDerivative (truncF, j.getItem(), oldL, oldL2, bufQ[i], |
---|
4259 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i] |
---|
4260 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
4261 | Â Â } |
---|
4262 | Â Â else |
---|
4263 | Â Â { |
---|
4264 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
4265 |     A[i]= logarithmicDerivative (truncF, j.getItem(), oldL, bufQ [i]); |
---|
4266 | Â Â } |
---|
4267 | Â Â useOldQs=Â true; |
---|
4268 | |
---|
4269 |   for (int i= 0; i < d; i++) |
---|
4270 | Â Â { |
---|
4271 |    if (bounds [i] + 1 <= oldL/2) |
---|
4272 | Â Â Â { |
---|
4273 |     int k= tmin (bounds [i] + 1, oldL/2); |
---|
4274 |     C= CFMatrix (oldL - k, factors.length()); |
---|
4275 |     for (int ii= 0; ii < factors.length(); ii++) |
---|
4276 | Â Â Â Â { |
---|
4277 |      if (A[ii].size() - 1 >= i) |
---|
4278 | Â Â Â Â Â { |
---|
4279 |       buf= getCoeffs (A[ii] [i], k); |
---|
4280 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
4281 | Â Â Â Â Â } |
---|
4282 | Â Â Â Â } |
---|
4283 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_pE(C); |
---|
4284 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
4285 |     transpose (NTLK, NTLK); |
---|
4286 |     kernel (NTLK, NTLK); |
---|
4287 |     transpose (NTLK, NTLK); |
---|
4288 | Â Â Â Â NTLN *=Â NTLK; |
---|
4289 |     if (NTLN.NumCols() == 1) |
---|
4290 | Â Â Â Â { |
---|
4291 |      delete [] A; |
---|
4292 |      return CFList (F); |
---|
4293 | Â Â Â Â } |
---|
4294 | Â Â Â } |
---|
4295 | Â Â } |
---|
4296 |   if (NTLN.NumCols() == 1) |
---|
4297 | Â Â { |
---|
4298 |    delete [] A; |
---|
4299 |    return CFList (F); |
---|
4300 | Â Â } |
---|
4301 | |
---|
4302 |   int * zeroOneVecs; |
---|
4303 | Â Â zeroOneVecs=Â extractZeroOneVecs (NTLN); |
---|
4304 | Â Â bufF=Â F; |
---|
4305 | Â Â bufUniFactors=Â factors; |
---|
4306 |   result= reconstruction (bufF, bufUniFactors, zeroOneVecs, oldL, NTLN); |
---|
4307 |   delete [] zeroOneVecs; |
---|
4308 |   if (degree (bufF) + 1 + degree (LC (bufF, 1)) < l && result.length() > 0) |
---|
4309 | Â Â { |
---|
4310 | Â Â Â F=Â bufF; |
---|
4311 | Â Â Â factors=Â bufUniFactors; |
---|
4312 |    delete [] A; |
---|
4313 |    return result; |
---|
4314 | Â Â } |
---|
4315 | |
---|
4316 | Â Â result=Â CFList(); |
---|
4317 | Â Â oldL2=Â oldL; |
---|
4318 | Â Â oldL *=Â 2; |
---|
4319 |   if (oldL > l) |
---|
4320 | Â Â { |
---|
4321 |    if (!hitBound) |
---|
4322 | Â Â Â { |
---|
4323 | Â Â Â Â oldL=Â l; |
---|
4324 | Â Â Â Â hitBound=Â true; |
---|
4325 | Â Â Â } |
---|
4326 | Â Â Â else |
---|
4327 | Â Â Â Â break; |
---|
4328 | Â Â } |
---|
4329 | Â } |
---|
4330 |  delete [] A; |
---|
4331 |  return result; |
---|
4332 | } |
---|
4333 | |
---|
4334 | //over field extension |
---|
4335 | CFList |
---|
4336 | extIncreasePrecision (CanonicalForm& F, CFList& factors, int oldL, int l, int d, |
---|
4337 |            int* bounds, CFArray& bufQ, mat_zz_p& NTLN, const |
---|
4338 |            CanonicalForm& evaluation, const ExtensionInfo& info, |
---|
4339 |            CFList& source, CFList& dest |
---|
4340 | Â Â Â Â Â Â Â Â Â Â Â ) |
---|
4341 | { |
---|
4342 | Â CFList result=Â CFList(); |
---|
4343 |  CFArray * A= new CFArray [factors.length()]; |
---|
4344 |  int oldL2= oldL/2; //be careful |
---|
4345 |  bool hitBound= false; |
---|
4346 |  bool useOldQs= false; |
---|
4347 |  bool GF= (CFFactory::gettype()==GaloisFieldDomain); |
---|
4348 |  int degMipo= degree (getMipo (info.getAlpha())); |
---|
4349 | Â Variable alpha=Â info.getAlpha(); |
---|
4350 | |
---|
4351 | Â Variable gamma=Â info.getBeta(); |
---|
4352 | Â CanonicalForm primElemAlpha=Â info.getGamma(); |
---|
4353 | Â CanonicalForm imPrimElemAlpha=Â info.getDelta(); |
---|
4354 |  if (NTLN.NumRows() != factors.length()) //refined factors |
---|
4355 |   ident (NTLN, factors.length()); |
---|
4356 | Â Variable y=Â F.mvar(); |
---|
4357 | Â CFListIterator j; |
---|
4358 |  CanonicalForm powX, imBasis, bufF, truncF; |
---|
4359 |  CFMatrix Mat, C; |
---|
4360 | Â CFIterator iter; |
---|
4361 | Â mat_zz_p*Â NTLMat; |
---|
4362 | Â CFArray buf; |
---|
4363 |  mat_zz_p* NTLC, NTLK; |
---|
4364 | Â CFList bufUniFactors; |
---|
4365 |  while (oldL <= l) |
---|
4366 | Â { |
---|
4367 | Â Â j=Â factors; |
---|
4368 |   if (GF) |
---|
4369 | Â Â Â setCharacteristic (getCharacteristic()); |
---|
4370 | |
---|
4371 |   powX= power (y-gamma, oldL); |
---|
4372 |   Mat= CFMatrix (oldL*degMipo, oldL*degMipo); |
---|
4373 |   for (int i= 0; i < oldL*degMipo; i++) |
---|
4374 | Â Â { |
---|
4375 |    imBasis= mod (power (y, i), powX); |
---|
4376 |    imBasis= imBasis (power (y, degMipo), y); |
---|
4377 |    imBasis= imBasis (y, gamma); |
---|
4378 | Â Â Â iter=Â imBasis; |
---|
4379 |    for (; iter.hasTerms(); iter++) |
---|
4380 |     Mat (iter.exp()+ 1, i+1)= iter.coeff(); |
---|
4381 | Â Â } |
---|
4382 | |
---|
4383 | Â Â NTLMat=Â convertFacCFMatrix2NTLmat_zz_p (Mat); |
---|
4384 | Â Â *NTLMat=Â inv (*NTLMat); |
---|
4385 |   if (GF) |
---|
4386 |    setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); |
---|
4387 | |
---|
4388 |   truncF= mod (F, power (y, oldL)); |
---|
4389 |   if (useOldQs) |
---|
4390 | Â Â { |
---|
4391 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
4392 |     A[i]= logarithmicDerivative (truncF, j.getItem(), oldL, oldL2, bufQ[i], |
---|
4393 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i]); |
---|
4394 | Â Â } |
---|
4395 | Â Â else |
---|
4396 | Â Â { |
---|
4397 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
4398 |     A[i]= logarithmicDerivative (truncF, j.getItem(), oldL, bufQ [i]); |
---|
4399 | Â Â } |
---|
4400 | Â Â useOldQs=Â true; |
---|
4401 | |
---|
4402 |   for (int i= 0; i < d; i++) |
---|
4403 | Â Â { |
---|
4404 |    if (bounds [i] + 1 <= oldL/2) |
---|
4405 | Â Â Â { |
---|
4406 |     int k= tmin (bounds [i] + 1, oldL/2); |
---|
4407 |     C= CFMatrix (oldL*degMipo - k, factors.length()); |
---|
4408 |     for (int ii= 0; ii < factors.length(); ii++) |
---|
4409 | Â Â Â Â { |
---|
4410 |      if (A[ii].size() - 1 >= i) |
---|
4411 | Â Â Â Â Â { |
---|
4412 |       if (GF) |
---|
4413 | Â Â Â Â Â Â { |
---|
4414 |        A [ii] [i]= A [ii] [i] (y-evaluation, y); |
---|
4415 | Â Â Â Â Â Â Â setCharacteristic (getCharacteristic()); |
---|
4416 |        A[ii] [i]= GF2FalphaRep (A[ii] [i], alpha); |
---|
4417 |        if (alpha != gamma) |
---|
4418 |         A [ii] [i]= mapDown (A[ii] [i], imPrimElemAlpha, primElemAlpha, |
---|
4419 |                    gamma, source, dest |
---|
4420 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
4421 |        buf= getCoeffs (A[ii] [i], k, oldL, degMipo, gamma, 0, *NTLMat); |
---|
4422 | Â Â Â Â Â Â } |
---|
4423 | Â Â Â Â Â Â else |
---|
4424 | Â Â Â Â Â Â { |
---|
4425 |        A [ii] [i]= A [ii] [i] (y-evaluation, y); |
---|
4426 |        if (alpha != gamma) |
---|
4427 |         A[ii] [i]= mapDown (A[ii] [i], imPrimElemAlpha, primElemAlpha, |
---|
4428 |                   gamma, source, dest |
---|
4429 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
4430 |        buf= getCoeffs (A[ii] [i], k, oldL, degMipo, gamma, 0, *NTLMat); |
---|
4431 | Â Â Â Â Â Â } |
---|
4432 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
4433 | Â Â Â Â Â } |
---|
4434 |      if (GF) |
---|
4435 |       setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); |
---|
4436 | Â Â Â Â } |
---|
4437 | |
---|
4438 |     if (GF) |
---|
4439 | Â Â Â Â Â setCharacteristic(getCharacteristic()); |
---|
4440 | |
---|
4441 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_p(C); |
---|
4442 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
4443 |     transpose (NTLK, NTLK); |
---|
4444 |     kernel (NTLK, NTLK); |
---|
4445 |     transpose (NTLK, NTLK); |
---|
4446 | Â Â Â Â NTLN *=Â NTLK; |
---|
4447 | |
---|
4448 |     if (GF) |
---|
4449 |      setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); |
---|
4450 | |
---|
4451 |     if (NTLN.NumCols() == 1) |
---|
4452 | Â Â Â Â { |
---|
4453 | Â Â Â Â Â Variable y=Â Variable (2); |
---|
4454 |      CanonicalForm tmp= F (y - evaluation, y); |
---|
4455 |      CFList source, dest; |
---|
4456 |      tmp= mapDown (tmp, info, source, dest); |
---|
4457 |      delete [] A; |
---|
4458 |      return CFList (tmp); |
---|
4459 | Â Â Â Â } |
---|
4460 | Â Â Â } |
---|
4461 | Â Â } |
---|
4462 |   if (NTLN.NumCols() == 1) |
---|
4463 | Â Â { |
---|
4464 | Â Â Â Variable y=Â Variable (2); |
---|
4465 |    CanonicalForm tmp= F (y - evaluation, y); |
---|
4466 |    CFList source, dest; |
---|
4467 |    tmp= mapDown (tmp, info, source, dest); |
---|
4468 |    delete [] A; |
---|
4469 |    return CFList (tmp); |
---|
4470 | Â Â } |
---|
4471 | |
---|
4472 |   int * zeroOneVecs; |
---|
4473 | Â Â zeroOneVecs=Â extractZeroOneVecs (NTLN); |
---|
4474 | Â Â bufF=Â F; |
---|
4475 | Â Â bufUniFactors=Â factors; |
---|
4476 |   result= extReconstruction (bufF, bufUniFactors, zeroOneVecs, oldL, NTLN, |
---|
4477 |                 info, evaluation |
---|
4478 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
4479 |   delete [] zeroOneVecs; |
---|
4480 |   if (degree (bufF) + 1 + degree (LC (bufF, 1)) < l && result.length() > 0) |
---|
4481 | Â Â { |
---|
4482 | Â Â Â F=Â bufF; |
---|
4483 | Â Â Â factors=Â bufUniFactors; |
---|
4484 |    return result; |
---|
4485 | Â Â } |
---|
4486 | |
---|
4487 | Â Â result=Â CFList(); |
---|
4488 | Â Â oldL2=Â oldL; |
---|
4489 | Â Â oldL *=Â 2; |
---|
4490 |   if (oldL > l) |
---|
4491 | Â Â { |
---|
4492 |    if (!hitBound) |
---|
4493 | Â Â Â { |
---|
4494 | Â Â Â Â oldL=Â l; |
---|
4495 | Â Â Â Â hitBound=Â true; |
---|
4496 | Â Â Â } |
---|
4497 | Â Â Â else |
---|
4498 | Â Â Â Â break; |
---|
4499 | Â Â } |
---|
4500 | Â } |
---|
4501 |  delete [] A; |
---|
4502 |  return result; |
---|
4503 | } |
---|
4504 | |
---|
4505 | #ifdef HAVE_FLINT |
---|
4506 | CFList |
---|
4507 | increasePrecisionFq2Fp (CanonicalForm& F, CFList& factors, int oldL, int l, |
---|
4508 |             int d, int* bounds, CFArray& bufQ, nmod_mat_t FLINTN, |
---|
4509 |             const Variable& alpha |
---|
4510 | Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
4511 | #else |
---|
4512 | CFList |
---|
4513 | increasePrecisionFq2Fp (CanonicalForm& F, CFList& factors, int oldL, int l, |
---|
4514 |             int d, int* bounds, CFArray& bufQ, mat_zz_p& NTLN, |
---|
4515 |             const Variable& alpha |
---|
4516 | Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
4517 | #endif |
---|
4518 | { |
---|
4519 | Â CFList result=Â CFList(); |
---|
4520 |  CFArray * A= new CFArray [factors.length()]; |
---|
4521 |  int extensionDeg= degree (getMipo (alpha)); |
---|
4522 |  int oldL2= oldL/2; |
---|
4523 |  bool hitBound= false; |
---|
4524 |  bool useOldQs= false; |
---|
4525 | #ifdef HAVE_FLINT |
---|
4526 |  if (nmod_mat_nrows (FLINTN) != factors.length()) //refined factors |
---|
4527 | Â { |
---|
4528 | Â Â nmod_mat_clear (FLINTN); |
---|
4529 | Â Â nmod_mat_init(FLINTN,factors.length(),factors.length(),getCharacteristic()); |
---|
4530 |   for (long i=factors.length()-1; i >= 0; i--) |
---|
4531 |    nmod_mat_entry (FLINTN, i, i)= 1; |
---|
4532 | Â } |
---|
4533 | #else |
---|
4534 |  if (NTLN.NumRows() != factors.length()) //refined factors |
---|
4535 |   ident (NTLN, factors.length()); |
---|
4536 | #endif |
---|
4537 | Â CFListIterator j; |
---|
4538 | Â CFMatrix C; |
---|
4539 | Â CFArray buf; |
---|
4540 | #ifdef HAVE_FLINT |
---|
4541 |  long rank; |
---|
4542 |  nmod_mat_t FLINTC, FLINTK, null; |
---|
4543 | #else |
---|
4544 |  mat_zz_p* NTLC, NTLK; |
---|
4545 | #endif |
---|
4546 |  CanonicalForm bufF, truncF; |
---|
4547 | Â CFList bufUniFactors; |
---|
4548 | Â Variable y=Â F.mvar(); |
---|
4549 |  while (oldL <= l) |
---|
4550 | Â { |
---|
4551 | Â Â j=Â factors; |
---|
4552 |   truncF= mod (F, power (y, oldL)); |
---|
4553 |   if (useOldQs) |
---|
4554 | Â Â { |
---|
4555 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
4556 |     A[i]= logarithmicDerivative (truncF, j.getItem(), oldL, oldL2, bufQ[i], |
---|
4557 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i] |
---|
4558 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
4559 | Â Â } |
---|
4560 | Â Â else |
---|
4561 | Â Â { |
---|
4562 |    for (int i= 0; i < factors.length(); i++, j++) |
---|
4563 |     A[i]= logarithmicDerivative (truncF, j.getItem(), oldL, bufQ [i]); |
---|
4564 | Â Â } |
---|
4565 | Â Â useOldQs=Â true; |
---|
4566 | |
---|
4567 |   for (int i= 0; i < d; i++) |
---|
4568 | Â Â { |
---|
4569 |    if (bounds [i] + 1 <= oldL/2) |
---|
4570 | Â Â Â { |
---|
4571 |     int k= tmin (bounds [i] + 1, oldL/2); |
---|
4572 |     C= CFMatrix ((oldL - k)*extensionDeg, factors.length()); |
---|
4573 |     for (int ii= 0; ii < factors.length(); ii++) |
---|
4574 | Â Â Â Â { |
---|
4575 |      if (A[ii].size() - 1 >= i) |
---|
4576 | Â Â Â Â Â { |
---|
4577 |       buf= getCoeffs (A[ii] [i], k, alpha); |
---|
4578 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
4579 | Â Â Â Â Â } |
---|
4580 | Â Â Â Â } |
---|
4581 | #ifdef HAVE_FLINT |
---|
4582 |     convertFacCFMatrix2nmod_mat_t (FLINTC, C); |
---|
4583 |     nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), |
---|
4584 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
4585 |     nmod_mat_mul (FLINTK, FLINTC, FLINTN); |
---|
4586 |     nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), |
---|
4587 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
4588 |     rank= nmod_mat_nullspace (null, FLINTK); |
---|
4589 | Â Â Â Â nmod_mat_clear (FLINTK); |
---|
4590 |     nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); |
---|
4591 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
4592 |     nmod_mat_init_set (FLINTC, FLINTN); |
---|
4593 | Â Â Â Â nmod_mat_clear (FLINTN); |
---|
4594 |     nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), |
---|
4595 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
4596 |     nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! |
---|
4597 | |
---|
4598 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
4599 | Â Â Â Â nmod_mat_window_clear (FLINTK); |
---|
4600 | Â Â Â Â nmod_mat_clear (null); |
---|
4601 | #else |
---|
4602 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_p(C); |
---|
4603 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
4604 |     transpose (NTLK, NTLK); |
---|
4605 |     kernel (NTLK, NTLK); |
---|
4606 |     transpose (NTLK, NTLK); |
---|
4607 | Â Â Â Â NTLN *=Â NTLK; |
---|
4608 | #endif |
---|
4609 | #ifdef HAVE_FLINT |
---|
4610 |     if (nmod_mat_ncols (FLINTN) == 1) |
---|
4611 | #else |
---|
4612 |     if (NTLN.NumCols() == 1) |
---|
4613 | #endif |
---|
4614 | Â Â Â Â { |
---|
4615 |      delete [] A; |
---|
4616 |      return CFList (F); |
---|
4617 | Â Â Â Â } |
---|
4618 | Â Â Â } |
---|
4619 | Â Â } |
---|
4620 | |
---|
4621 |   int * zeroOneVecs; |
---|
4622 | #ifdef HAVE_FLINT |
---|
4623 | Â Â zeroOneVecs=Â extractZeroOneVecs (FLINTN); |
---|
4624 | #else |
---|
4625 | Â Â zeroOneVecs=Â extractZeroOneVecs (NTLN); |
---|
4626 | #endif |
---|
4627 | |
---|
4628 | Â Â bufF=Â F; |
---|
4629 | Â Â bufUniFactors=Â factors; |
---|
4630 | #ifdef HAVE_FLINT |
---|
4631 |   result= reconstruction (bufF, bufUniFactors, zeroOneVecs, oldL, FLINTN); |
---|
4632 | #else |
---|
4633 |   result= reconstruction (bufF, bufUniFactors, zeroOneVecs, oldL, NTLN); |
---|
4634 | #endif |
---|
4635 |   delete [] zeroOneVecs; |
---|
4636 |   if (degree (bufF) + 1 + degree (LC (bufF, 1)) < l && result.length() > 0) |
---|
4637 | Â Â { |
---|
4638 | Â Â Â F=Â bufF; |
---|
4639 | Â Â Â factors=Â bufUniFactors; |
---|
4640 |    delete [] A; |
---|
4641 |    return result; |
---|
4642 | Â Â } |
---|
4643 | |
---|
4644 | Â Â result=Â CFList(); |
---|
4645 | Â Â oldL2=Â oldL; |
---|
4646 | Â Â oldL *=Â 2; |
---|
4647 |   if (oldL > l) |
---|
4648 | Â Â { |
---|
4649 |    if (!hitBound) |
---|
4650 | Â Â Â { |
---|
4651 | Â Â Â Â oldL=Â l; |
---|
4652 | Â Â Â Â hitBound=Â true; |
---|
4653 | Â Â Â } |
---|
4654 | Â Â Â else |
---|
4655 | Â Â Â Â break; |
---|
4656 | Â Â } |
---|
4657 | Â } |
---|
4658 |  delete [] A; |
---|
4659 |  return result; |
---|
4660 | } |
---|
4661 | |
---|
4662 | #ifdef HAVE_FLINT |
---|
4663 | CFList |
---|
4664 | furtherLiftingAndIncreasePrecision (CanonicalForm& F, CFList& |
---|
4665 |                   factors, int l, int liftBound, int d, int* |
---|
4666 |                   bounds, nmod_mat_t FLINTN, CFList& diophant, |
---|
4667 |                   CFMatrix& M, CFArray& Pi, CFArray& bufQ |
---|
4668 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
4669 | #else |
---|
4670 | CFList |
---|
4671 | furtherLiftingAndIncreasePrecision (CanonicalForm& F, CFList& |
---|
4672 |                   factors, int l, int liftBound, int d, int* |
---|
4673 |                   bounds, mat_zz_p& NTLN, CFList& diophant, |
---|
4674 |                   CFMatrix& M, CFArray& Pi, CFArray& bufQ |
---|
4675 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
4676 | #endif |
---|
4677 | { |
---|
4678 |  CanonicalForm LCF= LC (F, 1); |
---|
4679 | Â CFList result; |
---|
4680 |  bool irreducible= false; |
---|
4681 | Â CFList bufFactors=Â factors; |
---|
4682 |  CFArray *A = new CFArray [bufFactors.length()]; |
---|
4683 |  bool useOldQs= false; |
---|
4684 |  bool hitBound= false; |
---|
4685 |  int oldL= l; |
---|
4686 |  int stepSize= 8; //TODO choose better step size? |
---|
4687 |  l += tmax (tmin (8, degree (F) + 1 + degree (LC (F, 1))-l), 2); |
---|
4688 | #ifdef HAVE_FLINT |
---|
4689 |  if (nmod_mat_nrows (FLINTN) != factors.length()) //refined factors |
---|
4690 | Â { |
---|
4691 | Â Â nmod_mat_clear (FLINTN); |
---|
4692 | Â Â nmod_mat_init(FLINTN,factors.length(),factors.length(),getCharacteristic()); |
---|
4693 |   for (long i=factors.length()-1; i >= 0; i--) |
---|
4694 |    nmod_mat_entry (FLINTN, i, i)= 1; |
---|
4695 | Â } |
---|
4696 | #else |
---|
4697 |  if (NTLN.NumRows() != factors.length()) //refined factors |
---|
4698 |   ident (NTLN, factors.length()); |
---|
4699 | #endif |
---|
4700 | Â CFListIterator j; |
---|
4701 | Â CFMatrix C; |
---|
4702 | Â CFArray buf; |
---|
4703 | #ifdef HAVE_FLINT |
---|
4704 |  long rank; |
---|
4705 |  nmod_mat_t FLINTC, FLINTK, null; |
---|
4706 | #else |
---|
4707 |  mat_zz_p* NTLC, NTLK; |
---|
4708 | #endif |
---|
4709 |  CanonicalForm bufF, truncF; |
---|
4710 | Â Variable y=Â F.mvar(); |
---|
4711 |  while (l <= liftBound) |
---|
4712 | Â { |
---|
4713 | Â Â bufFactors.insert (LCF); |
---|
4714 |   henselLiftResume12 (F, bufFactors, oldL, l, Pi, diophant, M); |
---|
4715 | Â Â bufFactors.insert (LCF); |
---|
4716 | Â Â bufFactors.removeFirst(); |
---|
4717 | Â Â j=Â bufFactors; |
---|
4718 |   truncF= mod (F, power (y, l)); |
---|
4719 |   if (useOldQs) |
---|
4720 | Â Â { |
---|
4721 |    for (int i= 0; i < bufFactors.length(); i++, j++) |
---|
4722 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL, bufQ[i], |
---|
4723 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i]); |
---|
4724 | Â Â } |
---|
4725 | Â Â else |
---|
4726 | Â Â { |
---|
4727 |    for (int i= 0; i < bufFactors.length(); i++, j++) |
---|
4728 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ [i]); |
---|
4729 | Â Â } |
---|
4730 |   for (int i= 0; i < d; i++) |
---|
4731 | Â Â { |
---|
4732 |    if (bounds [i] + 1 <= l/2) |
---|
4733 | Â Â Â { |
---|
4734 |     int k= tmin (bounds [i] + 1, l/2); |
---|
4735 |     C= CFMatrix (l - k, bufFactors.length()); |
---|
4736 |     for (int ii= 0; ii < bufFactors.length(); ii++) |
---|
4737 | Â Â Â Â { |
---|
4738 |      if (A[ii].size() - 1 >= i) |
---|
4739 | Â Â Â Â Â { |
---|
4740 |       buf= getCoeffs (A[ii] [i], k); |
---|
4741 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
4742 | Â Â Â Â Â } |
---|
4743 | Â Â Â Â } |
---|
4744 | #ifdef HAVE_FLINT |
---|
4745 |     convertFacCFMatrix2nmod_mat_t (FLINTC, C); |
---|
4746 |     nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), |
---|
4747 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
4748 |     nmod_mat_mul (FLINTK, FLINTC, FLINTN); |
---|
4749 |     nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), |
---|
4750 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
4751 |     rank= nmod_mat_nullspace (null, FLINTK); |
---|
4752 | Â Â Â Â nmod_mat_clear (FLINTK); |
---|
4753 |     nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); |
---|
4754 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
4755 |     nmod_mat_init_set (FLINTC, FLINTN); |
---|
4756 | Â Â Â Â nmod_mat_clear (FLINTN); |
---|
4757 |     nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), |
---|
4758 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
4759 |     nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! |
---|
4760 | |
---|
4761 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
4762 | Â Â Â Â nmod_mat_window_clear (FLINTK); |
---|
4763 | Â Â Â Â nmod_mat_clear (null); |
---|
4764 | #else |
---|
4765 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_p(C); |
---|
4766 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
4767 |     transpose (NTLK, NTLK); |
---|
4768 |     kernel (NTLK, NTLK); |
---|
4769 |     transpose (NTLK, NTLK); |
---|
4770 | Â Â Â Â NTLN *=Â NTLK; |
---|
4771 | #endif |
---|
4772 | #ifdef HAVE_FLINT |
---|
4773 |     if (nmod_mat_ncols (FLINTN) == 1) |
---|
4774 | #else |
---|
4775 |     if (NTLN.NumCols() == 1) |
---|
4776 | #endif |
---|
4777 | Â Â Â Â { |
---|
4778 | Â Â Â Â Â irreducible=Â true; |
---|
4779 | Â Â Â Â Â break; |
---|
4780 | Â Â Â Â } |
---|
4781 | Â Â Â } |
---|
4782 | Â Â } |
---|
4783 | |
---|
4784 | #ifdef HAVE_FLINT |
---|
4785 |   if (nmod_mat_ncols (FLINTN) == 1) |
---|
4786 | #else |
---|
4787 |   if (NTLN.NumCols() == 1) |
---|
4788 | #endif |
---|
4789 | Â Â { |
---|
4790 | Â Â Â irreducible=Â true; |
---|
4791 | Â Â Â break; |
---|
4792 | Â Â } |
---|
4793 | |
---|
4794 | #ifdef HAVE_FLINT |
---|
4795 |   int * zeroOneVecs= extractZeroOneVecs (FLINTN); |
---|
4796 | #else |
---|
4797 |   int * zeroOneVecs= extractZeroOneVecs (NTLN); |
---|
4798 | #endif |
---|
4799 | Â Â bufF=Â F; |
---|
4800 | #ifdef HAVE_FLINT |
---|
4801 |   result= reconstruction (bufF, bufFactors, zeroOneVecs, l, FLINTN); |
---|
4802 | #else |
---|
4803 |   result= reconstruction (bufF, bufFactors, zeroOneVecs, l, NTLN); |
---|
4804 | #endif |
---|
4805 |   delete [] zeroOneVecs; |
---|
4806 |   if (result.length() > 0 && degree (bufF) + 1 + degree (LC (bufF, 1)) <= l) |
---|
4807 | Â Â { |
---|
4808 | Â Â Â F=Â bufF; |
---|
4809 | Â Â Â factors=Â bufFactors; |
---|
4810 |    delete [] A; |
---|
4811 |    return result; |
---|
4812 | Â Â } |
---|
4813 | |
---|
4814 | #ifdef HAVE_FLINT |
---|
4815 |   if (isReduced (FLINTN)) |
---|
4816 | #else |
---|
4817 |   if (isReduced (NTLN)) |
---|
4818 | #endif |
---|
4819 | Â Â { |
---|
4820 |    int factorsFound= 0; |
---|
4821 | Â Â Â bufF=Â F; |
---|
4822 | #ifdef HAVE_FLINT |
---|
4823 |    int* factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; |
---|
4824 |    for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) |
---|
4825 | #else |
---|
4826 |    int* factorsFoundIndex= new int [NTLN.NumCols()]; |
---|
4827 |    for (long i= 0; i < NTLN.NumCols(); i++) |
---|
4828 | #endif |
---|
4829 | Â Â Â Â factorsFoundIndex[i]=Â 0; |
---|
4830 | #ifdef HAVE_FLINT |
---|
4831 |    if (l < liftBound) |
---|
4832 |     reconstructionTry (result, bufF, bufFactors, l, factorsFound, |
---|
4833 |               factorsFoundIndex, FLINTN, false |
---|
4834 | Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
4835 | Â Â Â else |
---|
4836 |     reconstructionTry (result, bufF, bufFactors, degree (bufF) + 1 + |
---|
4837 |               degree (LCF), factorsFound, factorsFoundIndex, |
---|
4838 |               FLINTN, false |
---|
4839 | Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
4840 | |
---|
4841 |    if (nmod_mat_ncols (FLINTN) == result.length()) |
---|
4842 | #else |
---|
4843 |    if (l < liftBound) |
---|
4844 |     reconstructionTry (result, bufF, bufFactors, l, factorsFound, |
---|
4845 |               factorsFoundIndex, NTLN, false |
---|
4846 | Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
4847 | Â Â Â else |
---|
4848 |     reconstructionTry (result, bufF, bufFactors, degree (bufF) + 1 + |
---|
4849 |               degree (LCF), factorsFound, factorsFoundIndex, |
---|
4850 |               NTLN, false |
---|
4851 | Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
4852 | |
---|
4853 |    if (NTLN.NumCols() == result.length()) |
---|
4854 | #endif |
---|
4855 | Â Â Â { |
---|
4856 |     delete [] A; |
---|
4857 |     delete [] factorsFoundIndex; |
---|
4858 |     return result; |
---|
4859 | Â Â Â } |
---|
4860 |    delete [] factorsFoundIndex; |
---|
4861 | Â Â } |
---|
4862 | Â Â result=Â CFList(); |
---|
4863 | Â Â oldL=Â l; |
---|
4864 | Â Â stepSize *=Â 2; |
---|
4865 | Â Â l +=Â stepSize; |
---|
4866 |   if (l > liftBound) |
---|
4867 | Â Â { |
---|
4868 |    if (!hitBound) |
---|
4869 | Â Â Â { |
---|
4870 | Â Â Â Â l=Â liftBound; |
---|
4871 | Â Â Â Â hitBound=Â true; |
---|
4872 | Â Â Â } |
---|
4873 | Â Â Â else |
---|
4874 | Â Â Â Â break; |
---|
4875 | Â Â } |
---|
4876 | Â } |
---|
4877 |  if (irreducible) |
---|
4878 | Â { |
---|
4879 |   delete [] A; |
---|
4880 |   return CFList (F); |
---|
4881 | Â } |
---|
4882 |  delete [] A; |
---|
4883 | Â factors=Â bufFactors; |
---|
4884 |  return CFList(); |
---|
4885 | } |
---|
4886 | |
---|
4887 | //Fq |
---|
4888 | CFList |
---|
4889 | furtherLiftingAndIncreasePrecision (CanonicalForm& F, CFList& |
---|
4890 |                   factors, int l, int liftBound, int d, int* |
---|
4891 |                   bounds, mat_zz_pE& NTLN, CFList& diophant, |
---|
4892 |                   CFMatrix& M, CFArray& Pi, CFArray& bufQ |
---|
4893 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
4894 | { |
---|
4895 |  CanonicalForm LCF= LC (F, 1); |
---|
4896 | Â CFList result; |
---|
4897 |  bool irreducible= false; |
---|
4898 | Â CFList bufFactors=Â factors; |
---|
4899 |  CFArray *A = new CFArray [bufFactors.length()]; |
---|
4900 |  bool useOldQs= false; |
---|
4901 |  bool hitBound= false; |
---|
4902 |  int oldL= l; |
---|
4903 |  int stepSize= 8; //TODO choose better step size? |
---|
4904 |  l += tmax (tmin (8, degree (F) + 1 + degree (LC (F, 1))-l), 2); |
---|
4905 |  if (NTLN.NumRows() != factors.length()) //refined factors |
---|
4906 |   ident (NTLN, factors.length()); |
---|
4907 | Â CFListIterator j; |
---|
4908 | Â CFArray buf; |
---|
4909 |  mat_zz_pE* NTLC, NTLK; |
---|
4910 |  CanonicalForm bufF, truncF; |
---|
4911 | Â Variable y=Â F.mvar(); |
---|
4912 |  while (l <= liftBound) |
---|
4913 | Â { |
---|
4914 | Â Â bufFactors.insert (LCF); |
---|
4915 |   henselLiftResume12 (F, bufFactors, oldL, l, Pi, diophant, M); |
---|
4916 | Â Â j=Â bufFactors; |
---|
4917 |   truncF= mod (F, power (y, l)); |
---|
4918 |   if (useOldQs) |
---|
4919 | Â Â { |
---|
4920 |    for (int i= 0; i < bufFactors.length(); i++, j++) |
---|
4921 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL, bufQ[i], |
---|
4922 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i]); |
---|
4923 | Â Â } |
---|
4924 | Â Â else |
---|
4925 | Â Â { |
---|
4926 |    for (int i= 0; i < bufFactors.length(); i++, j++) |
---|
4927 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ [i]); |
---|
4928 | Â Â } |
---|
4929 |   for (int i= 0; i < d; i++) |
---|
4930 | Â Â { |
---|
4931 |    if (bounds [i] + 1 <= l/2) |
---|
4932 | Â Â Â { |
---|
4933 |     int k= tmin (bounds [i] + 1, l/2); |
---|
4934 |     CFMatrix C= CFMatrix (l - k, bufFactors.length()); |
---|
4935 |     for (int ii= 0; ii < bufFactors.length(); ii++) |
---|
4936 | Â Â Â Â { |
---|
4937 |      if (A[ii].size() - 1 >= i) |
---|
4938 | Â Â Â Â Â { |
---|
4939 |       buf= getCoeffs (A[ii] [i], k); |
---|
4940 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
4941 | Â Â Â Â Â } |
---|
4942 | Â Â Â Â } |
---|
4943 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_pE(C); |
---|
4944 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
4945 |     transpose (NTLK, NTLK); |
---|
4946 |     kernel (NTLK, NTLK); |
---|
4947 |     transpose (NTLK, NTLK); |
---|
4948 | Â Â Â Â NTLN *=Â NTLK; |
---|
4949 |     if (NTLN.NumCols() == 1) |
---|
4950 | Â Â Â Â { |
---|
4951 | Â Â Â Â Â irreducible=Â true; |
---|
4952 | Â Â Â Â Â break; |
---|
4953 | Â Â Â Â } |
---|
4954 | Â Â Â } |
---|
4955 | Â Â } |
---|
4956 |   if (NTLN.NumCols() == 1) |
---|
4957 | Â Â { |
---|
4958 | Â Â Â irreducible=Â true; |
---|
4959 | Â Â Â break; |
---|
4960 | Â Â } |
---|
4961 | |
---|
4962 |   int * zeroOneVecs= extractZeroOneVecs (NTLN); |
---|
4963 | Â Â bufF=Â F; |
---|
4964 |   result= reconstruction (bufF, bufFactors, zeroOneVecs, l, NTLN); |
---|
4965 |   delete [] zeroOneVecs; |
---|
4966 |   if (result.length() > 0 && degree (bufF) + 1 + degree (LC (bufF, 1)) <= l) |
---|
4967 | Â Â { |
---|
4968 | Â Â Â F=Â bufF; |
---|
4969 | Â Â Â factors=Â bufFactors; |
---|
4970 |    delete [] A; |
---|
4971 |    return result; |
---|
4972 | Â Â } |
---|
4973 | |
---|
4974 |   if (isReduced (NTLN)) |
---|
4975 | Â Â { |
---|
4976 |    int factorsFound= 0; |
---|
4977 | Â Â Â bufF=Â F; |
---|
4978 |    int* factorsFoundIndex= new int [NTLN.NumCols()]; |
---|
4979 |    for (long i= 0; i < NTLN.NumCols(); i++) |
---|
4980 | Â Â Â Â factorsFoundIndex[i]=Â 0; |
---|
4981 |    if (l < liftBound) |
---|
4982 |     reconstructionTry (result, bufF, bufFactors, l, factorsFound, |
---|
4983 |               factorsFoundIndex, NTLN, false |
---|
4984 | Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
4985 | Â Â Â else |
---|
4986 |     reconstructionTry (result, bufF, bufFactors, degree (bufF) + 1 + |
---|
4987 |               degree (LCF), factorsFound, factorsFoundIndex, |
---|
4988 |               NTLN, false |
---|
4989 | Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
4990 |    if (NTLN.NumCols() == result.length()) |
---|
4991 | Â Â Â { |
---|
4992 |     delete [] A; |
---|
4993 |     delete [] factorsFoundIndex; |
---|
4994 |     return result; |
---|
4995 | Â Â Â } |
---|
4996 |    delete [] factorsFoundIndex; |
---|
4997 | Â Â } |
---|
4998 | Â Â result=Â CFList(); |
---|
4999 | Â Â oldL=Â l; |
---|
5000 | Â Â stepSize *=Â 2; |
---|
5001 | Â Â l +=Â stepSize; |
---|
5002 |   if (l > liftBound) |
---|
5003 | Â Â { |
---|
5004 |    if (!hitBound) |
---|
5005 | Â Â Â { |
---|
5006 | Â Â Â Â l=Â liftBound; |
---|
5007 | Â Â Â Â hitBound=Â true; |
---|
5008 | Â Â Â } |
---|
5009 | Â Â Â else |
---|
5010 | Â Â Â Â break; |
---|
5011 | Â Â } |
---|
5012 | Â } |
---|
5013 |  if (irreducible) |
---|
5014 | Â { |
---|
5015 |   delete [] A; |
---|
5016 |   return CFList (F); |
---|
5017 | Â } |
---|
5018 |  delete [] A; |
---|
5019 | Â factors=Â bufFactors; |
---|
5020 |  return CFList(); |
---|
5021 | } |
---|
5022 | |
---|
5023 | //over field extension |
---|
5024 | CFList |
---|
5025 | extFurtherLiftingAndIncreasePrecision (CanonicalForm& F, CFList& factors, int l, |
---|
5026 |                     int liftBound, int d, int* bounds, |
---|
5027 |                     mat_zz_p& NTLN, CFList& diophant, |
---|
5028 |                     CFMatrix& M, CFArray& Pi, CFArray& bufQ, |
---|
5029 |                     const CanonicalForm& evaluation, const |
---|
5030 |                     ExtensionInfo& info, CFList& source, |
---|
5031 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CFList&Â dest |
---|
5032 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
5033 | { |
---|
5034 |  CanonicalForm LCF= LC (F, 1); |
---|
5035 | Â CFList result; |
---|
5036 |  bool irreducible= false; |
---|
5037 | Â CFList bufFactors=Â factors; |
---|
5038 |  CFArray *A = new CFArray [bufFactors.length()]; |
---|
5039 |  bool useOldQs= false; |
---|
5040 |  bool hitBound= false; |
---|
5041 |  bool GF= (CFFactory::gettype()==GaloisFieldDomain); |
---|
5042 |  int degMipo= degree (getMipo (info.getAlpha())); |
---|
5043 | Â Variable alpha=Â info.getAlpha(); |
---|
5044 |  int oldL= l; //be careful |
---|
5045 |  int stepSize= 8; |
---|
5046 |  l += tmax (tmin (8, degree (F) + 1 + degree (LC (F, 1))-l),2); |
---|
5047 | Â Variable gamma=Â info.getBeta(); |
---|
5048 | Â CanonicalForm primElemAlpha=Â info.getGamma(); |
---|
5049 | Â CanonicalForm imPrimElemAlpha=Â info.getDelta(); |
---|
5050 |  if (NTLN.NumRows() != factors.length()) //refined factors |
---|
5051 |   ident (NTLN, factors.length()); |
---|
5052 | Â Variable y=Â F.mvar(); |
---|
5053 |  CanonicalForm powX, imBasis, bufF, truncF; |
---|
5054 |  CFMatrix Mat, C; |
---|
5055 | Â CFIterator iter; |
---|
5056 |  mat_zz_p* NTLMat,*NTLC, NTLK; |
---|
5057 | Â CFListIterator j; |
---|
5058 | Â CFArray buf; |
---|
5059 |  while (l <= liftBound) |
---|
5060 | Â { |
---|
5061 | Â Â bufFactors.insert (LCF); |
---|
5062 |   henselLiftResume12 (F, bufFactors, oldL, l, Pi, diophant, M); |
---|
5063 | |
---|
5064 |   if (GF) |
---|
5065 | Â Â Â setCharacteristic (getCharacteristic()); |
---|
5066 | |
---|
5067 |   powX= power (y-gamma, l); |
---|
5068 |   Mat= CFMatrix (l*degMipo, l*degMipo); |
---|
5069 |   for (int i= 0; i < l*degMipo; i++) |
---|
5070 | Â Â { |
---|
5071 | |
---|
5072 |    imBasis= mod (power (y, i), powX); |
---|
5073 |    imBasis= imBasis (power (y, degMipo), y); |
---|
5074 |    imBasis= imBasis (y, gamma); |
---|
5075 | Â Â Â iter=Â imBasis; |
---|
5076 |    for (; iter.hasTerms(); iter++) |
---|
5077 |     Mat (iter.exp()+ 1, i+1)= iter.coeff(); |
---|
5078 | Â Â } |
---|
5079 | |
---|
5080 | Â Â NTLMat=Â convertFacCFMatrix2NTLmat_zz_p (Mat); |
---|
5081 | Â Â *NTLMat=Â inv (*NTLMat); |
---|
5082 | |
---|
5083 |   if (GF) |
---|
5084 |    setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); |
---|
5085 | |
---|
5086 | Â Â j=Â bufFactors; |
---|
5087 |   truncF= mod (F, power (y, l)); |
---|
5088 |   if (useOldQs) |
---|
5089 | Â Â { |
---|
5090 |    for (int i= 0; i < bufFactors.length(); i++, j++) |
---|
5091 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL, bufQ[i], |
---|
5092 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i]); |
---|
5093 | Â Â } |
---|
5094 | Â Â else |
---|
5095 | Â Â { |
---|
5096 |    for (int i= 0; i < bufFactors.length(); i++, j++) |
---|
5097 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ [i]); |
---|
5098 | Â Â } |
---|
5099 |   for (int i= 0; i < d; i++) |
---|
5100 | Â Â { |
---|
5101 |    if (bounds [i] + 1 <= l/2) |
---|
5102 | Â Â Â { |
---|
5103 |     int k= tmin (bounds [i] + 1, l/2); |
---|
5104 |     C= CFMatrix (l*degMipo - k, bufFactors.length()); |
---|
5105 |     for (int ii= 0; ii < bufFactors.length(); ii++) |
---|
5106 | Â Â Â Â { |
---|
5107 |      if (A[ii].size() - 1 >= i) |
---|
5108 | Â Â Â Â Â { |
---|
5109 |       if (GF) |
---|
5110 | Â Â Â Â Â Â { |
---|
5111 |        A [ii] [i]= A [ii] [i] (y-evaluation, y); |
---|
5112 | Â Â Â Â Â Â Â setCharacteristic (getCharacteristic()); |
---|
5113 |        A[ii] [i]= GF2FalphaRep (A[ii] [i], alpha); |
---|
5114 |        if (alpha != gamma) |
---|
5115 |         A [ii] [i]= mapDown (A[ii] [i], imPrimElemAlpha, primElemAlpha, |
---|
5116 |                    gamma, source, dest |
---|
5117 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5118 |        buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, *NTLMat); |
---|
5119 | Â Â Â Â Â Â } |
---|
5120 | Â Â Â Â Â Â else |
---|
5121 | Â Â Â Â Â Â { |
---|
5122 |        A [ii] [i]= A [ii] [i] (y-evaluation, y); |
---|
5123 |        if (alpha != gamma) |
---|
5124 |         A[ii] [i]= mapDown (A[ii] [i], imPrimElemAlpha, primElemAlpha, |
---|
5125 |                   gamma, source, dest |
---|
5126 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5127 |        buf= getCoeffs (A[ii] [i], k, l, degMipo, gamma, 0, *NTLMat); |
---|
5128 | Â Â Â Â Â Â } |
---|
5129 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
5130 | Â Â Â Â Â } |
---|
5131 |      if (GF) |
---|
5132 |       setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); |
---|
5133 | Â Â Â Â } |
---|
5134 | |
---|
5135 |     if (GF) |
---|
5136 | Â Â Â Â Â setCharacteristic(getCharacteristic()); |
---|
5137 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_p(C); |
---|
5138 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
5139 |     transpose (NTLK, NTLK); |
---|
5140 |     kernel (NTLK, NTLK); |
---|
5141 |     transpose (NTLK, NTLK); |
---|
5142 | Â Â Â Â NTLN *=Â NTLK; |
---|
5143 |     if (GF) |
---|
5144 |      setCharacteristic (getCharacteristic(), degMipo, info.getGFName()); |
---|
5145 | |
---|
5146 |     if (NTLN.NumCols() == 1) |
---|
5147 | Â Â Â Â { |
---|
5148 | Â Â Â Â Â irreducible=Â true; |
---|
5149 | Â Â Â Â Â break; |
---|
5150 | Â Â Â Â } |
---|
5151 | Â Â Â } |
---|
5152 | Â Â } |
---|
5153 |   if (NTLN.NumCols() == 1) |
---|
5154 | Â Â { |
---|
5155 | Â Â Â irreducible=Â true; |
---|
5156 | Â Â Â break; |
---|
5157 | Â Â } |
---|
5158 | |
---|
5159 |   int * zeroOneVecs= extractZeroOneVecs (NTLN); |
---|
5160 | Â Â bufF=Â F; |
---|
5161 |   result= extReconstruction (bufF, bufFactors, zeroOneVecs, l, NTLN, info, |
---|
5162 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â evaluation |
---|
5163 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5164 |   delete [] zeroOneVecs; |
---|
5165 |   if (result.length() > 0 && degree (bufF) + 1 + degree (LC (bufF, 1)) <= l) |
---|
5166 | Â Â { |
---|
5167 | Â Â Â F=Â bufF; |
---|
5168 | Â Â Â factors=Â bufFactors; |
---|
5169 |    delete [] A; |
---|
5170 |    return result; |
---|
5171 | Â Â } |
---|
5172 | |
---|
5173 |   if (isReduced (NTLN)) |
---|
5174 | Â Â { |
---|
5175 |    int factorsFound= 0; |
---|
5176 | Â Â Â bufF=Â F; |
---|
5177 |    int* factorsFoundIndex= new int [NTLN.NumCols()]; |
---|
5178 |    for (long i= 0; i < NTLN.NumCols(); i++) |
---|
5179 | Â Â Â Â factorsFoundIndex[i]=Â 0; |
---|
5180 |    if (l < degree (bufF) + 1 + degree (LCF)) |
---|
5181 |     extReconstructionTry (result, bufF, bufFactors, l, factorsFound, |
---|
5182 |                factorsFoundIndex, NTLN, false, info, evaluation |
---|
5183 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5184 | Â Â Â else |
---|
5185 |     extReconstructionTry (result, bufF, bufFactors, degree (bufF) + 1 + |
---|
5186 |                degree (LCF), factorsFound, factorsFoundIndex, |
---|
5187 |                NTLN, false, info, evaluation |
---|
5188 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5189 |    if (NTLN.NumCols() == result.length()) |
---|
5190 | Â Â Â { |
---|
5191 |     delete [] A; |
---|
5192 |     delete [] factorsFoundIndex; |
---|
5193 |     return result; |
---|
5194 | Â Â Â } |
---|
5195 |    delete [] factorsFoundIndex; |
---|
5196 | Â Â } |
---|
5197 | Â Â result=Â CFList(); |
---|
5198 | Â Â oldL=Â l; |
---|
5199 | Â Â stepSize *=Â 2; |
---|
5200 | Â Â l +=Â stepSize; |
---|
5201 |   if (l > liftBound) |
---|
5202 | Â Â { |
---|
5203 |    if (!hitBound) |
---|
5204 | Â Â Â { |
---|
5205 | Â Â Â Â l=Â liftBound; |
---|
5206 | Â Â Â Â hitBound=Â true; |
---|
5207 | Â Â Â } |
---|
5208 | Â Â Â else |
---|
5209 | Â Â Â Â break; |
---|
5210 | Â Â } |
---|
5211 | Â } |
---|
5212 |  if (irreducible) |
---|
5213 | Â { |
---|
5214 |   delete [] A; |
---|
5215 | Â Â Variable y=Â Variable (2); |
---|
5216 |   CanonicalForm tmp= F (y - evaluation, y); |
---|
5217 |   CFList source, dest; |
---|
5218 |   tmp= mapDown (tmp, info, source, dest); |
---|
5219 |   return CFList (tmp); |
---|
5220 | Â } |
---|
5221 |  delete [] A; |
---|
5222 | Â factors=Â bufFactors; |
---|
5223 |  return CFList(); |
---|
5224 | } |
---|
5225 | |
---|
5226 | #ifdef HAVE_FLINT |
---|
5227 | CFList |
---|
5228 | furtherLiftingAndIncreasePrecisionFq2Fp (CanonicalForm& F, CFList& factors, int |
---|
5229 |                      l, int liftBound, int d, int* bounds, |
---|
5230 |                      nmod_mat_t FLINTN, CFList& diophant, |
---|
5231 |                      CFMatrix& M, CFArray& Pi, CFArray& bufQ, |
---|
5232 |                      const Variable& alpha |
---|
5233 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
5234 | #else |
---|
5235 | CFList |
---|
5236 | furtherLiftingAndIncreasePrecisionFq2Fp (CanonicalForm& F, CFList& factors, int |
---|
5237 |                      l, int liftBound, int d, int* bounds, |
---|
5238 |                      mat_zz_p& NTLN, CFList& diophant, |
---|
5239 |                      CFMatrix& M, CFArray& Pi, CFArray& bufQ, |
---|
5240 |                      const Variable& alpha |
---|
5241 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
5242 | #endif |
---|
5243 | { |
---|
5244 |  CanonicalForm LCF= LC (F, 1); |
---|
5245 | Â CFList result; |
---|
5246 |  bool irreducible= false; |
---|
5247 | Â CFList bufFactors=Â factors; |
---|
5248 |  CFArray *A = new CFArray [bufFactors.length()]; |
---|
5249 |  bool useOldQs= false; |
---|
5250 |  int extensionDeg= degree (getMipo (alpha)); |
---|
5251 |  bool hitBound= false; |
---|
5252 |  int oldL= l; |
---|
5253 |  int stepSize= 8; //TODO choose better step size? |
---|
5254 |  l += tmax (tmin (8, degree (F) + 1 + degree (LC (F, 1))-l), 2); |
---|
5255 | #ifdef HAVE_FLINT |
---|
5256 |  if (nmod_mat_nrows (FLINTN) != factors.length()) //refined factors |
---|
5257 | Â { |
---|
5258 | Â Â nmod_mat_clear (FLINTN); |
---|
5259 | Â Â nmod_mat_init(FLINTN,factors.length(),factors.length(),getCharacteristic()); |
---|
5260 |   for (long i=factors.length()-1; i >= 0; i--) |
---|
5261 |    nmod_mat_entry (FLINTN, i, i)= 1; |
---|
5262 | Â } |
---|
5263 | #else |
---|
5264 |  if (NTLN.NumRows() != factors.length()) //refined factors |
---|
5265 |   ident (NTLN, factors.length()); |
---|
5266 | #endif |
---|
5267 | Â CFListIterator j; |
---|
5268 | Â CFMatrix C; |
---|
5269 | #ifdef HAVE_FLINT |
---|
5270 |  long rank; |
---|
5271 |  nmod_mat_t FLINTC, FLINTK, null; |
---|
5272 | #else |
---|
5273 |  mat_zz_p* NTLC, NTLK; |
---|
5274 | #endif |
---|
5275 |  CanonicalForm bufF, truncF; |
---|
5276 | Â Variable y=Â F.mvar(); |
---|
5277 |  while (l <= liftBound) |
---|
5278 | Â { |
---|
5279 | Â Â bufFactors.insert (LCF); |
---|
5280 |   henselLiftResume12 (F, bufFactors, oldL, l, Pi, diophant, M); |
---|
5281 | Â Â j=Â bufFactors; |
---|
5282 |   truncF= mod (F, power (y, l)); |
---|
5283 |   if (useOldQs) |
---|
5284 | Â Â { |
---|
5285 |    for (int i= 0; i < bufFactors.length(); i++, j++) |
---|
5286 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, oldL, bufQ[i], |
---|
5287 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bufQ[i]); |
---|
5288 | Â Â } |
---|
5289 | Â Â else |
---|
5290 | Â Â { |
---|
5291 |    for (int i= 0; i < bufFactors.length(); i++, j++) |
---|
5292 |     A[i]= logarithmicDerivative (truncF, j.getItem(), l, bufQ [i]); |
---|
5293 | Â Â } |
---|
5294 |   for (int i= 0; i < d; i++) |
---|
5295 | Â Â { |
---|
5296 |    if (bounds [i] + 1 <= l/2) |
---|
5297 | Â Â Â { |
---|
5298 |     int k= tmin (bounds [i] + 1, l/2); |
---|
5299 |     C= CFMatrix ((l - k)*extensionDeg, bufFactors.length()); |
---|
5300 |     for (int ii= 0; ii < bufFactors.length(); ii++) |
---|
5301 | Â Â Â Â { |
---|
5302 | Â Â Â Â Â CFArray buf; |
---|
5303 |      if (A[ii].size() - 1 >= i) |
---|
5304 | Â Â Â Â Â { |
---|
5305 |       buf= getCoeffs (A[ii] [i], k, alpha); |
---|
5306 |       writeInMatrix (C, buf, ii + 1, 0); |
---|
5307 | Â Â Â Â Â } |
---|
5308 | Â Â Â Â } |
---|
5309 | #ifdef HAVE_FLINT |
---|
5310 |     convertFacCFMatrix2nmod_mat_t (FLINTC, C); |
---|
5311 |     nmod_mat_init (FLINTK, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTN), |
---|
5312 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
5313 |     nmod_mat_mul (FLINTK, FLINTC, FLINTN); |
---|
5314 |     nmod_mat_init (null, nmod_mat_ncols (FLINTK), nmod_mat_ncols (FLINTK), |
---|
5315 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
5316 |     rank= nmod_mat_nullspace (null, FLINTK); |
---|
5317 | Â Â Â Â nmod_mat_clear (FLINTK); |
---|
5318 |     nmod_mat_window_init (FLINTK, null, 0, 0, nmod_mat_nrows(null), rank); |
---|
5319 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
5320 |     nmod_mat_init_set (FLINTC, FLINTN); |
---|
5321 | Â Â Â Â nmod_mat_clear (FLINTN); |
---|
5322 |     nmod_mat_init (FLINTN, nmod_mat_nrows (FLINTC), nmod_mat_ncols (FLINTK), |
---|
5323 | Â Â Â Â Â Â Â Â Â Â Â Â getCharacteristic()); |
---|
5324 |     nmod_mat_mul (FLINTN, FLINTC, FLINTK); //no aliasing allowed!! |
---|
5325 | |
---|
5326 | Â Â Â Â nmod_mat_clear (FLINTC); |
---|
5327 | Â Â Â Â nmod_mat_window_clear (FLINTK); |
---|
5328 | Â Â Â Â nmod_mat_clear (null); |
---|
5329 | #else |
---|
5330 | Â Â Â Â NTLC=Â convertFacCFMatrix2NTLmat_zz_p(C); |
---|
5331 | Â Â Â Â NTLK=Â (*NTLC)*NTLN; |
---|
5332 |     transpose (NTLK, NTLK); |
---|
5333 |     kernel (NTLK, NTLK); |
---|
5334 |     transpose (NTLK, NTLK); |
---|
5335 | Â Â Â Â NTLN *=Â NTLK; |
---|
5336 | #endif |
---|
5337 | #ifdef HAVE_FLINT |
---|
5338 |     if (nmod_mat_ncols (FLINTN) == 1) |
---|
5339 | #else |
---|
5340 |     if (NTLN.NumCols() == 1) |
---|
5341 | #endif |
---|
5342 | Â Â Â Â { |
---|
5343 | Â Â Â Â Â irreducible=Â true; |
---|
5344 | Â Â Â Â Â break; |
---|
5345 | Â Â Â Â } |
---|
5346 | Â Â Â } |
---|
5347 | Â Â } |
---|
5348 | #ifdef HAVE_FLINT |
---|
5349 |   if (nmod_mat_ncols (FLINTN) == 1) |
---|
5350 | #else |
---|
5351 |   if (NTLN.NumCols() == 1) |
---|
5352 | #endif |
---|
5353 | Â Â { |
---|
5354 | Â Â Â irreducible=Â true; |
---|
5355 | Â Â Â break; |
---|
5356 | Â Â } |
---|
5357 | |
---|
5358 | #ifdef HAVE_FLINT |
---|
5359 |   int * zeroOneVecs= extractZeroOneVecs (FLINTN); |
---|
5360 | #else |
---|
5361 |   int * zeroOneVecs= extractZeroOneVecs (NTLN); |
---|
5362 | #endif |
---|
5363 | Â Â CanonicalForm bufF=Â F; |
---|
5364 | #ifdef HAVE_FLINT |
---|
5365 |   result= reconstruction (bufF, bufFactors, zeroOneVecs, l, FLINTN); |
---|
5366 | #else |
---|
5367 |   result= reconstruction (bufF, bufFactors, zeroOneVecs, l, NTLN); |
---|
5368 | #endif |
---|
5369 |   delete [] zeroOneVecs; |
---|
5370 |   if (result.length() > 0 && degree (bufF) + 1 + degree (LC (bufF, 1)) <= l) |
---|
5371 | Â Â { |
---|
5372 | Â Â Â F=Â bufF; |
---|
5373 | Â Â Â factors=Â bufFactors; |
---|
5374 |    delete [] A; |
---|
5375 |    return result; |
---|
5376 | Â Â } |
---|
5377 | |
---|
5378 | #ifdef HAVE_FLINT |
---|
5379 |   if (isReduced (FLINTN)) |
---|
5380 | #else |
---|
5381 |   if (isReduced (NTLN)) |
---|
5382 | #endif |
---|
5383 | Â Â { |
---|
5384 |    int factorsFound= 0; |
---|
5385 | Â Â Â bufF=Â F; |
---|
5386 | #ifdef HAVE_FLINT |
---|
5387 |    int* factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; |
---|
5388 |    for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) |
---|
5389 | #else |
---|
5390 |    int* factorsFoundIndex= new int [NTLN.NumCols()]; |
---|
5391 |    for (long i= 0; i < NTLN.NumCols(); i++) |
---|
5392 | #endif |
---|
5393 | Â Â Â Â factorsFoundIndex[i]=Â 0; |
---|
5394 | #ifdef HAVE_FLINT |
---|
5395 |    if (l < degree (bufF) + 1 + degree (LCF)) |
---|
5396 |     reconstructionTry (result, bufF, bufFactors, l, factorsFound, |
---|
5397 |               factorsFoundIndex, FLINTN, false |
---|
5398 | Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5399 | Â Â Â else |
---|
5400 |     reconstructionTry (result, bufF, bufFactors, degree (bufF) + 1 + |
---|
5401 |               degree (LCF), factorsFound, factorsFoundIndex, |
---|
5402 |               FLINTN, false |
---|
5403 | Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5404 |    if (nmod_mat_ncols (FLINTN) == result.length()) |
---|
5405 | #else |
---|
5406 |    if (l < degree (bufF) + 1 + degree (LCF)) |
---|
5407 |     reconstructionTry (result, bufF, bufFactors, l, factorsFound, |
---|
5408 |               factorsFoundIndex, NTLN, false |
---|
5409 | Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5410 | Â Â Â else |
---|
5411 |     reconstructionTry (result, bufF, bufFactors, degree (bufF) + 1 + |
---|
5412 |               degree (LCF), factorsFound, factorsFoundIndex, |
---|
5413 |               NTLN, false |
---|
5414 | Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5415 |    if (NTLN.NumCols() == result.length()) |
---|
5416 | #endif |
---|
5417 | Â Â Â { |
---|
5418 |     delete [] A; |
---|
5419 |     delete [] factorsFoundIndex; |
---|
5420 |     return result; |
---|
5421 | Â Â Â } |
---|
5422 |    delete [] factorsFoundIndex; |
---|
5423 | Â Â } |
---|
5424 | Â Â result=Â CFList(); |
---|
5425 | Â Â oldL=Â l; |
---|
5426 | Â Â stepSize *=Â 2; |
---|
5427 | Â Â l +=Â stepSize; |
---|
5428 |   if (l > liftBound) |
---|
5429 | Â Â { |
---|
5430 |    if (!hitBound) |
---|
5431 | Â Â Â { |
---|
5432 | Â Â Â Â l=Â liftBound; |
---|
5433 | Â Â Â Â hitBound=Â true; |
---|
5434 | Â Â Â } |
---|
5435 | Â Â Â else |
---|
5436 | Â Â Â Â break; |
---|
5437 | Â Â } |
---|
5438 | Â } |
---|
5439 |  if (irreducible) |
---|
5440 | Â { |
---|
5441 |   delete [] A; |
---|
5442 |   return CFList (F); |
---|
5443 | Â } |
---|
5444 |  delete [] A; |
---|
5445 | Â factors=Â bufFactors; |
---|
5446 |  return CFList(); |
---|
5447 | } |
---|
5448 | |
---|
5449 | void |
---|
5450 | refineAndRestartLift (const CanonicalForm& F, const mat_zz_p& NTLN, int |
---|
5451 |            liftBound, int l, CFList& factors, CFMatrix& M, CFArray& |
---|
5452 |            Pi, CFList& diophant |
---|
5453 | Â Â Â Â Â Â Â Â Â Â Â ) |
---|
5454 | { |
---|
5455 | Â CFList bufFactors; |
---|
5456 | Â Variable y=Â Variable (2); |
---|
5457 |  CanonicalForm LCF= LC (F, 1); |
---|
5458 | Â CFListIterator iter; |
---|
5459 | Â CanonicalForm buf; |
---|
5460 |  for (long i= 1; i <= NTLN.NumCols(); i++) |
---|
5461 | Â { |
---|
5462 | Â Â iter=Â factors; |
---|
5463 | Â Â buf=Â 1; |
---|
5464 |   for (long j= 1; j <= NTLN.NumRows(); j++, iter++) |
---|
5465 | Â Â { |
---|
5466 |    if (!IsZero (NTLN (j,i))) |
---|
5467 |     buf= mulNTL (buf, mod (iter.getItem(), y)); |
---|
5468 | Â Â } |
---|
5469 | Â Â bufFactors.append (buf); |
---|
5470 | Â } |
---|
5471 | Â factors=Â bufFactors; |
---|
5472 |  M= CFMatrix (liftBound, factors.length()); |
---|
5473 | Â Pi=Â CFArray(); |
---|
5474 | Â diophant=Â CFList(); |
---|
5475 | Â factors.insert (LCF); |
---|
5476 |  henselLift12 (F, factors, l, Pi, diophant, M); |
---|
5477 | } |
---|
5478 | |
---|
5479 | #ifdef HAVE_FLINT |
---|
5480 | void |
---|
5481 | refineAndRestartLift (const CanonicalForm& F, const nmod_mat_t FLINTN, int |
---|
5482 |            liftBound, int l, CFList& factors, CFMatrix& M, CFArray& |
---|
5483 |            Pi, CFList& diophant |
---|
5484 | Â Â Â Â Â Â Â Â Â Â Â ) |
---|
5485 | { |
---|
5486 | Â CFList bufFactors; |
---|
5487 | Â Variable y=Â Variable (2); |
---|
5488 |  CanonicalForm LCF= LC (F, 1); |
---|
5489 | Â CFListIterator iter; |
---|
5490 | Â CanonicalForm buf; |
---|
5491 |  for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) |
---|
5492 | Â { |
---|
5493 | Â Â iter=Â factors; |
---|
5494 | Â Â buf=Â 1; |
---|
5495 |   for (long j= 0; j < nmod_mat_nrows (FLINTN); j++, iter++) |
---|
5496 | Â Â { |
---|
5497 |    if (!(nmod_mat_entry (FLINTN,j,i) == 0)) |
---|
5498 |     buf= mulNTL (buf, mod (iter.getItem(), y)); |
---|
5499 | Â Â } |
---|
5500 | Â Â bufFactors.append (buf); |
---|
5501 | Â } |
---|
5502 | Â factors=Â bufFactors; |
---|
5503 |  M= CFMatrix (liftBound, factors.length()); |
---|
5504 | Â Pi=Â CFArray(); |
---|
5505 | Â diophant=Â CFList(); |
---|
5506 | Â factors.insert (LCF); |
---|
5507 |  henselLift12 (F, factors, l, Pi, diophant, M); |
---|
5508 | } |
---|
5509 | #endif |
---|
5510 | |
---|
5511 | void |
---|
5512 | refineAndRestartLift (const CanonicalForm& F, const mat_zz_pE& NTLN, int |
---|
5513 |            liftBound, int l, CFList& factors, CFMatrix& M, CFArray& |
---|
5514 |            Pi, CFList& diophant |
---|
5515 | Â Â Â Â Â Â Â Â Â Â Â ) |
---|
5516 | { |
---|
5517 | Â CFList bufFactors; |
---|
5518 | Â Variable y=Â Variable (2); |
---|
5519 |  CanonicalForm LCF= LC (F, 1); |
---|
5520 | Â CFListIterator iter; |
---|
5521 | Â CanonicalForm buf; |
---|
5522 |  for (long i= 1; i <= NTLN.NumCols(); i++) |
---|
5523 | Â { |
---|
5524 | Â Â iter=Â factors; |
---|
5525 | Â Â buf=Â 1; |
---|
5526 |   for (long j= 1; j <= NTLN.NumRows(); j++, iter++) |
---|
5527 | Â Â { |
---|
5528 |    if (!IsZero (NTLN (j,i))) |
---|
5529 |     buf= mulNTL (buf, mod (iter.getItem(), y)); |
---|
5530 | Â Â } |
---|
5531 | Â Â bufFactors.append (buf); |
---|
5532 | Â } |
---|
5533 | Â factors=Â bufFactors; |
---|
5534 |  M= CFMatrix (liftBound, factors.length()); |
---|
5535 | Â Pi=Â CFArray(); |
---|
5536 | Â diophant=Â CFList(); |
---|
5537 | Â factors.insert (LCF); |
---|
5538 |  henselLift12 (F, factors, l, Pi, diophant, M); |
---|
5539 | } |
---|
5540 | |
---|
5541 | #ifdef HAVE_FLINT |
---|
5542 | CFList |
---|
5543 | earlyReconstructionAndLifting (const CanonicalForm& F, const nmod_mat_t N, |
---|
5544 |                 CanonicalForm& bufF, CFList& factors, int& l, |
---|
5545 |                 int& factorsFound, bool beenInThres, CFMatrix& M, |
---|
5546 |                 CFArray& Pi, CFList& diophant, bool symmetric, |
---|
5547 |                 const CanonicalForm& evaluation |
---|
5548 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
5549 | #else |
---|
5550 | CFList |
---|
5551 | earlyReconstructionAndLifting (const CanonicalForm& F, const mat_zz_p& N, |
---|
5552 |                 CanonicalForm& bufF, CFList& factors, int& l, |
---|
5553 |                 int& factorsFound, bool beenInThres, CFMatrix& M, |
---|
5554 |                 CFArray& Pi, CFList& diophant, bool symmetric, |
---|
5555 |                 const CanonicalForm& evaluation |
---|
5556 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
5557 | #endif |
---|
5558 | { |
---|
5559 |  int sizeOfLiftPre; |
---|
5560 |  int * liftPre= getLiftPrecisions (F, sizeOfLiftPre, degree (LC (F, 1), 2)); |
---|
5561 | |
---|
5562 | Â Variable y=Â F.mvar(); |
---|
5563 | Â factorsFound=Â 0; |
---|
5564 |  CanonicalForm LCF= LC (F, 1); |
---|
5565 | Â CFList result; |
---|
5566 |  int smallFactorDeg= tmin (11, liftPre [sizeOfLiftPre- 1] + 1); |
---|
5567 | #ifdef HAVE_FLINT |
---|
5568 | Â nmod_mat_t FLINTN; |
---|
5569 |  nmod_mat_init_set (FLINTN, N); |
---|
5570 |  int * factorsFoundIndex= new int [nmod_mat_ncols (FLINTN)]; |
---|
5571 |  for (long i= 0; i < nmod_mat_ncols (FLINTN); i++) |
---|
5572 | #else |
---|
5573 | Â mat_zz_p NTLN=Â N; |
---|
5574 |  int * factorsFoundIndex= new int [NTLN.NumCols()]; |
---|
5575 |  for (long i= 0; i < NTLN.NumCols(); i++) |
---|
5576 | #endif |
---|
5577 | Â Â factorsFoundIndex [i]=Â 0; |
---|
5578 | |
---|
5579 |  if (degree (F) + 1 > smallFactorDeg) |
---|
5580 | Â { |
---|
5581 |   if (l < smallFactorDeg) |
---|
5582 | Â Â { |
---|
5583 | Â Â Â factors.insert (LCF); |
---|
5584 |    henselLiftResume12 (F, factors, l, smallFactorDeg, Pi, diophant, M); |
---|
5585 | Â Â Â l=Â smallFactorDeg; |
---|
5586 | Â Â } |
---|
5587 | #ifdef HAVE_FLINT |
---|
5588 |   reconstructionTry (result, bufF, factors, smallFactorDeg, factorsFound, |
---|
5589 |             factorsFoundIndex, FLINTN, beenInThres |
---|
5590 | Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5591 |   if (result.length() == nmod_mat_ncols (FLINTN)) |
---|
5592 | Â Â { |
---|
5593 | Â Â Â nmod_mat_clear (FLINTN); |
---|
5594 | #else |
---|
5595 |   reconstructionTry (result, bufF, factors, smallFactorDeg, factorsFound, |
---|
5596 |             factorsFoundIndex, NTLN, beenInThres |
---|
5597 | Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5598 |   if (result.length() == NTLN.NumCols()) |
---|
5599 | Â Â { |
---|
5600 | #endif |
---|
5601 |    delete [] liftPre; |
---|
5602 |    delete [] factorsFoundIndex; |
---|
5603 |    return result; |
---|
5604 | Â Â } |
---|
5605 | Â } |
---|
5606 | |
---|
5607 |  int i= sizeOfLiftPre - 1; |
---|
5608 |  int dummy= 1; |
---|
5609 |  if (sizeOfLiftPre > 1 && sizeOfLiftPre < 30) |
---|
5610 | Â { |
---|
5611 |   while (i > 0) |
---|
5612 | Â Â { |
---|
5613 |    if (l < liftPre[i-1] + 1) |
---|
5614 | Â Â Â { |
---|
5615 | Â Â Â Â factors.insert (LCF); |
---|
5616 |     henselLiftResume12 (F, factors, l, liftPre[i-1] + 1, Pi, diophant, M); |
---|
5617 | Â Â Â Â l=Â liftPre[i-1]Â +Â 1; |
---|
5618 | Â Â Â } |
---|
5619 | Â Â Â else |
---|
5620 | Â Â Â { |
---|
5621 | Â Â Â Â i--; |
---|
5622 |     if (i != 0) |
---|
5623 | Â Â Â Â Â continue; |
---|
5624 | Â Â Â } |
---|
5625 | #ifdef HAVE_FLINT |
---|
5626 |    reconstructionTry (result, bufF, factors, l, factorsFound, |
---|
5627 |              factorsFoundIndex, FLINTN, beenInThres |
---|
5628 | Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5629 |    if (result.length() == nmod_mat_ncols (FLINTN)) |
---|
5630 | Â Â Â { |
---|
5631 | Â Â Â Â nmod_mat_clear (FLINTN); |
---|
5632 | #else |
---|
5633 |    reconstructionTry (result, bufF, factors, l, factorsFound, |
---|
5634 |              factorsFoundIndex, NTLN, beenInThres |
---|
5635 | Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5636 |    if (result.length() == NTLN.NumCols()) |
---|
5637 | Â Â Â { |
---|
5638 | #endif |
---|
5639 |     delete [] liftPre; |
---|
5640 |     delete [] factorsFoundIndex; |
---|
5641 |     return result; |
---|
5642 | Â Â Â } |
---|
5643 | Â Â Â i--; |
---|
5644 | Â Â } |
---|
5645 | Â } |
---|
5646 | Â else |
---|
5647 | Â { |
---|
5648 | Â Â i=Â 1; |
---|
5649 |   while ((degree (F,y)/4)*i + 4 <= smallFactorDeg) |
---|
5650 | Â Â Â i++; |
---|
5651 |   while (i < 5) |
---|
5652 | Â Â { |
---|
5653 |    dummy= tmin (degree (F,y)+1, (degree (F,y)/4)*i+4); |
---|
5654 |    if (l < dummy) |
---|
5655 | Â Â Â { |
---|
5656 | Â Â Â Â factors.insert (LCF); |
---|
5657 |     henselLiftResume12 (F, factors, l, dummy, Pi, diophant, M); |
---|
5658 | Â Â Â Â l=Â dummy; |
---|
5659 |     if (i == 1 && degree (F)%4==0 && symmetric && factors.length() == 2 && |
---|
5660 | Â Â Â Â Â Â LC (F,1).inCoeffDomain()Â && |
---|
5661 |       (degree (factors.getFirst(), 1) == degree (factors.getLast(),1))) |
---|
5662 | Â Â Â Â { |
---|
5663 | Â Â Â Â Â Variable x=Â Variable (1); |
---|
5664 |      CanonicalForm g, h, gg, hh, multiplier1, multiplier2, check1, check2; |
---|
5665 |      int m= degree (F)/4+1; |
---|
5666 | Â Â Â Â Â g=Â factors.getFirst(); |
---|
5667 | Â Â Â Â Â h=Â factors.getLast(); |
---|
5668 |      g= mod (g, power (y,m)); |
---|
5669 |      h= mod (h, power (y,m)); |
---|
5670 |      g= g (y-evaluation, y); |
---|
5671 |      h= h (y-evaluation, y); |
---|
5672 | Â Â Â Â Â gg=Â mod (swapvar (g,x,y),power (x,m)); |
---|
5673 |      gg= gg (y + evaluation, y); |
---|
5674 | Â Â Â Â Â multiplier1=Â factors.getLast()[m-1][0]/gg[m-1][0]; |
---|
5675 |      gg= div (gg, power (y,m)); |
---|
5676 | Â Â Â Â Â gg=Â gg*power (y,m); |
---|
5677 | Â Â Â Â Â hh=Â mod (swapvar (h,x,y),power (x,m)); |
---|
5678 |      hh= hh (y + evaluation, y); |
---|
5679 | Â Â Â Â Â multiplier2=Â factors.getFirst()[m-1][0]/hh[m-1][0]; |
---|
5680 |      hh= div (hh, power (y,m)); |
---|
5681 | Â Â Â Â Â hh=Â hh*power (y,m); |
---|
5682 |      gg= multiplier1*gg+mod (factors.getLast(), power (y,m)); |
---|
5683 |      hh= multiplier2*hh+mod (factors.getFirst(), power (y,m)); |
---|
5684 | Â Â Â Â Â check1=Â gg (y-evaluation,y); |
---|
5685 | Â Â Â Â Â check2=Â hh (y-evaluation,y); |
---|
5686 |      check1= swapvar (check1, x, y); |
---|
5687 |      if (check1/Lc (check1) == check2/Lc (check2)) |
---|
5688 | Â Â Â Â Â { |
---|
5689 | #ifdef HAVE_FLINT |
---|
5690 | Â Â Â Â Â Â nmod_mat_clear (FLINTN); |
---|
5691 | #endif |
---|
5692 | Â Â Â Â Â Â result.append (gg); |
---|
5693 | Â Â Â Â Â Â result.append (hh); |
---|
5694 |       delete [] liftPre; |
---|
5695 |       delete [] factorsFoundIndex; |
---|
5696 |       return result; |
---|
5697 | Â Â Â Â Â } |
---|
5698 | Â Â Â Â } |
---|
5699 | Â Â Â } |
---|
5700 | Â Â Â else |
---|
5701 | Â Â Â { |
---|
5702 | Â Â Â Â i++; |
---|
5703 |     if (i < 5) |
---|
5704 | Â Â Â Â Â continue; |
---|
5705 | Â Â Â } |
---|
5706 | #ifdef HAVE_FLINT |
---|
5707 |    reconstructionTry (result, bufF, factors, l, factorsFound, |
---|
5708 |              factorsFoundIndex, FLINTN, beenInThres |
---|
5709 | Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5710 |    if (result.length() == nmod_mat_ncols (FLINTN)) |
---|
5711 | Â Â Â { |
---|
5712 | Â Â Â Â nmod_mat_clear (FLINTN); |
---|
5713 | #else |
---|
5714 |    reconstructionTry (result, bufF, factors, l, factorsFound, |
---|
5715 |              factorsFoundIndex, NTLN, beenInThres |
---|
5716 | Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5717 |    if (result.length() == NTLN.NumCols()) |
---|
5718 | Â Â Â { |
---|
5719 | #endif |
---|
5720 |     delete [] liftPre; |
---|
5721 |     delete [] factorsFoundIndex; |
---|
5722 |     return result; |
---|
5723 | Â Â Â } |
---|
5724 | Â Â Â i++; |
---|
5725 | Â Â } |
---|
5726 | Â } |
---|
5727 | |
---|
5728 | #ifdef HAVE_FLINT |
---|
5729 | Â nmod_mat_clear (FLINTN); |
---|
5730 | #endif |
---|
5731 |  delete [] liftPre; |
---|
5732 |  delete [] factorsFoundIndex; |
---|
5733 |  return result; |
---|
5734 | } |
---|
5735 | |
---|
5736 | CFList |
---|
5737 | earlyReconstructionAndLifting (const CanonicalForm& F, const mat_zz_pE& N, |
---|
5738 |                 CanonicalForm& bufF, CFList& factors, int& l, |
---|
5739 |                 int& factorsFound, bool beenInThres, CFMatrix& M, |
---|
5740 |                 CFArray& Pi, CFList& diophant, bool symmetric, |
---|
5741 |                 const CanonicalForm& evaluation |
---|
5742 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
5743 | { |
---|
5744 |  int sizeOfLiftPre; |
---|
5745 |  int * liftPre= getLiftPrecisions (F, sizeOfLiftPre, degree (LC (F, 1), 2)); |
---|
5746 | Â Variable y=Â F.mvar(); |
---|
5747 | Â factorsFound=Â 0; |
---|
5748 |  CanonicalForm LCF= LC (F, 1); |
---|
5749 | Â CFList result; |
---|
5750 |  int smallFactorDeg= 11; |
---|
5751 | Â mat_zz_pE NTLN=Â N; |
---|
5752 |  int * factorsFoundIndex= new int [NTLN.NumCols()]; |
---|
5753 |  for (long i= 0; i < NTLN.NumCols(); i++) |
---|
5754 | Â Â factorsFoundIndex [i]=Â 0; |
---|
5755 | |
---|
5756 |  if (degree (F) + 1 > smallFactorDeg) |
---|
5757 | Â { |
---|
5758 |   if (l < smallFactorDeg) |
---|
5759 | Â Â { |
---|
5760 | Â Â Â factors.insert (LCF); |
---|
5761 |    henselLiftResume12 (F, factors, l, smallFactorDeg, Pi, diophant, M); |
---|
5762 | Â Â Â l=Â smallFactorDeg; |
---|
5763 | Â Â } |
---|
5764 |   reconstructionTry (result, bufF, factors, smallFactorDeg, factorsFound, |
---|
5765 |             factorsFoundIndex, NTLN, beenInThres |
---|
5766 | Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5767 |   if (result.length() == NTLN.NumCols()) |
---|
5768 | Â Â { |
---|
5769 |    delete [] liftPre; |
---|
5770 |    delete [] factorsFoundIndex; |
---|
5771 |    return result; |
---|
5772 | Â Â } |
---|
5773 | Â } |
---|
5774 | |
---|
5775 |  int i= sizeOfLiftPre - 1; |
---|
5776 |  int dummy= 1; |
---|
5777 |  if (sizeOfLiftPre > 1 && sizeOfLiftPre < 30) |
---|
5778 | Â { |
---|
5779 |   while (i > 0) |
---|
5780 | Â Â { |
---|
5781 |    if (l < liftPre[i-1] + 1) |
---|
5782 | Â Â Â { |
---|
5783 | Â Â Â Â factors.insert (LCF); |
---|
5784 |     henselLiftResume12 (F, factors, l, liftPre[i-1] + 1, Pi, diophant, M); |
---|
5785 | Â Â Â Â l=Â liftPre[i-1]Â +Â 1; |
---|
5786 | Â Â Â } |
---|
5787 | Â Â Â else |
---|
5788 | Â Â Â { |
---|
5789 | Â Â Â Â i--; |
---|
5790 |     if (i != 0) |
---|
5791 | Â Â Â Â Â continue; |
---|
5792 | Â Â Â } |
---|
5793 |    reconstructionTry (result, bufF, factors, l, factorsFound, |
---|
5794 |              factorsFoundIndex, NTLN, beenInThres |
---|
5795 | Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5796 |    if (result.length() == NTLN.NumCols()) |
---|
5797 | Â Â Â { |
---|
5798 |     delete [] liftPre; |
---|
5799 |     delete [] factorsFoundIndex; |
---|
5800 |     return result; |
---|
5801 | Â Â Â } |
---|
5802 | Â Â Â i--; |
---|
5803 | Â Â } |
---|
5804 | Â } |
---|
5805 | Â else |
---|
5806 | Â { |
---|
5807 | Â Â i=Â 1; |
---|
5808 |   while ((degree (F,y)/4)*i + 4 <= smallFactorDeg) |
---|
5809 | Â Â Â i++; |
---|
5810 |   while (i < 5) |
---|
5811 | Â Â { |
---|
5812 |    dummy= tmin (degree (F,y)+1, (degree (F,y)/4)*i+4); |
---|
5813 |    if (l < dummy) |
---|
5814 | Â Â Â { |
---|
5815 | Â Â Â Â factors.insert (LCF); |
---|
5816 |     henselLiftResume12 (F, factors, l, dummy, Pi, diophant, M); |
---|
5817 | Â Â Â Â l=Â dummy; |
---|
5818 |     if (i == 1 && degree (F)%4==0 && symmetric && factors.length() == 2 && |
---|
5819 | Â Â Â Â Â Â LC (F,1).inCoeffDomain()Â && |
---|
5820 |       (degree (factors.getFirst(), 1) == degree (factors.getLast(),1))) |
---|
5821 | Â Â Â Â { |
---|
5822 | Â Â Â Â Â Variable x=Â Variable (1); |
---|
5823 |      CanonicalForm g, h, gg, hh, multiplier1, multiplier2, check1, check2; |
---|
5824 |      int m= degree (F)/4+1; |
---|
5825 | Â Â Â Â Â g=Â factors.getFirst(); |
---|
5826 | Â Â Â Â Â h=Â factors.getLast(); |
---|
5827 |      g= mod (g, power (y,m)); |
---|
5828 |      h= mod (h, power (y,m)); |
---|
5829 |      g= g (y-evaluation, y); |
---|
5830 |      h= h (y-evaluation, y); |
---|
5831 | Â Â Â Â Â gg=Â mod (swapvar (g,x,y),power (x,m)); |
---|
5832 |      gg= gg (y + evaluation, y); |
---|
5833 | Â Â Â Â Â multiplier1=Â factors.getLast()[m-1][0]/gg[m-1][0]; |
---|
5834 |      gg= div (gg, power (y,m)); |
---|
5835 | Â Â Â Â Â gg=Â gg*power (y,m); |
---|
5836 | Â Â Â Â Â hh=Â mod (swapvar (h,x,y),power (x,m)); |
---|
5837 |      hh= hh (y + evaluation, y); |
---|
5838 | Â Â Â Â Â multiplier2=Â factors.getFirst()[m-1][0]/hh[m-1][0]; |
---|
5839 |      hh= div (hh, power (y,m)); |
---|
5840 | Â Â Â Â Â hh=Â hh*power (y,m); |
---|
5841 |      gg= multiplier1*gg+mod (factors.getLast(), power (y,m)); |
---|
5842 |      hh= multiplier2*hh+mod (factors.getFirst(), power (y,m)); |
---|
5843 | Â Â Â Â Â check1=Â gg (y-evaluation,y); |
---|
5844 | Â Â Â Â Â check2=Â hh (y-evaluation,y); |
---|
5845 |      check1= swapvar (check1, x, y); |
---|
5846 |      if (check1/Lc (check1) == check2/Lc (check2)) |
---|
5847 | Â Â Â Â Â { |
---|
5848 | Â Â Â Â Â Â result.append (gg); |
---|
5849 | Â Â Â Â Â Â result.append (hh); |
---|
5850 |       delete [] liftPre; |
---|
5851 |       delete [] factorsFoundIndex; |
---|
5852 |       return result; |
---|
5853 | Â Â Â Â Â } |
---|
5854 | Â Â Â Â } |
---|
5855 | Â Â Â } |
---|
5856 | Â Â Â else |
---|
5857 | Â Â Â { |
---|
5858 | Â Â Â Â i++; |
---|
5859 |     if (i < 5) |
---|
5860 | Â Â Â Â Â continue; |
---|
5861 | Â Â Â } |
---|
5862 |    reconstructionTry (result, bufF, factors, l, factorsFound, |
---|
5863 |              factorsFoundIndex, NTLN, beenInThres |
---|
5864 | Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5865 |    if (result.length() == NTLN.NumCols()) |
---|
5866 | Â Â Â { |
---|
5867 |     delete [] liftPre; |
---|
5868 |     delete [] factorsFoundIndex; |
---|
5869 |     return result; |
---|
5870 | Â Â Â } |
---|
5871 | Â Â Â i++; |
---|
5872 | Â Â } |
---|
5873 | Â } |
---|
5874 | |
---|
5875 |  delete [] liftPre; |
---|
5876 |  delete [] factorsFoundIndex; |
---|
5877 |  return result; |
---|
5878 | } |
---|
5879 | |
---|
5880 | //over field extension |
---|
5881 | CFList |
---|
5882 | extEarlyReconstructionAndLifting (const CanonicalForm& F, const mat_zz_p& N, |
---|
5883 |                  CanonicalForm& bufF, CFList& factors, int& l, |
---|
5884 |                  int& factorsFound, bool beenInThres, CFMatrix& |
---|
5885 |                  M, CFArray& Pi, CFList& diophant, const |
---|
5886 |                  ExtensionInfo& info, const CanonicalForm& |
---|
5887 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â evaluation |
---|
5888 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
5889 | { |
---|
5890 |  int sizeOfLiftPre; |
---|
5891 |  int * liftPre= getLiftPrecisions (F, sizeOfLiftPre, degree (LC (F, 1), 2)); |
---|
5892 | Â Variable y=Â F.mvar(); |
---|
5893 | Â factorsFound=Â 0; |
---|
5894 |  CanonicalForm LCF= LC (F, 1); |
---|
5895 | Â CFList result; |
---|
5896 |  int smallFactorDeg= 11; |
---|
5897 | Â mat_zz_p NTLN=Â N; |
---|
5898 |  int * factorsFoundIndex= new int [NTLN.NumCols()]; |
---|
5899 |  for (long i= 0; i < NTLN.NumCols(); i++) |
---|
5900 | Â Â factorsFoundIndex [i]=Â 0; |
---|
5901 | |
---|
5902 |  if (degree (F) + 1 > smallFactorDeg) |
---|
5903 | Â { |
---|
5904 |   if (l < smallFactorDeg) |
---|
5905 | Â Â { |
---|
5906 | Â Â Â factors.insert (LCF); |
---|
5907 |    henselLiftResume12 (F, factors, l, smallFactorDeg, Pi, diophant, M); |
---|
5908 | Â Â Â l=Â smallFactorDeg; |
---|
5909 | Â Â } |
---|
5910 |   extReconstructionTry (result, bufF, factors, smallFactorDeg, factorsFound, |
---|
5911 |              factorsFoundIndex, NTLN, beenInThres, info, |
---|
5912 | Â Â Â Â Â Â Â Â Â Â Â Â Â evaluation |
---|
5913 | Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5914 |   if (result.length() == NTLN.NumCols()) |
---|
5915 | Â Â { |
---|
5916 |    delete [] liftPre; |
---|
5917 |    delete [] factorsFoundIndex; |
---|
5918 |    return result; |
---|
5919 | Â Â } |
---|
5920 | Â } |
---|
5921 | |
---|
5922 |  int i= sizeOfLiftPre - 1; |
---|
5923 |  int dummy= 1; |
---|
5924 |  if (sizeOfLiftPre > 1 && sizeOfLiftPre < 30) |
---|
5925 | Â { |
---|
5926 |   while (i > 0) |
---|
5927 | Â Â { |
---|
5928 |    if (l < liftPre[i-1] + 1) |
---|
5929 | Â Â Â { |
---|
5930 | Â Â Â Â factors.insert (LCF); |
---|
5931 |     henselLiftResume12 (F, factors, l, liftPre[i-1] + 1, Pi, diophant, M); |
---|
5932 | Â Â Â Â l=Â liftPre[i-1]Â +Â 1; |
---|
5933 | Â Â Â } |
---|
5934 | Â Â Â else |
---|
5935 | Â Â Â { |
---|
5936 | Â Â Â Â i--; |
---|
5937 |     if (i != 0) |
---|
5938 | Â Â Â Â Â continue; |
---|
5939 | Â Â Â } |
---|
5940 |    extReconstructionTry (result, bufF, factors, l, factorsFound, |
---|
5941 |               factorsFoundIndex, NTLN, beenInThres, info, |
---|
5942 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â evaluation |
---|
5943 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5944 |    if (result.length() == NTLN.NumCols()) |
---|
5945 | Â Â Â { |
---|
5946 |     delete [] liftPre; |
---|
5947 |     delete [] factorsFoundIndex; |
---|
5948 |     return result; |
---|
5949 | Â Â Â } |
---|
5950 | Â Â Â i--; |
---|
5951 | Â Â } |
---|
5952 | Â } |
---|
5953 | Â else |
---|
5954 | Â { |
---|
5955 | Â Â i=Â 1; |
---|
5956 |   while ((degree (F,y)/4)*i + 4 <= smallFactorDeg) |
---|
5957 | Â Â Â i++; |
---|
5958 |   while (i < 5) |
---|
5959 | Â Â { |
---|
5960 |    dummy= tmin (degree (F,y)+1, (degree (F,y)/4)*i+4); |
---|
5961 |    if (l < dummy) |
---|
5962 | Â Â Â { |
---|
5963 | Â Â Â Â factors.insert (LCF); |
---|
5964 |     henselLiftResume12 (F, factors, l, dummy, Pi, diophant, M); |
---|
5965 | Â Â Â Â l=Â dummy; |
---|
5966 | Â Â Â } |
---|
5967 | Â Â Â else |
---|
5968 | Â Â Â { |
---|
5969 | Â Â Â Â i++; |
---|
5970 |     if (i < 5) |
---|
5971 | Â Â Â Â Â continue; |
---|
5972 | Â Â Â } |
---|
5973 |    extReconstructionTry (result, bufF, factors, l, factorsFound, |
---|
5974 |               factorsFoundIndex, NTLN, beenInThres, info, |
---|
5975 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â evaluation |
---|
5976 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); |
---|
5977 |    if (result.length() == NTLN.NumCols()) |
---|
5978 | Â Â Â { |
---|
5979 |     delete [] liftPre; |
---|
5980 |     delete [] factorsFoundIndex; |
---|
5981 |     return result; |
---|
5982 | Â Â Â } |
---|
5983 | Â Â Â i++; |
---|
5984 | Â Â } |
---|
5985 | Â } |
---|
5986 | |
---|
5987 |  delete [] liftPre; |
---|
5988 |  delete [] factorsFoundIndex; |
---|
5989 |  return result; |
---|
5990 | } |
---|
5991 | |
---|
5992 | CFList |
---|
5993 | sieveSmallFactors (const CanonicalForm& G, CFList& uniFactors, DegreePattern& |
---|
5994 |           degPat, CanonicalForm& H, CFList& diophant, CFArray& Pi, |
---|
5995 |           CFMatrix& M, bool& success, int d |
---|
5996 | Â Â Â Â Â Â Â Â Â ) |
---|
5997 | { |
---|
5998 | Â CanonicalForm F=Â G; |
---|
5999 | Â CFList bufUniFactors=Â uniFactors; |
---|
6000 | Â |
---|