Changeset 11d9d00 in git
- Timestamp:
- Dec 15, 2014, 1:19:16 AM (9 years ago)
- Branches:
- (u'spielwiese', 'd0474371d8c5d8068ab70bfb42719c97936b18a6')
- Children:
- 4083faab6546fc5c3396c90683e190ab3b4d1327
- Parents:
- 8af63a71de0015f0413204e1a7a8620a8d37cc7a350269c461fd0afbb2c4d79cc7d38d2793207b12
- Files:
-
- 3 added
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/grwalk.lib
r350269 r11d9d00 255 255 } 256 256 257 proc gwalk(ideal Go, list #)258 "SYNTAX: gwalk(ideal i );259 gwalk(ideal i, int vec v, intvec w);257 proc gwalk(ideal Go, int reduction,int printout, list #) 258 "SYNTAX: gwalk(ideal i, int reduction, int printout); 259 gwalk(ideal i, int reduction, int printout, intvec v, intvec w); 260 260 TYPE: ideal 261 261 PURPOSE: compute the standard basis of the ideal, calculated via … … 284 284 //print("//** help ring = " + string(basering)); 285 285 ideal G = fetch(xR, Go); 286 G = system("Mwalk", G, curr_weight, target_weight,basering );286 G = system("Mwalk", G, curr_weight, target_weight,basering,reduction,printout); 287 287 288 288 setring xR; … … 300 300 ring r = 32003,(z,y,x), lp; 301 301 ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; 302 gwalk(I );302 gwalk(I,0,1); 303 303 } 304 304 … … 346 346 } 347 347 348 proc fwalk(ideal Go, list #)349 "SYNTAX: fwalk(ideal i );350 fwalk(ideal i, int vec v, intvec w);348 proc fwalk(ideal Go, int reduction, int printout, list #) 349 "SYNTAX: fwalk(ideal i,int reductioin); 350 fwalk(ideal i, int reduction intvec v, intvec w); 351 351 TYPE: ideal 352 352 PURPOSE: compute the standard basis of the ideal w.r.t. the … … 372 372 373 373 ideal G = fetch(xR, Go); 374 G = system("Mfwalk", G, curr_weight, target_weight );374 G = system("Mfwalk", G, curr_weight, target_weight, reduction, printout); 375 375 376 376 setring xR; … … 387 387 ring r = 32003,(z,y,x), lp; 388 388 ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; 389 fwalk(I); 389 int reduction = 1; 390 int printout = 1; 391 fwalk(I,reduction,printout); 390 392 } 391 393 … … 437 439 } 438 440 439 proc pwalk(ideal Go, int n1, int n2, list #)440 "SYNTAX: pwalk(int d, ideal i, int n1, int n2 );441 pwalk(int d, ideal i, int n1, int n2, int vec v, intvec w);441 proc pwalk(ideal Go, int n1, int n2, int reduction, int printout, list #) 442 "SYNTAX: pwalk(int d, ideal i, int n1, int n2, int reduction, int printout); 443 pwalk(int d, ideal i, int n1, int n2, int reduction, int printout, intvec v, intvec w); 442 444 TYPE: ideal 443 445 PURPOSE: compute the standard basis of the ideal, calculated via … … 477 479 ideal G = fetch(xR, Go); 478 480 479 G = system("Mpwalk", G, n1, n2, curr_weight, target_weight,nP);481 G = system("Mpwalk",G,n1,n2,curr_weight,target_weight,nP,reduction,printout); 480 482 481 483 setring xR; … … 492 494 ring r = 32003,(z,y,x), lp; 493 495 ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; 494 //I = std(I); 495 //ring rr = 32003,(z,y,x),lp; 496 //ideal I = fetch(r,I); 497 pwalk(I,2,2); 496 int reduction = 1; 497 int printout = 2; 498 pwalk(I,2,2,reduction,printout); 498 499 } 499 500 -
Singular/LIB/hess.lib
r8af63a r11d9d00 1799 1799 1800 1800 ring r_ext=(char(basering),@a),(x,y,z),lp; 1801 poly aux=imap(base_r,aux); 1802 minpoly=number(subst(aux,x,@a)); 1801 1803 poly F=imap(r_auxz,F); 1802 1804 poly f_xz=subst(F,y,1); 1803 poly aux=imap(base_r,aux);1804 minpoly=number(subst(aux,x,@a));1805 1805 map phi=r_ext,x+@a,0,z; 1806 1806 poly f_origin=phi(f_xz); -
Singular/LIB/modwalk.lib
-
Property
mode
changed from
100644
to100755
r350269 r11d9d00 16 16 17 17 PROCEDURES: 18 modpWalk(ideal,int,int,int[,int,int,int,int]) standard basis conversion of I in prime characteristic 18 19 modWalk(ideal,int,int[,int,int,int,int]); standard basis conversion of I using modular methods (chinese remainder) 19 20 "; … … 29 30 //////////////////////////////////////////////////////////////////////////////// 30 31 31 static proc modpWalk(def II, int p, int variant, list #)32 proc modpWalk(def II, int p, int variant, int reduction, list #) 32 33 "USAGE: modpWalk(I,p,#); I ideal, p integer, variant integer 33 34 ASSUME: If size(#) > 0, then … … 80 81 } 81 82 } 82 83 //------------------------- make i homogeneous -----------------------------84 if(!mixedTest() && !h)85 {86 if(!((find(ordstr_R0, "M") > 0) || (find(ordstr_R0, "a") > 0) || neg))87 {88 if(!((order == "simple") || (sizerl > 4)))89 {90 list rl@r = ringlist(@r);91 nvar@r = nvars(@r);92 intvec w;93 for(k = 1; k <= nvar@r; k++)94 {95 w[k] = deg(var(k));96 }97 w[nvar@r + 1] = 1;98 rl@r[2][nvar@r + 1] = "homvar";99 rl@r[3][2][2] = w;100 def HomR = ring(rl@r);101 setring HomR;102 ideal i = imap(@r, i);103 i = homog(i, homvar);104 }105 }106 }107 108 83 //------------------------- compute a standard basis mod p ----------------------------- 109 110 84 if(variant == 1) 111 85 { 112 86 if(size(#)>0) 113 87 { 114 i = rwalk(i,radius,pert_deg,#); 115 // rwalk(i,radius,pert_deg,#); std(i); 116 } 117 else 118 { 119 i = rwalk(i,radius,pert_deg); 88 i = rwalk(i,radius,pert_deg,reduction,#); 89 } 90 else 91 { 92 i = rwalk(i,radius,pert_deg,reduction); 120 93 } 121 94 } … … 124 97 if(size(#) == 2) 125 98 { 126 i = gwalk(i, #);127 } 128 else 129 { 130 i = gwalk(i );99 i = gwalk(i,reduction,#); 100 } 101 else 102 { 103 i = gwalk(i,reduction); 131 104 } 132 105 } … … 135 108 if(size(#) == 2) 136 109 { 137 i = frandwalk(i,radius, #);138 } 139 else 140 { 141 i = frandwalk(i,radius );110 i = frandwalk(i,radius,reduction,#); 111 } 112 else 113 { 114 i = frandwalk(i,radius,reduction); 142 115 } 143 116 } … … 157 130 if(size(#) == 2) 158 131 { 159 i=prwalk(i,radius,pert_deg,pert_deg, #);160 } 161 else 162 { 163 i=prwalk(i,radius,pert_deg,pert_deg );132 i=prwalk(i,radius,pert_deg,pert_deg,reduction,#); 133 } 134 else 135 { 136 i=prwalk(i,radius,pert_deg,pert_deg,reduction); 164 137 } 165 138 } … … 168 141 if(size(#) == 2) 169 142 { 170 i=pwalk(i,pert_deg,pert_deg,#); 171 } 172 else 173 { 174 i=pwalk(i,pert_deg,pert_deg); 175 } 176 } 177 178 if(!mixedTest() && !h) 179 { 180 if(!((find(ordstr_R0, "M") > 0) || (find(ordstr_R0, "a") > 0) || neg)) 181 { 182 if(!((order == "simple") || (sizerl > 4))) 183 { 184 i = subst(i, homvar, 1); 185 i = simplify(i, 34); 186 setring @r; 187 i = imap(HomR, i); 188 i = interred(i); 189 kill HomR; 190 } 191 } 192 } 143 i=pwalk(i,pert_deg,pert_deg,reduction,#); 144 } 145 else 146 { 147 i=pwalk(i,pert_deg,pert_deg,reduction); 148 } 149 } 150 193 151 setring R0; 194 152 return(list(fetch(@r,i),p)); … … 204 162 ring ra = 0,x(1..4),(a(a),lp); 205 163 ideal I = std(cyclic(4)); 164 int reduction = 1; 206 165 ring rb = 0,x(1..4),(a(b),lp); 207 166 ideal I = imap(ra,I); 208 modpWalk(I,p,1, a,b);167 modpWalk(I,p,1,reduction,a,b); 209 168 std(I); 210 169 } … … 212 171 //////////////////////////////////////////////////////////////////////////////// 213 172 214 proc modWalk(def II, int variant, list #)173 proc modWalk(def II, int variant, int reduction, list #) 215 174 "USAGE: modWalk(II); II ideal or list(ideal,int) 216 175 ASSUME: If variant = … … 487 446 if(n2 > 4) 488 447 { 489 //L[5] = prime(random(an,en));448 L[5] = prime(random(an,en)); 490 449 } 491 450 if(printlevel >= 10) … … 504 463 for(i=1; i<=size(L); i++) 505 464 { 506 Arguments[i] = list(II,L[i],variant, list(curr_weight,target_weight));465 Arguments[i] = list(II,L[i],variant,reduction,list(curr_weight,target_weight)); 507 466 } 508 467 } … … 511 470 for(i=1; i<=size(L); i++) 512 471 { 513 Arguments[i] = list(II,L[i],variant );472 Arguments[i] = list(II,L[i],variant,reduction); 514 473 } 515 474 } … … 528 487 //------------------- Now all leading ideals are the same -------------------- 529 488 //------------------- Lift results to basering via farey --------------------- 530 531 489 tt = timer; rt = rtimer; 532 490 N = T2[1]; … … 545 503 546 504 //---------------- Test if we already have a standard basis of I -------------- 547 548 505 tt = timer; rt = rtimer; 549 pTest = pTestSB(I,J,L,variant); 550 //pTest = primeTestSB(I,J,L,variant); 506 pTest = primeTest(J, prime(random(1000000000,2134567879))); 551 507 if(printlevel >= 10) 552 508 { … … 596 552 } 597 553 //-------------- We do not already have a standard basis of I, therefore do the main computation for more primes -------------- 598 599 554 T1 = H; 600 555 T2 = N; … … 613 568 for(i=j; i<=size(L); i++) 614 569 { 615 //Arguments[i-j+1] = list(II,L[i],variant,list(curr_weight,target_weight)); 616 Arguments[size(Arguments)+1] = list(II,L[i],variant,list(curr_weight,target_weight)); 570 Arguments[size(Arguments)+1] = list(II,L[i],variant,reduction,list(curr_weight,target_weight)); 617 571 } 618 572 } … … 621 575 for(i=j; i<=size(L); i++) 622 576 { 623 //Arguments[i-j+1] = list(II,L[i],variant); 624 Arguments[size(Arguments)+1] = list(II,L[i],variant); 577 Arguments[size(Arguments)+1] = list(II,L[i],variant,reduction); 625 578 } 626 579 } … … 632 585 for(i=1; i<=size(PP); i++) 633 586 { 634 //P[size(P) + 1] = PP[i];635 587 T1[size(T1) + 1] = PP[i][1]; 636 588 T2[size(T2) + 1] = bigint(PP[i][2]); … … 649 601 echo = 2; 650 602 ring R=0,(x,y,z),lp; 651 ideal I= -x+y2z-z,xz+1,x2+y2-1;652 // I is a standard basis in dp653 ideal J = modWalk(I,1 );603 ideal I= y3+xyz+y2z+xz3, 3+xy+x2y+y2z; 604 int reduction = 0; 605 ideal J = modWalk(I,1,1); 654 606 J; 655 607 } … … 772 724 return(J); 773 725 } 774 ////////////////////////////////////////////////////////////////////////////////// 775 static proc primeTestSB(def II, ideal J, list L, int variant, list #) 776 "USAGE: primeTestSB(I,J,L,variant,#); I,J ideals, L intvec of primes, variant int 777 RETURN: 1 (resp. 0) if for a randomly chosen prime p that is not in L 778 J mod p is (resp. is not) a standard basis of I mod p 779 EXAMPLE: example primeTestSB; shows an example 780 " 781 { 782 if(typeof(II) == "ideal") 783 { 784 ideal I = II; 785 int radius = 2; 786 } 787 if(typeof(II) == "list") 788 { 789 ideal I = II[1]; 790 int radius = II[2]; 791 } 792 793 int i,j,k,p; 794 def R = basering; 795 list r = ringlist(R); 796 797 while(!j) 798 { 799 j = 1; 800 p = prime(random(1000000000,2134567879)); 801 for(i = 1; i <= size(L); i++) 802 { 803 if(p == L[i]) 804 { 805 j = 0; 806 break; 807 } 808 } 809 if(j) 810 { 811 for(i = 1; i <= ncols(I); i++) 812 { 813 for(k = 2; k <= size(I[i]); k++) 814 { 815 if((denominator(leadcoef(I[i][k])) mod p) == 0) 816 { 817 j = 0; 818 break; 819 } 820 } 821 if(!j) 822 { 823 break; 824 } 825 } 826 } 827 if(j) 828 { 829 if(!primeTest(I,p)) 830 { 831 j = 0; 832 } 833 } 834 } 835 r[1] = p; 836 def @R = ring(r); 837 setring @R; 838 ideal I = imap(R,I); 839 ideal J = imap(R,J); 840 attrib(J,"isSB",1); 841 842 int t = timer; 843 j = 1; 844 if(isIncluded(I,J) == 0) 845 { 846 j = 0; 847 } 848 if(printlevel >= 11) 849 { 850 "isIncluded(I,J) takes "+string(timer - t)+" seconds"; 851 "j = "+string(j); 852 } 853 t = timer; 854 if(j) 855 { 856 if(size(#) > 0) 857 { 858 ideal K = modpWalk(I,p,variant,#)[1]; 859 } 860 else 861 { 862 ideal K = modpWalk(I,p,variant)[1]; 863 } 864 t = timer; 865 if(isIncluded(J,K) == 0) 866 { 867 j = 0; 868 } 869 if(printlevel >= 11) 870 { 871 "isIncluded(K,J) takes "+string(timer - t)+" seconds"; 872 "j = "+string(j); 873 } 874 } 875 setring R; 876 877 return(j); 878 } 879 example 880 { "EXAMPLE:"; echo = 2; 881 intvec L = 2,3,5; 882 ring r = 0,(x,y,z),lp; 883 ideal I = x+1,x+y+1; 884 ideal J = x+1,y; 885 primeTestSB(I,I,L,1); 886 primeTestSB(I,J,L,1); 887 } 888 889 //////////////////////////////////////////////////////////////////////////////// 890 static proc pTestSB(ideal I, ideal J, list L, int variant, list #) 891 "USAGE: pTestSB(I,J,L,variant,#); I,J ideals, L intvec of primes, variant int 892 RETURN: 1 (resp. 0) if for a randomly chosen prime p that is not in L 893 J mod p is (resp. is not) a standard basis of I mod p 894 EXAMPLE: example pTestSB; shows an example 895 " 896 { 897 int i,j,k,p; 898 def R = basering; 899 list r = ringlist(R); 900 901 while(!j) 902 { 903 j = 1; 904 p = prime(random(1000000000,2134567879)); 905 for(i = 1; i <= size(L); i++) 906 { 907 if(p == L[i]) { j = 0; break; } 908 } 909 if(j) 910 { 911 for(i = 1; i <= ncols(I); i++) 912 { 913 for(k = 2; k <= size(I[i]); k++) 914 { 915 if((denominator(leadcoef(I[i][k])) mod p) == 0) { j = 0; break; } 916 } 917 if(!j){ break; } 918 } 919 } 920 if(j) 921 { 922 if(!primeTest(I,p)) { j = 0; } 923 } 924 } 925 r[1] = p; 926 def @R = ring(r); 927 setring @R; 928 ideal I = imap(R,I); 929 ideal J = imap(R,J); 930 attrib(J,"isSB",1); 931 932 int t = timer; 933 j = 1; 934 if(isIncluded(I,J) == 0) { j = 0; } 935 936 if(printlevel >= 11) 937 { 938 "isIncluded(I,J) takes "+string(timer - t)+" seconds"; 939 "j = "+string(j); 940 } 941 942 t = timer; 943 if(j) 944 { 945 if(size(#) > 0) 946 { 947 ideal K = modpStd(I,p,variant,#[1])[1]; 948 } 949 else 950 { 951 ideal K = groebner(I); 952 } 953 t = timer; 954 if(isIncluded(J,K) == 0) { j = 0; } 955 956 if(printlevel >= 11) 957 { 958 "isIncluded(J,K) takes "+string(timer - t)+" seconds"; 959 "j = "+string(j); 960 } 961 } 962 setring R; 963 return(j); 964 } 965 example 966 { "EXAMPLE:"; echo = 2; 967 intvec L = 2,3,5; 968 ring r = 0,(x,y,z),dp; 969 ideal I = x+1,x+y+1; 970 ideal J = x+1,y; 971 pTestSB(I,I,L,2); 972 pTestSB(I,J,L,2); 973 } 726 974 727 //////////////////////////////////////////////////////////////////////////////// 975 728 static proc mixedTest() -
Property
mode
changed from
-
Singular/LIB/normal.lib
r8af63a r11d9d00 1 1 ////////////////////////////////////////////////////////////////////////////// 2 version="version normal.lib 4.0. 0.0 Jun_2013"; // $Id$2 version="version normal.lib 4.0.1.1 Dec_2014 "; // $Id$ 3 3 category="Commutative Algebra"; 4 4 info=" … … 2329 2329 execute("ring Rhelp=("+charstr(R0)+"),(@s),dp;"); 2330 2330 } 2331 execute("minpoly = "+smp+";"); 2331 if (smp!="0") 2332 { execute("minpoly = "+smp+";");} 2332 2333 def newR=R+Rhelp; 2333 2334 setring newR; -
Singular/LIB/primdec.lib
r8af63a r11d9d00 2685 2685 } 2686 2686 //---Ende Provisorium 2687 string mp="poly p="+string(minpoly)+";";2687 string mp="poly @p="+string(minpoly)+";"; 2688 2688 string gnir="ring RH="+string(char(R))+",("+varstr(R)+","+string(par(1)) 2689 2689 +"),dp;"; … … 2697 2697 if(i[j]!=I[j]){break;} 2698 2698 } 2699 if((j>ncols(i))&&(deg( p)==1))2699 if((j>ncols(i))&&(deg(@p)==1)) 2700 2700 { 2701 2701 setring R; … … 2709 2709 else 2710 2710 { 2711 i=i, p;2711 i=i,@p; 2712 2712 } 2713 2713 list pr; … … 2726 2726 pr=minAssPrimes(i); 2727 2727 } 2728 2728 2729 if(n<nvars(basering)) 2729 2730 { … … 2747 2748 list pr=imap(RH,pr); 2748 2749 } 2750 2749 2751 list re; 2750 2752 if(w==2) … … 2828 2830 } 2829 2831 homo=homog(i); 2830 if(homo ==1)2832 if(homo) 2831 2833 { 2832 2834 if(attrib(i,"isSB")!=1) … … 4174 4176 // 4175 4177 /////////////////////////////////////////////////////////////////////////////// 4176 4177 4178 static proc simplifyIdeal(ideal i) 4178 4179 { 4179 4180 ASSUME(1, hasFieldCoefficient(basering) ); 4180 ASSUME(1, not isQuotientRing(basering) ) ;4181 4181 ASSUME(1, hasGlobalOrdering(basering) ) ; 4182 4182 4183 4183 def r=basering; 4184 4185 ideal iwork=i; 4186 ideal imap2=maxideal(1); 4184 4187 4185 4188 int j,k; 4186 4189 map phi; 4187 4190 poly p; 4188 4189 ideal iwork=i;4190 4191 ideal imap1=maxideal(1); 4191 ideal imap2=maxideal(1); 4192 4193 4194 for(j=1;j<=nvars(basering);j++) 4195 { 4196 for(k=1;k<=size(i);k++) 4192 // first try: very simple substitutions 4193 intvec tested=0:nvars(r); 4194 for(j=1;j<=nvars(r);j++) 4195 { 4196 for(k=1;k<=ncols(i);k++) 4197 4197 { 4198 4198 if(deg(iwork[k]/var(j))==0) 4199 4199 { 4200 4200 p=-1/leadcoef(iwork[k]/var(j))*iwork[k]; 4201 imap1[j]=p+2*var(j); 4202 phi=r,imap1; 4203 iwork=phi(iwork); 4204 iwork=subst(iwork,var(j),0); 4205 iwork[k]=var(j); 4206 imap1=maxideal(1); 4207 imap2[j]=-p; 4208 break; 4201 if(size(p)<=2) 4202 { 4203 tested[j]=1; 4204 imap1[j]=p+2*var(j); 4205 phi=r,imap1; 4206 iwork=phi(iwork); 4207 iwork=subst(iwork,var(j),0); 4208 iwork[k]=var(j); 4209 imap1=maxideal(1); 4210 imap2[j]=-p; 4211 break; 4212 } 4213 } 4214 } 4215 } 4216 // second try: substitutions not so simple 4217 for(j=1;j<=nvars(r);j++) 4218 { 4219 if (tested[j]==0) 4220 { 4221 for(k=1;k<=ncols(i);k++) 4222 { 4223 if(deg(iwork[k]/var(j))==0) 4224 { 4225 p=-1/leadcoef(iwork[k]/var(j))*iwork[k]; 4226 imap1[j]=p+2*var(j); 4227 phi=r,imap1; 4228 iwork=phi(iwork); 4229 iwork=subst(iwork,var(j),0); 4230 iwork[k]=var(j); 4231 imap1=maxideal(1); 4232 imap2[j]=-p; 4233 break; 4234 } 4209 4235 } 4210 4236 } … … 5863 5889 ASSUME(0, not isQuotientRing(basering) ) ; 5864 5890 dbprint(printlevel - voice, "Radical, version 2006.05.08"); 5891 if(size(i) == 0){return(ideal(0));} 5865 5892 if(attrib(basering,"global")!=1) 5866 5893 { … … 5877 5904 return(j); 5878 5905 } 5879 if(size(i) == 0){return(ideal(0));}5880 5906 int j; 5881 5907 def P0 = basering; -
Singular/LIB/rwalk.lib
-
Property
mode
changed from
100644
to100755
r350269 r11d9d00 10 10 rwalk(ideal,int,int[,intvec,intvec]); standard basis of ideal via Random Walk algorithm 11 11 rwalk(ideal,int[,intvec,intvec]); standard basis of ideal via Random Perturbation Walk algorithm 12 fr walk(ideal,int[,intvec,intvec]); standard basis of ideal via Random Fractal Walk algorithm12 frandwalk(ideal,int[,intvec,intvec]); standard basis of ideal via Random Fractal Walk algorithm 13 13 "; 14 14 … … 141 141 * Random Walk * 142 142 ****************/ 143 proc rwalk(ideal Go, int radius, int pert_deg, list #)143 proc rwalk(ideal Go, int radius, int pert_deg, int reduction, int printout, list #) 144 144 "SYNTAX: rwalk(ideal i, int radius); 145 145 if size(#)>0 then rwalk(ideal i, int radius, intvec v, intvec w); 146 intermediate Groebner bases are not reduced if reduction = 0 146 147 TYPE: ideal 147 148 PURPOSE: compute the standard basis of the ideal, calculated via … … 178 179 179 180 ideal G = fetch(xR, Go); 180 G = system("Mrwalk", G, curr_weight, target_weight, radius, pert_deg, basering);181 G = system("Mrwalk", G, curr_weight, target_weight, radius, pert_deg, reduction, printout); 181 182 182 183 setring xR; … … 196 197 int radius = 1; 197 198 int perturb_deg = 2; 198 rwalk(I,radius,perturb_deg); 199 int reduction = 0; 200 int printout = 1; 201 rwalk(I,radius,perturb_deg,reduction,printout); 199 202 } 200 203 … … 202 205 * Perturbation Walk with random element * 203 206 *****************************************/ 204 proc prwalk(ideal Go, int radius, int o_pert_deg, int t_pert_deg, list #)207 proc prwalk(ideal Go, int radius, int o_pert_deg, int t_pert_deg, int reduction, int printout, list #) 205 208 "SYNTAX: rwalk(ideal i, int radius); 206 209 if size(#)>0 then rwalk(ideal i, int radius, intvec v, intvec w); … … 227 230 OSCTW= OrderStringalp_NP("al", #); 228 231 } 232 int nP = OSCTW[1]; 229 233 string ord_str = OSCTW[2]; 230 234 intvec curr_weight = OSCTW[3]; // original weight vector … … 238 242 239 243 ideal G = fetch(xR, Go); 240 G = system("Mprwalk", G, curr_weight, target_weight, radius, o_pert_deg, t_pert_deg, basering); 244 G = system("Mprwalk", G, curr_weight, target_weight, radius, o_pert_deg, t_pert_deg, 245 nP, reduction, printout); 241 246 242 247 setring xR; … … 257 262 int o_perturb_deg = 2; 258 263 int t_perturb_deg = 2; 259 prwalk(I,radius,o_perturb_deg,t_perturb_deg); 264 int reduction = 0; 265 int printout = 2; 266 prwalk(I,radius,o_perturb_deg,t_perturb_deg,reduction,printout); 260 267 } 261 268 … … 263 270 * Fractal Walk with random element * 264 271 ************************************/ 265 proc frandwalk(ideal Go, int radius, list #)266 "SYNTAX: frwalk(ideal i, int radius );267 frwalk(ideal i, int radius, int vec v, intvec w);272 proc frandwalk(ideal Go, int radius, int reduction, int printout, list #) 273 "SYNTAX: frwalk(ideal i, int radius, int reduction, int printout); 274 frwalk(ideal i, int radius, int reduction, int printout, intvec v, intvec w); 268 275 TYPE: ideal 269 276 PURPOSE: compute the standard basis of the ideal, calculated via … … 299 306 ideal G = fetch(xR, Go); 300 307 int pert_deg = 2; 301 G = system("Mfrwalk", G, curr_weight, target_weight, radius); 308 309 G = system("Mfrwalk", G, curr_weight, target_weight, radius, reduction, printout); 302 310 303 311 setring xR; … … 314 322 ring r = 0,(z,y,x), lp; 315 323 ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; 316 frandwalk(I,2); 317 } 324 int reduction = 0; 325 frandwalk(I,2,0,1); 326 } -
Property
mode
changed from
-
Singular/LIB/schreyer.lib
r8af63a r11d9d00 49 49 "; 50 50 51 52 51 static proc prepareSyz( module I, list # ) 53 52 { … … 79 78 } 80 79 81 // DetailedPrint(I);80 // Syzextra::DetailedPrint(I); 82 81 83 82 return(I); … … 93 92 { 94 93 v = J[i]; 95 if( leadcomp(v) > c )94 if( Syzextra::leadcomp(v) > c ) 96 95 { 97 96 II[i] = v; … … 118 117 vv = 0; 119 118 120 while( leadcomp(v) <= c )119 while( Syzextra::leadcomp(v) <= c ) 121 120 { 122 121 vv = vv + lead(v); … … 144 143 "Sinit::Input"; 145 144 type(M); 146 // DetailedPrint(M);145 // Syzextra::DetailedPrint(M); 147 146 attrib(M); 148 147 } … … 157 156 } 158 157 159 def S = MakeInducedSchreyerOrdering(1); // 1 puts history terms to the back158 def S = Syzextra::MakeInducedSchreyerOrdering(1); // 1 puts history terms to the back 160 159 // TODO: NOTE: +1 causes trouble to Singular interpreter!!!??? 161 160 setring S; // a new ring with a Schreyer ordering … … 165 164 "Sinit::StartingISRing"; 166 165 basering; 167 // DetailedPrint(basering);166 // Syzextra::DetailedPrint(basering); 168 167 } 169 168 … … 190 189 attrib(M); 191 190 attrib(M, "isHomog"); 192 // DetailedPrint(M);191 // Syzextra::DetailedPrint(M); 193 192 } 194 193 … … 200 199 transpose( transpose(M) * transpose(MRES) ); 201 200 "ERROR: transpose( transpose(M) * transpose(MRES) ) != 0!!!"; 202 m2_end(666);201 Syzextra::m2_end(666); 203 202 } 204 203 } … … 215 214 { 216 215 "Sinit::MRES"; 217 DetailedPrint(MRES);216 Syzextra::DetailedPrint(MRES); 218 217 attrib(MRES, "isHomog"); 219 218 attrib(S); … … 232 231 { 233 232 "Sstep::NextInducedRing"; 234 DetailedPrint(basering);233 Syzextra::DetailedPrint(basering); 235 234 236 235 attrib(basering, "InducionLeads"); 237 236 attrib(basering, "InducionStart"); 238 237 239 GetInducedData();238 Syzextra::GetInducedData(); 240 239 } 241 240 … … 246 245 def L = lead(M); 247 246 intvec @V = deg(M[1..ncols(M)]); @W; @V; @W = @V; attrib(L, "isHomog", @W); 248 SetInducedReferrence(L, @RANK, 0);247 Syzextra::SetInducedReferrence(L, @RANK, 0); 249 248 */ 250 249 … … 255 254 256 255 // General setting: 257 // SetInducedReferrence(MRES, 0, 0); // limit: 0!256 // Syzextra::SetInducedReferrence(MRES, 0, 0); // limit: 0! 258 257 int @l = size(RES); 259 258 … … 287 286 deg(M[1..ncols(M)]); // no use of @W :(? 288 287 @RANK; 289 DetailedPrint(MRES);288 Syzextra::DetailedPrint(MRES); 290 289 attrib(MRES, "isHomog"); @W; 291 290 deg(MRES[1..ncols(MRES)]); … … 294 293 295 294 296 SetInducedReferrence(L, limit, 0);295 Syzextra::SetInducedReferrence(L, limit, 0); 297 296 298 297 def K = prepareSyz(M, @RANK); 299 298 // K; 300 299 301 // attrib(K, "isHomog", @V); DetailedPrint(K, 1000);300 // attrib(K, "isHomog", @V); Syzextra::DetailedPrint(K, 1000); 302 301 303 302 // pause(); 304 303 305 K = idPrepare(K, @RANK); // std(K); // ?304 K = Syzextra::idPrepare(K, @RANK); // std(K); // ? 306 305 K = simplify(K, 2); 307 306 … … 310 309 module N = separateSyzGB(K, @RANK)[2]; // 1^st syz. module: vectors which start in lower part (comp >= @RANK) 311 310 312 // "N_0: "; N; DetailedPrint(N, 10);311 // "N_0: "; N; Syzextra::DetailedPrint(N, 10); 313 312 314 313 // basering; print(@V); type(N); … … 328 327 MRES; 329 328 330 "N: "; N; DetailedPrint(N, 10);331 332 "K:"; K; DetailedPrint(K, 10);329 "N: "; N; Syzextra::DetailedPrint(N, 10); 330 331 "K:"; K; Syzextra::DetailedPrint(K, 10); 333 332 334 333 "RANKS: ", @RANK; … … 339 338 "transpose(N) * transpose(MRES): "; 340 339 transpose(N) * transpose(MRES); 341 DetailedPrint(module(_), 2);342 m2_end(666);340 Syzextra::DetailedPrint(module(_), 2); 341 Syzextra::m2_end(666); 343 342 } 344 343 } … … 357 356 { 358 357 "Sstep::NextSyzOutput: "; 359 DetailedPrint(N);358 Syzextra::DetailedPrint(N); 360 359 attrib(N, "isHomog"); 361 360 } … … 371 370 " 372 371 { 373 def data = GetInducedData();372 def data = Syzextra::GetInducedData(); 374 373 375 374 if( (!defined(RES)) || (!defined(MRES)) || (typeof(data) != "list") || (size(data) != 2) ) … … 505 504 if( size(M) > 0 ) 506 505 { 507 S ort_c_ds(@N);506 Syzextra::Sort_c_ds(@N); 508 507 509 508 if( @KERCHECK ) … … 527 526 528 527 "ERROR: MySort: wrong sorting in 'MySort': @N != @M!!!"; 529 m2_end(666);528 Syzextra::m2_end(666); 530 529 } 531 530 } … … 549 548 ERROR("Sorry: need an ideal or a module for input"); 550 549 } 551 552 // TODO! DONE?553 550 def @save = basering; 554 551 … … 588 585 } 589 586 590 587 int @RINGCHANGE = 0; 588 589 if( typeof( attrib(SSinit, "RINGCHANGE") ) == "int" ) 590 { 591 @RINGCHANGE = attrib(SSinit, "RINGCHANGE"); 592 } 593 594 591 595 if( @DEBUG ) 592 596 { 593 597 "SSinit::Input"; 594 598 type(M); 595 // DetailedPrint(M);596 599 attrib(M); 597 600 } … … 606 609 option(set, opts); 607 610 kill opts; 608 }// else 609 // { 610 M = simplify(M, 1 + 2 + 4 + 32); // interreduce? 611 // } 611 } 612 613 M = simplify(M, 1 + 2 + 4 + 32); 612 614 613 615 if( @IGNORETAILS ) … … 621 623 } 622 624 } 623 624 625 625 626 626 def @N = MySort(M); // TODO: replace with inplace sorting!!! 627 627 def LEAD = lead(@N); … … 646 646 647 647 "ERROR: wrong sorting (in SSnit): @N != M!!!"; 648 m2_end(666);648 Syzextra::m2_end(666); 649 649 } 650 650 … … 658 658 659 659 "ERROR: wrong sorting (in SSnit): @LEAD != LEAD!!!"; 660 m2_end(666);660 Syzextra::m2_end(666); 661 661 } 662 662 … … 665 665 M = @N; 666 666 667 def TAIL = Tail(M);667 def TAIL = Syzextra::Tail(M); 668 668 669 669 int @RANK = nrows(M); int @SIZE = ncols(M); … … 672 672 673 673 // TODO: what about real modules? weighted ones? 674 675 list @l = ringlist(@save); 676 677 int @z = 0; ideal @m = maxideal(1); intvec @wdeg = deg(@m[1..ncols(@m)]); 678 679 // NOTE: @wdeg will be ignored anyway :( 680 @l[3] = list(list("C", @z), list("lp", @wdeg)); 681 682 kill @z, @wdeg; // since these vars are ring independent! 683 684 def S = ring(@l); // --MakeInducedSchreyerOrdering(1); 685 686 module F = freemodule(@RANK); 687 intvec @V = deg(F[1..@RANK]); 688 689 setring S; // ring with an easy divisibility test ("C, lex") 690 691 if( @DEBUG ) 692 { 693 "SSinit::NewRing(C, lex)"; 694 basering; 695 DetailedPrint(basering); 696 } 674 675 if( @RINGCHANGE ) 676 { 677 list @l = ringlist(@save); 678 int @z = 0; ideal @m = maxideal(1); intvec @wdeg = deg(@m[1..ncols(@m)]); 679 // NOTE: @wdeg will be ignored anyway :( 680 @l[3] = list(list("C", @z), list("lp", @wdeg)); 681 kill @z, @m, @wdeg; // since these vars are ring independent! 682 def S = ring(@l); // -- Syzextra::MakeInducedSchreyerOrdering(1); 683 kill @l; 684 setring S; // ring with an easy divisibility test ("C, lex") // or not!??? 685 if( @DEBUG ) 686 { 687 "SSinit::NewRing(C,lex)?"; 688 basering; 689 Syzextra::DetailedPrint(basering); 690 } 691 } else 692 { def S = basering; } 697 693 698 694 // Setup the leading syzygy^{-1} module to zero: 699 695 module Z = 0; Z[@RANK] = 0; attrib(Z, "isHomog", intvec(0)); 696 697 if( !@RINGCHANGE ) 698 { 699 if( defined(RES) ) { if( @DEBUG ){ "WARN: killing existing object: RES!"; }; kill RES; } 700 if( defined(MRES) ) { if( @DEBUG ){ "WARN: killing existing object: MRES!"; }; kill MRES; } 701 if( defined(LRES) ) { if( @DEBUG ){ "WARN: killing existing object: LRES!"; }; kill LRES; } 702 if( defined(TRES) ) { if( @DEBUG ){ "WARN: killing existing object: TRES!"; }; kill TRES; } 703 } 700 704 701 705 module MRES = Z; … … 704 708 list LRES; LRES[1] = Z; 705 709 list TRES; TRES[1] = Z; 706 707 def M = imap(@save, M); 708 710 711 if( !defined(M) ) 712 { 713 def M = imap(@save, M); 714 } 715 716 module F = freemodule(@RANK); intvec @V = deg(F[1..@RANK]); kill F; 717 709 718 attrib(M, "isHomog", @V); 710 719 attrib(M, "isSB", 1); 711 720 attrib(M, "degrees", @DEGS); 712 721 713 def LEAD = imap(@save, LEAD); 722 if( !defined(LEAD) ) 723 { 724 def LEAD = imap(@save, LEAD); 725 } 714 726 715 727 attrib(LEAD, "isHomog", @V); 716 728 attrib(LEAD, "isSB", 1); 717 729 718 def TAIL = imap(@save, TAIL); 730 if( !defined(TAIL) ) 731 { 732 def TAIL = imap(@save, TAIL); 733 } 719 734 720 735 if( @DEBUG ) … … 724 739 attrib(M); 725 740 attrib(M, "isHomog"); 726 // DetailedPrint(M);727 741 } 728 742 … … 734 748 transpose( transpose(M) * transpose(MRES) ); 735 749 "ERROR: transpose( transpose(M) * transpose(MRES) ) != 0!!!"; 736 m2_end(666);750 Syzextra::m2_end(666); 737 751 } 738 752 } … … 765 779 } 766 780 767 768 781 if( typeof( attrib(SSinit, "HYBRIDNF") ) == "int" ) 769 782 { … … 773 786 attrib(S, "HYBRIDNF", 0); 774 787 } 775 788 789 // maybe resetting existing ring attributes! 776 790 attrib(S, "DEBUG", @DEBUG); 777 791 attrib(S, "SYZCHECK", @SYZCHECK); … … 785 799 "SSinit::MRES"; 786 800 MRES; 787 // DetailedPrint(MRES);801 // Syzextra::DetailedPrint(MRES); 788 802 attrib(MRES, "isHomog"); 789 803 attrib(S); … … 860 874 } 861 875 862 module SS = ComputeLeadingSyzygyTerms(L);876 module SS = Syzextra::ComputeLeadingSyzygyTerms(L); 863 877 864 878 if( @KERCHECK ) … … 878 892 { 879 893 a = L[i]; 880 c = leadcomp(a);894 c = Syzextra::leadcomp(a); 881 895 r = int(c); 882 896 883 aa = leadmonomial(a);897 aa = Syzextra::leadmonomial(a); 884 898 885 899 M = 0; … … 889 903 b = L[j]; 890 904 891 if( leadcomp(b) == c )905 if( Syzextra::leadcomp(b) == c ) 892 906 { 893 bb = leadmonomial(b);907 bb = Syzextra::leadmonomial(b); 894 908 895 909 M[j] = (lcm(aa, bb) / aa); … … 915 929 916 930 "basering: "; basering; 917 // DetailedPrint(basering);931 // Syzextra::DetailedPrint(basering); 918 932 919 933 "S: "; S; 920 // DetailedPrint(_, 1);934 // Syzextra::DetailedPrint(_, 1); 921 935 "SS: "; SS; 922 // DetailedPrint(_, 1);936 // Syzextra::DetailedPrint(_, 1); 923 937 924 938 "DIFF: "; 925 939 module(matrix(S) - matrix(SS)); 926 // DetailedPrint(_, 2);940 // Syzextra::DetailedPrint(_, 2); 927 941 print(matrix(S) - matrix(SS)); 928 m2_end(666);942 Syzextra::m2_end(666); 929 943 } 930 944 } … … 979 993 } 980 994 981 module SS = Compute2LeadingSyzygyTerms(L);995 module SS = Syzextra::Compute2LeadingSyzygyTerms(L); 982 996 983 997 if( @DEBUG ) … … 994 1008 transpose( transpose(SS) * transpose(L) ); 995 1009 "ERROR: transpose( transpose(SS) * transpose(L) ) != 0!!!"; 996 m2_end(666);1010 Syzextra::m2_end(666); 997 1011 } 998 1012 } … … 1023 1037 a = L[i]; 1024 1038 // "a: ", a; 1025 c = leadcomp(a);1039 c = Syzextra::leadcomp(a); 1026 1040 r = int(c); 1027 1041 1028 aa = leadmonomial(a);1042 aa = Syzextra::leadmonomial(a); 1029 1043 1030 1044 M = 0; … … 1035 1049 // "b: ", b; 1036 1050 1037 if( leadcomp(b) == c )1051 if( Syzextra::leadcomp(b) == c ) 1038 1052 { 1039 bb = leadmonomial(b);1053 bb = Syzextra::leadmonomial(b); 1040 1054 @lcm = lcm(aa, bb); 1041 1055 … … 1078 1092 transpose( transpose(S) * transpose(L) ); 1079 1093 "ERROR: transpose( transpose(S) * transpose(L) ) != 0!!!"; 1080 m2_end(666);1094 Syzextra::m2_end(666); 1081 1095 } 1082 1096 } … … 1087 1101 "ERROR: SSCompute2LeadingSyzygyTerms: size(S) != size(SS)"; 1088 1102 1089 "basering: "; basering; // DetailedPrint(basering);1103 "basering: "; basering; // Syzextra::DetailedPrint(basering); 1090 1104 1091 1105 "S: "; S; 1092 // DetailedPrint(S, 2);1106 // Syzextra::DetailedPrint(S, 2); 1093 1107 "SS: "; SS; 1094 // DetailedPrint(SS, 2);1095 m2_end(666);1108 // Syzextra::DetailedPrint(SS, 2); 1109 Syzextra::m2_end(666); 1096 1110 } 1097 1111 … … 1103 1117 1104 1118 "basering: "; basering; 1105 // DetailedPrint(basering);1119 // Syzextra::DetailedPrint(basering); 1106 1120 1107 1121 "lead(S ): "; lead(S ); 1108 // DetailedPrint(_, 2);1122 // Syzextra::DetailedPrint(_, 2); 1109 1123 "lead(SS): "; lead(SS); 1110 // DetailedPrint(_, 2);1124 // Syzextra::DetailedPrint(_, 2); 1111 1125 1112 1126 "DIFF: "; 1113 1127 print( matrix(lead(S)) - matrix(lead(SS)) ); 1114 1128 module(matrix(lead(S)) - matrix(lead(SS))); 1115 // DetailedPrint(_ , 4);1116 m2_end(666);1129 // Syzextra::DetailedPrint(_ , 4); 1130 Syzextra::m2_end(666); 1117 1131 } 1118 1132 … … 1120 1134 if( @TAILREDSYZ ) 1121 1135 { 1122 if( size(module(matrix( Tail(S)) - matrix(Tail(SS)))) > 0 )1136 if( size(module(matrix( Syzextra::Tail(S)) - matrix( Syzextra::Tail(SS)))) > 0 ) 1123 1137 { 1124 1138 "ERROR: SSCompute2LeadingSyzygyTerms: Tail(S) != Tail(SS) "; 1125 1139 1126 1140 "basering: "; basering; 1127 // DetailedPrint(basering);1128 1129 "Tail(S ): "; Tail(S );1130 // DetailedPrint(_, 2);1131 "Tail(SS): "; Tail(SS);1132 // DetailedPrint(_, 2);1141 // Syzextra::DetailedPrint(basering); 1142 1143 "Tail(S ): "; Syzextra::Tail(S ); 1144 // Syzextra::DetailedPrint(_, 2); 1145 "Tail(SS): "; Syzextra::Tail(SS); 1146 // Syzextra::DetailedPrint(_, 2); 1133 1147 1134 1148 "DIFF: "; 1135 module( matrix( Tail(S)) - matrix(Tail(SS)) );1136 // DetailedPrint(_, 4);1137 print( matrix( Tail(S)) - matrix(Tail(SS)) );1138 m2_end(666);1149 module( matrix( Syzextra::Tail(S)) - matrix( Syzextra::Tail(SS)) ); 1150 // Syzextra::DetailedPrint(_, 4); 1151 print( matrix( Syzextra::Tail(S)) - matrix( Syzextra::Tail(SS)) ); 1152 Syzextra::m2_end(666); 1139 1153 } 1140 1154 } … … 1142 1156 } 1143 1157 1144 module S2 = Tail(SS);1158 module S2 = Syzextra::Tail(SS); 1145 1159 SS = lead(SS); // (C,lp) on base ring! 1146 1160 … … 1153 1167 type(S2); 1154 1168 L; 1155 m2_end(666);1169 Syzextra::m2_end(666); 1156 1170 } 1157 1171 } … … 1214 1228 if( @DEBUG && (syzterm != 0) ) 1215 1229 { 1216 def @@c = leadcomp(syzterm); int @@r = int(@@c);1217 def @@product = leadmonomial(syzterm) * L[@@r];1230 def @@c = Syzextra::leadcomp(syzterm); int @@r = int(@@c); 1231 def @@product = Syzextra::leadmonomial(syzterm) * L[@@r]; 1218 1232 1219 1233 if( @@product != product) … … 1221 1235 "product: ", product, ", @@product: ", @@product; 1222 1236 "ERROR: 'syzterm' results in wrong product !!!???"; 1223 m2_end(666);1237 Syzextra::m2_end(666); 1224 1238 } 1225 1239 } … … 1227 1241 if( typeof(#[1]) == "module" ) 1228 1242 { 1229 vector my = FindReducer(product, syzterm, L/*, T*/, #[1]);1243 vector my = Syzextra::FindReducer(product, syzterm, L/*, T*/, #[1]); 1230 1244 } else 1231 1245 { 1232 vector my = FindReducer(product, syzterm, L/*, T*/);1246 vector my = Syzextra::FindReducer(product, syzterm, L/*, T*/); 1233 1247 } 1234 1248 … … 1236 1250 if( @KERCHECK ) 1237 1251 { 1238 bigint c = leadcomp(product); int r = int(c);1252 bigint c = Syzextra::leadcomp(product); int r = int(c); 1239 1253 1240 1254 def a, b, bb; … … 1247 1261 a = L[k]; 1248 1262 // with the same mod. component 1249 if( leadcomp(a) == c )1263 if( Syzextra::leadcomp(a) == c ) 1250 1264 { 1251 b = - ( leadmonomial(product) /leadmonomial(L[k]));1265 b = - ( Syzextra::leadmonomial(product) / Syzextra::leadmonomial(L[k])); 1252 1266 1253 1267 // which divides the product: looking for the 1st appropriate one! … … 1287 1301 if( my != nf ) 1288 1302 { 1289 "ERROR in FindReducer => ", my, " != nf: ", nf;1290 m2_end(666);1303 "ERROR in Syzextra::FindReducer => ", my, " != nf: ", nf; 1304 Syzextra::m2_end(666); 1291 1305 } 1292 1306 } … … 1346 1360 if( @SYZCHECK && (syzterm != 0) ) 1347 1361 { 1348 def @@c = leadcomp(syzterm); int @@r = int(@@c);1349 poly @@m = leadmonomial(syzterm); def @@t = L[@@r];1362 def @@c = Syzextra::leadcomp(syzterm); int @@r = int(@@c); 1363 poly @@m = Syzextra::leadmonomial(syzterm); def @@t = L[@@r]; 1350 1364 1351 1365 if( (@@m != m) || (@@t != t)) … … 1354 1368 "@@m: ", @@m, ", @@t: ", @@t; 1355 1369 "ERROR: 'syzterm' results in wrong m * t !!!"; 1356 m2_end(666);1370 Syzextra::m2_end(666); 1357 1371 } 1358 1372 } … … 1360 1374 if( typeof(#[1]) == "module" ) 1361 1375 { 1362 vector ss = ReduceTerm(m, t, syzterm, L, T, #[1]);1376 vector ss = Syzextra::ReduceTerm(m, t, syzterm, L, T, #[1]); 1363 1377 } else 1364 1378 { 1365 vector ss = ReduceTerm(m, t, syzterm, L, T);1379 vector ss = Syzextra::ReduceTerm(m, t, syzterm, L, T); 1366 1380 } 1367 1381 … … 1380 1394 if( size(s) != 0 ) 1381 1395 { 1382 poly @b = leadmonomial(s);1383 1384 def @c = leadcomp(s); int k = int(@c);1396 poly @b = Syzextra::leadmonomial(s); 1397 1398 def @c = Syzextra::leadcomp(s); int k = int(@c); 1385 1399 1386 1400 if( @TREEOUTPUT ){ "\CHILD{", (s), "}{", ( @b*L[k]), "}"; } … … 1392 1406 if( s != ss ) 1393 1407 { 1394 "ERROR in ReduceTerm => old: ", s, " != ker: ", ss;1408 "ERROR in Syzextra::ReduceTerm => old: ", s, " != ker: ", ss; 1395 1409 "m: ", m; 1396 1410 "t: ", t; 1397 1411 "syzterm: ", syzterm; 1398 1412 L; T; #; 1399 m2_end(666);1413 Syzextra::m2_end(666); 1400 1414 } 1401 1415 } … … 1445 1459 if( typeof(#[1]) == "module" ) 1446 1460 { 1447 vector ss = TraverseTail(m, @tail, L, T, #[1]);1461 vector ss = Syzextra::TraverseTail(m, @tail, L, T, #[1]); 1448 1462 } else 1449 1463 { 1450 vector ss = TraverseTail(m, @tail, L, T);1464 vector ss = Syzextra::TraverseTail(m, @tail, L, T); 1451 1465 } 1452 1466 … … 1468 1482 if( s != ss ) 1469 1483 { 1470 "ERROR in TraverseTail => old: ", s, " != ker: ", ss;1484 "ERROR in Syzextra::TraverseTail => old: ", s, " != ker: ", ss; 1471 1485 "m: ", m; 1472 1486 "@tail: ", @tail; 1473 1487 L; T; #; 1474 m2_end(666);1488 Syzextra::m2_end(666); 1475 1489 } 1476 1490 } … … 1521 1535 if( typeof(#[1]) == "module" ) 1522 1536 { 1523 def my = SchreyerSyzygyNF(syz_lead, syz_2, L, T, #[1]);1537 def my = Syzextra::SchreyerSyzygyNF(syz_lead, syz_2, L, T, #[1]); 1524 1538 } else 1525 1539 { 1526 def my = SchreyerSyzygyNF(syz_lead, syz_2, L, T);1540 def my = Syzextra::SchreyerSyzygyNF(syz_lead, syz_2, L, T); 1527 1541 } 1528 1542 … … 1531 1545 int @TREEOUTPUT = attrib(basering, "TREEOUTPUT"); 1532 1546 1533 def spoly = leadmonomial(syz_lead) * T[int(leadcomp(syz_lead))]1534 + leadmonomial(syz_2) * T[int(leadcomp(syz_2))];1547 def spoly = Syzextra::leadmonomial(syz_lead) * T[int( Syzextra::leadcomp(syz_lead))] 1548 + Syzextra::leadmonomial(syz_2) * T[int( Syzextra::leadcomp(syz_2))]; 1535 1549 1536 1550 vector @tail = syz_2; … … 1540 1554 while (size(spoly) > 0) 1541 1555 { 1542 syz_2 = SSFindReducer(lead(spoly), 0, L, #); spoly = Tail(spoly);1556 syz_2 = SSFindReducer(lead(spoly), 0, L, #); spoly = Syzextra::Tail(spoly); 1543 1557 1544 1558 if( size(syz_2) != 0) 1545 1559 { 1546 @b = leadmonomial(syz_2);1547 k = int( leadcomp(syz_2));1560 @b = Syzextra::leadmonomial(syz_2); 1561 k = int( Syzextra::leadcomp(syz_2)); 1548 1562 1549 1563 if( @TREEOUTPUT ){ "\CHILD{", (syz_2), "}{", ( lead(spoly)), "}"; } … … 1557 1571 if( my != @tail ) 1558 1572 { 1559 "ERROR in SchreyerSyzygyNF => old: ", @tail, " != ker: ", my;1573 "ERROR in Syzextra::SchreyerSyzygyNF => old: ", @tail, " != ker: ", my; 1560 1574 1561 1575 "syzygy_lead: ", syz_lead; … … 1563 1577 1564 1578 L; T; #; 1565 m2_end(666);1579 Syzextra::m2_end(666); 1566 1580 } 1567 1581 } … … 1583 1597 static proc SSComputeSyzygy(def L, def T) 1584 1598 { 1585 // rtimer, "***TIMESNAP0 for ComputeSyzygy(L,T): on level: [",attrib(basering,"SYZNUMBER"),"] :: t: ", timer, ", r: ", rtimer;1599 // rtimer, "***TIMESNAP0 for Syzextra::ComputeSyzygy(L,T): on level: [",attrib(basering,"SYZNUMBER"),"] :: t: ", timer, ", r: ", rtimer; 1586 1600 int @DEBUG = attrib(basering, "DEBUG"); 1587 1601 int @KERCHECK = attrib(basering, "KERCHECK"); … … 1592 1606 "SSComputeSyzygy::Input"; 1593 1607 "basering: ", basering; attrib(basering); 1594 // DetailedPrint(basering);1608 // Syzextra::DetailedPrint(basering); 1595 1609 1596 1610 // "iCompShift: ", iCompShift; … … 1601 1615 1602 1616 // option(prot); 1603 // rtimer, "***TIME for ComputeSyzygy(L,T): on level: [",attrib(basering,"SYZNUMBER"),"] :: t: ", timer, ", r: ", rtimer;1604 list @res= ComputeSyzygy(L,T);1605 // rtimer, "***TIME for ComputeSyzygy(L,T): on level: [",attrib(basering,"SYZNUMBER"),"] :: t: ", timer, ", r: ", rtimer;1617 // rtimer, "***TIME for Syzextra::ComputeSyzygy(L,T): on level: [",attrib(basering,"SYZNUMBER"),"] :: t: ", timer, ", r: ", rtimer; 1618 list @res= Syzextra::ComputeSyzygy(L,T); 1619 // rtimer, "***TIME for Syzextra::ComputeSyzygy(L,T): on level: [",attrib(basering,"SYZNUMBER"),"] :: t: ", timer, ", r: ", rtimer; 1606 1620 // option(noprot); // TODO: restore! 1607 1621 … … 1645 1659 type(LL); 1646 1660 type(@LL); 1647 m2_end(666);1661 Syzextra::m2_end(666); 1648 1662 } 1649 1663 … … 1656 1670 type(LL); 1657 1671 type(@LL); 1658 m2_end(666);1672 Syzextra::m2_end(666); 1659 1673 } 1660 1674 … … 1682 1696 if( !@IGNORETAILS ) 1683 1697 { 1684 c = leadcomp(a); r = int(c); aa =leadmonomial(a);1698 c = Syzextra::leadcomp(a); r = int(c); aa = Syzextra::leadmonomial(a); 1685 1699 1686 1700 if( @TREEOUTPUT ){ "\ROOT{", (lead(a)), "}"; } … … 1694 1708 if( @LEAD2SYZ ) // with the 2nd syz. term: 1695 1709 { 1696 a2 = LL2[k]; c = leadcomp(a2); r = int(c); aa =leadmonomial(a2);1710 a2 = LL2[k]; c = Syzextra::leadcomp(a2); r = int(c); aa = Syzextra::leadmonomial(a2); 1697 1711 1698 1712 if( @TREEOUTPUT ){ "\CHILD{", (lead(a2)), "}{", ( aa*L[r]), "}"; } … … 1721 1735 { 1722 1736 "ERROR in SSComputeSyzygy: could not find the 2nd syzygy term during the hybrid NF!!!"; 1723 m2_end(666);1737 Syzextra::m2_end(666); 1724 1738 } 1725 1739 } … … 1753 1767 // transpose( transpose(N) * transpose(MRES) ); 1754 1768 1755 m2_end(666);1769 Syzextra::m2_end(666); 1756 1770 } 1757 1771 … … 1770 1784 type(TT); 1771 1785 type(@TT); 1772 m2_end(666);1786 Syzextra::m2_end(666); 1773 1787 } 1774 1788 … … 1783 1797 type(LL); 1784 1798 type(@LL); 1785 m2_end(666);1799 Syzextra::m2_end(666); 1786 1800 } 1787 1801 … … 1804 1818 } 1805 1819 1806 // rtimer, "***TIMESNAP1 for ComputeSyzygy(L,T): on level: [",attrib(basering,"SYZNUMBER"),"] :: t: ", timer, ", r: ", rtimer;1820 // rtimer, "***TIMESNAP1 for Syzextra::ComputeSyzygy(L,T): on level: [",attrib(basering,"SYZNUMBER"),"] :: t: ", timer, ", r: ", rtimer; 1807 1821 return (@SYZ, @LL, @TT); 1808 1822 } … … 1826 1840 def L = lead(M); 1827 1841 intvec @V = deg(M[1..ncols(M)]); @W; @V; @W = @V; attrib(L, "isHomog", @W); 1828 SetInducedReferrence(L, @RANK, 0);1842 Syzextra::SetInducedReferrence(L, @RANK, 0); 1829 1843 */ 1830 1844 … … 1835 1849 1836 1850 // General setting: 1837 // SetInducedReferrence(MRES, 0, 0); // limit: 0!1851 // Syzextra::SetInducedReferrence(MRES, 0, 0); // limit: 0! 1838 1852 int @l = size(RES); 1839 1853 … … 1868 1882 @V; 1869 1883 @RANK; 1870 // DetailedPrint(MRES);1884 // Syzextra::DetailedPrint(MRES); 1871 1885 attrib(MRES, "isHomog"); 1872 1886 } … … 1892 1906 "MRES", MRES; 1893 1907 1894 "N: "; N; // DetailedPrint(N, 2);1895 1896 "LL:"; LL; // DetailedPrint(LL, 1);1897 "TT:"; TT; // DetailedPrint(TT, 10);1908 "N: "; N; // Syzextra::DetailedPrint(N, 2); 1909 1910 "LL:"; LL; // Syzextra::DetailedPrint(LL, 1); 1911 "TT:"; TT; // Syzextra::DetailedPrint(TT, 10); 1898 1912 1899 1913 "RANKS: ", @RANK; … … 1904 1918 "transpose(N) * transpose(MRES): "; 1905 1919 transpose(N) * transpose(MRES); 1906 // DetailedPrint(module(_), 2);1907 m2_end(666);1920 // Syzextra::DetailedPrint(module(_), 2); 1921 Syzextra::m2_end(666); 1908 1922 } 1909 1923 } … … 1932 1946 "SSstep::NextSyzOutput: "; 1933 1947 N; 1934 // DetailedPrint(N);1948 // Syzextra::DetailedPrint(N); 1935 1949 attrib(N); 1936 1950 } … … 1954 1968 1955 1969 /// TODO! 1956 // def data = GetInducedData();1970 // def data = Syzextra::GetInducedData(); 1957 1971 1958 1972 if( (!defined(RES)) || (!defined(MRES)) ) /* || (typeof(data) != "list") || (size(data) != 2) */ … … 2128 2142 } 2129 2143 2130 // cannot be automatically used via overloading :(2131 proc SRES_list(SRES SR)2132 "TODO!"2133 {2134 def save = basering;2135 def R = SR.r;2136 2137 if( 0 ) // ( save == R ) // TODO: not implemented :(((2138 {2139 list L = SR.rsltn;2140 return (L);2141 }2142 2143 setring R;2144 list L = SR.rsltn;2145 setring save;2146 return (imap( R, L ));2147 }2148 2149 2144 static proc SRES_minres(SRES SR) 2150 2145 { … … 2153 2148 def R = SR.r; S.r = R; 2154 2149 setring R; 2155 S.rsltn = minres(SR.rsltn); 2150 S.rsltn = minres(SR.rsltn); // in target ring :( 2156 2151 return (S); 2157 2152 } 2158 2153 2159 static proc loadme() 2160 { 2161 int @DEBUG = 0; // !system("with", "ndebug"); 2162 2163 if( @DEBUG ) 2164 { 2154 2155 // cannot be automatically used via overloading :( 2156 proc SRES_list(def SR) 2157 "USAGE: SRES_list(resolution) 2158 RETURN: list 2159 PURPOSE: convert given resolution to a list 2160 NOTE: result is over basering 2161 SEE ALSO: s_res, resolution 2162 EXAMPLE: example s_res; shows an example 2163 " 2164 { 2165 if( typeof(SR) != "SRES" ) 2166 { 2167 list @@@L = SR; 2168 return (@@@L); 2169 } 2170 2171 def save = basering; 2172 def R = SR.r; 2173 2174 // if( 0 ) // ( save == R ) // TODO: not implemented :((( 2175 // { list L = SR.rsltn; return (L); } 2165 2176 2166 // "ndebug?: ", system("with", "ndebug"); 2167 // "om_ndebug?: ", system("with", "om_ndebug"); 2168 2169 listvar(Syzextra); 2170 listvar(Schreyer); 2171 listvar(Top); 2172 } 2173 2174 if( !defined(Schreyer::DetailedPrint) ) 2175 { 2176 if( 1 ) 2177 { 2178 /* 2179 if( system("with", "ndebug") ) 2180 { 2181 "Loading the Debug version!"; 2182 } else 2183 { 2184 "Loading the Release version!"; 2185 } 2186 */ 2177 setring R; 2178 2179 list @@@L = SR.rsltn; 2180 setring save; 2181 return (imap( R, @@@L )); 2182 } 2183 2184 static proc mod_init() 2185 { 2186 int @DEBUG = 0; // !system("with", "ndebug"); // "om_ndebug?: ", system("with", "om_ndebug"); 2187 2188 if( @DEBUG ) { listvar(Top); } 2189 2190 if( !defined(SRES) ) 2191 { 2187 2192 load("syzextra.so"); 2188 2193 2189 if( @DEBUG ) 2190 { 2191 listvar(Syzextra); 2192 } 2194 if( @DEBUG ){ listvar(Syzextra); } 2193 2195 2194 // exportto(Top, Syzextra::ClearContent); 2195 // exportto(Top, Syzextra::ClearDenominators); 2196 exportto(Schreyer, Syzextra::m2_end); 2197 2198 // export Syzextra; 2199 2200 // exportto(Schreyer, Syzextra::noop); 2201 exportto(Schreyer, Syzextra::DetailedPrint); 2202 exportto(Schreyer, Syzextra::leadmonomial); 2203 exportto(Schreyer, Syzextra::leadcomp); 2204 // exportto(Schreyer, Syzextra::leadrawexp); 2205 // exportto(Schreyer, Syzextra::ISUpdateComponents); 2206 exportto(Schreyer, Syzextra::SetInducedReferrence); 2207 exportto(Schreyer, Syzextra::GetInducedData); 2208 // exportto(Schreyer, Syzextra::GetAMData); 2209 // exportto(Schreyer, Syzextra::SetSyzComp); 2210 exportto(Schreyer, Syzextra::MakeInducedSchreyerOrdering); 2211 // exportto(Schreyer, Syzextra::MakeSyzCompOrdering); 2212 exportto(Schreyer, Syzextra::idPrepare); 2213 // exportto(Schreyer, Syzextra::reduce_syz); 2214 // exportto(Schreyer, Syzextra::p_Content); 2215 2216 exportto(Schreyer, Syzextra::ProfilerStart); exportto(Schreyer, Syzextra::ProfilerStop); 2217 2218 exportto(Schreyer, Syzextra::Tail); 2219 exportto(Schreyer, Syzextra::ComputeLeadingSyzygyTerms); 2220 exportto(Schreyer, Syzextra::Compute2LeadingSyzygyTerms); 2221 exportto(Schreyer, Syzextra::Sort_c_ds); 2222 2223 exportto(Schreyer, Syzextra::FindReducer); 2224 2225 exportto(Schreyer, Syzextra::ReduceTerm); 2226 exportto(Schreyer, Syzextra::TraverseTail); 2227 2228 exportto(Schreyer, Syzextra::SchreyerSyzygyNF); 2229 exportto(Schreyer, Syzextra::ComputeSyzygy); 2230 2231 exportto(Schreyer, Syzextra::ComputeResolution); 2232 2233 exportto(Schreyer, Syzextra::NumberStatsInit); 2234 exportto(Schreyer, Syzextra::NumberStatsPrint); 2235 2236 newstruct("SRES","ring r,resolution rsltn"); // http://www.singular.uni-kl.de/Manual/latest/sing_179.htm#SEC218 2237 // TODO: SSres - return SRESOLUTION? 2238 2196 // exportto(Top, Syzextra::ClearContent); // exportto(Top, Syzextra::ClearDenominators); exportto(Schreyer, Syzextra::noop); 2197 // exportto(Schreyer, Syzextra::leadrawexp); // exportto(Schreyer, Syzextra::ISUpdateComponents); 2198 // exportto(Schreyer, Syzextra::GetAMData);// exportto(Schreyer, Syzextra::SetSyzComp); 2199 // exportto(Schreyer, Syzextra::MakeSyzCompOrdering); // exportto(Schreyer, Syzextra::reduce_syz);// exportto(Schreyer, Syzextra::p_Content); 2200 2201 // exportto(Schreyer, Syzextra::DetailedPrint); 2202 // exportto(Schreyer, Syzextra::m2_end); 2203 // exportto(Schreyer, Syzextra::leadmonomial); 2204 // exportto(Schreyer, Syzextra::leadcomp); 2205 // exportto(Schreyer, Syzextra::SetInducedReferrence); 2206 // exportto(Schreyer, Syzextra::GetInducedData); 2207 // exportto(Schreyer, Syzextra::MakeInducedSchreyerOrdering); 2208 // exportto(Schreyer, Syzextra::idPrepare); 2209 // exportto(Schreyer, Syzextra::ProfilerStart); exportto(Schreyer, Syzextra::ProfilerStop); 2210 // exportto(Schreyer, Syzextra::NumberStatsInit); exportto(Schreyer, Syzextra::NumberStatsPrint); 2211 // exportto(Schreyer, Syzextra::Tail); 2212 // exportto(Schreyer, Syzextra::ComputeLeadingSyzygyTerms); 2213 // exportto(Schreyer, Syzextra::Compute2LeadingSyzygyTerms); 2214 // exportto(Schreyer, Syzextra::Sort_c_ds); 2215 // exportto(Schreyer, Syzextra::FindReducer); 2216 // exportto(Schreyer, Syzextra::ReduceTerm); 2217 // exportto(Schreyer, Syzextra::TraverseTail); 2218 // exportto(Schreyer, Syzextra::SchreyerSyzygyNF); 2219 // exportto(Schreyer, Syzextra::ComputeSyzygy); 2220 // exportto(Schreyer, Syzextra::ComputeResolution); 2221 2222 // TODO: SSres - return SRESOLUTION? 2223 newstruct("SRES","ring r,resolution rsltn"); // http://www.singular.uni-kl.de/Manual/latest/sing_179.htm#SEC218 2239 2224 // system("install","SRES","string",SRES_string, 1); 2240 system("install","SRES","print",SRES_print, 1); 2241 2242 system("install","SRES","betti",SRES_betti1, 1); // http://www.singular.uni-kl.de/Manual/latest/sing_260.htm#SEC299 2243 system("install","SRES","betti",SRES_betti2, 2); // http://www.singular.uni-kl.de/Manual/latest/sing_260.htm#SEC299 2244 system("install","SRES","minres",SRES_minres, 1); // http://www.singular.uni-kl.de/Manual/latest/sing_344.htm#SEC383 2245 2246 // system("install","SRES","list", SRES_list, 1); // will never work :((( 2247 2248 // TODO: SSsyz? SSYZYGY? // TODO: C/C++ computation for Syzygy? 2249 // newstruct("SSYZ","ring r,module szg"); // http://www.singular.uni-kl.de/Manual/latest/sing_179.htm#SEC218 2250 // system("install","SSYZYGY","string",SSYZYGY_string, 1); 2251 // system("install","SSYZYGY","print",SSYZYGY_print, 1); 2252 // system("install","SSYZYGY","module",SSYZYGY_module, 1); 2253 } 2254 2255 // exportto(Top, DetailedPrint); 2256 // exportto(Top, GetInducedData); 2257 2258 if( @DEBUG ) 2259 { 2260 listvar(Top); 2261 listvar(Schreyer); 2262 } 2263 } 2264 2265 mod_assure_load(); 2266 } 2267 2268 2269 2270 static proc mod_assure_load() 2271 { 2272 if( !defined(GetInducedData) ) 2273 { 2274 "ERROR: Sorry but we are missing the dynamic module (syzextra.so)..."; 2275 $ 2276 // m2_end(666); // :( 2277 } 2278 } 2279 2280 static proc mod_init() 2281 { 2282 loadme(); 2225 system("install","SRES","print",SRES_print, 1); 2226 system("install","SRES","betti",SRES_betti1, 1); // http://www.singular.uni-kl.de/Manual/latest/sing_260.htm#SEC299 2227 system("install","SRES","betti",SRES_betti2, 2); // http://www.singular.uni-kl.de/Manual/latest/sing_260.htm#SEC299 2228 system("install","SRES","minres",SRES_minres, 1); // http://www.singular.uni-kl.de/Manual/latest/sing_344.htm#SEC383 2229 system("install","SRES","list", SRES_list, 1); // will never work :((( 2230 2231 // exportto(Top, s_res); // Syzextra::GetInducedData); 2232 2233 if( @DEBUG ) { listvar(Top); listvar(Schreyer); } 2234 } 2283 2235 } 2284 2236 … … 2395 2347 2396 2348 "ERROR: There were some wrong betti numbers... "; 2397 // m2_end(666);2349 // Syzextra::m2_end(666); 2398 2350 } else 2399 2351 { … … 2494 2446 { 2495 2447 "ERROR: non-square M!!!"; 2496 m2_end(666);2448 Syzextra::m2_end(666); 2497 2449 } 2498 2450 … … 2504 2456 "MRES': "; M; print(M); 2505 2457 2506 m2_end(666);2458 Syzextra::m2_end(666); 2507 2459 } 2508 2460 // "MRES': "; M; print(M); … … 2511 2463 { 2512 2464 "ERROR: wrong starting zero module!!!"; 2513 m2_end(666);2465 Syzextra::m2_end(666); 2514 2466 } 2515 2467 … … 2544 2496 2545 2497 option(redSB); option(redTail); 2546 if(@PROFILE){ ProfilerStart(@prof);}2498 if(@PROFILE){ Syzextra::ProfilerStart(@prof);} 2547 2499 timer=0;rtimer=0;def R=SSres(I,0);@m=rtimer; 2548 if(@PROFILE){ ProfilerStop();}2500 if(@PROFILE){ Syzextra::ProfilerStop();} 2549 2501 setring R;module M;list @l=list();@l[size(RES)-1]=list();r=nrows(RES[1]);for(i=2;i<=size(RES);i++){M=RES[i];rr=nrows(M);if((r>0)&&(size(M)>0)&&(r<rr)){M=transpose(M);M=M[(r+1)..ncols(M)];M=transpose(M);RES[i]=M;};r=rr;@l[i-1] = M;};resolution RR=@l;RR=minres(RR);def S=betti(RR,1);@t=rtimer; 2550 // DetailedPrint(RR,0);2502 // Syzextra::DetailedPrint(RR,0); 2551 2503 SCheck(R); 2552 2504 StopAddResTest(RR, S, @t,@m); … … 2556 2508 proc s_res(def I, int l) 2557 2509 "USAGE: s_res(ideal/module M, int len) 2558 RETURN: SRES, a blackbox object containing a (part of) Schreyer resolution2510 RETURN: resolution object or SRES 2559 2511 PURPOSE: compute a Schreyer resolution of M of length at most len (see [BMSS]) 2560 2512 NOTE: If given len is zero then nvars(basering) + 1 is used instead. 2561 @* SRES can be printed, treated by betti and minres or converted to list & mapped into the current ring with @code{SRES_list}2562 2513 @* This functions is not related to other helpers from this library. 2563 2514 @* One can switch on computation protocol and statistic (depending on the build) by setting the @code{prot} option. … … 2569 2520 " 2570 2521 { 2571 int @prot = (find(option(),"prot") != 0) && (defined(NumberStatsInit)) && (defined(NumberStatsPrint)); 2572 def R=SSinit(I); setring R; int @l = size(RES); 2573 SRES ret; ret.r = R; 2574 if(@prot){ NumberStatsInit(); } 2575 ret.rsltn = ComputeResolution(RES[@l], LRES[@l], TRES[@l], l); 2576 if(@prot){ NumberStatsPrint("Number statistic for s_res with ComputeResolution"); } 2522 int @prot = (find(option(),"prot") != 0) && (defined( Syzextra::NumberStatsInit)) && (defined( Syzextra::NumberStatsPrint)); 2523 def @save = basering; 2524 2525 int @RINGCHANGE = 0; 2526 2527 if( typeof( attrib(SSinit, "RINGCHANGE") ) == "int" ) 2528 { 2529 @RINGCHANGE = attrib(SSinit, "RINGCHANGE"); 2530 } 2531 2532 def R=SSinit(I); 2533 if( @RINGCHANGE ){ setring R; } 2534 2535 int @l = size(RES); 2536 if(@prot){ Syzextra::NumberStatsInit(); } 2537 def rsltn = Syzextra::ComputeResolution(RES[@l], LRES[@l], TRES[@l], l); 2538 if(@prot){ Syzextra::NumberStatsPrint("Number statistic for s_res with Syzextra::ComputeResolution"); } 2539 2540 if( !@RINGCHANGE ) 2541 { 2542 return (rsltn); // ret 2543 } 2544 2545 SRES ret; ret.r = R; ret.rsltn = rsltn; 2577 2546 return (ret); 2578 2547 } … … 2581 2550 ring R; 2582 2551 module M = maxideal(1); M; 2583 SRESrs = s_res(M, 0);2552 def rs = s_res(M, 0); 2584 2553 print(rs); 2585 2554 print(betti(rs, 0)); // non-minimal betties … … 2589 2558 } 2590 2559 2560 static proc s_res_bm(def I) 2561 { 2562 int @prot = (find(option(),"prot") != 0) && (defined( Syzextra::NumberStatsInit)) && (defined( Syzextra::NumberStatsPrint)); 2563 def @save = basering; 2564 2565 int @RINGCHANGE = 0; 2566 2567 if( typeof( attrib(SSinit, "RINGCHANGE") ) == "int" ) 2568 { 2569 @RINGCHANGE = attrib(SSinit, "RINGCHANGE"); 2570 } 2571 int t,tt,sum; 2572 2573 t=rtimer;def R=SSinit(I);tt=rtimer; 2574 2575 "%% Setup(SSinit) TIME:", tt - t; // if(@prot){ } ? 2576 int sum = (tt-t); 2577 2578 if( @RINGCHANGE ){ setring R; } 2579 2580 int @l = size(RES); 2581 module N, L, T, LL, TT; 2582 L = LRES[@l]; 2583 T = TRES[@l]; 2584 2585 2586 int ss = attrib(basering, "SYZNUMBER"); 2587 2588 while ( 1 ) 2589 { 2590 if(@prot){ Syzextra::NumberStatsInit(); } 2591 2592 // SSstep(): 2593 t=rtimer;(N,LL,TT)=SSComputeSyzygy(L,T);tt=rtimer; 2594 2595 @l = @l + 1; 2596 if(@prot){ Syzextra::NumberStatsPrint("Number statistic for SSComputeSyzygy["+string(@l-2)+"]"); } 2597 "%% SSstep[",@l-2, "] TIME:", tt - t; // if(@prot){ } ? 2598 sum = sum + (tt-t); 2599 2600 if( (size(LL) == 0) || (size(N) == 0) ) { break; } 2601 L = LL; T = TT; RES[@l] = N; // LRES[@l] = LL; TRES[@l] = TT; 2602 2603 ss = ss + 1; attrib(basering, "SYZNUMBER", ss ); 2604 } 2605 2606 "%% Whole Resolution (with "+string(@l)+"syzygies) TIME:", sum; // if(@prot){ } ? 2607 resolution rsltn = list(RES[2..size(RES)]); 2608 2609 if( !@RINGCHANGE ) 2610 { 2611 return (rsltn); // ret 2612 } 2613 2614 SRES ret; ret.r = R; ret.rsltn = rsltn; 2615 return (ret); 2616 } 2617 2618 2591 2619 static proc s_syz(def I) 2592 2620 { … … 2594 2622 int @l = size(RES); // def M = RES[@l]; 2595 2623 module N, LL, TT; (N, LL, TT) = SSComputeSyzygy(LRES[@l], TRES[@l]); 2596 SSYZ ret; ret.r = R; ret.szg = N; // Schreyer:: ComputeResolution(RES[2], LRES[2], TRES[2], 0);2624 SSYZ ret; ret.r = R; ret.szg = N; // Schreyer:: Syzextra::ComputeResolution(RES[2], LRES[2], TRES[2], 0); 2597 2625 return (ret); 2598 2626 } … … 2616 2644 2617 2645 option(redSB); option(redTail); 2618 if(@PROFILE){ ProfilerStart(@prof);}2619 timer=0;rtimer=0;def R=SSinit(I);setring R;def RR= ComputeResolution(RES[2], LRES[2], TRES[2], 0);2646 if(@PROFILE){ Syzextra::ProfilerStart(@prof);} 2647 timer=0;rtimer=0;def R=SSinit(I);setring R;def RR= Syzextra::ComputeResolution(RES[2], LRES[2], TRES[2], 0); 2620 2648 @m=rtimer; 2621 if(@PROFILE){ ProfilerStop();}2622 RR=minres(RR); def S=betti(RR,1);@t=rtimer;2623 // DetailedPrint(RR,0); print(RR); print(S, "betti");2649 if(@PROFILE){ Syzextra::ProfilerStop();} 2650 RR=minres(RR); def S=betti(RR,1);@t=rtimer; 2651 // Syzextra::DetailedPrint(RR,0); print(RR); print(S, "betti"); 2624 2652 SCheck(R); 2625 2653 StopAddResTest(RR, S, @t,@m); … … 2717 2745 static proc testSimple(list #) 2718 2746 { 2719 mod_assure_load();2720 2721 2747 def DEBUG = 0; 2722 2748 if(size(#) > 0) { DEBUG = #[1]; } -
Singular/LIB/standard.lib
r8af63a r11d9d00 1389 1389 return(nres(m,i)); 1390 1390 } 1391 1392 /* if( attrib(basering, "global") == 1 ) // preparations for s_res usage. in testing! 1393 { 1394 if (p_opt) { "using s_res";} 1395 if( !defined(s_res) ) 1396 { 1397 def @@v=option(get); option(noloadLib); option(noloadProc); LIB( "schreyer.lib" ); // for s_res 1398 option(set, @@v); kill @@v; 1399 } 1400 resolution re = s_res(m,i); 1401 if(size(#)>2) 1402 { 1403 re=minres(re); 1404 } 1405 return(re); 1406 }*/ 1391 1407 1392 1408 if(homog(m)==1) -
Singular/LIB/swalk.lib
-
Property
mode
changed from
100644
to100755
-
Property
mode
changed from
-
Singular/Makefile.am
r8af63a r11d9d00 1 ACLOCAL_AMFLAGS = -I 1 ACLOCAL_AMFLAGS = -I../m4 2 2 3 3 GIT_VERSION := $(shell $(top_srcdir)/git-version-gen $(top_srcdir)/.tarball-git-version) … … 156 156 bin_PROGRAMS = Singular ESingular TSingular $(optional_Singular_programs) 157 157 158 # the following dependency leads to Singular relinking upon a library update! 158 159 Singular ESingular TSingular $(optional_Singular_programs): ${abs_builddir}/LIB 159 160 -
Singular/extra.cc
r8af63a r11d9d00 709 709 return TRUE; 710 710 } 711 if (rField_is_Ring(currRing)) 712 { 713 WerrorS("field required"); 714 return TRUE; 715 } 711 716 matrix pMat = (matrix)h->Data(); 712 717 matrix lMat = (matrix)h->next->Data(); … … 943 948 if (h!=NULL) 944 949 { 945 res->rtyp=h->Typ(); 946 if (h->Typ()==BIGINTMAT_CMD) 947 { 948 res->data=(char *)singflint_LLL((bigintmat*)h->Data()); 949 return FALSE; 950 } 951 else if (h->Typ()==INTMAT_CMD) 952 { 953 res->data=(char *)singflint_LLL((intvec*)h->Data()); 954 return FALSE; 955 } 956 else return TRUE; 950 if(h->next == NULL) 951 { 952 res->rtyp=h->Typ(); 953 if (h->Typ()==BIGINTMAT_CMD) 954 { 955 res->data=(char *)singflint_LLL((bigintmat*)h->Data(), NULL); 956 return FALSE; 957 } 958 else if (h->Typ()==INTMAT_CMD) 959 { 960 res->data=(char *)singflint_LLL((intvec*)h->Data(), NULL); 961 return FALSE; 962 } 963 else return TRUE; 964 } 965 if(h->next->Typ()!= INT_CMD) 966 { 967 WerrorS("matrix,int or bigint,int expected"); 968 return TRUE; 969 } 970 if(h->next->Typ()== INT_CMD) 971 { 972 if(((int)((long)(h->next->Data())) != 0) && (int)((long)(h->next->Data()) != 1)) 973 { 974 WerrorS("int is different from 0, 1"); 975 return TRUE; 976 } 977 res->rtyp=h->Typ(); 978 if((long)(h->next->Data()) == 0) 979 { 980 if (h->Typ()==BIGINTMAT_CMD) 981 { 982 res->data=(char *)singflint_LLL((bigintmat*)h->Data(), NULL); 983 return FALSE; 984 } 985 else if (h->Typ()==INTMAT_CMD) 986 { 987 res->data=(char *)singflint_LLL((intvec*)h->Data(), NULL); 988 return FALSE; 989 } 990 else return TRUE; 991 } 992 // This will give also the transformation matrix U s.t. res = U * m 993 if((long)(h->next->Data()) == 1) 994 { 995 if (h->Typ()==BIGINTMAT_CMD) 996 { 997 bigintmat* m = (bigintmat*)h->Data(); 998 bigintmat* T = new bigintmat(m->rows(),m->rows(),m->basecoeffs()); 999 for(int i = 1; i<=m->rows(); i++) 1000 { 1001 n_Delete(&(BIMATELEM(*T,i,i)),T->basecoeffs()); 1002 BIMATELEM(*T,i,i)=n_Init(1, T->basecoeffs()); 1003 } 1004 m = singflint_LLL(m,T); 1005 lists L = (lists)omAllocBin(slists_bin); 1006 L->Init(2); 1007 L->m[0].rtyp = BIGINTMAT_CMD; L->m[0].data = (void*)m; 1008 L->m[1].rtyp = BIGINTMAT_CMD; L->m[1].data = (void*)T; 1009 res->data=L; 1010 res->rtyp=LIST_CMD; 1011 return FALSE; 1012 } 1013 else if (h->Typ()==INTMAT_CMD) 1014 { 1015 intvec* m = (intvec*)h->Data(); 1016 intvec* T = new intvec(m->rows(),m->rows(),(int)0); 1017 for(int i = 1; i<=m->rows(); i++) 1018 IMATELEM(*T,i,i)=1; 1019 m = singflint_LLL(m,T); 1020 lists L = (lists)omAllocBin(slists_bin); 1021 L->Init(2); 1022 L->m[0].rtyp = INTMAT_CMD; L->m[0].data = (void*)m; 1023 L->m[1].rtyp = INTMAT_CMD; L->m[1].data = (void*)T; 1024 res->data=L; 1025 res->rtyp=LIST_CMD; 1026 return FALSE; 1027 } 1028 else return TRUE; 1029 } 1030 } 1031 957 1032 } 958 1033 else return TRUE; -
Singular/ipshell.cc
r8af63a r11d9d00 2073 2073 // 0: string: integer 2074 2074 // no further entries --> Z 2075 int_number modBase = NULL;2075 mpz_ptr modBase = NULL; 2076 2076 unsigned int modExponent = 1; 2077 2077 2078 modBase = ( int_number) omAlloc(sizeof(mpz_t));2078 modBase = (mpz_ptr) omAlloc(sizeof(mpz_t)); 2079 2079 if (L->nr == 0) 2080 2080 { … … 2130 2130 { 2131 2131 //R->cf->ch = R->cf->modExponent; 2132 if ((mpz_cmp_ui(modBase, 2) == 0) && (modExponent <= 8*sizeof( NATNUMBER)))2132 if ((mpz_cmp_ui(modBase, 2) == 0) && (modExponent <= 8*sizeof(unsigned long))) 2133 2133 { 2134 2134 /* this branch should be active for modExponent = 2..32 resp. 2..64, … … 5123 5123 #ifdef HAVE_RINGS 5124 5124 //unsigned int ringtype = 0; 5125 int_number modBase = NULL;5125 mpz_ptr modBase = NULL; 5126 5126 unsigned int modExponent = 1; 5127 5127 #endif … … 5266 5266 else if ((pn->name != NULL) && (strcmp(pn->name, "integer") == 0)) 5267 5267 { 5268 modBase = ( int_number) omAlloc(sizeof(mpz_t));5268 modBase = (mpz_ptr) omAlloc(sizeof(mpz_t)); 5269 5269 mpz_init_set_si(modBase, 0); 5270 5270 if (pn->next!=NULL) … … 5309 5309 if (modExponent > 1 && cf == NULL) 5310 5310 { 5311 if ((mpz_cmp_ui(modBase, 2) == 0) && (modExponent <= 8*sizeof( NATNUMBER)))5311 if ((mpz_cmp_ui(modBase, 2) == 0) && (modExponent <= 8*sizeof(unsigned long))) 5312 5312 { 5313 5313 /* this branch should be active for modExponent = 2..32 resp. 2..64, -
Singular/number2.cc
r8af63a r11d9d00 44 44 { 45 45 ZnmInfo info; 46 mpz_ptr modBase= ( int_number) omAlloc(sizeof(mpz_t));46 mpz_ptr modBase= (mpz_ptr) omAlloc(sizeof(mpz_t)); 47 47 mpz_init_set_ui(modBase,i2); 48 48 info.base= modBase; -
Singular/walk.cc
-
Property
mode
changed from
100644
to100755
r350269 r11d9d00 431 431 #endif 432 432 433 #ifdef CHECK_IDEAL_MWALK433 //#ifdef CHECK_IDEAL_MWALK 434 434 static void idString(ideal L, const char* st) 435 435 { … … 443 443 Print(" %s;", pString(L->m[nL-1])); 444 444 } 445 #endif445 //#endif 446 446 447 447 #if defined(CHECK_IDEAL_MWALK) || defined(ENDWALKS) … … 560 560 } 561 561 return p0; 562 } 563 564 /***************************************************************************** 565 * compute the gcd of the entries of the vectors curr_weight and diff_weight * 566 *****************************************************************************/ 567 static int simplify_gcd(intvec* curr_weight, intvec* diff_weight) 568 { 569 int j; 570 int nRing = currRing->N; 571 int gcd_tmp = (*curr_weight)[0]; 572 for (j=1; j<nRing; j++) 573 { 574 gcd_tmp = gcd(gcd_tmp, (*curr_weight)[j]); 575 if(gcd_tmp == 1) 576 { 577 break; 578 } 579 } 580 if(gcd_tmp != 1) 581 { 582 for (j=0; j<nRing; j++) 583 { 584 gcd_tmp = gcd(gcd_tmp, (*diff_weight)[j]); 585 if(gcd_tmp == 1) 586 { 587 break; 588 } 589 } 590 } 591 return gcd_tmp; 562 592 } 563 593 … … 955 985 } 956 986 957 /***************************************************************************** 958 * create a weight matrix order as intvec of an extra weight vector (a(iv), lp)*959 ****************************************************************************** /987 /********************************************************************************* 988 * create a weight matrix order as intvec of an extra weight vector (a(iv),M(iw)) * 989 **********************************************************************************/ 960 990 intvec* MivMatrixOrderRefine(intvec* iv, intvec* iw) 961 991 { 962 assume( iv->length() == iw->length());963 int i, nR = iv->length();992 assume((iv->length())*(iv->length()) == iw->length()); 993 int i,j, nR = iv->length(); 964 994 965 995 intvec* ivm = new intvec(nR*nR); … … 968 998 { 969 999 (*ivm)[i] = (*iv)[i]; 970 (*ivm)[i+nR] = (*iw)[i]; 971 } 972 for(i=2; i<nR; i++) 973 { 974 (*ivm)[i*nR+i-2] = 1; 1000 } 1001 for(i=1; i<nR; i++) 1002 { 1003 for(j=0; j<nR; j++) 1004 { 1005 (*ivm)[j+i*nR] = (*iw)[j+i*nR]; 1006 } 975 1007 } 976 1008 return ivm; … … 1861 1893 } 1862 1894 1895 1896 /************************************************************** 1897 * Look for the position of the smallest absolut value in vec * 1898 **************************************************************/ 1899 static int MivAbsMaxArg(intvec* vec) 1900 { 1901 int k = MivAbsMax(vec); 1902 int i=0; 1903 while(1) 1904 { 1905 if((*vec)[i] == k || (*vec)[i] == -k) 1906 { 1907 break; 1908 } 1909 i++; 1910 } 1911 return i; 1912 } 1913 1914 1863 1915 /********************************************************************** 1864 1916 * Compute a next weight vector between curr_weight and target_weight * … … 1875 1927 1876 1928 int nRing = currRing->N; 1877 int checkRed, j, kkk,nG = IDELEMS(G);1929 int checkRed, j, nG = IDELEMS(G); 1878 1930 intvec* ivtemp; 1879 1931 … … 1913 1965 mpz_init(dcw); 1914 1966 1915 //int tn0, tn1, tz1, ncmp, gcd_tmp, ntmp;1916 1967 int gcd_tmp; 1917 1968 intvec* diff_weight = MivSub(target_weight, curr_weight); … … 1919 1970 intvec* diff_weight1 = MivSub(target_weight, curr_weight); 1920 1971 poly g; 1921 //poly g, gw; 1972 1922 1973 for (j=0; j<nG; j++) 1923 1974 { … … 1981 2032 } 1982 2033 } 1983 //Print("\n// Alloc Size = %d \n", nRing*sizeof(mpz_t));2034 //Print("\n// Alloc Size = %d \n", nRing*sizeof(mpz_t)); 1984 2035 mpz_t *vec=(mpz_t*)omAlloc(nRing*sizeof(mpz_t)); 1985 2036 1986 2037 1987 // there is no 0<t<1 and define the next weight vector that is equal to the current weight vector 2038 // there is no 0<t<1 and define the next weight vector that is equal 2039 // to the current weight vector 1988 2040 if(mpz_cmp(t_nenner, t_null) == 0) 1989 2041 { … … 2056 2108 #endif 2057 2109 2058 // BOOLEAN isdwpos; 2059 2060 // construct a new weight vector 2110 // construct a new weight vector and check whether vec[j] is overflow, 2111 // i.e. vec[j] > 2^31. 2112 // If vec[j] doesn't overflow, define a weight vector. Otherwise, 2113 // report that overflow appears. In the second case, test whether the 2114 // the correctness of the new vector plays an important role 2115 2061 2116 for (j=0; j<nRing; j++) 2062 2117 { … … 2102 2157 } 2103 2158 } 2104 2159 // reduce the vector with the gcd 2160 if(mpz_cmp_si(ggt,1) != 0) 2161 { 2162 for (j=0; j<nRing; j++) 2163 { 2164 mpz_divexact(vec[j], vec[j], ggt); 2165 } 2166 } 2105 2167 #ifdef NEXT_VECTORS_CC 2106 2168 PrintS("\n// gcd of elements of the vector: "); … … 2108 2170 #endif 2109 2171 2110 /**********************************************************************2111 * construct a new weight vector and check whether vec[j] is overflow, *2112 * i.e. vec[j] > 2^31. *2113 * If vec[j] doesn't overflow, define a weight vector. Otherwise, *2114 * report that overflow appears. In the second case, test whether the *2115 * the correctness of the new vector plays an important role *2116 **********************************************************************/2117 kkk=0;2118 2172 for(j=0; j<nRing; j++) 2119 2173 { … … 2131 2185 2132 2186 REDUCTION: 2187 checkRed = 1; 2133 2188 for (j=0; j<nRing; j++) 2134 2189 { 2135 (*diff_weight)[j] = mpz_get_si(vec[j]); 2136 } 2137 while(MivAbsMax(diff_weight) >= 5) 2138 { 2139 for (j=0; j<nRing; j++) 2140 { 2141 if(mpz_cmp_si(ggt,1)==0) 2142 { 2143 (*diff_weight1)[j] = floor(0.1*(*diff_weight)[j] + 0.5); 2144 // Print("\n// vector[%d] = %d \n",j+1, (*diff_weight1)[j]); 2145 } 2146 else 2147 { 2148 mpz_divexact(vec[j], vec[j], ggt); 2149 (*diff_weight1)[j] = floor(0.1*(*diff_weight)[j] + 0.5); 2150 // Print("\n// vector[%d] = %d \n",j+1, (*diff_weight1)[j]); 2151 } 2152 /* 2153 if((*diff_weight1)[j] == 0) 2154 { 2155 kkk = kkk + 1; 2156 } 2157 */ 2158 } 2159 2160 2161 /* 2162 if(kkk > nRing - 1) 2163 { 2164 // diff_weight was reduced to zero 2165 // Print("\n // MwalkNextWeightCC: geaenderter Vector gleich Null! \n"); 2166 goto TEST_OVERFLOW; 2167 } 2168 */ 2169 2170 if(test_w_in_ConeCC(G,diff_weight1) != 0) 2171 { 2172 Print("\n// MwalkNextWeightCC: geaenderter vector liegt in Groebnerkegel! \n"); 2173 for (j=0; j<nRing; j++) 2174 { 2175 (*diff_weight)[j] = (*diff_weight1)[j]; 2176 } 2177 if(MivAbsMax(diff_weight) < 5) 2178 { 2179 checkRed = 1; 2180 goto SIMPLIFY_GCD; 2181 } 2182 } 2183 else 2184 { 2185 // Print("\n// MwalkNextWeightCC: geaenderter vector liegt nicht in Groebnerkegel! \n"); 2186 break; 2187 } 2190 (*diff_weight1)[j] = mpz_get_si(vec[j]); 2191 } 2192 while(test_w_in_ConeCC(G,diff_weight1)) 2193 { 2194 for(j=0; j<nRing; j++) 2195 { 2196 (*diff_weight)[j] = (*diff_weight1)[j]; 2197 mpz_set_si(vec[j], (*diff_weight)[j]); 2198 } 2199 for(j=0; j<nRing; j++) 2200 { 2201 (*diff_weight1)[j] = floor(0.1*(*diff_weight)[j] + 0.5); 2202 } 2203 } 2204 if(MivAbsMax(diff_weight)>10000) 2205 { 2206 for(j=0; j<nRing; j++) 2207 { 2208 (*diff_weight1)[j] = (*diff_weight)[j]; 2209 } 2210 j = 0; 2211 while(test_w_in_ConeCC(G,diff_weight1)) 2212 { 2213 (*diff_weight)[j] = (*diff_weight1)[j]; 2214 mpz_set_si(vec[j], (*diff_weight)[j]); 2215 j = MivAbsMaxArg(diff_weight1); 2216 (*diff_weight1)[j] = floor(0.1*(*diff_weight1)[j] + 0.5); 2217 } 2218 goto SIMPLIFY_GCD; 2188 2219 } 2189 2220 … … 2224 2255 mpz_clear(t_null); 2225 2256 2226 2227 2228 2257 if(Overflow_Error == FALSE) 2229 2258 { 2230 2259 Overflow_Error = nError; 2231 2260 } 2232 rComplete(currRing);2233 for( kkk=0; kkk<IDELEMS(G);kkk++)2234 { 2235 poly p=G->m[ kkk];2261 rComplete(currRing); 2262 for(j=0; j<IDELEMS(G); j++) 2263 { 2264 poly p=G->m[j]; 2236 2265 while(p!=NULL) 2237 2266 { … … 2273 2302 } 2274 2303 2275 /************************************************************** 2304 /******************************************************************** 2276 2305 * define and execute a new ring which order is (a(vb),a(va),lp,C) * 2277 * ************************************************************ /2306 * ******************************************************************/ 2278 2307 static void VMrHomogeneous(intvec* va, intvec* vb) 2279 2308 { … … 2427 2456 //rChangeCurrRing(r); 2428 2457 } 2429 2458 //unused 2459 #if 0 2430 2460 static ring VMrDefault1(intvec* va) 2431 2461 { … … 2498 2528 return r; 2499 2529 } 2500 2530 #endif 2501 2531 /**************************************************************** 2502 2532 * define and execute a new ring with ordering (a(va),Wp(vb),C) * … … 3128 3158 else 3129 3159 { 3130 rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung3160 rChangeCurrRing(VMrDefault(curr_weight)); 3131 3161 } 3132 3162 newRing = currRing; … … 3884 3914 else 3885 3915 { 3886 rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung3916 rChangeCurrRing(VMrDefault(curr_weight)); 3887 3917 } 3888 3918 newRing = currRing; … … 4145 4175 else 4146 4176 { 4147 rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung4177 rChangeCurrRing(VMrDefault(curr_weight)); 4148 4178 } 4149 4179 newRing = currRing; … … 4287 4317 intvec* Xivlp; 4288 4318 4289 #if 04290 /********************************4291 * compute a next weight vector *4292 ********************************/4293 static intvec* MWalkRandomNextWeight(ideal G, intvec* curr_weight, intvec* target_weight, int weight_rad, int pert_deg)4294 {4295 int i, weight_norm;4296 int nV = currRing->N;4297 intvec* next_weight2;4298 intvec* next_weight22 = new intvec(nV);4299 intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight, G);4300 if(MivComp(next_weight, target_weight) == 1)4301 {4302 return(next_weight);4303 }4304 else4305 {4306 //compute a perturbed next weight vector "next_weight1"4307 intvec* next_weight1 = MkInterRedNextWeight(MPertVectors(G, MivMatrixOrder(curr_weight), pert_deg), target_weight, G);4308 //Print("\n // size of next_weight1 = %d", sizeof((*next_weight1)));4309 4310 //compute a random next weight vector "next_weight2"4311 while(1)4312 {4313 weight_norm = 0;4314 while(weight_norm == 0)4315 {4316 for(i=0; i<nV; i++)4317 {4318 //Print("\n// next_weight[%d] = %d", i, (*next_weight)[i]);4319 (*next_weight22)[i] = rand() % 60000 - 30000;4320 weight_norm = weight_norm + (*next_weight22)[i]*(*next_weight22)[i];4321 }4322 weight_norm = 1 + floor(sqrt(weight_norm));4323 }4324 4325 for(i=nV-1; i>=0; i--)4326 {4327 if((*next_weight22)[i] < 0)4328 {4329 (*next_weight22)[i] = 1 + (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);4330 }4331 else4332 {4333 (*next_weight22)[i] = (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);4334 }4335 //Print("\n// next_weight22[%d] = %d", i, (*next_weight22)[i]);4336 }4337 4338 if(test_w_in_ConeCC(G, next_weight22) == 1)4339 {4340 //Print("\n//MWalkRandomNextWeight: next_weight2 im Kegel\n");4341 next_weight2 = MkInterRedNextWeight(next_weight22, target_weight, G);4342 delete next_weight22;4343 break;4344 }4345 }4346 intvec* result = new intvec(nV);4347 ideal G_test = MwalkInitialForm(G, next_weight);4348 ideal G_test1 = MwalkInitialForm(G, next_weight1);4349 ideal G_test2 = MwalkInitialForm(G, next_weight2);4350 4351 // compare next_weights4352 if(IDELEMS(G_test1) < IDELEMS(G_test))4353 {4354 if(IDELEMS(G_test2) <= IDELEMS(G_test1)) // |G_test2| <= |G_test1| < |G_test|4355 {4356 for(i=0; i<nV; i++)4357 {4358 (*result)[i] = (*next_weight2)[i];4359 }4360 }4361 else // |G_test1| < |G_test|, |G_test1| < |G_test2|4362 {4363 for(i=0; i<nV; i++)4364 {4365 (*result)[i] = (*next_weight1)[i];4366 }4367 }4368 }4369 else4370 {4371 if(IDELEMS(G_test2) <= IDELEMS(G_test)) // |G_test2| <= |G_test| <= |G_test1|4372 {4373 for(i=0; i<nV; i++)4374 {4375 (*result)[i] = (*next_weight2)[i];4376 }4377 }4378 else // |G_test| <= |G_test1|, |G_test| < |G_test2|4379 {4380 for(i=0; i<nV; i++)4381 {4382 (*result)[i] = (*next_weight)[i];4383 }4384 }4385 }4386 delete next_weight;4387 delete next_weight1;4388 idDelete(&G_test);4389 idDelete(&G_test1);4390 idDelete(&G_test2);4391 if(test_w_in_ConeCC(G, result) == 1)4392 {4393 delete next_weight2;4394 return result;4395 }4396 else4397 {4398 delete result;4399 return next_weight2;4400 }4401 }4402 }4403 #endif4404 4319 4405 4320 /******************************** … … 4416 4331 4417 4332 //compute a perturbed next weight vector "next_weight1" 4418 //intvec* next_weight1 = MkInterRedNextWeight(MPertVectors(G,MivMatrixOrderRefine(curr_weight,target_weight),pert_deg),target_weight,G);4419 4333 intvec* next_weight1 =MkInterRedNextWeight(curr_weight,target_weight,G); 4420 4334 //compute a random next weight vector "next_weight2" … … 4445 4359 { 4446 4360 next_weight2 = MkInterRedNextWeight(next_weight22,target_weight,G); 4361 if(MivAbsMax(next_weight2)>1147483647) 4362 { 4363 for(i=0; i<nV; i++) 4364 { 4365 (*next_weight22)[i] = (*next_weight2)[i]; 4366 } 4367 i = 0; 4368 while(test_w_in_ConeCC(G,next_weight22)) 4369 { 4370 (*next_weight2)[i] = (*next_weight22)[i]; 4371 i = MivAbsMaxArg(next_weight22); 4372 (*next_weight22)[i] = floor(0.1*(*next_weight22)[i] + 0.5); 4373 } 4374 } 4447 4375 delete next_weight22; 4448 4376 break; … … 4575 4503 else 4576 4504 { 4577 rChangeCurrRing(VMrDefault(orig_target_weight)); // Aenderung4505 rChangeCurrRing(VMrDefault(orig_target_weight)); 4578 4506 } 4579 4507 TargetRing = currRing; … … 4646 4574 else 4647 4575 { 4648 rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung4576 rChangeCurrRing(VMrDefault(curr_weight)); 4649 4577 } 4650 4578 newRing = currRing; … … 4755 4683 else 4756 4684 { 4757 rChangeCurrRing(VMrDefault(orig_target_weight)); // Aenderung4685 rChangeCurrRing(VMrDefault(orig_target_weight)); 4758 4686 } 4759 4687 F1 = idrMoveR(G, newRing,currRing); … … 4786 4714 else 4787 4715 { 4788 rChangeCurrRing(VMrDefault(orig_target_weight)); // Aenderung4716 rChangeCurrRing(VMrDefault(orig_target_weight)); 4789 4717 } 4790 4718 KSTD_Finish: … … 4884 4812 tim = clock(); 4885 4813 /* 4886 Print("\n// **** Gr ᅵbnerwalk took %d steps and ", nwalk);4814 Print("\n// **** Groebnerwalk took %d steps and ", nwalk); 4887 4815 PrintS("\n// **** call the rec. Pert. Walk to compute a red GB of:"); 4888 4816 idElements(Gomega, "G_omega"); … … 4914 4842 oldRing = currRing; 4915 4843 4916 / * create a new ring newRing */4844 // create a new ring newRing 4917 4845 if (rParameter(currRing) != NULL) 4918 4846 { … … 4921 4849 else 4922 4850 { 4923 rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung4851 rChangeCurrRing(VMrDefault(curr_weight)); 4924 4852 } 4925 4853 newRing = currRing; … … 4947 4875 else 4948 4876 { 4949 rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung4877 rChangeCurrRing(VMrDefault(curr_weight)); 4950 4878 } 4951 4879 newRing = currRing; … … 4959 4887 M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight); 4960 4888 delete hilb_func; 4961 #endif // BUCHBERGER_ALG4889 #endif 4962 4890 tstd = tstd + clock() - to; 4963 4891 … … 4968 4896 4969 4897 to = clock(); 4970 // compute a representation of the generators of submod (M) with respect to those of mod (Gomega). Gomega is a reduced Groebner basis w.r.t. the current ring. 4898 // compute a representation of the generators of submod (M) with respect 4899 // to those of mod (Gomega). 4900 // Gomega is a reduced Groebner basis w.r.t. the current ring. 4971 4901 F = MLifttwoIdeal(Gomega2, M1, G); 4972 4902 tlift = tlift + clock() - to; … … 5018 4948 else 5019 4949 { 5020 rChangeCurrRing(VMrDefault(target_weight)); // Aenderung4950 rChangeCurrRing(VMrDefault(target_weight)); 5021 4951 } 5022 4952 F1 = idrMoveR(G, newRing,currRing); … … 5065 4995 * THE GROEBNER WALK ALGORITHM * 5066 4996 *******************************/ 5067 ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M, ring baseRing) 4997 ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M, 4998 ring baseRing, int reduction, int printout) 5068 4999 { 5069 BITSET save1 = si_opt_1; // save current options 5070 //si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 5071 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 5072 //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB)); 5000 // save current options 5001 BITSET save1 = si_opt_1; 5002 if(reduction == 0) 5003 { 5004 // no reduced Groebner basis 5005 si_opt_1 &= (~Sy_bit(OPT_REDSB)); 5006 // not tail reductions 5007 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); 5008 } 5073 5009 Set_Error(FALSE); 5074 5010 Overflow_Error = FALSE; … … 5111 5047 #endif 5112 5048 rComplete(currRing); 5113 #ifdef CHECK_IDEAL_MWALK 5114 idString(Go,"Go"); 5115 #endif 5049 //#ifdef CHECK_IDEAL_MWALK 5050 if(printout > 2) 5051 { 5052 idString(Go,"//** Mwalk: Go"); 5053 } 5054 //#endif 5116 5055 #ifdef TIME_TEST 5117 5056 to = clock(); 5118 5057 #endif 5119 if(orig_M->length() == nV) 5120 { 5121 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp) 5122 } 5123 else 5124 { 5125 newRing = VMatrDefault(orig_M); 5126 } 5058 if(orig_M->length() == nV) 5059 { 5060 // define a new ring with ordering "(a(curr_weight),lp) 5061 newRing = VMrDefault(curr_weight); 5062 } 5063 else 5064 { 5065 newRing = VMatrDefault(orig_M); 5066 } 5127 5067 rChangeCurrRing(newRing); 5128 5068 ideal G = MstdCC(idrMoveR(Go,baseRing,currRing)); … … 5140 5080 to = clock(); 5141 5081 #endif 5142 #ifdef CHECK_IDEAL_MWALK 5143 idString(G,"G"); 5144 #endif 5145 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5082 //#ifdef CHECK_IDEAL_MWALK 5083 if(printout > 2) 5084 { 5085 idString(G,"//** Mwalk: G"); 5086 } 5087 //#endif 5088 // compute an initial form ideal of <G> w.r.t. "curr_vector" 5089 Gomega = MwalkInitialForm(G, curr_weight); 5146 5090 #ifdef TIME_TEST 5147 tif = tif + clock()-to; //time for computing initial form ideal 5148 #endif 5149 #ifdef CHECK_IDEAL_MWALK 5150 idString(Gomega,"Gomega"); 5151 #endif 5091 //time for computing initial form ideal 5092 tif = tif + clock()-to; 5093 #endif 5094 //#ifdef CHECK_IDEAL_MWALK 5095 if(printout > 1) 5096 { 5097 idString(Gomega,"//** Mwalk: Gomega"); 5098 } 5099 //#endif 5152 5100 #ifndef BUCHBERGER_ALG 5153 5101 if(isNolVector(curr_weight) == 0) … … 5164 5112 if(orig_M->length() == nV) 5165 5113 { 5166 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp) 5114 // define a new ring with ordering "(a(curr_weight),lp) 5115 newRing = VMrDefault(curr_weight); 5167 5116 } 5168 5117 else … … 5175 5124 if(target_M->length() == nV) 5176 5125 { 5177 newRing = VMrRefine(curr_weight,target_weight); //define a new ring with ordering "(a(curr_weight),Wp(target_weight))" 5126 //define a new ring with ordering "(a(curr_weight),Wp(target_weight))" 5127 newRing = VMrRefine(curr_weight,target_weight); 5178 5128 } 5179 5129 else 5180 5130 { 5131 //define a new ring with matrix ordering 5181 5132 newRing = VMatrRefine(target_M,curr_weight); 5182 5133 } … … 5199 5150 #endif 5200 5151 idSkipZeroes(M); 5201 #ifdef CHECK_IDEAL_MWALK 5202 PrintS("\n//** Mwalk: computed M.\n"); 5203 idString(M, "M"); 5204 #endif 5152 //#ifdef CHECK_IDEAL_MWALK 5153 if(printout > 2) 5154 { 5155 idString(M, "//** Mwalk: M"); 5156 } 5157 //#endif 5205 5158 //change the ring to baseRing 5206 5159 rChangeCurrRing(baseRing); … … 5212 5165 to = clock(); 5213 5166 #endif 5214 // compute a representation of the generators of submod (M) with respect to those of mod (Gomega), where Gomega is a reduced Groebner basis w.r.t. the current ring 5167 // compute a representation of the generators of submod (M) with respect to those of mod (Gomega), 5168 // where Gomega is a reduced Groebner basis w.r.t. the current ring 5215 5169 F = MLifttwoIdeal(Gomega2, M1, G); 5216 5170 #ifdef TIME_TEST 5217 5171 tlift = tlift + clock() - to; 5218 5172 #endif 5219 #ifdef CHECK_IDEAL_MWALK 5220 idString(F, "F"); 5221 #endif 5173 //#ifdef CHECK_IDEAL_MWALK 5174 if(printout > 2) 5175 { 5176 idString(F, "//** Mwalk: F"); 5177 } 5178 //#endif 5222 5179 idDelete(&Gomega2); 5223 5180 idDelete(&M1); … … 5229 5186 to = clock(); 5230 5187 #endif 5231 //G = kStd(F1,NULL,testHomog,NULL,NULL,0,0,NULL); 5188 5232 5189 #ifdef TIME_TEST 5233 5190 tstd = tstd + clock() - to; 5234 5191 #endif 5235 5192 idSkipZeroes(G); 5236 #ifdef CHECK_IDEAL_MWALK 5237 idString(G, "G"); 5238 #endif 5193 //#ifdef CHECK_IDEAL_MWALK 5194 if(printout > 2) 5195 { 5196 idString(G, "//** Mwalk: G"); 5197 } 5198 //#endif 5239 5199 #ifdef TIME_TEST 5240 5200 to = clock(); … … 5244 5204 tnw = tnw + clock() - to; 5245 5205 #endif 5246 #ifdef PRINT_VECTORS 5247 MivString(curr_weight, target_weight, next_weight); 5248 #endif 5249 if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)// || test_w_in_ConeCC(G, target_weight) == 1 || MivComp(next_weight,curr_weight) == 1) 5250 { 5251 #ifdef CHECK_IDEAL_MWALK 5252 PrintS("\n//** Mwalk: entering last cone.\n"); 5253 #endif 5206 //#ifdef PRINT_VECTORS 5207 if(printout > 0) 5208 { 5209 MivString(curr_weight, target_weight, next_weight); 5210 } 5211 //#endif 5212 if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1 || test_w_in_ConeCC(G, target_weight) == 1) 5213 { 5214 //#ifdef CHECK_IDEAL_MWALK 5215 if(printout > 0) 5216 { 5217 PrintS("\n//** Mwalk: entering last cone.\n"); 5218 } 5219 //#endif 5254 5220 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5255 5221 if(target_M->length() == nV) … … 5264 5230 Gomega1 = idrMoveR(Gomega, baseRing,currRing); 5265 5231 idDelete(&Gomega); 5266 #ifdef CHECK_IDEAL_MWALK 5267 idString(Gomega1, "Gomega"); 5268 #endif 5232 //#ifdef CHECK_IDEAL_MWALK 5233 if(printout > 1) 5234 { 5235 idString(Gomega1, "//** Mwalk: Gomega"); 5236 } 5237 //#endif 5269 5238 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL); 5270 #ifdef CHECK_IDEAL_MWALK 5271 idString(M,"M"); 5272 #endif 5239 //#ifdef CHECK_IDEAL_MWALK 5240 if(printout > 1) 5241 { 5242 idString(M,"//** Mwalk: M"); 5243 } 5244 //#endif 5273 5245 rChangeCurrRing(baseRing); 5274 5246 M1 = idrMoveR(M, newRing,currRing); … … 5277 5249 idDelete(&Gomega1); 5278 5250 F = MLifttwoIdeal(Gomega2, M1, G); 5279 #ifdef CHECK_IDEAL_MWALK 5280 idString(F,"F"); 5281 #endif 5251 //#ifdef CHECK_IDEAL_MWALK 5252 if(printout > 2) 5253 { 5254 idString(F,"//** Mwalk: F"); 5255 } 5256 //#endif 5282 5257 idDelete(&Gomega2); 5283 5258 idDelete(&M1); … … 5291 5266 to = clock(); 5292 5267 #endif 5293 // if(si_opt_1 == (Sy_bit(OPT_REDSB))) 5294 // { 5295 G = kInterRedCC(G,NULL); //reduce the Groebner basis <G> w.r.t. currRing, if option(redSB) is set 5296 // } 5268 //interreduce the Groebner basis <G> w.r.t. currRing 5269 G = kInterRedCC(G,NULL); 5297 5270 #ifdef TIME_TEST 5298 5271 tred = tred + clock() - to; … … 5301 5274 delete next_weight; 5302 5275 break; 5303 #ifdef CHECK_IDEAL_MWALK 5304 PrintS("\n//** Mwalk: last cone.\n"); 5305 #endif 5306 } 5307 #ifdef CHECK_IDEAL_MWALK 5308 PrintS("\n//** Mwalk: update weight vectors.\n"); 5309 #endif 5276 } 5310 5277 for(i=nV-1; i>=0; i--) 5311 5278 { … … 5318 5285 ideal result = idrMoveR(G,baseRing,currRing); 5319 5286 idDelete(&G); 5320 /*#ifdef CHECK_IDEAL_MWALK5321 pDelete(&p);5322 #endif*/5323 5287 delete tmp_weight; 5324 5288 delete ivNull; … … 5328 5292 #endif 5329 5293 #ifdef TIME_TEST 5330 Print("\n//** Mwalk: Groebner Walk took %d steps.\n", nstep);5331 5294 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep); 5332 Print("\n//** Mwalk: Ergebnis.\n");5333 5295 //Print("\n// pSetm_Error = (%d)", ErrorCheck()); 5334 5296 //Print("\n// Overflow_Error? (%d)\n", Overflow_Error); 5335 5297 #endif 5298 Print("\n//** Mwalk: Groebner Walk took %d steps.\n", nstep); 5336 5299 return(result); 5337 5300 } 5338 5301 5339 // 07.11.20125340 // THE RANDOM WALK ALGORITHM ideal Go, intvec* orig_M, intvec* target_M, ring baseRing 5341 ideal Mrwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, int pert_deg, ring baseRing)5302 // THE RANDOM WALK ALGORITHM 5303 ideal Mrwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, int pert_deg, 5304 int reduction, int printout) 5342 5305 { 5343 5306 BITSET save1 = si_opt_1; // save current options 5344 //si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 5345 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 5346 //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB)); 5307 if(reduction == 0) 5308 { 5309 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 5310 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 5311 //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB)); 5312 } 5347 5313 Set_Error(FALSE); 5348 5314 Overflow_Error = FALSE; … … 5354 5320 #endif 5355 5321 nstep=0; 5356 int i, nwalk,endwalks = 0;5357 int nV = baseRing->N;5322 int i,polylength,nwalk,endwalks = 0; 5323 int nV = currRing->N; 5358 5324 5359 5325 ideal Gomega, M, F, Gomega1, Gomega2, M1; //, F1; 5360 5326 ring newRing; 5361 ring XXRing = baseRing; 5327 ring baseRing = currRing; 5328 ring XXRing = currRing; 5362 5329 intvec* ivNull = new intvec(nV); 5363 5330 intvec* curr_weight = new intvec(nV); … … 5365 5332 intvec* exivlp = Mivlp(nV); 5366 5333 intvec* tmp_weight = new intvec(nV); 5334 intvec* next_weight= new intvec(nV); 5367 5335 for(i=0; i<nV; i++) 5368 5336 { … … 5385 5353 #endif 5386 5354 rComplete(currRing); 5387 #ifdef CHECK_IDEAL_MWALK5388 idString(Go,"Go");5389 #endif5390 5355 #ifdef TIME_TEST 5391 5356 to = clock(); 5392 5357 #endif 5393 5394 5395 5396 5397 5398 5399 5400 5358 if(orig_M->length() == nV) 5359 { 5360 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp) 5361 } 5362 else 5363 { 5364 newRing = VMatrDefault(orig_M); 5365 } 5401 5366 rChangeCurrRing(newRing); 5402 5367 ideal G = MstdCC(idrMoveR(Go,baseRing,currRing)); … … 5414 5379 to = clock(); 5415 5380 #endif 5416 #ifdef CHECK_IDEAL_MWALK 5417 idString(G,"G"); 5418 #endif 5381 //#ifdef CHECK_IDEAL_MWALK 5382 if(printout > 2) 5383 { 5384 idString(G,"//** Mrwalk: G"); 5385 } 5386 //#endif 5419 5387 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5388 //polylength = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise 5389 polylength = lengthpoly(Gomega); 5420 5390 #ifdef TIME_TEST 5421 5391 tif = tif + clock()-to; //time for computing initial form ideal 5422 5392 #endif 5423 #ifdef CHECK_IDEAL_MWALK 5424 idString(Gomega,"Gomega"); 5425 #endif 5393 //#ifdef CHECK_IDEAL_MWALK 5394 if(printout > 1) 5395 { 5396 idString(Gomega,"//** Mrwalk: Gomega"); 5397 } 5398 //#endif 5426 5399 #ifndef BUCHBERGER_ALG 5427 5400 if(isNolVector(curr_weight) == 0) … … 5473 5446 #endif 5474 5447 idSkipZeroes(M); 5475 #ifdef CHECK_IDEAL_MWALK 5476 PrintS("\n//** Mwalk: computed M.\n"); 5477 idString(M, "M"); 5478 #endif 5448 //#ifdef CHECK_IDEAL_MWALK 5449 if(printout > 2) 5450 { 5451 idString(M, "//** Mrwalk: M"); 5452 } 5453 //#endif 5479 5454 //change the ring to baseRing 5480 5455 rChangeCurrRing(baseRing); … … 5486 5461 to = clock(); 5487 5462 #endif 5488 // compute a representation of the generators of submod (M) with respect to those of mod (Gomega), where Gomega is a reduced Groebner basis w.r.t. the current ring 5463 // compute a representation of the generators of submod (M) with respect to those of mod (Gomega), 5464 // where Gomega is a reduced Groebner basis w.r.t. the current ring 5489 5465 F = MLifttwoIdeal(Gomega2, M1, G); 5490 5466 #ifdef TIME_TEST 5491 5467 tlift = tlift + clock() - to; 5492 5468 #endif 5493 #ifdef CHECK_IDEAL_MWALK 5494 idString(F, "F"); 5495 #endif 5469 //#ifdef CHECK_IDEAL_MWALK 5470 if(printout > 2) 5471 { 5472 idString(F, "//** Mrwalk: F"); 5473 } 5474 //#endif 5496 5475 idDelete(&Gomega2); 5497 5476 idDelete(&M1); … … 5502 5481 #ifdef TIME_TEST 5503 5482 to = clock(); 5504 #endif5505 //G = kStd(F1,NULL,testHomog,NULL,NULL,0,0,NULL);5506 #ifdef TIME_TEST5507 5483 tstd = tstd + clock() - to; 5508 5484 #endif 5509 5485 idSkipZeroes(G); 5510 #ifdef CHECK_IDEAL_MWALK 5511 idString(G, "G"); 5512 #endif 5486 //#ifdef CHECK_IDEAL_MWALK 5487 if(printout > 2) 5488 { 5489 idString(G, "//** Mrwalk: G"); 5490 } 5491 //#endif 5513 5492 #ifdef TIME_TEST 5514 5493 to = clock(); 5515 5494 #endif 5516 intvec* next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, pert_deg);//next_weight = MwalkNextWeightCC(curr_weight,target_weight,G); 5495 next_weight = MwalkNextWeightCC(curr_weight,target_weight,G); 5496 if(polylength > 0) 5497 { 5498 //there is a polynomial in Gomega with at least 3 monomials, 5499 //low-dimensional facet of the cone 5500 delete next_weight; 5501 next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, pert_deg); 5502 } 5517 5503 #ifdef TIME_TEST 5518 5504 tnw = tnw + clock() - to; 5519 5505 #endif 5520 #ifdef PRINT_VECTORS 5521 MivString(curr_weight, target_weight, next_weight); 5522 #endif 5506 //#ifdef PRINT_VECTORS 5507 if(printout > 0) 5508 { 5509 MivString(curr_weight, target_weight, next_weight); 5510 } 5511 //#endif 5523 5512 if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)// || test_w_in_ConeCC(G, target_weight) == 1 || MivComp(next_weight,curr_weight) == 1) 5524 5513 { … … 5527 5516 #endif 5528 5517 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5518 //#ifdef CHECK_IDEAL_MWALK 5519 if(printout > 1) 5520 { 5521 idString(Gomega, "//** Mrwalk: Gomega"); 5522 } 5523 //#endif 5529 5524 if(target_M->length() == nV) 5530 5525 { … … 5538 5533 Gomega1 = idrMoveR(Gomega, baseRing,currRing); 5539 5534 idDelete(&Gomega); 5540 #ifdef CHECK_IDEAL_MWALK5541 idString(Gomega1, "Gomega");5542 #endif5543 5535 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL); 5544 #ifdef CHECK_IDEAL_MWALK 5545 idString(M,"M"); 5546 #endif 5536 //#ifdef CHECK_IDEAL_MWALK 5537 if(printout > 2) 5538 { 5539 idString(M,"//** Mrwalk: M"); 5540 } 5541 //#endif 5547 5542 rChangeCurrRing(baseRing); 5548 5543 M1 = idrMoveR(M, newRing,currRing); … … 5551 5546 idDelete(&Gomega1); 5552 5547 F = MLifttwoIdeal(Gomega2, M1, G); 5553 #ifdef CHECK_IDEAL_MWALK5554 idString(F,"F");5555 #endif5556 5548 idDelete(&Gomega2); 5557 5549 idDelete(&M1); … … 5560 5552 idDelete(&F); 5561 5553 baseRing = currRing; 5562 si_opt_1 = save1; //set original options, e. g. option(RedSB)5563 5554 idSkipZeroes(G); 5564 5555 #ifdef TIME_TEST 5565 5556 to = clock(); 5566 5557 #endif 5567 // if(si_opt_1 == (Sy_bit(OPT_REDSB))) 5568 // { 5569 //G = kInterRedCC(G,NULL); //reduce the Groebner basis <G> w.r.t. currRing, if option(redSB) is set 5570 // } 5558 //#ifdef CHECK_IDEAL_MWALK 5559 if(printout > 2) 5560 { 5561 idString(G,"//** Mrwalk: G"); 5562 } 5563 /*#endif 5564 if(si_opt_1 == (Sy_bit(OPT_REDSB))) 5565 {*/ 5566 G = kInterRedCC(G,NULL); //interreduce the Groebner basis <G> w.r.t. currRing 5567 // } 5571 5568 #ifdef TIME_TEST 5572 5569 tred = tred + clock() - to; … … 5575 5572 delete next_weight; 5576 5573 break; 5577 #ifdef CHECK_IDEAL_MWALK 5578 PrintS("\n//** Mwalk: last cone.\n"); 5579 #endif 5580 } 5581 #ifdef CHECK_IDEAL_MWALK 5582 PrintS("\n//** Mwalk: update weight vectors.\n"); 5583 #endif 5574 } 5584 5575 for(i=nV-1; i>=0; i--) 5585 5576 { … … 5589 5580 delete next_weight; 5590 5581 } 5582 baseRing = currRing; 5591 5583 rChangeCurrRing(XXRing); 5592 5584 ideal result = idrMoveR(G,baseRing,currRing); 5593 5585 idDelete(&G); 5594 /*#ifdef CHECK_IDEAL_MWALK 5595 pDelete(&p); 5596 #endif*/ 5586 si_opt_1 = save1; //set original options, e. g. option(RedSB) 5597 5587 delete tmp_weight; 5598 5588 delete ivNull; … … 5601 5591 delete last_omega; 5602 5592 #endif 5593 Print("\n//** Mrwalk: Groebner Walk took %d steps.\n", nstep); 5603 5594 #ifdef TIME_TEST 5604 Print("\n//** Mwalk: Groebner Walk took %d steps.\n", nstep);5605 5595 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep); 5606 Print("\n//** Mwalk: Ergebnis.\n");5607 5596 //Print("\n// pSetm_Error = (%d)", ErrorCheck()); 5608 5597 //Print("\n// Overflow_Error? (%d)\n", Overflow_Error); … … 5751 5740 // use kStd, if nP = 0, else call LastGB 5752 5741 ideal Mpwalk(ideal Go, int op_deg, int tp_deg,intvec* curr_weight, 5753 intvec* target_weight, int nP )5742 intvec* target_weight, int nP, int reduction, int printout) 5754 5743 { 5744 BITSET save1 = si_opt_1; // save current options 5745 if(reduction == 0) 5746 { 5747 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 5748 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 5749 //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB)); 5750 } 5755 5751 Set_Error(FALSE ); 5756 5752 Overflow_Error = FALSE; … … 5790 5786 ring XXRing = currRing; 5791 5787 5792 5793 5788 to = clock(); 5794 / * perturbs the original vector */5789 // perturbs the original vector 5795 5790 if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) := "dp" 5796 5791 { … … 5809 5804 DefRingPar(curr_weight); 5810 5805 else 5811 rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung 15806 rChangeCurrRing(VMrDefault(curr_weight)); 5812 5807 5813 5808 G = idrMoveR(Go, XXRing,currRing); … … 5824 5819 ring HelpRing = currRing; 5825 5820 5826 / * perturbs the target weight vector */5821 // perturbs the target weight vector 5827 5822 if(tp_deg > 1 && tp_deg <= nV) 5828 5823 { … … 5830 5825 DefRingPar(target_weight); 5831 5826 else 5832 rChangeCurrRing(VMrDefault(target_weight)); // Aenderung 25827 rChangeCurrRing(VMrDefault(target_weight)); 5833 5828 5834 5829 TargetRing = currRing; … … 5852 5847 G = idrMoveR(ssG, TargetRing,currRing); 5853 5848 } 5854 /* 5855 Print("\n// Perturbationwalkalg. vom Gradpaar (%d,%d):",op_deg,tp_deg); 5856 ivString(curr_weight, "new sigma"); 5857 ivString(target_weight, "new tau"); 5858 */ 5849 if(printout > 0) 5850 { 5851 Print("\n//** Mpwalk: Perturbation Walk of degree (%d,%d):",op_deg,tp_deg); 5852 ivString(curr_weight, "//** Mpwalk: new current weight"); 5853 ivString(target_weight, "//** Mpwalk: new target weight"); 5854 } 5859 5855 while(1) 5860 5856 { … … 5864 5860 "curr_weight" */ 5865 5861 Gomega = MwalkInitialForm(G, curr_weight); 5866 5862 //#ifdef CHECK_IDEAL_MWALK 5863 if(printout > 1) 5864 { 5865 idString(Gomega,"//** Mpwalk: Gomega"); 5866 } 5867 //#endif 5867 5868 5868 5869 #ifdef ENDWALKS 5869 if(endwalks == 1){ 5870 if(endwalks == 1) 5871 { 5870 5872 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 5871 5873 idElements(G, "G"); 5872 // idElements(Gomega, "Gw");5873 5874 headidString(G, "G"); 5874 //headidString(Gomega, "Gw");5875 5875 } 5876 5876 #endif … … 5891 5891 DefRingPar(curr_weight); 5892 5892 else 5893 rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung 35893 rChangeCurrRing(VMrDefault(curr_weight)); 5894 5894 5895 5895 newRing = currRing; … … 5918 5918 M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight); 5919 5919 delete hilb_func; 5920 #endif // BUCHBERGER_ALG 5920 #endif 5921 //#ifdef CHECK_IDEAL_MWALK 5922 if(printout > 2) 5923 { 5924 idString(M,"//** Mpwalk: M"); 5925 } 5926 //#endif 5921 5927 5922 5928 if(endwalks == 1){ … … 5934 5940 M1 = idrMoveR(M, newRing,currRing); 5935 5941 Gomega2 = idrMoveR(Gomega1, newRing,currRing); 5936 5937 //if(endwalks==1) PrintS("\n// Lifting is working:..");5938 5942 5939 5943 to=clock(); … … 5947 5951 xtlift=clock()-to; 5948 5952 5953 //#ifdef CHECK_IDEAL_MWALK 5954 if(printout > 2) 5955 { 5956 idString(F,"//** Mpwalk: F"); 5957 } 5958 //#endif 5959 5949 5960 idDelete(&M1); 5950 5961 idDelete(&Gomega2); … … 5954 5965 rChangeCurrRing(newRing); 5955 5966 F1 = idrMoveR(F, oldRing,currRing); 5956 5957 //if(endwalks==1)PrintS("\n// InterRed is working now:");5958 5967 5959 5968 to=clock(); … … 5971 5980 5972 5981 to=clock(); 5973 / * compute a next weight vector */5982 // compute a next weight vector 5974 5983 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G); 5975 5984 tnw=tnw+clock()-to; 5976 #ifdef PRINT_VECTORS 5977 MivString(curr_weight, target_weight, next_weight); 5978 #endif 5985 //#ifdef PRINT_VECTORS 5986 if(printout > 2) 5987 { 5988 MivString(curr_weight, target_weight, next_weight); 5989 } 5990 //#endif 5979 5991 5980 5992 if(Overflow_Error == TRUE) … … 6014 6026 DefRingPar(orig_target); 6015 6027 else 6016 rChangeCurrRing(VMrDefault(orig_target)); //Aenderung6028 rChangeCurrRing(VMrDefault(orig_target)); 6017 6029 6018 6030 TargetRing=currRing; … … 6068 6080 Eresult = idrMoveR(G, newRing,currRing); 6069 6081 } 6082 si_opt_1 = save1; //set original options, e. g. option(RedSB) 6070 6083 delete ivNull; 6071 6084 if(tp_deg != 1) … … 6082 6095 tnw+xtnw); 6083 6096 6084 Print("\n// pSetm_Error = (%d)", ErrorCheck()); 6085 Print("\n// It took %d steps and Overflow_Error? (%d)\n", nstep, Overflow_Error); 6086 #endif 6097 //Print("\n// pSetm_Error = (%d)", ErrorCheck()); 6098 //Print("\n// It took %d steps and Overflow_Error? (%d)\n", nstep, Overflow_Error); 6099 #endif 6100 Print("\n//** Mpwalk: Perturbation Walk took %d steps.\n", nstep); 6101 return(Eresult); 6102 } 6103 6104 /******************************************************* 6105 * THE PERTURBATION WALK ALGORITHM WITH RANDOM ELEMENT * 6106 *******************************************************/ 6107 ideal Mprwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, 6108 int op_deg, int tp_deg, int nP, int reduction, int printout) 6109 { 6110 BITSET save1 = si_opt_1; // save current options 6111 if(reduction == 0) 6112 { 6113 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 6114 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 6115 //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB)); 6116 } 6117 Set_Error(FALSE); 6118 Overflow_Error = FALSE; 6119 //Print("// pSetm_Error = (%d)", ErrorCheck()); 6120 6121 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0; 6122 xtextra=0; 6123 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; 6124 tinput = clock(); 6125 6126 clock_t tim; 6127 6128 nstep = 0; 6129 int i, ntwC=1, ntestw=1, polylength, nV = currRing->N; 6130 int endwalks=0; 6131 6132 ideal Gomega, M, F, G, Gomega1, Gomega2, M1,F1,Eresult,ssG; 6133 ring newRing, oldRing, TargetRing; 6134 intvec* iv_M_dp; 6135 intvec* iv_M_lp; 6136 intvec* exivlp = Mivlp(nV); 6137 intvec* curr_weight = new intvec(nV); 6138 intvec* target_weight = new intvec(nV); 6139 for(i=0; i<nV; i++) 6140 { 6141 (*curr_weight)[i] = (*orig_M)[i]; 6142 (*target_weight)[i] = (*target_M)[i]; 6143 } 6144 intvec* orig_target = target_weight; 6145 intvec* pert_target_vector = target_weight; 6146 intvec* ivNull = new intvec(nV); 6147 intvec* iv_dp = MivUnit(nV);// define (1,1,...,1) 6148 #ifndef BUCHBERGER_ALG 6149 intvec* hilb_func; 6150 #endif 6151 intvec* next_weight; 6152 6153 // to avoid (1,0,...,0) as the target vector 6154 intvec* last_omega = new intvec(nV); 6155 for(i=nV-1; i>0; i--) 6156 (*last_omega)[i] = 1; 6157 (*last_omega)[0] = 10000; 6158 6159 ring XXRing = currRing; 6160 6161 to = clock(); 6162 // perturbs the original vector 6163 if(orig_M->length() == nV) 6164 { 6165 if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) := "dp" 6166 { 6167 G = MstdCC(Go); 6168 tostd = clock()-to; 6169 if(op_deg != 1) 6170 { 6171 iv_M_dp = MivMatrixOrderdp(nV); 6172 //ivString(iv_M_dp, "iv_M_dp"); 6173 curr_weight = MPertVectors(G, iv_M_dp, op_deg); 6174 } 6175 } 6176 else 6177 { 6178 //define ring order := (a(curr_weight),lp); 6179 if (rParameter(currRing) != NULL) 6180 DefRingPar(curr_weight); 6181 else 6182 rChangeCurrRing(VMrDefault(curr_weight)); 6183 6184 G = idrMoveR(Go, XXRing,currRing); 6185 G = MstdCC(G); 6186 tostd = clock()-to; 6187 if(op_deg != 1) 6188 { 6189 iv_M_dp = MivMatrixOrder(curr_weight); 6190 curr_weight = MPertVectors(G, iv_M_dp, op_deg); 6191 } 6192 } 6193 } 6194 else 6195 { 6196 rChangeCurrRing(VMatrDefault(orig_M)); 6197 G = idrMoveR(Go, XXRing,currRing); 6198 G = MstdCC(G); 6199 tostd = clock()-to; 6200 if(op_deg != 1) 6201 { 6202 curr_weight = MPertVectors(G, orig_M, op_deg); 6203 } 6204 } 6205 6206 delete iv_dp; 6207 if(op_deg != 1) delete iv_M_dp; 6208 6209 ring HelpRing = currRing; 6210 6211 // perturbs the target weight vector 6212 if(target_M->length() == nV) 6213 { 6214 if(tp_deg > 1 && tp_deg <= nV) 6215 { 6216 if (rParameter(currRing) != NULL) 6217 DefRingPar(target_weight); 6218 else 6219 rChangeCurrRing(VMrDefault(target_weight)); 6220 6221 TargetRing = currRing; 6222 ssG = idrMoveR(G,HelpRing,currRing); 6223 if(MivSame(target_weight, exivlp) == 1) 6224 { 6225 iv_M_lp = MivMatrixOrderlp(nV); 6226 //ivString(iv_M_lp, "iv_M_lp"); 6227 //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg); 6228 target_weight = MPertVectors(ssG, iv_M_lp, tp_deg); 6229 } 6230 else 6231 { 6232 iv_M_lp = MivMatrixOrder(target_weight); 6233 //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg); 6234 target_weight = MPertVectors(ssG, iv_M_lp, tp_deg); 6235 } 6236 delete iv_M_lp; 6237 pert_target_vector = target_weight; 6238 rChangeCurrRing(HelpRing); 6239 G = idrMoveR(ssG, TargetRing,currRing); 6240 } 6241 } 6242 else 6243 { 6244 if(tp_deg > 1 && tp_deg <= nV) 6245 { 6246 rChangeCurrRing(VMatrDefault(target_M)); 6247 TargetRing = currRing; 6248 ssG = idrMoveR(G,HelpRing,currRing); 6249 target_weight = MPertVectors(ssG, target_M, tp_deg); 6250 } 6251 } 6252 if(printout > 0) 6253 { 6254 Print("\n//** Mprwalk: Random Perturbation Walk of degree (%d,%d):",op_deg,tp_deg); 6255 ivString(curr_weight, "//** Mprwalk: new current weight"); 6256 ivString(target_weight, "//** Mprwalk: new target weight"); 6257 } 6258 while(1) 6259 { 6260 nstep ++; 6261 to = clock(); 6262 /* compute an initial form ideal of <G> w.r.t. the weight vector 6263 "curr_weight" */ 6264 Gomega = MwalkInitialForm(G, curr_weight); 6265 //#ifdef CHECK_IDEAL_MWALK 6266 if(printout > 1) 6267 { 6268 idString(Gomega,"//** Mprwalk: Gomega"); 6269 } 6270 //#endif 6271 polylength = lengthpoly(Gomega); 6272 #ifdef ENDWALKS 6273 if(endwalks == 1) 6274 { 6275 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6276 idElements(G, "G"); 6277 headidString(G, "G"); 6278 } 6279 #endif 6280 6281 tif = tif + clock()-to; 6282 6283 #ifndef BUCHBERGER_ALG 6284 if(isNolVector(curr_weight) == 0) 6285 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing); 6286 else 6287 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing); 6288 #endif // BUCHBERGER_ALG 6289 6290 oldRing = currRing; 6291 6292 if(target_M->length() == nV) 6293 { 6294 // define a new ring with ordering "(a(curr_weight),lp) 6295 if (rParameter(currRing) != NULL) 6296 DefRingPar(curr_weight); 6297 else 6298 rChangeCurrRing(VMrDefault(curr_weight)); 6299 } 6300 else 6301 { 6302 rChangeCurrRing(VMatrRefine(target_M,curr_weight)); 6303 } 6304 newRing = currRing; 6305 Gomega1 = idrMoveR(Gomega, oldRing,currRing); 6306 6307 #ifdef ENDWALKS 6308 if(endwalks==1) 6309 { 6310 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6311 idElements(Gomega1, "Gw"); 6312 headidString(Gomega1, "headGw"); 6313 PrintS("\n// compute a rGB of Gw:\n"); 6314 6315 #ifndef BUCHBERGER_ALG 6316 ivString(hilb_func, "w"); 6317 #endif 6318 } 6319 #endif 6320 6321 tim = clock(); 6322 to = clock(); 6323 /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */ 6324 #ifdef BUCHBERGER_ALG 6325 M = MstdhomCC(Gomega1); 6326 #else 6327 M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight); 6328 delete hilb_func; 6329 #endif 6330 //#ifdef CHECK_IDEAL_MWALK 6331 if(printout > 2) 6332 { 6333 idString(M,"//** Mprwalk: M"); 6334 } 6335 //#endif 6336 6337 if(endwalks == 1) 6338 { 6339 xtstd = xtstd+clock()-to; 6340 #ifdef ENDWALKS 6341 Print("\n// time for the last std(Gw) = %.2f sec\n", 6342 ((double) clock())/1000000 -((double)tim) /1000000); 6343 #endif 6344 } 6345 else 6346 tstd=tstd+clock()-to; 6347 6348 /* change the ring to oldRing */ 6349 rChangeCurrRing(oldRing); 6350 M1 = idrMoveR(M, newRing,currRing); 6351 Gomega2 = idrMoveR(Gomega1, newRing,currRing); 6352 6353 to=clock(); 6354 /* compute a representation of the generators of submod (M) 6355 with respect to those of mod (Gomega). 6356 Gomega is a reduced Groebner basis w.r.t. the current ring */ 6357 F = MLifttwoIdeal(Gomega2, M1, G); 6358 if(endwalks != 1) 6359 tlift = tlift+clock()-to; 6360 else 6361 xtlift=clock()-to; 6362 6363 //#ifdef CHECK_IDEAL_MWALK 6364 if(printout > 2) 6365 { 6366 idString(F,"//** Mprwalk: F"); 6367 } 6368 //#endif 6369 6370 idDelete(&M1); 6371 idDelete(&Gomega2); 6372 idDelete(&G); 6373 6374 /* change the ring to newRing */ 6375 rChangeCurrRing(newRing); 6376 F1 = idrMoveR(F, oldRing,currRing); 6377 6378 to=clock(); 6379 /* reduce the Groebner basis <G> w.r.t. new ring */ 6380 G = kInterRedCC(F1, NULL); 6381 if(endwalks != 1) 6382 tred = tred+clock()-to; 6383 else 6384 xtred=clock()-to; 6385 6386 idDelete(&F1); 6387 6388 if(endwalks == 1) 6389 break; 6390 6391 to=clock(); 6392 // compute a next weight vector 6393 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G); 6394 if(polylength > 0) 6395 { 6396 //there is a polynomial in Gomega with at least 3 monomials, 6397 //low-dimensional facet of the cone 6398 delete next_weight; 6399 next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg); 6400 } 6401 tnw=tnw+clock()-to; 6402 //#ifdef PRINT_VECTORS 6403 if(printout > 2) 6404 { 6405 MivString(curr_weight, target_weight, next_weight); 6406 } 6407 //#endif 6408 6409 if(Overflow_Error == TRUE) 6410 { 6411 ntwC = 0; 6412 //ntestomega = 1; 6413 //Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6414 //idElements(G, "G"); 6415 delete next_weight; 6416 goto FINISH_160302; 6417 } 6418 if(MivComp(next_weight, ivNull) == 1){ 6419 newRing = currRing; 6420 delete next_weight; 6421 //Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6422 break; 6423 } 6424 if(MivComp(next_weight, target_weight) == 1) 6425 endwalks = 1; 6426 6427 for(i=nV-1; i>=0; i--) 6428 (*curr_weight)[i] = (*next_weight)[i]; 6429 6430 delete next_weight; 6431 }//while 6432 6433 if(tp_deg != 1) 6434 { 6435 FINISH_160302: 6436 if(target_M->length() == nV) 6437 { 6438 if(MivSame(orig_target, exivlp) == 1) 6439 if (rParameter(currRing) != NULL) 6440 DefRingParlp(); 6441 else 6442 VMrDefaultlp(); 6443 else 6444 if (rParameter(currRing) != NULL) 6445 DefRingPar(orig_target); 6446 else 6447 rChangeCurrRing(VMrDefault(orig_target)); 6448 } 6449 else 6450 { 6451 rChangeCurrRing(VMatrDefault(target_M)); 6452 } 6453 TargetRing=currRing; 6454 F1 = idrMoveR(G, newRing,currRing); 6455 #ifdef CHECK_IDEAL 6456 headidString(G, "G"); 6457 #endif 6458 6459 // check whether the pertubed target vector stays in the correct cone 6460 if(ntwC != 0){ 6461 ntestw = test_w_in_ConeCC(F1, pert_target_vector); 6462 } 6463 6464 if( ntestw != 1 || ntwC == 0) 6465 { 6466 /* 6467 if(ntestw != 1){ 6468 ivString(pert_target_vector, "tau"); 6469 PrintS("\n// ** perturbed target vector doesn't stay in cone!!"); 6470 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6471 idElements(F1, "G"); 6472 } 6473 */ 6474 // LastGB is "better" than the kStd subroutine 6475 to=clock(); 6476 ideal eF1; 6477 if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1 || target_M->length() != nV){ 6478 // PrintS("\n// ** calls \"std\" to compute a GB"); 6479 eF1 = MstdCC(F1); 6480 idDelete(&F1); 6481 } 6482 else { 6483 // PrintS("\n// ** calls \"LastGB\" to compute a GB"); 6484 rChangeCurrRing(newRing); 6485 ideal F2 = idrMoveR(F1, TargetRing,currRing); 6486 eF1 = LastGB(F2, curr_weight, tp_deg-1); 6487 F2=NULL; 6488 } 6489 xtextra=clock()-to; 6490 ring exTargetRing = currRing; 6491 6492 rChangeCurrRing(XXRing); 6493 Eresult = idrMoveR(eF1, exTargetRing,currRing); 6494 } 6495 else{ 6496 rChangeCurrRing(XXRing); 6497 Eresult = idrMoveR(F1, TargetRing,currRing); 6498 } 6499 } 6500 else { 6501 rChangeCurrRing(XXRing); 6502 Eresult = idrMoveR(G, newRing,currRing); 6503 } 6504 si_opt_1 = save1; //set original options, e. g. option(RedSB) 6505 delete ivNull; 6506 if(tp_deg != 1) 6507 delete target_weight; 6508 6509 if(op_deg != 1 ) 6510 delete curr_weight; 6511 6512 delete exivlp; 6513 delete last_omega; 6514 6515 #ifdef TIME_TEST 6516 TimeStringFractal(tinput, tostd, tif+xtif, tstd+xtstd,0, tlift+xtlift, tred+xtred, 6517 tnw+xtnw); 6518 6519 //Print("\n// pSetm_Error = (%d)", ErrorCheck()); 6520 //Print("\n// It took %d steps and Overflow_Error? (%d)\n", nstep, Overflow_Error); 6521 #endif 6522 Print("\n//** Mprwalk: Perturbation Walk took %d steps.\n", nstep); 6087 6523 return(Eresult); 6088 6524 } … … 6110 6546 * Perturb the start weight vector at the top level, i.e. nlev = 1 * 6111 6547 ***********************************************************************/ 6112 static ideal rec_fractal_call(ideal G, int nlev, intvec* omtmp)6548 static ideal rec_fractal_call(ideal G, int nlev, intvec* ivtarget, int printout) 6113 6549 { 6114 6550 Overflow_Error = FALSE; … … 6127 6563 intvec* next_vect; 6128 6564 intvec* omega2 = new intvec(nV); 6565 intvec* omtmp = new intvec(nV); 6129 6566 intvec* altomega = new intvec(nV); 6130 6567 6568 for(i = nV -1; i>0; i--) 6569 { 6570 (*omtmp)[i] = (*ivtarget)[i]; 6571 } 6131 6572 //BOOLEAN isnewtarget = FALSE; 6132 6573 … … 6169 6610 NEXT_VECTOR_FRACTAL: 6170 6611 to=clock(); 6171 / * determine the next border */6612 // determine the next border 6172 6613 next_vect = MkInterRedNextWeight(omega,omega2,G); 6173 6614 xtnw=xtnw+clock()-to; 6174 #ifdef PRINT_VECTORS 6175 MivString(omega, omega2, next_vect); 6176 #endif 6615 6177 6616 oRing = currRing; 6178 6617 6179 / * We only perturb the current target vector at the recursion level 1 */6618 // We only perturb the current target vector at the recursion level 1 6180 6619 if(Xngleich == 0 && nlev == 1) //(ngleich == 0) important, e.g. ex2, ex3 6181 6620 if (MivComp(next_vect, omega2) == 1) 6182 6621 { 6183 /* to dispense with taking initial (and lifting/interreducing 6184 after the call of recursion */ 6185 //Print("\n\n// ** Perturb the both vectors with degree %d with",nlev); 6186 //idElements(G, "G"); 6622 // to dispense with taking initial (and lifting/interreducing 6623 // after the call of recursion 6624 if(printout > 0) 6625 { 6626 Print("\n//** rec_fractal_call: Perturb the both vectors with degree %d.",nlev); 6627 //idElements(G, "G"); 6628 } 6187 6629 6188 6630 Xngleich = 1; 6189 6631 nlev +=1; 6190 6632 6191 if (rParameter(currRing) != NULL) 6192 DefRingPar(omtmp); 6633 if(ivtarget->length() == nV) 6634 { 6635 if (rParameter(currRing) != NULL) 6636 DefRingPar(omtmp); 6637 else 6638 rChangeCurrRing(VMrDefault(omtmp)); 6639 } 6193 6640 else 6194 rChangeCurrRing(VMrDefault1(omtmp)); //Aenderung3 6195 6641 { 6642 rChangeCurrRing(VMatrDefault(ivtarget)); 6643 } 6196 6644 testring = currRing; 6197 6645 Gt = idrMoveR(G, oRing,currRing); 6198 6646 6199 /* perturb the original target vector w.r.t. the current GB */ 6200 delete Xtau; 6201 Xtau = NewVectorlp(Gt); 6647 // perturb the original target vector w.r.t. the current GB 6648 if(ivtarget->length() == nV) 6649 { 6650 delete Xtau; 6651 Xtau = NewVectorlp(Gt); 6652 } 6653 else 6654 { 6655 delete Xtau; 6656 Xtau = Mfpertvector(Gt,ivtarget); 6657 } 6202 6658 6203 6659 rChangeCurrRing(oRing); 6204 6660 G = idrMoveR(Gt, testring,currRing); 6205 6661 6206 / * perturb the current vector w.r.t. the current GB */6662 // perturb the current vector w.r.t. the current GB 6207 6663 Mwlp = MivWeightOrderlp(omega); 6208 6664 Xsigma = Mfpertvector(G, Mwlp); … … 6222 6678 next_vect = MkInterRedNextWeight(omega,omega2,G); 6223 6679 xtnw=xtnw+clock()-to; 6224 6225 #ifdef PRINT_VECTORS 6680 } 6681 //#ifdef PRINT_VECTORS 6682 if(printout > 0) 6683 { 6226 6684 MivString(omega, omega2, next_vect); 6227 #endif 6228 } 6229 6685 } 6686 //#endif 6230 6687 6231 6688 /* check whether the the computed vector is in the correct cone */ … … 6236 6693 { 6237 6694 delete next_vect; 6238 if (rParameter(currRing) != NULL) 6239 { 6240 DefRingPar(omtmp); 6695 if(ivtarget->length() == nV) 6696 { 6697 if (rParameter(currRing) != NULL) 6698 DefRingPar(omtmp); 6699 else 6700 rChangeCurrRing(VMrDefault(omtmp)); 6241 6701 } 6242 6702 else 6243 6703 { 6244 rChangeCurrRing(VM rDefault1(omtmp)); // Aenderung46704 rChangeCurrRing(VMatrDefault(ivtarget)); 6245 6705 } 6246 6706 #ifdef TEST_OVERFLOW … … 6248 6708 Gt = NULL; return(Gt); 6249 6709 #endif 6250 6251 //Print("\n\n// apply BB's alg. in ring r = %s;", rString(currRing)); 6710 if(printout > 0) 6711 { 6712 Print("\n//** rec_fractal_call: applying Buchberger's algorithm in ring r = %s;", 6713 rString(currRing)); 6714 } 6252 6715 to=clock(); 6253 6716 Gt = idrMoveR(G, oRing,currRing); … … 6258 6721 delete omega2; 6259 6722 delete altomega; 6260 6261 //Print("\n// Leaving the %d-th recursion with %d steps", nlev, nwalks); 6262 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 6723 if(printout > 0) 6724 { 6725 Print("\n//** rec_fractal_call: Leaving the %d-th recursion with %d steps.\n", 6726 nlev, nwalks); 6727 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 6728 } 6729 6263 6730 nnflow ++; 6264 6731 … … 6277 6744 if (MivComp(next_vect, XivNull) == 1) 6278 6745 { 6279 if (rParameter(currRing) != NULL) 6280 DefRingPar(omtmp); 6746 if(ivtarget->length() == nV) 6747 { 6748 if (rParameter(currRing) != NULL) 6749 DefRingPar(omtmp); 6750 else 6751 rChangeCurrRing(VMrDefault(omtmp)); 6752 } 6281 6753 else 6282 rChangeCurrRing(VMrDefault1(omtmp)); //Aenderung5 6754 { 6755 rChangeCurrRing(VMatrDefault(ivtarget)); 6756 } 6283 6757 6284 6758 testring = currRing; … … 6289 6763 delete next_vect; 6290 6764 delete altomega; 6291 //Print("\n// Leaving the %d-th recursion with %d steps ",nlev, nwalks); 6292 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 6293 6765 if(printout > 0) 6766 { 6767 Print("\n//** rec_fractal_call: Leaving the %d-th recursion with %d steps.\n", 6768 nlev, nwalks); 6769 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 6770 } 6294 6771 return (Gt); 6295 6772 } … … 6302 6779 //07.08.03 6303 6780 //ivString(Xtau, "old Xtau"); 6304 intvec* Xtautmp = Mfpertvector(Gt, MivMatrixOrder(omtmp)); 6781 intvec* Xtautmp; 6782 if(ivtarget->length() == nV) 6783 { 6784 Xtautmp = Mfpertvector(Gt, MivMatrixOrder(omtmp)); 6785 } 6786 else 6787 { 6788 Xtautmp = Mfpertvector(Gt, ivtarget); 6789 } 6305 6790 #ifdef TEST_OVERFLOW 6306 6791 if(Overflow_Error == TRUE) … … 6330 6815 6331 6816 FRACTAL_MSTDCC: 6332 //Print("\n// apply BB-Alg in ring = %s;", rString(currRing)); 6817 if(printout > 0) 6818 { 6819 Print("\n//** rec_fractal_call: apply Buchberger's algorithm in ring = %s.\n", 6820 rString(currRing)); 6821 } 6333 6822 to=clock(); 6334 6823 G = MstdCC(Gt); … … 6338 6827 6339 6828 // update the original target vector w.r.t. the current GB 6340 if(MivSame(Xivinput, Xivlp) == 1) 6341 if (rParameter(currRing) != NULL) 6342 DefRingParlp(); 6829 if(ivtarget->length() == nV) 6830 { 6831 if(MivSame(Xivinput, Xivlp) == 1) 6832 if (rParameter(currRing) != NULL) 6833 DefRingParlp(); 6834 else 6835 VMrDefaultlp(); 6343 6836 else 6344 VMrDefaultlp(); 6837 if (rParameter(currRing) != NULL) 6838 DefRingPar(Xivinput); 6839 else 6840 rChangeCurrRing(VMrDefault(Xivinput)); 6841 } 6345 6842 else 6346 if (rParameter(currRing) != NULL) 6347 DefRingPar(Xivinput); 6348 else 6349 rChangeCurrRing(VMrDefault1(Xivinput)); //Aenderung6 6350 6843 { 6844 rChangeCurrRing(VMatrRefine(ivtarget,Xivinput)); 6845 } 6351 6846 testring = currRing; 6352 6847 Gt = idrMoveR(G, oRing,currRing); … … 6361 6856 delete next_vect; 6362 6857 delete altomega; 6363 /* 6364 Print("\n// Leaving the %d-th recursion with %d steps,", nlev,nwalks); 6365 Print(" ** Overflow_Error? (%d)", Overflow_Error); 6366 */ 6858 if(printout > 0) 6859 { 6860 Print("\n//** rec_fractal_call: Leaving the %d-th recursion with %d steps.\n", 6861 nlev, nwalks); 6862 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 6863 } 6367 6864 if(Overflow_Error == TRUE) 6368 6865 nnflow ++; … … 6383 6880 Gomega = MwalkInitialForm(G, omega); 6384 6881 xtif=xtif+clock()-to; 6385 6882 if(printout > 1) 6883 { 6884 idString(Gomega,"//** rec_fractal_call: Gomega"); 6885 } 6386 6886 #ifndef BUCHBERGER_ALG 6387 6887 if(isNolVector(omega) == 0) … … 6390 6890 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing); 6391 6891 #endif // BUCHBERGER_ALG 6392 6393 if (rParameter(currRing) != NULL) 6394 DefRingPar(omega); 6892 if(ivtarget->length() == nV) 6893 { 6894 if (rParameter(currRing) != NULL) 6895 DefRingPar(omega); 6896 else 6897 rChangeCurrRing(VMrDefault(omega)); 6898 } 6395 6899 else 6396 rChangeCurrRing(VMrDefault1(omega)); //Aenderung7 6397 6900 { 6901 rChangeCurrRing(VMatrRefine(ivtarget,omega)); 6902 } 6398 6903 Gomega1 = idrMoveR(Gomega, oRing,currRing); 6399 6904 6400 / * Maximal recursion depth, to compute a red. GB */6401 / * Fractal walk with the alternative recursion */6402 / * alternative recursion */6905 // Maximal recursion depth, to compute a red. GB 6906 // Fractal walk with the alternative recursion 6907 // alternative recursion 6403 6908 // if(nlev == nV || lengthpoly(Gomega1) == 0) 6404 6909 if(nlev == Xnlev || lengthpoly(Gomega1) == 0) 6405 6910 //if(nlev == nV) // blind recursion 6406 6911 { 6407 /*6408 if(Xnlev != nV)6409 {6410 Print("\n// ** Xnlev = %d", Xnlev);6411 ivString(Xtau, "Xtau");6412 }6413 */6414 6912 to=clock(); 6415 6913 #ifdef BUCHBERGER_ALG … … 6421 6919 xtstd=xtstd+clock()-to; 6422 6920 } 6423 else { 6921 else 6922 { 6424 6923 rChangeCurrRing(oRing); 6425 6924 Gomega1 = idrMoveR(Gomega1, oRing,currRing); 6426 Gresult = rec_fractal_call(idCopy(Gomega1),nlev+1,omega); 6427 } 6428 6429 //convert a Groebner basis from a ring to another ring, 6925 Gresult = rec_fractal_call(idCopy(Gomega1),nlev+1,omega,printout); 6926 } 6927 if(printout > 2) 6928 { 6929 idString(Gresult,"//** rec_fractal_call: M"); 6930 } 6931 //convert a Groebner basis from a ring to another ring 6430 6932 new_ring = currRing; 6431 6933 … … 6435 6937 6436 6938 to=clock(); 6437 / * Lifting process */6939 // Lifting process 6438 6940 F = MLifttwoIdeal(Gomega2, Gresult1, G); 6439 6941 xtlift=xtlift+clock()-to; 6942 if(printout > 2) 6943 { 6944 idString(F,"//** rec_fractal_call: F"); 6945 } 6440 6946 idDelete(&Gresult1); 6441 6947 idDelete(&Gomega2); … … 6456 6962 * Perturb the start weight vector at the top level with random element * 6457 6963 ************************************************************************/ 6458 static ideal rec_r_fractal_call(ideal G, int nlev, intvec* omtmp, int weight_rad) 6964 static ideal rec_r_fractal_call(ideal G, int nlev, intvec* ivtarget, 6965 int weight_rad, int printout) 6459 6966 { 6460 6967 Overflow_Error = FALSE; 6461 6968 //Print("\n\n// Entering the %d-th recursion:", nlev); 6462 6969 6463 int i, nV = currRing->N;6970 int i, polylength, nV = currRing->N; 6464 6971 ring new_ring, testring; 6465 6972 //ring extoRing; … … 6473 6980 intvec* next_vect; 6474 6981 intvec* omega2 = new intvec(nV); 6982 intvec* omtmp = new intvec(nV); 6475 6983 intvec* altomega = new intvec(nV); 6476 6984 6477 6985 //BOOLEAN isnewtarget = FALSE; 6478 6986 6987 for(i = nV -1; i>0; i--) 6988 { 6989 (*omtmp)[i] = (*ivtarget)[i]; 6990 } 6479 6991 // to avoid (1,0,...,0) as the target vector (Hans) 6480 6992 intvec* last_omega = new intvec(nV); … … 6516 7028 to=clock(); 6517 7029 /* determine the next border */ 6518 next_vect = MWalkRandomNextWeight(G, omega,omega2, weight_rad, 1+nlev); 6519 //next_vect = MkInterRedNextWeight(omega,omega2,G); 7030 next_vect = MkInterRedNextWeight(omega,omega2,G); 7031 if(polylength > 0) 7032 { 7033 //there is a polynomial in Gomega with at least 3 monomials, 7034 //low-dimensional facet of the cone 7035 delete next_vect; 7036 next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,1+nlev); 7037 if(isNolVector(next_vect)) 7038 { 7039 delete next_vect; 7040 next_vect = MkInterRedNextWeight(omega,omega2,G); 7041 } 7042 } 6520 7043 xtnw=xtnw+clock()-to; 6521 #ifdef PRINT_VECTORS 6522 MivString(omega, omega2, next_vect); 6523 #endif 7044 6524 7045 oRing = currRing; 6525 7046 6526 / * We only perturb the current target vector at the recursion level 1 */7047 // We only perturb the current target vector at the recursion level 1 6527 7048 if(Xngleich == 0 && nlev == 1) //(ngleich == 0) important, e.g. ex2, ex3 6528 7049 if (MivComp(next_vect, omega2) == 1) 6529 7050 { 6530 /* to dispense with taking initial (and lifting/interreducing 6531 after the call of recursion */ 6532 //Print("\n\n// ** Perturb the both vectors with degree %d with",nlev); 6533 //idElements(G, "G"); 6534 7051 // to dispense with taking initials and lifting/interreducing 7052 // after the call of recursion. 7053 if(printout > 0) 7054 { 7055 Print("\n//** rec_r_fractal_call: Perturb the both vectors with degree %d.",nlev); 7056 //idElements(G, "G"); 7057 } 6535 7058 Xngleich = 1; 6536 7059 nlev +=1; 6537 6538 if (rParameter(currRing) != NULL) 6539 DefRingPar(omtmp); 7060 if(ivtarget->length() == nV) 7061 { 7062 if (rParameter(currRing) != NULL) 7063 DefRingPar(omtmp); 7064 else 7065 rChangeCurrRing(VMrDefault(omtmp)); 7066 } 6540 7067 else 6541 rChangeCurrRing(VMrDefault1(omtmp)); //Aenderung3 6542 7068 { 7069 rChangeCurrRing(VMatrDefault(ivtarget)); 7070 } 6543 7071 testring = currRing; 6544 7072 Gt = idrMoveR(G, oRing,currRing); 6545 7073 6546 /* perturb the original target vector w.r.t. the current GB */ 6547 delete Xtau; 6548 Xtau = NewVectorlp(Gt); 7074 // perturb the original target vector w.r.t. the current GB 7075 if(ivtarget->length() == nV) 7076 { 7077 delete Xtau; 7078 Xtau = NewVectorlp(Gt); 7079 } 7080 else 7081 { 7082 delete Xtau; 7083 Xtau = Mfpertvector(Gt,ivtarget); 7084 } 6549 7085 6550 7086 rChangeCurrRing(oRing); 6551 G = idrMoveR(Gt, 6552 6553 / * perturb the current vector w.r.t. the current GB */7087 G = idrMoveR(Gt,testring,currRing); 7088 7089 // perturb the current vector w.r.t. the current GB 6554 7090 Mwlp = MivWeightOrderlp(omega); 7091 if(ivtarget->length() > nV) 7092 { 7093 delete Mwlp; 7094 Mwlp = MivMatrixOrderRefine(omega,ivtarget); 7095 } 6555 7096 Xsigma = Mfpertvector(G, Mwlp); 6556 7097 delete Mwlp; … … 6568 7109 6569 7110 next_vect = MkInterRedNextWeight(omega,omega2,G); 7111 if(polylength > 0) 7112 { 7113 //there is a polynomial in Gomega with at least 3 monomials, 7114 //low-dimensional facet of the cone 7115 delete next_vect; 7116 next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,1+nlev); 7117 if(isNolVector(next_vect)) 7118 { 7119 delete next_vect; 7120 next_vect = MkInterRedNextWeight(omega,omega2,G); 7121 } 7122 } 6570 7123 xtnw=xtnw+clock()-to; 6571 6572 #ifdef PRINT_VECTORS 7124 } 7125 //#ifdef PRINT_VECTORS 7126 if(printout > 0) 7127 { 6573 7128 MivString(omega, omega2, next_vect); 6574 #endif 6575 } 6576 6577 6578 /* check whether the the computed vector is in the correct cone */ 6579 /* If no, the reduced GB of an omega-homogeneous ideal will be 7129 } 7130 //#endif 7131 7132 /* check whether the the computed vector is in the correct cone 7133 If no, the reduced GB of an omega-homogeneous ideal will be 6580 7134 computed by Buchberger algorithm and stop this recursion step*/ 6581 7135 //if(test_w_in_ConeCC(G, next_vect) != 1) //e.g. Example s7, cyc6 … … 6583 7137 { 6584 7138 delete next_vect; 6585 if (rParameter(currRing) != NULL) 6586 { 6587 DefRingPar(omtmp); 7139 if(ivtarget->length() == nV) 7140 { 7141 if (rParameter(currRing) != NULL) 7142 { 7143 DefRingPar(omtmp); 7144 } 7145 else 7146 { 7147 rChangeCurrRing(VMrDefault(omtmp)); 7148 } 6588 7149 } 6589 7150 else 6590 7151 { 6591 rChangeCurrRing(VM rDefault1(omtmp)); // Aenderung47152 rChangeCurrRing(VMatrDefault(ivtarget)); 6592 7153 } 6593 7154 #ifdef TEST_OVERFLOW 6594 7155 Gt = idrMoveR(G, oRing,currRing); 6595 Gt = NULL; return(Gt); 6596 #endif 6597 6598 //Print("\n\n// apply BB's alg. in ring r = %s;", rString(currRing)); 7156 Gt = NULL; 7157 return(Gt); 7158 #endif 7159 if(printout > 0) 7160 { 7161 Print("\n//** rec_r_fractal_call: applying Buchberger's algorithm in ring r = %s;", 7162 rString(currRing)); 7163 } 6599 7164 to=clock(); 6600 7165 Gt = idrMoveR(G, oRing,currRing); … … 6605 7170 delete omega2; 6606 7171 delete altomega; 6607 6608 //Print("\n// Leaving the %d-th recursion with %d steps", nlev, nwalks); 6609 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 7172 if(printout > 0) 7173 { 7174 Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n", 7175 nlev, nwalks); 7176 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 7177 } 6610 7178 nnflow ++; 6611 6612 7179 Overflow_Error = FALSE; 6613 7180 return (G1); 6614 7181 } 6615 6616 6617 /* If the perturbed target vector stays in the correct cone, 6618 return the current GB, 6619 otherwise, return the computed GB by the Buchberger-algorithm. 6620 Then we update the perturbed target vectors w.r.t. this GB. */ 6621 6622 /* the computed vector is equal to the origin vector, since 6623 t is not defined */ 7182 /* 7183 If the perturbed target vector stays in the correct cone, 7184 return the current Groebner basis. 7185 Otherwise, return the Groebner basis computed with Buchberger's 7186 algorithm. 7187 Then we update the perturbed target vectors w.r.t. this GB. 7188 */ 6624 7189 if (MivComp(next_vect, XivNull) == 1) 6625 7190 { 6626 if (rParameter(currRing) != NULL) 6627 DefRingPar(omtmp); 7191 // The computed vector is equal to the origin vector, 7192 // because t is not defined 7193 if(ivtarget->length() == nV) 7194 { 7195 if (rParameter(currRing) != NULL) 7196 DefRingPar(omtmp); 7197 else 7198 rChangeCurrRing(VMrDefault(omtmp)); 7199 } 6628 7200 else 6629 rChangeCurrRing(VMrDefault1(omtmp)); //Aenderung5 6630 7201 { 7202 rChangeCurrRing(VMatrDefault(ivtarget)); 7203 } 6631 7204 testring = currRing; 6632 7205 Gt = idrMoveR(G, oRing,currRing); 6633 7206 6634 if(test_w_in_ConeCC(Gt, omega2) == 1) { 7207 if(test_w_in_ConeCC(Gt, omega2) == 1) 7208 { 6635 7209 delete omega2; 6636 7210 delete next_vect; 6637 7211 delete altomega; 6638 //Print("\n// Leaving the %d-th recursion with %d steps ",nlev, nwalks); 6639 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 6640 7212 if(printout > 0) 7213 { 7214 Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n", 7215 nlev, nwalks); 7216 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 7217 } 6641 7218 return (Gt); 6642 7219 } 6643 7220 else 6644 { 6645 //ivString(omega2, "tau'"); 6646 //Print("\n// tau' doesn't stay in the correct cone!!"); 6647 7221 { 7222 if(printout > 0) 7223 { 7224 Print("\n//** rec_r_fractal_call: target weight doesn't stay in the correct cone.\n"); 7225 } 6648 7226 #ifndef MSTDCC_FRACTAL 6649 //07.08.036650 7227 //ivString(Xtau, "old Xtau"); 6651 intvec* Xtautmp = Mfpertvector(Gt, MivMatrixOrder(omtmp)); 7228 intvec* Xtautmp; 7229 if(ivtarget->length() == nV) 7230 { 7231 Xtautmp = Mfpertvector(Gt, MivMatrixOrder(omtmp)); 7232 } 7233 else 7234 { 7235 Xtautmp = Mfpertvector(Gt, ivtarget); 7236 } 6652 7237 #ifdef TEST_OVERFLOW 6653 7238 if(Overflow_Error == TRUE) … … 6677 7262 6678 7263 FRACTAL_MSTDCC: 6679 //Print("\n// apply BB-Alg in ring = %s;", rString(currRing)); 7264 if(printout > 0) 7265 { 7266 Print("\n//** rec_r_fractal_call: apply Buchberge's algorithm in ring = %s.\n", 7267 rString(currRing)); 7268 } 6680 7269 to=clock(); 6681 7270 G = MstdCC(Gt); … … 6685 7274 6686 7275 // update the original target vector w.r.t. the current GB 6687 if(MivSame(Xivinput, Xivlp) == 1) 6688 if (rParameter(currRing) != NULL) 6689 DefRingParlp(); 7276 if(ivtarget->length() == nV) 7277 { 7278 if(MivSame(Xivinput, Xivlp) == 1) 7279 if (rParameter(currRing) != NULL) 7280 DefRingParlp(); 7281 else 7282 VMrDefaultlp(); 6690 7283 else 6691 VMrDefaultlp(); 7284 if (rParameter(currRing) != NULL) 7285 DefRingPar(Xivinput); 7286 else 7287 rChangeCurrRing(VMrDefault(Xivinput)); 7288 } 6692 7289 else 6693 if (rParameter(currRing) != NULL) 6694 DefRingPar(Xivinput); 6695 else 6696 rChangeCurrRing(VMrDefault1(Xivinput)); //Aenderung6 6697 7290 { 7291 rChangeCurrRing(VMatrRefine(ivtarget,Xivinput)); 7292 } 6698 7293 testring = currRing; 6699 7294 Gt = idrMoveR(G, oRing,currRing); … … 6708 7303 delete next_vect; 6709 7304 delete altomega; 6710 /* 6711 Print("\n// Leaving the %d-th recursion with %d steps,", nlev,nwalks); 6712 Print(" ** Overflow_Error? (%d)", Overflow_Error); 6713 */ 7305 if(printout > 0) 7306 { 7307 Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n", 7308 nlev,nwalks); 7309 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 7310 } 6714 7311 if(Overflow_Error == TRUE) 6715 7312 nnflow ++; … … 6727 7324 6728 7325 to=clock(); 6729 / * Take the initial form of <G> w.r.t. omega */7326 // Take the initial form of <G> w.r.t. omega 6730 7327 Gomega = MwalkInitialForm(G, omega); 6731 7328 xtif=xtif+clock()-to; 6732 7329 //polylength = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise 7330 polylength = lengthpoly(Gomega); 7331 if(printout > 1) 7332 { 7333 idString(Gomega,"//** rec_r_fractal_call: Gomega"); 7334 } 6733 7335 #ifndef BUCHBERGER_ALG 6734 7336 if(isNolVector(omega) == 0) … … 6736 7338 else 6737 7339 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing); 6738 #endif // BUCHBERGER_ALG 6739 6740 if (rParameter(currRing) != NULL) 6741 DefRingPar(omega); 7340 #endif 7341 if(ivtarget->length() == nV) 7342 { 7343 if (rParameter(currRing) != NULL) 7344 DefRingPar(omega); 7345 else 7346 rChangeCurrRing(VMrDefault(omega)); 7347 } 6742 7348 else 6743 rChangeCurrRing(VMrDefault1(omega)); //Aenderung7 6744 7349 { 7350 rChangeCurrRing(VMatrRefine(ivtarget,omega)); 7351 } 6745 7352 Gomega1 = idrMoveR(Gomega, oRing,currRing); 6746 7353 6747 /* Maximal recursion depth, to compute a red. GB */ 6748 /* Fractal walk with the alternative recursion */ 6749 /* alternative recursion */ 6750 // if(nlev == nV || lengthpoly(Gomega1) == 0) 7354 // Maximal recursion depth, to compute a red. GB 7355 // Fractal walk with the alternative recursion 7356 // alternative recursion 6751 7357 if(nlev == Xnlev || lengthpoly(Gomega1) == 0) 6752 //if(nlev == nV) // blind recursion 6753 { 6754 /* 6755 if(Xnlev != nV) 6756 { 6757 Print("\n// ** Xnlev = %d", Xnlev); 6758 ivString(Xtau, "Xtau"); 6759 } 6760 */ 7358 { 6761 7359 to=clock(); 6762 7360 #ifdef BUCHBERGER_ALG … … 6765 7363 Gresult =kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,omega); 6766 7364 delete hilb_func; 6767 #endif // BUCHBERGER_ALG7365 #endif 6768 7366 xtstd=xtstd+clock()-to; 6769 7367 } 6770 else { 7368 else 7369 { 6771 7370 rChangeCurrRing(oRing); 6772 7371 Gomega1 = idrMoveR(Gomega1, oRing,currRing); 6773 Gresult = rec_fractal_call(idCopy(Gomega1),nlev+1,omega); 6774 } 6775 6776 //convert a Groebner basis from a ring to another ring, 7372 Gresult = rec_fractal_call(idCopy(Gomega1),nlev+1,omega,printout); 7373 } 7374 if(printout > 2) 7375 { 7376 idString(Gresult,"//** rec_r_fractal_call: M"); 7377 } 7378 //convert a Groebner basis from a ring to another ring 6777 7379 new_ring = currRing; 6778 7380 … … 6782 7384 6783 7385 to=clock(); 6784 / * Lifting process */7386 // Lifting process 6785 7387 F = MLifttwoIdeal(Gomega2, Gresult1, G); 6786 7388 xtlift=xtlift+clock()-to; 7389 7390 if(printout > 2) 7391 { 7392 idString(F,"//** rec_r_fractal_call: F"); 7393 } 7394 6787 7395 idDelete(&Gresult1); 6788 7396 idDelete(&Gomega2); … … 6793 7401 6794 7402 to=clock(); 6795 / * Interreduce G */7403 // Interreduce G 6796 7404 G = kInterRedCC(F1, NULL); 6797 7405 xtred=xtred+clock()-to; … … 6799 7407 } 6800 7408 } 6801 6802 6803 7409 6804 7410 … … 6807 7413 * * 6808 7414 * The main procedur Mfwalk calls the recursive Subroutine * 6809 * rec_fractal_call to compute the wanted Gr ᅵbner basis.*6810 * At the main procedur we compute the reduced Gr ᅵbner basis w.r.t. a "fast"*7415 * rec_fractal_call to compute the wanted Groebner basis. * 7416 * At the main procedur we compute the reduced Groebner basis w.r.t. a "fast" * 6811 7417 * order, e.g. "dp" and a sequence of weight vectors which are row vectors * 6812 7418 * of a matrix. This matrix defines the given monomial order, e.g. "lp" * 6813 7419 *******************************************************************************/ 6814 ideal Mfwalk(ideal G, intvec* ivstart, intvec* ivtarget) 7420 ideal Mfwalk(ideal G, intvec* ivstart, intvec* ivtarget, 7421 int reduction, int printout) 6815 7422 { 7423 BITSET save1 = si_opt_1; // save current options 7424 if(reduction == 0) 7425 { 7426 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 7427 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 7428 } 6816 7429 Set_Error(FALSE); 6817 7430 Overflow_Error = FALSE; … … 6848 7461 intvec* iv_dp = MivUnit(nV); // define (1,1,...,1) 6849 7462 intvec* Mdp; 6850 6851 if(MivSame(ivstart, iv_dp) != 1) 6852 Mdp = MivWeightOrderdp(ivstart); 7463 if(ivstart->length() == nV) 7464 { 7465 if(MivSame(ivstart, iv_dp) != 1) 7466 Mdp = MivWeightOrderdp(ivstart); 7467 else 7468 Mdp = MivMatrixOrderdp(nV); 7469 } 6853 7470 else 6854 Mdp = MivMatrixOrderdp(nV); 7471 { 7472 Mdp = ivstart; 7473 } 6855 7474 6856 7475 Xsigma = Mfpertvector(I, Mdp); … … 6869 7488 Xivlp = Mivlp(nV); 6870 7489 6871 if(MivComp(ivtarget, Xivlp) != 1) 6872 { 6873 if (rParameter(currRing) != NULL) 6874 DefRingPar(ivtarget); 7490 if(ivtarget->length() == nV) 7491 { 7492 if(MivComp(ivtarget, Xivlp) != 1) 7493 { 7494 if (rParameter(currRing) != NULL) 7495 DefRingPar(ivtarget); 7496 else 7497 rChangeCurrRing(VMrDefault(ivtarget)); 7498 7499 I1 = idrMoveR(I, oldRing,currRing); 7500 Mlp = MivWeightOrderlp(ivtarget); 7501 Xtau = Mfpertvector(I1, Mlp); 7502 } 6875 7503 else 6876 rChangeCurrRing(VMrDefault1(ivtarget)); //Aenderung1 6877 6878 I1 = idrMoveR(I, oldRing,currRing); 6879 Mlp = MivWeightOrderlp(ivtarget); 6880 Xtau = Mfpertvector(I1, Mlp); 7504 { 7505 if (rParameter(currRing) != NULL) 7506 DefRingParlp(); 7507 else 7508 VMrDefaultlp(); 7509 7510 I1 = idrMoveR(I, oldRing,currRing); 7511 Mlp = MivMatrixOrderlp(nV); 7512 Xtau = Mfpertvector(I1, Mlp); 7513 } 6881 7514 } 6882 7515 else 6883 7516 { 6884 if (rParameter(currRing) != NULL) 6885 DefRingParlp(); 6886 else 6887 VMrDefaultlp(); 6888 6889 I1 = idrMoveR(I, oldRing,currRing); 6890 Mlp = MivMatrixOrderlp(nV); 7517 rChangeCurrRing(VMatrDefault(ivtarget)); 7518 I1 = idrMoveR(I,oldRing,currRing); 7519 Mlp = ivtarget; 6891 7520 Xtau = Mfpertvector(I1, Mlp); 6892 7521 } … … 6899 7528 id_Delete(&I, oldRing); 6900 7529 ring tRing = currRing; 6901 6902 if (rParameter(currRing) != NULL) 6903 DefRingPar(ivstart); 7530 if(ivtarget->length() == nV) 7531 { 7532 if (rParameter(currRing) != NULL) 7533 DefRingPar(ivstart); 7534 else 7535 rChangeCurrRing(VMrDefault(ivstart)); 7536 } 6904 7537 else 6905 rChangeCurrRing(VMrDefault1(ivstart)); //Aenderung2 7538 { 7539 rChangeCurrRing(VMatrDefault(ivstart)); 7540 } 6906 7541 6907 7542 I = idrMoveR(I1,tRing,currRing); … … 6914 7549 ring helpRing = currRing; 6915 7550 6916 J = rec_fractal_call(J, 1, ivtarget);7551 J = rec_fractal_call(J,1,ivtarget,printout); 6917 7552 6918 7553 rChangeCurrRing(oldRing); … … 6920 7555 idSkipZeroes(resF); 6921 7556 7557 si_opt_1 = save1; //set original options, e. g. option(RedSB) 6922 7558 delete Xivlp; 6923 7559 delete Xsigma; … … 6938 7574 } 6939 7575 6940 ideal Mfrwalk(ideal G, intvec* ivstart, intvec* ivtarget,int weight_rad) 7576 /******************************************************************************* 7577 * The implementation of the fractal walk algorithm with random element * 7578 * * 7579 * The main procedur Mfwalk calls the recursive Subroutine * 7580 * rec_r_fractal_call to compute the wanted Groebner basis. * 7581 * At the main procedure we compute the reduced Groebner basis w.r.t. a "fast" * 7582 * order, e.g. "dp" and a sequence of weight vectors which are row vectors * 7583 * of a matrix. This matrix defines the given monomial order, e.g. "lp" * 7584 *******************************************************************************/ 7585 ideal Mfrwalk(ideal G, intvec* ivstart, intvec* ivtarget, 7586 int weight_rad, int reduction, int printout) 6941 7587 { 7588 BITSET save1 = si_opt_1; // save current options 7589 if(reduction == 0) 7590 { 7591 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 7592 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 7593 } 6942 7594 Set_Error(FALSE); 6943 7595 Overflow_Error = FALSE; … … 6974 7626 intvec* iv_dp = MivUnit(nV); // define (1,1,...,1) 6975 7627 intvec* Mdp; 6976 6977 if(MivSame(ivstart, iv_dp) != 1) 6978 Mdp = MivWeightOrderdp(ivstart); 7628 if(ivstart->length() == nV) 7629 { 7630 if(MivSame(ivstart, iv_dp) != 1) 7631 Mdp = MivWeightOrderdp(ivstart); 7632 else 7633 Mdp = MivMatrixOrderdp(nV); 7634 } 6979 7635 else 6980 Mdp = MivMatrixOrderdp(nV); 7636 { 7637 Mdp = ivstart; 7638 } 6981 7639 6982 7640 Xsigma = Mfpertvector(I, Mdp); … … 6995 7653 Xivlp = Mivlp(nV); 6996 7654 6997 if(MivComp(ivtarget, Xivlp) != 1) 6998 { 6999 if (rParameter(currRing) != NULL) 7000 DefRingPar(ivtarget); 7655 if(ivtarget->length() == nV) 7656 { 7657 if(MivComp(ivtarget, Xivlp) != 1) 7658 { 7659 if (rParameter(currRing) != NULL) 7660 DefRingPar(ivtarget); 7661 else 7662 rChangeCurrRing(VMrDefault(ivtarget)); 7663 7664 I1 = idrMoveR(I, oldRing,currRing); 7665 Mlp = MivWeightOrderlp(ivtarget); 7666 Xtau = Mfpertvector(I1, Mlp); 7667 } 7001 7668 else 7002 rChangeCurrRing(VMrDefault1(ivtarget)); //Aenderung1 7003 7004 I1 = idrMoveR(I, oldRing,currRing); 7005 Mlp = MivWeightOrderlp(ivtarget); 7006 Xtau = Mfpertvector(I1, Mlp); 7669 { 7670 if (rParameter(currRing) != NULL) 7671 DefRingParlp(); 7672 else 7673 VMrDefaultlp(); 7674 7675 I1 = idrMoveR(I, oldRing,currRing); 7676 Mlp = MivMatrixOrderlp(nV); 7677 Xtau = Mfpertvector(I1, Mlp); 7678 } 7007 7679 } 7008 7680 else 7009 7681 { 7010 if (rParameter(currRing) != NULL) 7011 DefRingParlp(); 7012 else 7013 VMrDefaultlp(); 7014 7015 I1 = idrMoveR(I, oldRing,currRing); 7016 Mlp = MivMatrixOrderlp(nV); 7682 rChangeCurrRing(VMatrDefault(ivtarget)); 7683 I1 = idrMoveR(I,oldRing,currRing); 7684 Mlp = ivtarget; 7017 7685 Xtau = Mfpertvector(I1, Mlp); 7018 7686 } … … 7025 7693 id_Delete(&I, oldRing); 7026 7694 ring tRing = currRing; 7027 7028 if (rParameter(currRing) != NULL) 7029 DefRingPar(ivstart); 7695 if(ivtarget->length() == nV) 7696 { 7697 if (rParameter(currRing) != NULL) 7698 DefRingPar(ivstart); 7699 else 7700 rChangeCurrRing(VMrDefault(ivstart)); 7701 } 7030 7702 else 7031 rChangeCurrRing(VMrDefault1(ivstart)); //Aenderung2 7703 { 7704 rChangeCurrRing(VMatrDefault(ivstart)); 7705 } 7032 7706 7033 7707 I = idrMoveR(I1,tRing,currRing); … … 7039 7713 ideal resF; 7040 7714 ring helpRing = currRing; 7041 //ideal G, int nlev, intvec* omtmp, int weight_rad) 7042 J = rec_r_fractal_call(J, 1, ivtarget,weight_rad);7715 7716 J = rec_r_fractal_call(J,1,ivtarget,weight_rad,printout); 7043 7717 7044 7718 rChangeCurrRing(oldRing); … … 7046 7720 idSkipZeroes(resF); 7047 7721 7722 si_opt_1 = save1; //set original options, e. g. option(RedSB) 7048 7723 delete Xivlp; 7049 7724 delete Xsigma; … … 7101 7776 intvec* hilb_func; 7102 7777 #endif 7103 / * to avoid (1,0,...,0) as the target vector */7778 // to avoid (1,0,...,0) as the target vector 7104 7779 intvec* last_omega = new intvec(nV); 7105 7780 for(i=nV-1; i>0; i--) … … 7116 7791 7117 7792 to=clock(); 7118 / * compute a red. GB w.r.t. the help ring */7793 // compute a red. GB w.r.t. the help ring 7119 7794 if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) = "dp" 7120 7795 G = MstdCC(G); … … 7125 7800 DefRingPar(curr_weight); 7126 7801 else 7127 rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung 47802 rChangeCurrRing(VMrDefault(curr_weight)); 7128 7803 G = idrMoveR(G, XXRing,currRing); 7129 7804 G = MstdCC(G); … … 7151 7826 DefRingPar(curr_weight); 7152 7827 else 7153 rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung 57828 rChangeCurrRing(VMrDefault(curr_weight)); 7154 7829 to=clock(); 7155 7830 Gw = idrMoveR(G, exring,currRing); … … 7186 7861 DefRingPar(curr_weight); 7187 7862 else 7188 rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung 67863 rChangeCurrRing(VMrDefault(curr_weight)); 7189 7864 7190 7865 newRing = currRing; … … 7271 7946 DefRingPar(target_tmp); 7272 7947 else 7273 rChangeCurrRing(VMrDefault(target_tmp)); // Aenderung 87948 rChangeCurrRing(VMrDefault(target_tmp)); 7274 7949 7275 7950 lpRing = currRing; … … 7331 8006 DefRingPar(target_tmp); 7332 8007 else 7333 rChangeCurrRing(VMrDefault(target_tmp)); //Aenderung 98008 rChangeCurrRing(VMrDefault(target_tmp)); 7334 8009 7335 8010 lpRing = currRing; … … 7534 8209 else 7535 8210 { 7536 rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung 108211 rChangeCurrRing(VMrDefault(curr_weight)); 7537 8212 } 7538 8213 G = idrMoveR(G, XXRing,currRing); … … 7567 8242 else 7568 8243 { 7569 rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung 118244 rChangeCurrRing(VMrDefault(curr_weight)); 7570 8245 } 7571 8246 to=clock(); … … 7610 8285 else 7611 8286 { 7612 rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung 128287 rChangeCurrRing(VMrDefault(curr_weight)); 7613 8288 } 7614 8289 newRing = currRing; … … 7779 8454 else 7780 8455 { 7781 rChangeCurrRing(VMrDefault(target_tmp)); // Aenderung 138456 rChangeCurrRing(VMrDefault(target_tmp)); 7782 8457 } 7783 8458 } … … 7852 8527 else 7853 8528 { 7854 rChangeCurrRing(VMrDefault(target_tmp)); // Aenderung 148529 rChangeCurrRing(VMrDefault(target_tmp)); 7855 8530 } 7856 8531 } … … 8095 8770 else 8096 8771 { 8097 rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung 158772 rChangeCurrRing(VMrDefault(curr_weight)); 8098 8773 } 8099 8774 newRing = currRing; … … 8237 8912 8238 8913 //Print("\n// \"Mpwalk\" (1,%d) took %d steps and %.2f sec. Overflow_Error (%d)", tp_deg, nwalk, ((double) clock()-tinput)/1000000, nOverflow_Error); 8239 8914 Print("\n// Mprwalk took %d steps. Ring= %s;\n", nwalk, rString(currRing)); 8240 8915 return(result); 8241 }8242 8243 /*******************************************************8244 * THE PERTURBATION WALK ALGORITHM WITH RANDOM ELEMENT *8245 *******************************************************/8246 ideal Mprwalk(ideal Go, intvec* curr_weight, intvec* target_weight, int weight_rad, int op_deg, int tp_deg, ring baseRing)8247 {8248 BITSET save1 = si_opt_1; // save current options8249 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis8250 Set_Error(FALSE);8251 Overflow_Error = FALSE;8252 #ifdef TIME_TEST8253 clock_t tinput=0, tostd=0, tif=0, tstd=0, tlift=0, tred=0, tnw=0;8254 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;8255 tinput = clock();8256 clock_t tim;8257 #endif8258 int i,nwalk,nV = baseRing->N;8259 8260 ideal G, Gomega, M, F, Gomega1, Gomega2, M1;8261 ring newRing;8262 ring XXRing = baseRing;8263 intvec* exivlp = Mivlp(nV);8264 intvec* orig_target = target_weight;8265 intvec* pert_target_vector = target_weight;8266 intvec* ivNull = new intvec(nV);8267 intvec* tmp_weight = new intvec(nV);8268 #ifdef CHECK_IDEAL_MWALK8269 poly p;8270 #endif8271 for(i=0; i<nV; i++)8272 {8273 (*tmp_weight)[i] = (*curr_weight)[i];8274 }8275 #ifndef BUCHBERGER_ALG8276 intvec* hilb_func;8277 // to avoid (1,0,...,0) as the target vector8278 intvec* last_omega = new intvec(nV);8279 for(i=0 i<nV; i++)8280 {8281 (*last_omega)[i] = 1;8282 }8283 (*last_omega)[0] = 10000;8284 #endif8285 baseRing = currRing;8286 newRing = VMrDefault(curr_weight);8287 rChangeCurrRing(newRing);8288 G = idrMoveR(Go,baseRing,currRing);8289 #ifdef TIME_TEST8290 to = clock();8291 #endif8292 G = kStd(G,NULL,testHomog,NULL,NULL,0,0,NULL);8293 idSkipZeroes(G);8294 #ifdef TIME_TEST8295 tostd = tostd + to - clock();8296 #endif8297 #ifdef CHECK_IDEAL_MWALK8298 idString(G,"G");8299 #endif8300 if(op_deg >1)8301 {8302 if(MivComp(curr_weight,MivUnit(nV)) == 1) //ring order is "dp"8303 {8304 curr_weight = MPertVectors(G, MivMatrixOrderdp(nV), op_deg);8305 }8306 else //ring order is not "dp"8307 {8308 curr_weight = MPertVectors(G, MivMatrixOrder(curr_weight), op_deg);8309 }8310 }8311 baseRing = currRing;8312 if(tp_deg > 1 && tp_deg <= nV)8313 {8314 pert_target_vector = target_weight;8315 }8316 #ifdef CHECK_IDEAL_MWALK8317 ivString(curr_weight, "new curr_weight");8318 ivString(target_weight, "new target_weight");8319 #endif8320 nwalk = 0;8321 while(1)8322 {8323 nwalk ++;8324 #ifdef TIME_TEST8325 to = clock();8326 #endif8327 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"8328 #ifdef TIME_TEST8329 tif = tif + clock()-to; //time for computing initial form ideal8330 #endif8331 #ifdef CHECK_IDEAL_MWALK8332 idString(Gomega,"Gomega");8333 #endif8334 #ifndef BUCHBERGER_ALG8335 if(isNolVector(curr_weight) == 0)8336 {8337 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);8338 }8339 else8340 {8341 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);8342 }8343 #endif8344 if(nwalk == 1)8345 {8346 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)8347 }8348 else8349 {8350 newRing = VMrRefine(curr_weight,target_weight); //define a new ring with ordering "(a(curr_weight),Wp(target_weight))"8351 }8352 rChangeCurrRing(newRing);8353 Gomega1 = idrMoveR(Gomega, baseRing,currRing);8354 idDelete(&Gomega);8355 // compute a Groebner basis of <Gomega> w.r.t. "newRing"8356 #ifdef TIME_TEST8357 to = clock();8358 #endif8359 #ifndef BUCHBERGER_ALG8360 M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);8361 delete hilb_func;8362 #else8363 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);8364 #endif8365 idSkipZeroes(M);8366 #ifdef TIME_TEST8367 tstd = tstd + clock() - to;8368 #endif8369 #ifdef CHECK_IDEAL_MWALK8370 idString(M, "M");8371 #endif8372 //change the ring to baseRing8373 rChangeCurrRing(baseRing);8374 M1 = idrMoveR(M, newRing,currRing);8375 idDelete(&M);8376 Gomega2 = idrMoveR(Gomega1, newRing,currRing);8377 idDelete(&Gomega1);8378 to = clock();8379 // compute a representation of the generators of submod (M) with respect to those of mod (Gomega), where Gomega is a reduced Groebner basis w.r.t. the current ring8380 F = MLifttwoIdeal(Gomega2, M1, G);8381 idSkipZeroes(F);8382 #ifdef TIME_TEST8383 tlift = tlift + clock() - to;8384 #endif8385 #ifdef CHECK_IDEAL_MWALK8386 idString(F,"F");8387 #endif8388 rChangeCurrRing(newRing); // change the ring to newRing8389 G = idrMoveR(F,baseRing,currRing);8390 idDelete(&F);8391 baseRing = currRing; // set baseRing equal to newRing8392 #ifdef CHECK_IDEAL_MWALK8393 idString(G,"G");8394 #endif8395 #ifdef TIME_TEST8396 to = clock();8397 #endif8398 intvec* next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg);8399 #ifdef TIME_TEST8400 tnw = tnw + clock() - to;8401 #endif8402 #ifdef PRINT_VECTORS8403 MivString(curr_weight, target_weight, next_weight);8404 #endif8405 if(Overflow_Error == TRUE)8406 {8407 PrintS("\n//**Mprwalk: OVERFLOW: The computed vector does not stay in cone, the result may be wrong.\n");8408 delete next_weight;8409 break;8410 }8411 8412 if(test_w_in_ConeCC(G,target_weight) == 1 || MivComp(next_weight, ivNull) == 1)8413 {8414 delete next_weight;8415 break;8416 }8417 //update tmp_weight and curr_weight8418 for(i=nV-1; i>=0; i--)8419 {8420 (*tmp_weight)[i] = (*curr_weight)[i];8421 (*curr_weight)[i] = (*next_weight)[i];8422 }8423 delete next_weight;8424 } //end of while-loop8425 Print("\n// Mprwalk took %d steps. Ring= %s;\n", nwalk, rString(currRing));8426 idSkipZeroes(G);8427 si_opt_1 = save1; //set original options, e. g. option(RedSB)8428 baseRing = currRing;8429 rChangeCurrRing(XXRing);8430 ideal Res = idrMoveR(G,baseRing,currRing);8431 delete tmp_weight;8432 delete ivNull;8433 delete exivlp;8434 #ifndef BUCHBERGER_ALG8435 delete last_omega;8436 #endif8437 #ifdef TIME_TEST8438 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep);8439 #endif8440 return(Res);8441 8916 } 8442 8917 … … 8517 8992 else 8518 8993 { 8519 rChangeCurrRing(VMrDefault(cw_tmp)); // Aenderung 168994 rChangeCurrRing(VMrDefault(cw_tmp)); 8520 8995 } 8521 8996 G = idrMoveR(Go, XXRing,currRing); … … 8591 9066 else 8592 9067 { 8593 rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung 179068 rChangeCurrRing(VMrDefault(curr_weight)); 8594 9069 } 8595 9070 newRing = currRing; … … 8653 9128 else 8654 9129 { 8655 rChangeCurrRing(VMrDefault(target_weight)); // Aenderung 189130 rChangeCurrRing(VMrDefault(target_weight)); 8656 9131 } 8657 9132 F1 = idrMoveR(G, newRing,currRing); -
Property
mode
changed from
-
Singular/walk.h
-
Property
mode
changed from
100644
to100755
r350269 r11d9d00 54 54 // compute a Groebner basis of an ideal G w.r.t. lexicographic order 55 55 //ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M); 56 ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M, ring baseRing );56 ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M, ring baseRing, int reduction, int printout); 57 57 58 58 // random walk algorithm to compute a Groebner basis 59 ideal Mrwalk(ideal Go, intvec* curr_weight, intvec* target_weight, int weight_rad, int pert_deg, ring baseRing); 59 60 ideal Mrwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, int pert_deg, int reduction, int printout); 60 61 61 62 /* the perturbation walk algorithm */ 62 63 63 ideal Mpwalk(ideal Go, int op_deg, int tp_deg,intvec* curr_weight,intvec* target_weight, int nP );64 ideal Mpwalk(ideal Go, int op_deg, int tp_deg,intvec* curr_weight,intvec* target_weight, int nP, int reduction, int printout); 64 65 65 66 /* the perturbation walk algorithm with random element */ 66 67 ideal Mprwalk(ideal Go, intvec* curr_weight, intvec* target_weight, int weight_rad, int op_deg, int tp_deg, ring baseRing); 67 ideal Mprwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, int op_deg, int tp_deg, int nP, int reduction, int printout); 68 68 69 69 /* The fractal walk algorithm */ 70 ideal Mfwalk(ideal G, intvec* ivstart, intvec* ivtarget );70 ideal Mfwalk(ideal G, intvec* ivstart, intvec* ivtarget, int reduction, int printout); 71 71 72 72 /* The fractal walk algorithm with random element */ 73 ideal Mfrwalk(ideal G, intvec* ivstart, intvec* ivtarget, int weight_rad);73 ideal Mfrwalk(ideal G, intvec* ivstart, intvec* ivtarget, int weight_rad, int reduction, int printout); 74 74 75 75 /* Implement Tran's idea */ -
Property
mode
changed from
-
Tst/Long/ok_l2.lst
r8af63a r11d9d00 1 1 algemodstd_l 2 2 bug_tr642 3 bug_tr677 3 4 king_3_colors_l 4 5 modstd_l -
Tst/Long/primdec_l.res.gz.uu
r8af63a r11d9d00 1 1 begin 640 primdec_l.res.gz 2 M'XL(" +EN3U0``W!R:6UD96-?;"YR97,`[%W;CN0X<GWOKTCLTRR4*HC!NP?=3 M@ +T&C`4,P_#NBSU8#/)6657N'JP[;\K\>I^@1(K*4EZJNK:F=R<QF$J1(H/!4 M $T%&,!@S^M.?__6/_S$:C<2GT;__\5]&OUNOUG>?'Z>_^_'#G]HW]&F$RI\?5 M ?WE<__#['S_P[^C3I]%?OSY^F2]F/W^^^V6QNUNM)^O40WX:I6=UQW1_U[8^6 M (JVSAN9N]/7QE^7HZT=)527'/TS&T_%L/!\OQO?CY?AA_/3[\0]_&,__^ONN7 M O_TT>IPO)I]'CQ]3G;L;30J:%K-R7BS'J=K?C>YI^5!.4I6H[D:+^V4YZVH$8 M &BWIJ9QV5<3D0*VX+Y:EZ.KEW4A.YH6<S@N:S8OY?3%?EI.2IN6L7"8.A>IF9 M */3=Z//C:@WDQ,<OC[_\\VKU;W_^GQ\>N_D(D^8C/GZ=S!]GD\^]]]U\Z>/B10 M _S:/_S70QGV*H]#'**3C<7QJ(UM._O`P^?K#XUATC:A*C=3'ELZ?_ONH#;3F11 M RV3]];$>??DX`XF?5XNOCXM5/A@1ZXKX\<-/XB__]`&2^!D/'P/,]X5H*N@O12 M 'TM4%/</!2V?BD6LEZ@/4J/0'M(JYN6R>:?PCBMF35&C*$Q5"6Y?3)OG61%^13 M YDVI[6C^\K%3D`\8.^.*^S:LE<N,.8J,O1];,F-KF1BY+]\1&96S4'9HW+\;14 M "U&%L*$\0H,>!;,R+>=!<U"B7FM4@*<Y9'5/#PWQZ0R+^?ZI'?`>&@8MFT&215 M X/FI"((&/T]-8[0EM&5!/S$Q3"+L#_RL6Y4-#;EVVO;AEV!ZQNH;@("BR(`&16 M B%$`YZ'$B*7"B*5ID"H7RX)U2K%.H0G&+(@IV4P'"P8P[#K\QN&-?(@3"3-@17 M 1G.FJ&P';.>SN.>.'L*3#VVCZ0+<+)@E-$7[Y0.U\U@^/`5>GTJYI(=$H<5Q18 M P3RA+7A[*J:1C?9W`6H/)5H\!`E50(,)%>H^-`^H4,FP4#%;@#NS8!X7#63419 M -'D(<J&"8:*"<2(`P#R!)>!$Y0(=(4'#,`;Y"-9+]4215_!=`J.L'*%AB<C[20 M ,*^&&1F8X9?5(BD+X\*JPP,SAMI['YB4@3T*/#4MZ3X^+,N62H"TF"XC.(PQ21 M Z!$F'&124L=/8C&B&[0!K24FJ)>Q6?E0RJ>T"&!*'@F+@'J+@(X7`;WE(J!L22 M $="Y14!OM@CHY"*@URX">N=%0.^V".BWM@@T.Q/4.1/Q=\BO..-:=`:,W\V+23 M UJY&V]6I7^OWI9<Z]IFF*M/:P6(2&*+OB:'(S3.8GCLZ@[[..^+TZW(4_:UC24 M H'(*T?5Y/U#><?3H[3T#@'H<+!L/+S*![99RY69KL>0U?&+H/KOF'+OV.;ON25 M /%@]1LN_Y;**NY'AW4@>'6WFR5&>=B<<R49ZAAT.HU#RD1O;R\:V7$0'6[,=26 M 9?L83QL!I8?&6"\20<L&Y@&F!)LKFH)JV]Q%@QU*,'PS[,\%_H6H^&G&M&9M27 M 8[93V,=A5V!_9_34UF(6"PFJO/)FP3;-8'@6+>,"4YO!Q#R5LX4J%PJ#+6"528 M %Q+8J!DMN/U"@34>"6]0N6`KMY#]T];PL6:>T.D.#]/N<'!T,AH\ELQC[6DB29 M ^=DFB(627*CSKCK1Y2<;ME+1.B7JT95JSC2+Z(Z4R0])H[-'TQL0HIS#&K((30 M V)0&8[E@)X!]HP?X3,'VEPK%IR1CMN-E,./MB!``&K'OXG+K^I#T@.U_VW8931 M +%`TNVEN01NR25"TU.RKQ?:4_,-<7>:+UKBG/LO`#\U9O:$'\Z>PA].B4`]I32 M _5A>/^JT->])9D`XS^1S2D0ODM()09V552LGQU->=*)ZE;2N%=CK9792;+W^33 M U",P#T),A+#O/+34CC?BOQ^IG5IA?V]B.[_:3CF!Y[R+>=]0SG)Q]$SBB_V634 M %U`^Y93U[3CE_5H[VS?F;&D?ADQ\YMR8(^?&LGS*6:X-LV4NYF/7ISGRX>A435 M SHY>\))8L.F>@8FR4]9@1^FEKLS\:O1.>'3S'G+/%V7NI23XGCDJ<=#<5TE`36 M 'KLK$=$ACR6BFYR6"/!IOR7A?>RZ)+Q/>B\=\*]S8`:$=</S&_",GH#[-/KR37 M XX<O/XDQ1J,FGA6*?%R>3!?%!/O^=+XHYC"ODT6)$O%M2VC##OZT]>ZYS-'G38 M 28B&<0F@3J8<$YI,8<.F;,@F<RY/\;>8@QV\X==LX::\@W+]!*\>RDF@P)[_39 M A*9/Q2180-`!\Z#Q!([X6($-?T+\`F_GX<SPY2<:!]7@!P[0808TQ78\A;@F40 M _+Q@P<W"^X;]AGEBYIOI!_8ILH\JR=S/&G8+U=3-`J>$"GX*'7CQ,[,*W?!W41 M *IG9Z8P?"7^GD"TF$MZ'.GX=WN+/C.<$*I*YGX2'L+WR@^3MAA]4,S')K#5<42 M 2QZ4V56QGXK]5.RG0K_07(6>X<$TQB*J@?\T6B]6Z__\^OAE\G7_PU^_TIBO43 M DE(#67T:_>_CY\^CK^E^28KNBDW2\27B=+P:K\>;\7:\&]?C_?CP[!)1RN>744 M B%+=C:;;8K5)]WU2HV97K+,:<S=:H6;;U5BTV1>KNJMQJ#D4ZZS&HQ=J]JE&45 M 57>CS;[8=FV40,VAV&4UF-<6-?O$M<KN6)6Z=+&H]/F+164N7RPJ>_EB4;DK46 M +A:5OWRQJ*O+%XM:#%TL'M(A;I^.;W4ZNNW2>6V;SF.;_JETM2FFVT3DD(CL47 M $Y$Z$=DE(NO^N72(BUTBL$T$UHG`JG\F78.+W95<;',B.B<"%;Z6R"81F7[`48 M WVL!72<"JYR`S0&MB^E^@(LA/#8YH&Z0BWJ`P&8`4'#A,P+;NMB<Y^+$5&`749 M ,T0QEVMEV\T%8A&YCNX')K,=F$R?CUQ)=YC-$!_;B[/)M72-S>H\L$.S82JY50 M JG8:MDT4-A?YR/5TA^UOB(]+5.)&0/GU<$.LN1QN)MC<"S>0-=>ZC3(TU[J-51 M 2)M;W$95FWO89O$T-Z_-:FPN4YO]H;WHW.P/\29RVCYBV-6N><2HT_:1Y=JP52 M )7@2[2//HGW$B-.&/X$!IPW;PG.#P!%5W*!YY-&V@1]B*PLV(Q(ROR-LD:`,53 M "<J0H`P)RI"@#`G*D*`,"<J0H`X)ZI"@#@GJD*`.">J0H`X)ZI"@#@GJD*`.54 M ">J0H&=(J`L718?<:]_G'GN=.^J[W#??YD[Y9N@L\`943YW67T-ZG9-.ANTM55 M F!Z@?.JT?B7Y;4Y^E9-/MO"5C%^B?.J@?"7Y30^7:'+C$--O8/P2Y6CL7\GX56 M ^B0NW\+T.:K1L3C+\"XGO3V-1T\#HX]QENG74XX.S3'C^U>0[VM@="B.&7\C57 M RM&)NEY%=CGY[6E<7J8B5U.-3ML+5"1Z=I'\M^CUZRDG1_&LCFQ[H$0O[I6<58 M OQ'EY)P><UZ?1N;TXHD^Y5G.WXAR<HK/:DO=0^:Z97]94UY'-3G@Y[&.#G&D59 M O\GIOU!+WHAR<OK/ZG</E2MWJLNZ_3JJZ9!QS/$NI[U]*YS?@"K[P</ZW+M+60 M VU-.O>XM]'J?TZ][%QR[?=<47O:.NB(\[9U,)7^L*.SA;W<=:7;SM[M.+.SK61 M ;RE[SW*B#A'V^K<=??;\^UL4'P#ZVRV?`S;Y$(X/#EG9<SD#G0\AE"F[X'+V62 M GKC<R858,!U+Q*+)\"%>N[NLS"8U0X#X8)2Q1WPXVF;O/9=WF:0JKL@8E"',63 M DY7YF+;)>TBNR#2)6<QD)IG%;(:26:0,(FE#14:1F:1-5L%<=B"HZGB;57D864 M J:GA8UTV426YG+F`B@\$69G5?),QH=C.KS,"ELM9!\?E;)7S47.=+70PN<IT65 M 37.,*1.L9@;S26KFD+)UQQQVD];IZ)MJ<H^RJ;'9,:2I<=F)JJGA(VHV<</G66 M U&Q>A@^KV3Q,.+%F[_F0O,K>*RYG]H.O^`:O"[N+/\JW%)EO-L=[9>_4V4W+67 M YINMR[=AS_8OGJ[U4.+3M:'7+.C9'!SI:B(GHDEY4*M.!#:)P#H16"4"73I068 M L]7UPJ^OBM#U0EJ)P`N"8F:0@^VUTP@;:B_TVH&YNY)(LP>?"+T.260[,)7V69 M 6.TO$+D8$.^%7O<#<SDODO8$)*[7T<T`(LWNUP^_OBH:+8:U]/QL,C["OMP/70 M O5Z[XGJ7';W0ZY"&#/&1R25LC'$C,!<RN+[_D_T;AMO>)SYXU0'B.CQZ&2/)71 M \+_%86V`\E5AMN_JK/9MX;4S>$2'ZBWB@@.43X79OO]HU8DPV_<;K7IQ>.U[72 M B7F_.,S6<R57.?F>!J9#W/7[]8LHOR+,=B7]=""]/LSV(LHGPVS?<3CBA''\73 M CD,^UUC'34[[6AG&>,A9Z_AZRB?#:U<N^%_A,N=4>.TU3L[[WE1>%V9[%BL]74 M "HT<Q[#T<0@KMYBAPA['%=QQ=,4?QQDX\M:/,X0K]G[R99T%KCCTMLG+JKF175 M 3^6CP!9'WE9YV39W]:GLF@O[5/;-K7T"JFKNZU-9-)?VJ<RBRN)L+*PL@,EQ76 M MVU>YER3O,SLY65F+R^[?CB*VD2!)+8V6R"5><EV['#0;5/W8V[3O*SZ01V.77 M N66!4@ZY]8)\(6AY%'#;]>-MJZS,`;=I7A;]H"8'VZ9Y6399#JG<CZMRK.U978 M J"TO,WAYV?5BH"I$L++`6=6+#H9`VSI[S<RM^W&V/&`U$&>;KK+F)L2,L_5C79 M 0V`OJW`AI)M5^!!6[BI,"/KF%2$8N,XJ0M@WBXISF&U#F89PG&U%&<@<:`.-80 M ;W&_+AP+1^UFT&'E\NW5Y\E--L^,WL2<Z&U,?-[%C.<Z)COO8\[R(:8AKV(:81 M \C;F&S=[3)MN7,<\XWW,'S[$%.!I3`%>Q13@=4P!WL04X&U,`-[%!.!I3`!>82 M Q03@34P`WL;TWSJF__*@.O;2L9>.8^DXEHZ]]#@9S2\_F=C3Q)XF]C1Q;B;.83 M S<2YV=C+QEXV]K*12QM[V7%RX;[\Y&)/%WNZV-.-58.!&R=+P(5V3!\EX;GG84 M .CS(9B@?>_HXIH^]1!6[X8E:!:AB1SRU/?$415^-D]U!*:C-NGFB:$I"*2I/85 M ISV=^B3]$10G+"CR+2B*5%`:GZ)X1-(@(=/8,O$N$^\R]0UJU!C&4(K]DS()86 M E?H'=6IL9BA%WE7B7:7^2:V$3OUU&E^G\9-JB:!;C9F/Z\]=2$G7_EE*NJD^87 M Q33TZIH4=".>IZ`;.DY!-_(X!=VHXQ1THX]3T(TY3D$W]C@%W;CC%'3CCU/088 M ;76<@FZSQ'M+EU+0K3R?@F[5Y11TJR^GH%MS10JZM9=3T*V[G()N_2T%_9:"89 M ?DM!_\VGH+OJEH+>(B%N*>@M$G1+0;^EH%]'^9:"?DM!OT#YEH)^2T&_I:!G90 M R)Q>/+<4]%L*^LMVJEL*>L?Q+04]U=Q2T&\IZ*%\2T%ORM]/"KJ3MQ3T6PKZ91 M +07]-Y^"[M0M!;TC?TM!/T?YEH*>\+BEH-]2T&\IZ*^B?$M!OZ6@G^/XEH)^92 M 2T&_I:#?4M"3V&XIZ+<4]+_C%'2G;RGHMQ3T6PKZKY6"[LR%%'1GGZ6@.]<E93 M 9SN?_J_HH_9_BSZ<A^ZKYWGH7MR-A-V;0OF]+OU>%4K4="@$[64AY9X*(?:%94 M E2E1W-/=2-%>\TM5$!KO"V&YBY'H(D2-YA;]//IU'U3V\FY$!M5*U8%ZX3N^95 M LJ\H^XM?4?87OJ+LK_B*LK_B*\K^BJ\HB^KR5Y1%=?DKRJ(:_(KRH?#6V@_)