1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /* |
---|
5 | * ABSTRACT: fractal walk stuff |
---|
6 | * |
---|
7 | */ |
---|
8 | #include <string.h> |
---|
9 | #include "config.h" |
---|
10 | #include <kernel/mod2.h> |
---|
11 | #include <misc/options.h> |
---|
12 | #include <misc/intvec.h> |
---|
13 | #include <misc/int64vec.h> |
---|
14 | #include <kernel/polys.h> |
---|
15 | #include <kernel/ideals.h> |
---|
16 | #include <polys/monomials/ring.h> |
---|
17 | #include <kernel/walkMain.h> |
---|
18 | #include <kernel/walkSupport.h> |
---|
19 | #include <polys/prCopy.h> |
---|
20 | #include <kernel/kstd1.h> |
---|
21 | #include <polys/matpol.h> |
---|
22 | #include <polys/monomials/ring.h> |
---|
23 | |
---|
24 | |
---|
25 | /////////////////////////////////////////////////////////////////// |
---|
26 | //Groebner Walk and Fractal Walk |
---|
27 | /////////////////////////////////////////////////////////////////// |
---|
28 | //v1.3 2004-11-15 |
---|
29 | /////////////////////////////////////////////////////////////////// |
---|
30 | //implemented by Henrik Strohmayer |
---|
31 | /////////////////////////////////////////////////////////////////// |
---|
32 | //in C++: |
---|
33 | /////////////////////////////////////////////////////////////////// |
---|
34 | |
---|
35 | |
---|
36 | int overflow_error; //global variable |
---|
37 | |
---|
38 | /* |
---|
39 | overflow_error table |
---|
40 | 1: Miv64DotProduct mult |
---|
41 | 2: Miv64DotProduct add |
---|
42 | 3: gett64 zaehler mult |
---|
43 | 4: gett64 zaehler add |
---|
44 | 5: gett64 nenner mult |
---|
45 | 6: gett64 nenner add |
---|
46 | 7: nextw64 mult a |
---|
47 | 8: nextw64 mult b |
---|
48 | 9: nextw64 add |
---|
49 | 10: getinveps64 mult |
---|
50 | 11: getinveps64 add |
---|
51 | 12: getTaun64 mult |
---|
52 | 13: getTaun64 add |
---|
53 | */ |
---|
54 | |
---|
55 | /////////////////////////////////////////////////////////////////// |
---|
56 | //fistWalkStep64 |
---|
57 | /////////////////////////////////////////////////////////////////// |
---|
58 | //Description: adapts currRing for the algorithm and moves G into |
---|
59 | //it, calculating the appropriate GB if currw not is inside of |
---|
60 | //the current groebner cone |
---|
61 | /////////////////////////////////////////////////////////////////// |
---|
62 | //Assumes: that the option redSB is turned off |
---|
63 | /////////////////////////////////////////////////////////////////// |
---|
64 | //Uses: init64, rCopy0AndAddA, rComplete, rChangeCurrRing, matIdLift, |
---|
65 | //mpMult, idInterRed, idStd, idCopy, idrMoveR,currwOnBorder64 |
---|
66 | /////////////////////////////////////////////////////////////////// |
---|
67 | |
---|
68 | WalkState firstWalkStep64(ideal & G,int64vec* currw64, ring destRing){ |
---|
69 | WalkState state=WalkOk; |
---|
70 | /* OLDRING **************************************************** */ |
---|
71 | ideal nextG; |
---|
72 | |
---|
73 | if (currwOnBorder64(G,currw64)) |
---|
74 | { |
---|
75 | ideal Gw=init64(G,currw64); |
---|
76 | ring oldRing=currRing; |
---|
77 | /* NEWRING **************************************************** */ |
---|
78 | ring rnew=rCopy0AndAddA(destRing,currw64); |
---|
79 | rComplete(rnew); |
---|
80 | rChangeCurrRing(rnew); |
---|
81 | |
---|
82 | ideal newGw=idrMoveR(Gw, oldRing, rnew); |
---|
83 | |
---|
84 | |
---|
85 | //HIER GEANDERT |
---|
86 | matrix L=mpNew(1,1); |
---|
87 | idLiftStd(newGw,&L); |
---|
88 | |
---|
89 | // //turn off bucket representation of polynomials and on redSB |
---|
90 | // optionState=test; |
---|
91 | // //test|=Sy_bit(OPT_NOT_BUCKETS); |
---|
92 | // test|=Sy_bit(OPT_REDSB); |
---|
93 | |
---|
94 | // ideal newStdGw=idStd(newGw); |
---|
95 | |
---|
96 | // //turn on bucket representation of polynomials and off redSB |
---|
97 | // test=optionState; |
---|
98 | |
---|
99 | // matrix L=matIdLift(newGw,newStdGw); |
---|
100 | // idDelete(&newStdGw); |
---|
101 | |
---|
102 | idDelete(&newGw); |
---|
103 | |
---|
104 | nextG=idrMoveR(G,oldRing, rnew); idTest(nextG); |
---|
105 | |
---|
106 | matrix nextGmat=(matrix)nextG; |
---|
107 | |
---|
108 | matrix resMat=mp_Mult(nextGmat,L,rnew); |
---|
109 | idDelete((ideal *)&nextGmat); |
---|
110 | idDelete((ideal *)&L); |
---|
111 | |
---|
112 | nextG=(ideal)resMat; |
---|
113 | |
---|
114 | BITSET save1,save2; |
---|
115 | SI_SAVE_OPT(save1,save2); |
---|
116 | si_opt_1|=Sy_bit(OPT_REDSB); |
---|
117 | nextG = idInterRed(nextG); |
---|
118 | SI_RESTORE_OPT(save1,save2); |
---|
119 | } |
---|
120 | else |
---|
121 | { |
---|
122 | ring oldRing=currRing; |
---|
123 | ring rnew=rCopy0AndAddA(destRing,currw64); |
---|
124 | rComplete(rnew); |
---|
125 | rChangeCurrRing(rnew); |
---|
126 | nextG=idrMoveR(G,oldRing, rnew); |
---|
127 | } |
---|
128 | |
---|
129 | G=nextG; |
---|
130 | return(state); |
---|
131 | } |
---|
132 | |
---|
133 | /////////////////////////////////////////////////////////////////// |
---|
134 | |
---|
135 | |
---|
136 | /////////////////////////////////////////////////////////////////// |
---|
137 | //walkStep64 |
---|
138 | /////////////////////////////////////////////////////////////////// |
---|
139 | //Description: one step in the groebner walk |
---|
140 | /////////////////////////////////////////////////////////////////// |
---|
141 | //Assumes: that the option redSB is turned off |
---|
142 | /////////////////////////////////////////////////////////////////// |
---|
143 | //Uses: init, rCopyAndChangeA, matIdLift, mpMult, |
---|
144 | //idInterRed, mStd, idCopy, idrMoveR |
---|
145 | /////////////////////////////////////////////////////////////////// |
---|
146 | |
---|
147 | WalkState walkStep64(ideal & G,int64vec* currw64, int step) |
---|
148 | { |
---|
149 | WalkState state=WalkOk; |
---|
150 | |
---|
151 | /* OLDRING ****************************************************** */ |
---|
152 | ideal Gw=init64(G,currw64); |
---|
153 | |
---|
154 | ring oldRing=currRing; |
---|
155 | |
---|
156 | /* NEWRING ****************************************************** */ |
---|
157 | rCopyAndChangeA(currw64); |
---|
158 | |
---|
159 | ideal newGw=idrMoveR(Gw, oldRing,currRing); |
---|
160 | |
---|
161 | //HIER GEANDERT |
---|
162 | matrix L=mpNew(1,1); |
---|
163 | ideal newStdGw=idLiftStd(newGw,&L); |
---|
164 | |
---|
165 | //what it looked like before idStd and idLift were replaced |
---|
166 | //by idLiftStd |
---|
167 | // optionState=test; |
---|
168 | // test|=Sy_bit(OPT_REDSB); |
---|
169 | // test|=Sy_bit(OPT_NOT_BUCKETS); |
---|
170 | |
---|
171 | // //PrintS(" new initial forms:\n"); |
---|
172 | // for (int ii=0; ii <IDELEMS(newGw); ii++) pCleardenom(newGw->m[ii]); |
---|
173 | // //idShow(newGw); |
---|
174 | // ideal newStdGw=idStd(newGw); |
---|
175 | // PrintS(" std for initial forms done\n"); |
---|
176 | |
---|
177 | // test=optionState; |
---|
178 | |
---|
179 | // matrix L=matIdLift(newGw,newStdGw); |
---|
180 | |
---|
181 | // idDelete(&newStdGw); |
---|
182 | |
---|
183 | idDelete(&newGw); |
---|
184 | //PrintS(" lift for initial forms done\n"); |
---|
185 | |
---|
186 | ideal nextG=idrMoveR(G,oldRing,currRing); |
---|
187 | rDelete(oldRing); |
---|
188 | |
---|
189 | matrix nextGmat=(matrix)nextG; |
---|
190 | |
---|
191 | matrix resMat=mp_Mult(nextGmat,L,currRing); |
---|
192 | idDelete((ideal *)&nextGmat); |
---|
193 | idDelete((ideal *)&L); |
---|
194 | //PrintS(" lift done\n"); |
---|
195 | |
---|
196 | nextG=(ideal)resMat; |
---|
197 | |
---|
198 | BITSET save1,save2; |
---|
199 | SI_SAVE_OPT(save1,save2); |
---|
200 | si_opt_1|=Sy_bit(OPT_REDSB); |
---|
201 | nextG = idInterRed(nextG); |
---|
202 | SI_RESTORE_OPT(save1,save2); |
---|
203 | |
---|
204 | G=nextG; |
---|
205 | return(state); |
---|
206 | } |
---|
207 | |
---|
208 | /////////////////////////////////////////////////////////////////// |
---|
209 | |
---|
210 | |
---|
211 | /////////////////////////////////////////////////////////////////// |
---|
212 | //walk64 |
---|
213 | /////////////////////////////////////////////////////////////////// |
---|
214 | //Description: the main function of groebner walk, keeping |
---|
215 | //everything together |
---|
216 | /////////////////////////////////////////////////////////////////// |
---|
217 | //Uses: mStd, getnthrow, firstwalkStep64, nextt64, |
---|
218 | //nextw64, walkStep64, changecurrRing |
---|
219 | /////////////////////////////////////////////////////////////////// |
---|
220 | |
---|
221 | WalkState walk64(ideal I,int64vec* currw64,ring destRing, |
---|
222 | int64vec* destVec64,ideal & destIdeal,BOOLEAN sourceIsSB) |
---|
223 | { |
---|
224 | //some initializations |
---|
225 | WalkState state=WalkOk; |
---|
226 | BITSET save1,save2; |
---|
227 | SI_SAVE_OPT(save1,save2); |
---|
228 | |
---|
229 | si_opt_1|=Sy_bit(OPT_REDTAIL); |
---|
230 | overflow_error=FALSE; |
---|
231 | int step=0; |
---|
232 | ideal G=I; |
---|
233 | |
---|
234 | si_opt_1|=Sy_bit(OPT_REDSB); |
---|
235 | if(!sourceIsSB) |
---|
236 | { |
---|
237 | ideal GG=idStd(G); |
---|
238 | idDelete(&G); G=GG; |
---|
239 | } |
---|
240 | else |
---|
241 | G=idInterRed(G); |
---|
242 | SI_RESTORE_OPT(save1,save2); |
---|
243 | |
---|
244 | ideal nextG; |
---|
245 | state=firstWalkStep64(G,currw64,destRing); |
---|
246 | nextG=G; |
---|
247 | |
---|
248 | if(overflow_error) |
---|
249 | { |
---|
250 | state=WalkOverFlowError; |
---|
251 | return(state); |
---|
252 | } |
---|
253 | |
---|
254 | int64 nexttvec0,nexttvec1; |
---|
255 | //int64vec* nexttvec64=nextt64(nextG,currw64,destVec64); |
---|
256 | nextt64(nextG,currw64,destVec64,nexttvec0,nexttvec1); |
---|
257 | |
---|
258 | //while(0<t<=1) ( t=((*nexttvec64)[0])/((*nexttvec64)[1]) ) |
---|
259 | //while( (*nexttvec64)[0]<=(*nexttvec64)[1] ) { |
---|
260 | while (nexttvec0<=nexttvec1 ) |
---|
261 | { |
---|
262 | step=step+1; |
---|
263 | |
---|
264 | //int64vec *tt=nextw64(currw64,destVec64,nexttvec64); |
---|
265 | int64vec *tt=nextw64(currw64,destVec64,nexttvec0,nexttvec1); |
---|
266 | delete currw64; currw64=tt; tt=NULL; |
---|
267 | |
---|
268 | if (TEST_OPT_PROT) |
---|
269 | { |
---|
270 | PrintS("walk step:"); currw64->show(); PrintLn(); |
---|
271 | } |
---|
272 | |
---|
273 | state=walkStep64(nextG,currw64,step); |
---|
274 | //uppdates nextG if all is OK |
---|
275 | |
---|
276 | if(overflow_error) |
---|
277 | return(WalkOverFlowError); |
---|
278 | |
---|
279 | //delete nexttvec64; |
---|
280 | //nexttvec64=nextt64(nextG,currw64,destVec64); |
---|
281 | nextt64(nextG,currw64,destVec64,nexttvec0,nexttvec1); |
---|
282 | |
---|
283 | } |
---|
284 | |
---|
285 | destIdeal=sortRedSB(nextG); |
---|
286 | return(state); |
---|
287 | } |
---|
288 | |
---|
289 | /////////////////////////////////////////////////////////////////// |
---|
290 | |
---|
291 | |
---|
292 | |
---|
293 | /////////////////////////////////////////////////////////////////// |
---|
294 | //FRACTAL WALK PART BEGINS HERE |
---|
295 | /////////////////////////////////////////////////////////////////// |
---|
296 | |
---|
297 | /////////////////////////////////////////////////////////////////// |
---|
298 | //firstFractalWalkStep64 |
---|
299 | /////////////////////////////////////////////////////////////////// |
---|
300 | //Description: called once before fractalRec64 is called, to set up |
---|
301 | //the ring and move G into it, has two different strategies |
---|
302 | /////////////////////////////////////////////////////////////////// |
---|
303 | //Uses: firstWalkStep64,currwOnBorder64,getTaun64,rCopy0AndAddA, |
---|
304 | //getiv64,iv64Size,rComplete,rChangeCurrRing,idrMoveR,idStd,matIdLift |
---|
305 | /////////////////////////////////////////////////////////////////// |
---|
306 | |
---|
307 | |
---|
308 | //unperturbedStartVectorStrategy IS NOW NOT ALLWAYS AS DEFAULT SET |
---|
309 | //TO TRUE BUT IS INPUT FROM fractalWalk64 |
---|
310 | WalkState firstFractalWalkStep64(ideal & G,int64vec* & currw64, |
---|
311 | intvec* currMat, ring destRing, |
---|
312 | BOOLEAN unperturbedStartVectorStrategy){ |
---|
313 | |
---|
314 | //This strategy Uses the ordinary walk for the first step |
---|
315 | if(unperturbedStartVectorStrategy){ |
---|
316 | return(unperturbedFirstStep64(G,currw64,destRing)); |
---|
317 | //here G is updated since its adress is given as argument |
---|
318 | } |
---|
319 | |
---|
320 | //This strategy makes sure that the start vector lies inside the start cone |
---|
321 | //thus no step is needed within the start cone. |
---|
322 | else{ |
---|
323 | if(currwOnBorder64(G,currw64)) |
---|
324 | { |
---|
325 | int64 dummy64; |
---|
326 | getTaun64(G,currMat,iv64Size(currw64),&currw64,dummy64); |
---|
327 | //currw64=getiv64(getTaun64(G,currMat,iv64Size(currw64))); |
---|
328 | } |
---|
329 | ring oldRing=currRing; |
---|
330 | ring newRing=rCopy0AndAddA(destRing,currw64); |
---|
331 | rComplete(newRing); |
---|
332 | rChangeCurrRing(newRing); |
---|
333 | G=idrMoveR(G,oldRing,newRing); |
---|
334 | } |
---|
335 | |
---|
336 | return(WalkOk); |
---|
337 | } |
---|
338 | |
---|
339 | /////////////////////////////////////////////////////////////////// |
---|
340 | |
---|
341 | |
---|
342 | |
---|
343 | //DIESE FUNKTION ERSETZT firstWalkStep FUR fractalWalk |
---|
344 | /////////////////////////////////////////////////////////////////// |
---|
345 | //unperturbedFirstStep64 |
---|
346 | /////////////////////////////////////////////////////////////////// |
---|
347 | //Description: adapts currRing for the algorithm and moves G into |
---|
348 | //it, calculating the appropriate GB if currw not is inside of |
---|
349 | //the current groebner cone |
---|
350 | /////////////////////////////////////////////////////////////////// |
---|
351 | //Assumes: that the option redSB is turned off |
---|
352 | /////////////////////////////////////////////////////////////////// |
---|
353 | //Uses: init64, rCopy0AndAddA, rComplete, rChangeCurrRing, matIdLift, |
---|
354 | //mpMult, idInterRed, idStd, idCopy, idrMoveR,currwOnBorder64 |
---|
355 | /////////////////////////////////////////////////////////////////// |
---|
356 | |
---|
357 | WalkState unperturbedFirstStep64(ideal & G,int64vec* currw64, ring destRing) |
---|
358 | { |
---|
359 | WalkState state=WalkOk; |
---|
360 | /* OLDRING **************************************************** */ |
---|
361 | ideal nextG; |
---|
362 | BITSET save1,save2; |
---|
363 | SI_SAVE_OPT(save1,save2); |
---|
364 | |
---|
365 | if (currwOnBorder64(G,currw64)) |
---|
366 | { |
---|
367 | ideal Gw=init64(G,currw64); |
---|
368 | ring oldRing=currRing; |
---|
369 | /* NEWRING **************************************************** */ |
---|
370 | ring rnew=rCopy0AndAddA(destRing,currw64); |
---|
371 | rComplete(rnew); |
---|
372 | rChangeCurrRing(rnew); |
---|
373 | |
---|
374 | ideal newGw=idrMoveR(Gw, oldRing,rnew); |
---|
375 | |
---|
376 | //turn off bucket representation of polynomials and on redSB |
---|
377 | //si_opt_1|=Sy_bit(OPT_NOT_BUCKETS); |
---|
378 | si_opt_1|=Sy_bit(OPT_REDSB); |
---|
379 | |
---|
380 | ideal newStdGw=idStd(newGw); |
---|
381 | |
---|
382 | //turn on bucket representation of polynomials and off redSB |
---|
383 | SI_RESTORE_OPT(save1,save2); |
---|
384 | |
---|
385 | matrix L=matIdLift(newGw,newStdGw); |
---|
386 | idDelete(&newStdGw); |
---|
387 | idDelete(&newGw); |
---|
388 | |
---|
389 | nextG=idrMoveR(G,oldRing,rnew); idTest(nextG); |
---|
390 | |
---|
391 | matrix nextGmat=(matrix)nextG; |
---|
392 | |
---|
393 | matrix resMat=mp_Mult(nextGmat,L,rnew); |
---|
394 | idDelete((ideal *)&nextGmat); |
---|
395 | idDelete((ideal *)&L); |
---|
396 | |
---|
397 | nextG=(ideal)resMat; |
---|
398 | |
---|
399 | si_opt_1|=Sy_bit(OPT_REDSB); |
---|
400 | nextG = idInterRed(nextG); |
---|
401 | SI_RESTORE_OPT(save1,save2); |
---|
402 | } |
---|
403 | else |
---|
404 | { |
---|
405 | ring oldRing=currRing; |
---|
406 | ring rnew=rCopy0AndAddA(destRing,currw64); |
---|
407 | rComplete(rnew); |
---|
408 | rChangeCurrRing(rnew); |
---|
409 | nextG=idrMoveR(G,oldRing,rnew); |
---|
410 | } |
---|
411 | |
---|
412 | G=nextG; |
---|
413 | return(state); |
---|
414 | } |
---|
415 | |
---|
416 | /////////////////////////////////////////////////////////////////// |
---|
417 | |
---|
418 | |
---|
419 | |
---|
420 | /////////////////////////////////////////////////////////////////// |
---|
421 | //fractalRec64 |
---|
422 | /////////////////////////////////////////////////////////////////// |
---|
423 | //Description: the recursion function used in fractalWalk64 |
---|
424 | //(see appropriate par of thesis for more details) |
---|
425 | /////////////////////////////////////////////////////////////////// |
---|
426 | //Assumes: that the option redSB is turned off |
---|
427 | /////////////////////////////////////////////////////////////////// |
---|
428 | //Uses: getTaun64,getint64,getiv64,invEpsOk64,nextt64,nextw64, |
---|
429 | //init64,idCopy,noPolysOfMoreThanTwoTerms,rCopy0,rComplete, |
---|
430 | //rChangeCurrRing,rSetWeightVec,idrMoveR,mpMult,idInterRed |
---|
431 | /////////////////////////////////////////////////////////////////// |
---|
432 | |
---|
433 | WalkState fractalRec64(ideal & G,int64vec* currw64, intvec* destMat, |
---|
434 | int level,int step) |
---|
435 | { |
---|
436 | |
---|
437 | if (TEST_OPT_PROT) |
---|
438 | { PrintS("fractal walk, weights");currw64->show();PrintLn(); } |
---|
439 | WalkState state=WalkOk; |
---|
440 | BITSET save1,save2; |
---|
441 | SI_SAVE_OPT(save1,save2); |
---|
442 | |
---|
443 | //1 |
---|
444 | int64vec* w=(currw64); |
---|
445 | int64vec* old_w=(currw64); |
---|
446 | int64vec* sigma=(currw64); |
---|
447 | |
---|
448 | //lists taunpair64=getTaun64(G,destMat,level); |
---|
449 | //int64vec* w2=getiv64(taunpair64); |
---|
450 | //int64 inveps64=getint64(taunpair64); |
---|
451 | int64vec* w2; |
---|
452 | int64 inveps64; |
---|
453 | getTaun64(G,destMat,level,&w2,inveps64); |
---|
454 | |
---|
455 | //2 |
---|
456 | while(1){ |
---|
457 | |
---|
458 | //int64vec* tvec64=nextt64(G,w,w2); |
---|
459 | int64 tvec0,tvec1; |
---|
460 | nextt64(G,w,w2,tvec0,tvec1); |
---|
461 | |
---|
462 | if(overflow_error){ |
---|
463 | return WalkOverFlowError; |
---|
464 | } |
---|
465 | |
---|
466 | //tvec[1]>tvec[2] iff t>1 or t ist undefined i.e.is (2,0) |
---|
467 | //if ((*tvec64)[0]>(*tvec64)[1]) |
---|
468 | if (tvec0>tvec1) |
---|
469 | { |
---|
470 | if(invEpsOk64(G,destMat,level,inveps64)) { |
---|
471 | return(state); |
---|
472 | } |
---|
473 | else |
---|
474 | { |
---|
475 | //taunpair64=getTaun64(G,destMat,level); |
---|
476 | //w2=getiv64(taunpair64); |
---|
477 | //inveps64=getint64(taunpair64); |
---|
478 | delete w2; |
---|
479 | getTaun64(G,destMat,level,&w2,inveps64); |
---|
480 | |
---|
481 | //tvec64=nextt64(G,w,w2); |
---|
482 | nextt64(G,w,w2,tvec0,tvec1); |
---|
483 | |
---|
484 | if(overflow_error){ |
---|
485 | return WalkOverFlowError; |
---|
486 | } |
---|
487 | |
---|
488 | //if((*tvec64)[0]>(*tvec64)[1]) |
---|
489 | if(tvec0>tvec1) |
---|
490 | { |
---|
491 | return(state); |
---|
492 | } |
---|
493 | } |
---|
494 | } |
---|
495 | |
---|
496 | //i.e. t=1 and we have reached the target vector |
---|
497 | //if( ((*tvec64)[0]==(*tvec64)[1]) && (level!=iv64Size(w)) ) |
---|
498 | if( (tvec0==tvec1) && (level!=iv64Size(w)) ) |
---|
499 | { |
---|
500 | state=fractalRec64(G,old_w,destMat,level+1,step); |
---|
501 | return(state); |
---|
502 | } |
---|
503 | else |
---|
504 | { |
---|
505 | w=nextw64(w,w2,tvec0,tvec1); |
---|
506 | |
---|
507 | //3 |
---|
508 | ideal Gw=init64(G,w); //finding initial ideal for new w |
---|
509 | |
---|
510 | ring oldRing=currRing; |
---|
511 | |
---|
512 | ideal GwCp=idCopy(Gw); |
---|
513 | ideal GCp=idCopy(G); |
---|
514 | |
---|
515 | ideal newGw; |
---|
516 | ideal newStdGw; |
---|
517 | ideal newG; |
---|
518 | |
---|
519 | //4 |
---|
520 | if ( level==iv64Size(w) || noPolysWithMoreThanTwoTerms(Gw) ){ |
---|
521 | |
---|
522 | //5 |
---|
523 | /*NEWRING**********************************************************/ |
---|
524 | |
---|
525 | //this assumes order has A-vector as first vector |
---|
526 | ring newring=rCopy0(currRing); |
---|
527 | rComplete(newring); |
---|
528 | rSetWeightVec(newring,w->iv64GetVec()); |
---|
529 | rChangeCurrRing(newring); |
---|
530 | //rSetWeightVec(newring,w->iv64GetVec()); |
---|
531 | //rComplete(newring,1); |
---|
532 | |
---|
533 | newGw=idrMoveR(GwCp,oldRing,newring); |
---|
534 | |
---|
535 | si_opt_1|=Sy_bit(OPT_REDSB); |
---|
536 | newStdGw=idStd(newGw); //computes new reduced GB of Gw |
---|
537 | SI_RESTORE_OPT(save1,save2); |
---|
538 | } |
---|
539 | else |
---|
540 | { |
---|
541 | //7 |
---|
542 | /*THE RING FROM THE RECURSION STEP BELOW***************************/ |
---|
543 | //Here we can choose whether to call fractalrec with old_w, |
---|
544 | //which is the last w from the top level, or with sigma, |
---|
545 | //the original start vector. The impact on the algorithm is not obvious. |
---|
546 | |
---|
547 | state=fractalRec64(Gw,sigma,destMat,level+1,step); |
---|
548 | |
---|
549 | //The resulting GB is Gw since its adress is given as argument. |
---|
550 | ideal recG=Gw; |
---|
551 | ring temp=currRing; |
---|
552 | |
---|
553 | /*NEWRING**********************************************************/ |
---|
554 | |
---|
555 | //this assumes order has A-vector as first vector |
---|
556 | ring newring=rCopy0(currRing); |
---|
557 | rComplete(newring); |
---|
558 | rChangeCurrRing(newring); |
---|
559 | rSetWeightVec(currRing,w->iv64GetVec()); |
---|
560 | rComplete(newring,1); |
---|
561 | |
---|
562 | newGw=idrMoveR(GwCp,oldRing,newring); |
---|
563 | |
---|
564 | newStdGw=idrMoveR(recG,temp,newring); |
---|
565 | } |
---|
566 | |
---|
567 | //8 |
---|
568 | //lifting comes either after level=nvars(ring), after Gw has |
---|
569 | //no poly with more than two terms or after |
---|
570 | //fractalRec64(Gw,level+1) has returned |
---|
571 | |
---|
572 | //si_opt_1|=Sy_bit(OPT_NOT_BUCKETS); |
---|
573 | matrix L=matIdLift(newGw,newStdGw); |
---|
574 | SI_RESTORE_OPT(save1,save2); |
---|
575 | |
---|
576 | newG=idrMoveR(GCp,oldRing,currRing); |
---|
577 | matrix MG=(matrix)newG; |
---|
578 | |
---|
579 | matrix resMat=mp_Mult(MG,L,currRing); |
---|
580 | idDelete((ideal *)&MG); |
---|
581 | idDelete((ideal *)&L); |
---|
582 | G=(ideal)resMat; |
---|
583 | |
---|
584 | //9 |
---|
585 | |
---|
586 | si_opt_1|=Sy_bit(OPT_REDSB); |
---|
587 | G=idInterRed(G); |
---|
588 | SI_RESTORE_OPT(save1,save2); |
---|
589 | |
---|
590 | old_w=iv64Copy(w); |
---|
591 | if(level==1) step=step+1; |
---|
592 | |
---|
593 | } |
---|
594 | |
---|
595 | } |
---|
596 | } |
---|
597 | |
---|
598 | |
---|
599 | /////////////////////////////////////////////////////////////////// |
---|
600 | |
---|
601 | |
---|
602 | //ANOTHER INPUT-VARIABLE ADDED: unperturbedStartVectorStrategy |
---|
603 | //THIS SHOULD BE SET IN walkProc.cc BY THE USER |
---|
604 | /////////////////////////////////////////////////////////////////// |
---|
605 | //fractalWalk64 |
---|
606 | /////////////////////////////////////////////////////////////////// |
---|
607 | //Description: |
---|
608 | /////////////////////////////////////////////////////////////////// |
---|
609 | //Uses:fractalRec64,firstFractalWalkStep64,idStd,idInterRed, |
---|
610 | //int64VecToIntVec,getNthRow,sortRedSB |
---|
611 | /////////////////////////////////////////////////////////////////// |
---|
612 | |
---|
613 | WalkState fractalWalk64(ideal sourceIdeal,ring destRing, |
---|
614 | ideal & destIdeal,BOOLEAN sourceIsSB, |
---|
615 | BOOLEAN unperturbedStartVectorStrategy) |
---|
616 | { |
---|
617 | |
---|
618 | overflow_error=FALSE; //global |
---|
619 | WalkState state=WalkOk; |
---|
620 | BITSET save1,save2; |
---|
621 | SI_SAVE_OPT(save1,save2); |
---|
622 | |
---|
623 | si_opt_1|= (Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB)); |
---|
624 | ideal G; |
---|
625 | |
---|
626 | if(!sourceIsSB) |
---|
627 | { |
---|
628 | G=idStd(sourceIdeal); |
---|
629 | } |
---|
630 | |
---|
631 | else |
---|
632 | { |
---|
633 | G=idInterRed(idCopy(sourceIdeal)); |
---|
634 | } |
---|
635 | |
---|
636 | SI_RESTORE_OPT(save1,save2); //switches REDSB off |
---|
637 | |
---|
638 | //matrices for the orders of the rings |
---|
639 | intvec *destMat=int64VecToIntVec(rGetGlobalOrderMatrix(destRing)); |
---|
640 | intvec *currMat=int64VecToIntVec(rGetGlobalOrderMatrix(currRing)); |
---|
641 | |
---|
642 | int64vec* currw64=getNthRow64(currMat,1); //start vector |
---|
643 | |
---|
644 | state=firstFractalWalkStep64(G,currw64,currMat,destRing, |
---|
645 | unperturbedStartVectorStrategy); |
---|
646 | delete currMat; |
---|
647 | |
---|
648 | state=fractalRec64(G,currw64,destMat,1,1); |
---|
649 | if(state==WalkOk) |
---|
650 | destIdeal=G; |
---|
651 | |
---|
652 | if(overflow_error) |
---|
653 | state=WalkOverFlowError; |
---|
654 | |
---|
655 | delete currw64; |
---|
656 | delete destMat; |
---|
657 | return state; |
---|
658 | } |
---|
659 | |
---|
660 | |
---|
661 | ///////////////////////////////////////////////////////////// |
---|