1 | /////////////////////////////////////////////////////////////////////////////// |
---|
2 | version="version modwalk.lib 4.0.0.0 Jun_2013 "; |
---|
3 | category = "Commutative Algebra"; |
---|
4 | info=" |
---|
5 | LIBRARY: modwalk.lib Groebner basis convertion |
---|
6 | |
---|
7 | AUTHORS: S. Oberfranz oberfran@mathematik.uni-kl.de |
---|
8 | |
---|
9 | OVERVIEW: |
---|
10 | |
---|
11 | A library for converting Groebner bases of an ideal in the polynomial |
---|
12 | ring over the rational numbers using modular methods. The procedures are |
---|
13 | inspired by the following paper: |
---|
14 | Elizabeth A. Arnold: Modular algorithms for computing Groebner bases. |
---|
15 | Journal of Symbolic Computation 35, 403-419 (2003). |
---|
16 | |
---|
17 | PROCEDURES: |
---|
18 | modpWalk(ideal,int,int,int[,int,int,int,int]) standard basis conversion of I in prime characteristic |
---|
19 | modWalk(ideal,int,int[,int,int,int,int]); standard basis conversion of I using modular methods (chinese remainder) |
---|
20 | "; |
---|
21 | |
---|
22 | LIB "poly.lib"; |
---|
23 | LIB "ring.lib"; |
---|
24 | LIB "parallel.lib"; |
---|
25 | LIB "rwalk.lib"; |
---|
26 | LIB "grwalk.lib"; |
---|
27 | LIB "modstd.lib"; |
---|
28 | |
---|
29 | |
---|
30 | //////////////////////////////////////////////////////////////////////////////// |
---|
31 | |
---|
32 | proc modpWalk(def II, int p, int variant, int reduction, list #) |
---|
33 | "USAGE: modpWalk(I,p,#); I ideal, p integer, variant integer |
---|
34 | ASSUME: If size(#) > 0, then |
---|
35 | #[1] is an intvec describing the current weight vector |
---|
36 | #[2] is an intvec describing the target weight vector |
---|
37 | RETURN: ideal - a standard basis of I mod p, integer - p |
---|
38 | NOTE: The procedure computes a standard basis of the ideal I modulo p and |
---|
39 | fetches the result to the basering. |
---|
40 | EXAMPLE: example modpWalk; shows an example |
---|
41 | " |
---|
42 | { |
---|
43 | option(redSB); |
---|
44 | int k,nvar@r; |
---|
45 | def R0 = basering; |
---|
46 | string ordstr_R0 = ordstr(R0); |
---|
47 | list rl = ringlist(R0); |
---|
48 | int sizerl = size(rl); |
---|
49 | int neg = 1 - attrib(R0,"global"); |
---|
50 | if(typeof(II) == "ideal") |
---|
51 | { |
---|
52 | ideal I = II; |
---|
53 | int radius = 2; |
---|
54 | int pert_deg = 2; |
---|
55 | } |
---|
56 | if(typeof(II) == "list" && typeof(II[1]) == "ideal") |
---|
57 | { |
---|
58 | ideal I = II[1]; |
---|
59 | if(size(II) == 2) |
---|
60 | { |
---|
61 | int radius = II[2]; |
---|
62 | int pert_deg = 2; |
---|
63 | } |
---|
64 | if(size(II) == 3) |
---|
65 | { |
---|
66 | int radius = II[2]; |
---|
67 | int pert_deg = II[3]; |
---|
68 | } |
---|
69 | } |
---|
70 | rl[1] = p; |
---|
71 | int h = homog(I); |
---|
72 | def @r = ring(rl); |
---|
73 | setring @r; |
---|
74 | ideal i = fetch(R0,I); |
---|
75 | string order; |
---|
76 | if(system("nblocks") <= 2) |
---|
77 | { |
---|
78 | if(find(ordstr_R0, "M") + find(ordstr_R0, "lp") + find(ordstr_R0, "rp") <= 0) |
---|
79 | { |
---|
80 | order = "simple"; |
---|
81 | } |
---|
82 | } |
---|
83 | <<<<<<< HEAD |
---|
84 | ======= |
---|
85 | |
---|
86 | //------------------------- make i homogeneous ----------------------------- |
---|
87 | if(!mixedTest() && !h) |
---|
88 | { |
---|
89 | if(!((find(ordstr_R0, "M") > 0) || (find(ordstr_R0, "a") > 0) || neg)) |
---|
90 | { |
---|
91 | if(!((order == "simple") || (sizerl > 4))) |
---|
92 | { |
---|
93 | list rl@r = ringlist(@r); |
---|
94 | nvar@r = nvars(@r); |
---|
95 | intvec w; |
---|
96 | for(k = 1; k <= nvar@r; k++) |
---|
97 | { |
---|
98 | w[k] = deg(var(k)); |
---|
99 | } |
---|
100 | w[nvar@r + 1] = 1; |
---|
101 | rl@r[2][nvar@r + 1] = "homvar"; |
---|
102 | rl@r[3][2][2] = w; |
---|
103 | def HomR = ring(rl@r); |
---|
104 | setring HomR; |
---|
105 | ideal i = imap(@r, i); |
---|
106 | i = homog(i, homvar); |
---|
107 | } |
---|
108 | } |
---|
109 | } |
---|
110 | |
---|
111 | >>>>>>> f533f6f7667328bccb271b19b2f603aaebe41596 |
---|
112 | //------------------------- compute a standard basis mod p ----------------------------- |
---|
113 | if(variant == 1) |
---|
114 | { |
---|
115 | if(size(#)>0) |
---|
116 | { |
---|
117 | i = rwalk(i,radius,pert_deg,reduction,#); |
---|
118 | } |
---|
119 | else |
---|
120 | { |
---|
121 | i = rwalk(i,radius,pert_deg,reduction); |
---|
122 | } |
---|
123 | } |
---|
124 | if(variant == 2) |
---|
125 | { |
---|
126 | if(size(#) == 2) |
---|
127 | { |
---|
128 | i = gwalk(i,reduction,#); |
---|
129 | } |
---|
130 | else |
---|
131 | { |
---|
132 | i = gwalk(i,reduction); |
---|
133 | } |
---|
134 | } |
---|
135 | if(variant == 3) |
---|
136 | { |
---|
137 | if(size(#) == 2) |
---|
138 | { |
---|
139 | i = frandwalk(i,radius,reduction,#); |
---|
140 | } |
---|
141 | else |
---|
142 | { |
---|
143 | i = frandwalk(i,radius,reduction); |
---|
144 | } |
---|
145 | } |
---|
146 | if(variant == 4) |
---|
147 | { |
---|
148 | if(size(#) == 2) |
---|
149 | { |
---|
150 | i=fwalk(i,#); |
---|
151 | } |
---|
152 | else |
---|
153 | { |
---|
154 | i=fwalk(i); |
---|
155 | } |
---|
156 | } |
---|
157 | if(variant == 5) |
---|
158 | { |
---|
159 | if(size(#) == 2) |
---|
160 | { |
---|
161 | i=prwalk(i,radius,pert_deg,pert_deg,reduction,#); |
---|
162 | } |
---|
163 | else |
---|
164 | { |
---|
165 | i=prwalk(i,radius,pert_deg,pert_deg,reduction); |
---|
166 | } |
---|
167 | } |
---|
168 | if(variant == 6) |
---|
169 | { |
---|
170 | if(size(#) == 2) |
---|
171 | { |
---|
172 | i=pwalk(i,pert_deg,pert_deg,reduction,#); |
---|
173 | } |
---|
174 | else |
---|
175 | { |
---|
176 | <<<<<<< HEAD |
---|
177 | i=pwalk(i,pert_deg,pert_deg,reduction); |
---|
178 | ======= |
---|
179 | i=pwalk(i,pert_deg,pert_deg); |
---|
180 | } |
---|
181 | } |
---|
182 | |
---|
183 | if(!mixedTest() && !h) |
---|
184 | { |
---|
185 | if(!((find(ordstr_R0, "M") > 0) || (find(ordstr_R0, "a") > 0) || neg)) |
---|
186 | { |
---|
187 | if(!((order == "simple") || (sizerl > 4))) |
---|
188 | { |
---|
189 | i = subst(i, homvar, 1); |
---|
190 | i = simplify(i, 34); |
---|
191 | setring @r; |
---|
192 | i = imap(HomR, i); |
---|
193 | i = interred(i); |
---|
194 | kill HomR; |
---|
195 | } |
---|
196 | >>>>>>> f533f6f7667328bccb271b19b2f603aaebe41596 |
---|
197 | } |
---|
198 | } |
---|
199 | |
---|
200 | setring R0; |
---|
201 | return(list(fetch(@r,i),p)); |
---|
202 | } |
---|
203 | example |
---|
204 | { |
---|
205 | "EXAMPLE:"; echo = 2; |
---|
206 | option(redSB); |
---|
207 | |
---|
208 | int p = 181; |
---|
209 | intvec a = 2,1,3,4; |
---|
210 | intvec b = 1,9,1,1; |
---|
211 | ring ra = 0,x(1..4),(a(a),lp); |
---|
212 | ideal I = std(cyclic(4)); |
---|
213 | int reduction = 1; |
---|
214 | ring rb = 0,x(1..4),(a(b),lp); |
---|
215 | ideal I = imap(ra,I); |
---|
216 | modpWalk(I,p,1,reduction,a,b); |
---|
217 | std(I); |
---|
218 | } |
---|
219 | |
---|
220 | //////////////////////////////////////////////////////////////////////////////// |
---|
221 | |
---|
222 | proc modWalk(def II, int variant, int reduction, list #) |
---|
223 | "USAGE: modWalk(II); II ideal or list(ideal,int) |
---|
224 | ASSUME: If variant = |
---|
225 | @* - 1 the Random Walk algorithm with radius II[2] is applied |
---|
226 | to II[1] if II = list(ideal, int). It is applied to II with radius 2 |
---|
227 | if II is an ideal. |
---|
228 | @* - 2, the Groebner Walk algorithm is applied to II[1] or to II, respectively. |
---|
229 | @* - 3, the Fractal Walk algorithm with random element is applied to II[1] or II, |
---|
230 | respectively. |
---|
231 | @* - 4, the Fractal Walk algorithm is applied to II[1] or II, respectively. |
---|
232 | @* - 5, the Perturbation Walk algorithm with random element is applied to II[1] |
---|
233 | or II, respectively, with radius II[3] and perturbation degree II[2]. |
---|
234 | @* - 6, the Perturbation Walk algorithm is applied to II[1] or II, respectively, |
---|
235 | with perturbation degree II[3]. |
---|
236 | If size(#) > 0, then # contains either 1, 2 or 4 integers such that |
---|
237 | @* - #[1] is the number of available processors for the computation, |
---|
238 | @* - #[2] is an optional parameter for the exactness of the computation, |
---|
239 | if #[2] = 1, the procedure computes a standard basis for sure, |
---|
240 | @* - #[3] is the number of primes until the first lifting, |
---|
241 | @* - #[4] is the constant number of primes between two liftings until |
---|
242 | the computation stops. |
---|
243 | RETURN: a standard basis of I if no warning appears. |
---|
244 | NOTE: The procedure converts a standard basis of I (over the rational |
---|
245 | numbers) from the ordering \"a(v),lp\", "dp\" or \"Dp\" to the ordering |
---|
246 | \"(a(w),lp\" or \"a(1,0,...,0),lp\" by using modular methods. |
---|
247 | By default the procedure computes a standard basis of I for sure, but |
---|
248 | if the optional parameter #[2] = 0, it computes a standard basis of I |
---|
249 | with high probability. |
---|
250 | EXAMPLE: example modWalk; shows an example |
---|
251 | " |
---|
252 | { |
---|
253 | int TT = timer; |
---|
254 | int RT = rtimer; |
---|
255 | int i,j,pTest,sizeTest,weighted,n1; |
---|
256 | bigint N; |
---|
257 | |
---|
258 | def R0 = basering; |
---|
259 | list rl = ringlist(R0); |
---|
260 | if((npars(R0) > 0) || (rl[1] > 0)) |
---|
261 | { |
---|
262 | ERROR("Characteristic of basering should be zero, basering should have no parameters."); |
---|
263 | } |
---|
264 | |
---|
265 | if(typeof(II) == "ideal") |
---|
266 | { |
---|
267 | ideal I = II; |
---|
268 | kill II; |
---|
269 | list II; |
---|
270 | II[1] = I; |
---|
271 | II[2] = 2; |
---|
272 | II[3] = 2; |
---|
273 | } |
---|
274 | else |
---|
275 | { |
---|
276 | if(typeof(II) == "list" && typeof(II[1]) == "ideal") |
---|
277 | { |
---|
278 | ideal I = II[1]; |
---|
279 | if(size(II) == 1) |
---|
280 | { |
---|
281 | II[2] = 2; |
---|
282 | II[3] = 2; |
---|
283 | } |
---|
284 | if(size(II) == 2) |
---|
285 | { |
---|
286 | II[3] = 2; |
---|
287 | } |
---|
288 | |
---|
289 | } |
---|
290 | else |
---|
291 | { |
---|
292 | ERROR("Unexpected type of input."); |
---|
293 | } |
---|
294 | } |
---|
295 | |
---|
296 | //-------------------- Initialize optional parameters ------------------------ |
---|
297 | n1 = system("--cpus"); |
---|
298 | if(size(#) == 0) |
---|
299 | { |
---|
300 | int exactness = 1; |
---|
301 | int n2 = 10; |
---|
302 | int n3 = 10; |
---|
303 | } |
---|
304 | else |
---|
305 | { |
---|
306 | if(size(#) == 1) |
---|
307 | { |
---|
308 | if(typeof(#[1]) == "int") |
---|
309 | { |
---|
310 | if(#[1] < n1) |
---|
311 | { |
---|
312 | n1 = #[1]; |
---|
313 | } |
---|
314 | int exactness = 1; |
---|
315 | if(n1 >= 10) |
---|
316 | { |
---|
317 | int n2 = n1 + 1; |
---|
318 | int n3 = n1; |
---|
319 | } |
---|
320 | else |
---|
321 | { |
---|
322 | int n2 = 10; |
---|
323 | int n3 = 10; |
---|
324 | } |
---|
325 | } |
---|
326 | else |
---|
327 | { |
---|
328 | ERROR("Unexpected type of input."); |
---|
329 | } |
---|
330 | } |
---|
331 | if(size(#) == 2) |
---|
332 | { |
---|
333 | if(typeof(#[1]) == "int" && typeof(#[2]) == "int") |
---|
334 | { |
---|
335 | if(#[1] < n1) |
---|
336 | { |
---|
337 | n1 = #[1]; |
---|
338 | } |
---|
339 | int exactness = #[2]; |
---|
340 | if(n1 >= 10) |
---|
341 | { |
---|
342 | int n2 = n1 + 1; |
---|
343 | int n3 = n1; |
---|
344 | } |
---|
345 | else |
---|
346 | { |
---|
347 | int n2 = 10; |
---|
348 | int n3 = 10; |
---|
349 | } |
---|
350 | } |
---|
351 | else |
---|
352 | { |
---|
353 | if(typeof(#[1]) == "intvec" && typeof(#[2]) == "intvec") |
---|
354 | { |
---|
355 | intvec curr_weight = #[1]; |
---|
356 | intvec target_weight = #[2]; |
---|
357 | weighted = 1; |
---|
358 | int n2 = 10; |
---|
359 | int n3 = 10; |
---|
360 | int exactness = 1; |
---|
361 | } |
---|
362 | else |
---|
363 | { |
---|
364 | ERROR("Unexpected type of input."); |
---|
365 | } |
---|
366 | } |
---|
367 | } |
---|
368 | if(size(#) == 3) |
---|
369 | { |
---|
370 | if(typeof(#[1]) == "intvec" && typeof(#[2]) == "intvec" && typeof(#[3]) == "int") |
---|
371 | { |
---|
372 | intvec curr_weight = #[1]; |
---|
373 | intvec target_weight = #[2]; |
---|
374 | weighted = 1; |
---|
375 | n1 = #[3]; |
---|
376 | int n2 = 10; |
---|
377 | int n3 = 10; |
---|
378 | int exactness = 1; |
---|
379 | } |
---|
380 | else |
---|
381 | { |
---|
382 | ERROR("Unexpected type of input."); |
---|
383 | } |
---|
384 | } |
---|
385 | if(size(#) == 4) |
---|
386 | { |
---|
387 | if(typeof(#[1]) == "intvec" && typeof(#[2]) == "intvec" && typeof(#[3]) == "int" |
---|
388 | && typeof(#[4]) == "int") |
---|
389 | { |
---|
390 | intvec curr_weight = #[1]; |
---|
391 | intvec target_weight = #[2]; |
---|
392 | weighted = 1; |
---|
393 | if(#[1] < n1) |
---|
394 | { |
---|
395 | n1 = #[3]; |
---|
396 | } |
---|
397 | int exactness = #[4]; |
---|
398 | if(n1 >= 10) |
---|
399 | { |
---|
400 | int n2 = n1 + 1; |
---|
401 | int n3 = n1; |
---|
402 | } |
---|
403 | else |
---|
404 | { |
---|
405 | int n2 = 10; |
---|
406 | int n3 = 10; |
---|
407 | } |
---|
408 | } |
---|
409 | else |
---|
410 | { |
---|
411 | if(typeof(#[1]) == "int" && typeof(#[2]) == "int" && typeof(#[3]) == "int" && typeof(#[4]) == "int") |
---|
412 | { |
---|
413 | if(#[1] < n1) |
---|
414 | { |
---|
415 | n1 = #[1]; |
---|
416 | } |
---|
417 | int exactness = #[2]; |
---|
418 | if(n1 >= #[3]) |
---|
419 | { |
---|
420 | int n2 = n1 + 1; |
---|
421 | } |
---|
422 | else |
---|
423 | { |
---|
424 | int n2 = #[3]; |
---|
425 | } |
---|
426 | if(n1 >= #[4]) |
---|
427 | { |
---|
428 | int n3 = n1; |
---|
429 | } |
---|
430 | else |
---|
431 | { |
---|
432 | int n3 = #[4]; |
---|
433 | } |
---|
434 | } |
---|
435 | else |
---|
436 | { |
---|
437 | ERROR("Unexpected type of input."); |
---|
438 | } |
---|
439 | } |
---|
440 | } |
---|
441 | if(size(#) == 6) |
---|
442 | { |
---|
443 | if(typeof(#[1]) == "intvec" && typeof(#[2]) == "intvec" && typeof(#[3]) == "int" && typeof(#[4]) == "int" && typeof(#[5]) == "int" && typeof(#[6]) == "int") |
---|
444 | { |
---|
445 | intvec curr_weight = #[1]; |
---|
446 | intvec target_weight = #[2]; |
---|
447 | weighted = 1; |
---|
448 | if(#[3] < n1) |
---|
449 | { |
---|
450 | n1 = #[3]; |
---|
451 | } |
---|
452 | int exactness = #[4]; |
---|
453 | if(n1 >= #[5]) |
---|
454 | { |
---|
455 | int n2 = n1 + 1; |
---|
456 | } |
---|
457 | else |
---|
458 | { |
---|
459 | int n2 = #[5]; |
---|
460 | } |
---|
461 | if(n1 >= #[6]) |
---|
462 | { |
---|
463 | int n3 = n1; |
---|
464 | } |
---|
465 | else |
---|
466 | { |
---|
467 | int n3 = #[6]; |
---|
468 | } |
---|
469 | } |
---|
470 | else |
---|
471 | { |
---|
472 | ERROR("Expected list(intvec,intvec,int,int,int,int) as optional parameter list."); |
---|
473 | } |
---|
474 | } |
---|
475 | if(size(#) == 1 || size(#) == 5 || size(#) > 6) |
---|
476 | { |
---|
477 | ERROR("Expected 0,2,3,4 or 5 optional arguments."); |
---|
478 | } |
---|
479 | } |
---|
480 | if(printlevel >= 10) |
---|
481 | { |
---|
482 | "n1 = "+string(n1)+", n2 = "+string(n2)+", n3 = "+string(n3)+", exactness = "+string(exactness); |
---|
483 | } |
---|
484 | |
---|
485 | //------------------------- Save current options ----------------------------- |
---|
486 | intvec opt = option(get); |
---|
487 | //option(redSB); |
---|
488 | |
---|
489 | //-------------------- Initialize the list of primes ------------------------- |
---|
490 | int tt = timer; |
---|
491 | int rt = rtimer; |
---|
492 | int en = 2134567879; |
---|
493 | int an = 1000000000; |
---|
494 | intvec L = primeList(I,n2); |
---|
495 | if(n2 > 4) |
---|
496 | { |
---|
497 | L[5] = prime(random(an,en)); |
---|
498 | } |
---|
499 | if(printlevel >= 10) |
---|
500 | { |
---|
501 | "CPU-time for primeList: "+string(timer-tt)+" seconds."; |
---|
502 | "Real-time for primeList: "+string(rtimer-rt)+" seconds."; |
---|
503 | } |
---|
504 | int h = homog(I); |
---|
505 | list P,T1,T2,LL,Arguments,PP; |
---|
506 | ideal J,K,H; |
---|
507 | |
---|
508 | //------------------- parallelized Groebner Walk in positive characteristic -------------------- |
---|
509 | |
---|
510 | if(weighted) |
---|
511 | { |
---|
512 | for(i=1; i<=size(L); i++) |
---|
513 | { |
---|
514 | Arguments[i] = list(II,L[i],variant,reduction,list(curr_weight,target_weight)); |
---|
515 | } |
---|
516 | } |
---|
517 | else |
---|
518 | { |
---|
519 | for(i=1; i<=size(L); i++) |
---|
520 | { |
---|
521 | Arguments[i] = list(II,L[i],variant,reduction); |
---|
522 | } |
---|
523 | } |
---|
524 | P = parallelWaitAll("modpWalk",Arguments); |
---|
525 | for(i=1; i<=size(P); i++) |
---|
526 | { |
---|
527 | T1[i] = P[i][1]; |
---|
528 | T2[i] = bigint(P[i][2]); |
---|
529 | } |
---|
530 | |
---|
531 | while(1) |
---|
532 | { |
---|
533 | LL = deleteUnluckyPrimes(T1,T2,h); |
---|
534 | T1 = LL[1]; |
---|
535 | T2 = LL[2]; |
---|
536 | //------------------- Now all leading ideals are the same -------------------- |
---|
537 | //------------------- Lift results to basering via farey --------------------- |
---|
538 | tt = timer; rt = rtimer; |
---|
539 | N = T2[1]; |
---|
540 | for(i=2; i<=size(T2); i++) |
---|
541 | { |
---|
542 | N = N*T2[i]; |
---|
543 | } |
---|
544 | H = chinrem(T1,T2); |
---|
545 | J = parallelFarey(H,N,n1); |
---|
546 | //J=farey(H,N); |
---|
547 | if(printlevel >= 10) |
---|
548 | { |
---|
549 | "CPU-time for lifting-process is "+string(timer - tt)+" seconds."; |
---|
550 | "Real-time for lifting-process is "+string(rtimer - rt)+" seconds."; |
---|
551 | } |
---|
552 | |
---|
553 | //---------------- Test if we already have a standard basis of I -------------- |
---|
554 | tt = timer; rt = rtimer; |
---|
555 | pTest = primeTest(J, prime(random(1000000000,2134567879))); |
---|
556 | if(printlevel >= 10) |
---|
557 | { |
---|
558 | "CPU-time for pTest is "+string(timer - tt)+" seconds."; |
---|
559 | "Real-time for pTest is "+string(rtimer - rt)+" seconds."; |
---|
560 | } |
---|
561 | if(pTest) |
---|
562 | { |
---|
563 | if(printlevel >= 10) |
---|
564 | { |
---|
565 | "CPU-time for computation without final tests is "+string(timer - TT)+" seconds."; |
---|
566 | "Real-time for computation without final tests is "+string(rtimer - RT)+" seconds."; |
---|
567 | } |
---|
568 | attrib(J,"isSB",1); |
---|
569 | if(exactness == 0) |
---|
570 | { |
---|
571 | option(set, opt); |
---|
572 | return(J); |
---|
573 | } |
---|
574 | else |
---|
575 | { |
---|
576 | tt = timer; |
---|
577 | rt = rtimer; |
---|
578 | sizeTest = 1 - isIdealIncluded(I,J,n1); |
---|
579 | if(printlevel >= 10) |
---|
580 | { |
---|
581 | "CPU-time for checking if I subset <G> is "+string(timer - tt)+" seconds."; |
---|
582 | "Real-time for checking if I subset <G> is "+string(rtimer - rt)+" seconds."; |
---|
583 | } |
---|
584 | if(sizeTest == 0) |
---|
585 | { |
---|
586 | tt = timer; |
---|
587 | rt = rtimer; |
---|
588 | K = std(J); |
---|
589 | if(printlevel >= 10) |
---|
590 | { |
---|
591 | "CPU-time for last std-computation is "+string(timer - tt)+" seconds."; |
---|
592 | "Real-time for last std-computation is "+string(rtimer - rt)+" seconds."; |
---|
593 | } |
---|
594 | if(size(reduce(K,J)) == 0) |
---|
595 | { |
---|
596 | option(set, opt); |
---|
597 | return(J); |
---|
598 | } |
---|
599 | } |
---|
600 | } |
---|
601 | } |
---|
602 | //-------------- We do not already have a standard basis of I, therefore do the main computation for more primes -------------- |
---|
603 | T1 = H; |
---|
604 | T2 = N; |
---|
605 | j = size(L)+1; |
---|
606 | tt = timer; rt = rtimer; |
---|
607 | L = primeList(I,n3,L,n1); |
---|
608 | if(printlevel >= 10) |
---|
609 | { |
---|
610 | "CPU-time for primeList: "+string(timer-tt)+" seconds."; |
---|
611 | "Real-time for primeList: "+string(rtimer-rt)+" seconds."; |
---|
612 | } |
---|
613 | Arguments = list(); |
---|
614 | PP = list(); |
---|
615 | if(weighted) |
---|
616 | { |
---|
617 | for(i=j; i<=size(L); i++) |
---|
618 | { |
---|
619 | Arguments[size(Arguments)+1] = list(II,L[i],variant,reduction,list(curr_weight,target_weight)); |
---|
620 | } |
---|
621 | } |
---|
622 | else |
---|
623 | { |
---|
624 | for(i=j; i<=size(L); i++) |
---|
625 | { |
---|
626 | Arguments[size(Arguments)+1] = list(II,L[i],variant,reduction); |
---|
627 | } |
---|
628 | } |
---|
629 | PP = parallelWaitAll("modpWalk",Arguments); |
---|
630 | if(printlevel >= 10) |
---|
631 | { |
---|
632 | "parallel modpWalk"; |
---|
633 | } |
---|
634 | for(i=1; i<=size(PP); i++) |
---|
635 | { |
---|
636 | T1[size(T1) + 1] = PP[i][1]; |
---|
637 | T2[size(T2) + 1] = bigint(PP[i][2]); |
---|
638 | } |
---|
639 | } |
---|
640 | if(printlevel >= 10) |
---|
641 | { |
---|
642 | "CPU-time for computation with final tests is "+string(timer - TT)+" seconds."; |
---|
643 | "Real-time for computation with final tests is "+string(rtimer - RT)+" seconds."; |
---|
644 | } |
---|
645 | } |
---|
646 | |
---|
647 | example |
---|
648 | { |
---|
649 | "EXAMPLE:"; |
---|
650 | echo = 2; |
---|
651 | ring R=0,(x,y,z),lp; |
---|
652 | ideal I= y3+xyz+y2z+xz3, 3+xy+x2y+y2z; |
---|
653 | int reduction = 0; |
---|
654 | ideal J = modWalk(I,1,1); |
---|
655 | J; |
---|
656 | } |
---|
657 | |
---|
658 | //////////////////////////////////////////////////////////////////////////////// |
---|
659 | static proc isIdealIncluded(ideal I, ideal J, int n1) |
---|
660 | "USAGE: isIdealIncluded(I,J,int n1); I ideal, J ideal, n1 integer |
---|
661 | " |
---|
662 | { |
---|
663 | if(n1 > 1) |
---|
664 | { |
---|
665 | int k; |
---|
666 | list args,results; |
---|
667 | for(k=1; k<=size(I); k++) |
---|
668 | { |
---|
669 | args[k] = list(ideal(I[k]),J,1); |
---|
670 | } |
---|
671 | results = parallelWaitAll("reduce",args); |
---|
672 | for(k=1; k<=size(results); k++) |
---|
673 | { |
---|
674 | if(results[k] == 0) |
---|
675 | { |
---|
676 | return(1); |
---|
677 | } |
---|
678 | } |
---|
679 | return(0); |
---|
680 | } |
---|
681 | else |
---|
682 | { |
---|
683 | if(reduce(I,J,1) == 0) |
---|
684 | { |
---|
685 | return(1); |
---|
686 | } |
---|
687 | else |
---|
688 | { |
---|
689 | return(0); |
---|
690 | } |
---|
691 | } |
---|
692 | } |
---|
693 | |
---|
694 | //////////////////////////////////////////////////////////////////////////////// |
---|
695 | static proc parallelChinrem(list T1, list T2, int n1) |
---|
696 | "USAGE: parallelChinrem(T1,T2); T1 list of ideals, T2 list of primes, n1 integer" |
---|
697 | { |
---|
698 | int i,j,k; |
---|
699 | |
---|
700 | ideal H,J; |
---|
701 | |
---|
702 | list arguments_chinrem,results_chinrem; |
---|
703 | for(i=1; i<=size(T1); i++) |
---|
704 | { |
---|
705 | J = ideal(T1[i]); |
---|
706 | attrib(J,"isSB",1); |
---|
707 | arguments_chinrem[size(arguments_chinrem)+1] = list(list(J),T2); |
---|
708 | } |
---|
709 | results_chinrem = parallelWaitAll("chinrem",arguments_chinrem); |
---|
710 | for(j=1; j <= size(results_chinrem); j++) |
---|
711 | { |
---|
712 | J = results_chinrem[j]; |
---|
713 | attrib(J,"isSB",1); |
---|
714 | if(isIdealIncluded(J,H,n1) == 0) |
---|
715 | { |
---|
716 | if(H == 0) |
---|
717 | { |
---|
718 | H = J; |
---|
719 | } |
---|
720 | else |
---|
721 | { |
---|
722 | H = H,J; |
---|
723 | } |
---|
724 | } |
---|
725 | } |
---|
726 | return(H); |
---|
727 | } |
---|
728 | |
---|
729 | //////////////////////////////////////////////////////////////////////////////// |
---|
730 | static proc parallelFarey(ideal H, bigint N, int n1) |
---|
731 | "USAGE: parallelFarey(H,N,n1); H ideal, N bigint, n1 integer |
---|
732 | " |
---|
733 | { |
---|
734 | int i,j; |
---|
735 | int ii = 1; |
---|
736 | list arguments_farey,results_farey; |
---|
737 | for(i=1; i<=size(H); i++) |
---|
738 | { |
---|
739 | for(j=1; j<=size(H[i]); j++) |
---|
740 | { |
---|
741 | arguments_farey[size(arguments_farey)+1] = list(H[i][j],N); |
---|
742 | } |
---|
743 | } |
---|
744 | results_farey = parallelWaitAll("farey",arguments_farey); |
---|
745 | ideal J,K; |
---|
746 | poly f_farey; |
---|
747 | while(ii<=size(results_farey)) |
---|
748 | { |
---|
749 | for(i=1; i<=size(H); i++) |
---|
750 | { |
---|
751 | f_farey = 0; |
---|
752 | for(j=1; j<=size(H[i]); j++) |
---|
753 | { |
---|
754 | f_farey = f_farey + results_farey[ii][1]; |
---|
755 | ii++; |
---|
756 | } |
---|
757 | K = ideal(f_farey); |
---|
758 | attrib(K,"isSB",1); |
---|
759 | attrib(J,"isSB",1); |
---|
760 | if(isIdealIncluded(K,J,n1) == 0) |
---|
761 | { |
---|
762 | if(J == 0) |
---|
763 | { |
---|
764 | J = K; |
---|
765 | } |
---|
766 | else |
---|
767 | { |
---|
768 | J = J,K; |
---|
769 | } |
---|
770 | } |
---|
771 | } |
---|
772 | } |
---|
773 | return(J); |
---|
774 | } |
---|
775 | |
---|
776 | //////////////////////////////////////////////////////////////////////////////// |
---|
777 | static proc mixedTest() |
---|
778 | "USAGE: mixedTest(); |
---|
779 | RETURN: 1 if ordering of basering is mixed, 0 else |
---|
780 | EXAMPLE: example mixedTest(); shows an example |
---|
781 | " |
---|
782 | { |
---|
783 | int i,p,m; |
---|
784 | for(i = 1; i <= nvars(basering); i++) |
---|
785 | { |
---|
786 | if(var(i) > 1) |
---|
787 | { |
---|
788 | p++; |
---|
789 | } |
---|
790 | else |
---|
791 | { |
---|
792 | m++; |
---|
793 | } |
---|
794 | } |
---|
795 | if((p > 0) && (m > 0)) { return(1); } |
---|
796 | return(0); |
---|
797 | } |
---|
798 | example |
---|
799 | { "EXAMPLE:"; echo = 2; |
---|
800 | ring R1 = 0,(x,y,z),dp; |
---|
801 | mixedTest(); |
---|
802 | ring R2 = 31,(x(1..4),y(1..3)),(ds(4),lp(3)); |
---|
803 | mixedTest(); |
---|
804 | ring R3 = 181,x(1..9),(dp(5),lp(4)); |
---|
805 | mixedTest(); |
---|
806 | } |
---|