Changeset 285d21 in git for Singular/LIB/freegb.lib
- Timestamp:
- Feb 27, 2008, 12:36:12 AM (16 years ago)
- Branches:
- (u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
- Children:
- a92dff3697f0a605f93ad3003fd0d033b72d64b1
- Parents:
- 4d43ff458adf4e30c9059ffaf846500aa5d64c61
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/freegb.lib
r4d43ff r285d21 1 1 ////////////////////////////////////////////////////////////////////////////// 2 version="$Id: freegb.lib,v 1. 6 2008-02-23 20:14:12 levandov Exp $";2 version="$Id: freegb.lib,v 1.7 2008-02-26 23:36:12 levandov Exp $"; 3 3 category="Noncommutative"; 4 4 info=" … … 7 7 8 8 PROCEDURES: 9 freegb (list L, int n); compute two-sided Groebner basis of ideal, encoded via L, up to degree n9 freegbasis(list L, int n); compute two-sided Groebner basis of ideal, encoded via L, up to degree n 10 10 lst2str(list L); convert a list (of modules) into polynomials in free algebra 11 11 mod2str(module M); convert a module into a polynomial in free algebra … … 278 278 } 279 279 280 // new conversion routines 281 282 proc id2words(ideal I, int d) 283 { 284 // input: ideal I of polys in letter-place notation 285 // in the ring with d real vars 286 // output: the list of strings: associative words 287 // extract names of vars 288 int i,m,n; string s; string place = "(1)"; 289 list lv; 290 for(i=1; i<=d; i++) 291 { 292 s = string(var(i)); 293 // get rid of place 294 n = find(s, place); 295 if (n>0) 296 { 297 s = s[1..n-1]; 298 } 299 lv[i] = s; 300 } 301 poly p,q; 302 for (i=1; i<=ncols(I); i++) 303 { 304 if (I[i] != 0) 305 { 306 p = I[i]; 307 while (p!=0) 308 { 309 q = leadmonom(p); 310 311 } 312 } 313 } 314 315 return(lv); 316 } 317 example 318 { 319 "EXAMPLE:"; echo = 2; 320 ring r = 0,(x(1),y(1),z(1)),dp; 321 ideal I = x(1)*y(2) -z(1)*x(2); 322 id2words(I,3); 323 } 324 325 326 327 proc mono2word(poly p, int d) 328 { 329 330 } 331 280 332 // given the element -7xy^2x, it is represented as [-7,x,y^2,x] or as [-7,x,y,y,x] 281 333 // use the orig ord on (x,y,z) and expand it blockwise to (x(i),y(i),z(i)) … … 288 340 289 341 // 1. form a new ring 290 // 2. produce shifted generators291 // 3. compute GB 292 // 4. skip shifted elts 342 // 2. NOP 343 // 3. compute GB -> with the kernel stuff 344 // 4. skip shifted elts (check that no such exist?) 293 345 // 5. go back to orig vars, produce strings/modules 294 346 // 6. return the result 295 347 296 proc freegb (list LM, int d)297 "USAGE: freegb (L, d); L a list of modules, d an integer348 proc freegbasis(list LM, int d) 349 "USAGE: freegbasis(L, d); L a list of modules, d an integer 298 350 RETURN: ring 299 351 PURPOSE: compute the two-sided Groebner basis of an ideal, encoded by L in 300 352 the free associative algebra, up to degree d 301 EXAMPLE: example freegb ; shows examples353 EXAMPLE: example freegbasis; shows examples 302 354 " 303 355 { … … 351 403 // ordering: d blocks of the ord on r 352 404 // try to get whether the ord on r is blockord itself 353 // TODO: make L(2) ordering! exponent is maximally 2354 405 s = size(LR[3]); 355 406 if (s==2) … … 402 453 M = LM[l]; 403 454 sm = ncols(M); // in intvec iv the sizes are stored 404 for (i=0; i<=d-iv[l]; i++) 405 { 406 // modules, e.g. free polynomials 407 for (j=1; j<=sm; j++) 408 { 409 //vectors, e.g. free monomials 410 v = M[j]; 411 sv = size(v); 412 // "sv:";sv; 413 sp = "@@p = @@p + "; 414 for (k=2; k<=sv; k++) 415 { 416 sp = sp + string(v[k])+"("+string(k-1+i)+")*"; 417 } 418 sp = sp + string(v[1])+";"; // coef; 419 setring @R; 420 execute(sp); 421 setring save; 422 } 455 // modules, e.g. free polynomials 456 for (j=1; j<=sm; j++) 457 { 458 //vectors, e.g. free monomials 459 v = M[j]; 460 sv = size(v); 461 // "sv:";sv; 462 sp = "@@p = @@p + "; 463 for (k=2; k<=sv; k++) 464 { 465 sp = sp + string(v[k])+"("+string(k-1)+")*"; 466 } 467 sp = sp + string(v[1])+";"; // coef; 423 468 setring @R; 424 // "@@p:"; @@p; 425 I = I,@@p; 426 @@p = 0; 469 execute(sp); 427 470 setring save; 428 471 } 472 setring @R; 473 // "@@p:"; @@p; 474 I = I,@@p; 475 @@p = 0; 476 setring save; 429 477 } 430 478 kill sp; … … 432 480 setring @R; 433 481 dbprint(ppl,"computing GB"); 434 // ideal J = groebner(I);435 ideal J = slimgb(I);482 ideal J = system("freegb",I,d,nvars(save)); 483 // ideal J = slimgb(I); 436 484 dbprint(ppl,J); 437 485 // 4. skip shifted elts … … 548 596 list L; L[1] = M; L[2] = N; 549 597 lst2str(L); 550 def U = freegb (L,5);598 def U = freegbasis(L,5); 551 599 lst2str(U); 552 600 } 553 601 554 // 1. form a new ring 555 // 2. NOP 556 // 3. compute GB -> with the kernel stuff 557 // 4. skip shifted elts (check that no such exist?) 558 // 5. go back to orig vars, produce strings/modules 559 // 6. return the result 560 561 proc freegbnew(list LM, int d) 562 "USAGE: freegb(L, d); L a list of modules, d an integer 602 proc crs(list LM, int d) 603 "USAGE: crs(L, d); L a list of modules, d an integer 563 604 RETURN: ring 564 PURPOSE: compute the two-sided Groebner basis of an ideal, encoded by L in 565 the free associative algebra, up to degree d 566 EXAMPLE: example freegb; shows examples 605 PURPOSE: create a ring and shift the ideal 606 EXAMPLE: example crs; shows examples 567 607 " 568 608 { … … 605 645 for (j=1; j<=s; j++) 606 646 { 607 tmp[i*s+j] = string(tmp[j])+"("+string(i +1)+")";647 tmp[i*s+j] = string(tmp[j])+"("+string(i)+")"; 608 648 } 609 649 } 610 650 for (i=1; i<=s; i++) 611 651 { 612 tmp[i] = string(tmp[i])+"("+string( 1)+")";652 tmp[i] = string(tmp[i])+"("+string(0)+")"; 613 653 } 614 654 L[2] = tmp; … … 666 706 M = LM[l]; 667 707 sm = ncols(M); // in intvec iv the sizes are stored 668 // modules, e.g. free polynomials 669 for (j=1; j<=sm; j++) 670 { 671 //vectors, e.g. free monomials 672 v = M[j]; 673 sv = size(v); 674 // "sv:";sv; 675 sp = "@@p = @@p + "; 676 for (k=2; k<=sv; k++) 677 { 678 sp = sp + string(v[k])+"("+string(k-1)+")*"; 679 } 680 sp = sp + string(v[1])+";"; // coef; 708 for (i=0; i<=d-iv[l]; i++) 709 { 710 // modules, e.g. free polynomials 711 for (j=1; j<=sm; j++) 712 { 713 //vectors, e.g. free monomials 714 v = M[j]; 715 sv = size(v); 716 // "sv:";sv; 717 sp = "@@p = @@p + "; 718 for (k=2; k<=sv; k++) 719 { 720 sp = sp + string(v[k])+"("+string(k-2+i)+")*"; 721 } 722 sp = sp + string(v[1])+";"; // coef; 723 setring @R; 724 execute(sp); 725 setring save; 726 } 681 727 setring @R; 682 execute(sp); 728 // "@@p:"; @@p; 729 I = I,@@p; 730 @@p = 0; 683 731 setring save; 684 732 } 685 setring @R; 686 // "@@p:"; @@p; 687 I = I,@@p; 688 @@p = 0; 689 setring save; 690 } 691 kill sp; 692 // 3. compute GB 733 } 693 734 setring @R; 694 dbprint(ppl,"computing GB"); 695 // ideal J = system("",I); 696 ideal J = slimgb(I); 697 dbprint(ppl,J); 698 // 4. skip shifted elts 699 ideal K = select1(J,1,s); // s = size(OrigNames) 700 dbprint(ppl,K); 701 dbprint(ppl, "done with GB"); 702 // K contains vars x(1),...z(1) = images of originals 703 // 5. go back to orig vars, produce strings/modules 704 if (K[1] == 0) 705 { 706 "no reasonable output, GB gives 0"; 707 return(0); 708 } 709 int sk = size(K); 710 int sp, sx, a, b; 711 intvec x; 712 poly p,q; 713 poly pn; 714 // vars in 'save' 715 setring save; 716 module N; 717 list LN; 718 vector V; 719 poly pn; 720 // test and skip exponents >=2 721 setring @R; 722 for(i=1; i<=sk; i++) 723 { 724 p = K[i]; 725 while (p!=0) 726 { 727 q = lead(p); 728 // "processing q:";q; 729 x = leadexp(q); 730 sx = size(x); 731 for(k=1; k<=sx; k++) 732 { 733 if ( x[k] >= 2 ) 734 { 735 err = "skip: the value x[k] is " + string(x[k]); 736 dbprint(ppl,err); 737 // return(0); 738 K[i] = 0; 739 p = 0; 740 q = 0; 741 break; 742 } 743 } 744 p = p - q; 745 } 746 } 747 K = simplify(K,2); 748 sk = size(K); 749 for(i=1; i<=sk; i++) 750 { 751 // setring save; 752 // V = 0; 753 setring @R; 754 p = K[i]; 755 while (p!=0) 756 { 757 q = lead(p); 758 err = "processing q:" + string(q); 759 dbprint(ppl,err); 760 x = leadexp(q); 761 sx = size(x); 762 pn = leadcoef(q); 763 setring save; 764 pn = imap(@R,pn); 765 V = V + leadcoef(pn)*gen(1); 766 for(k=1; k<=sx; k++) 767 { 768 if (x[k] ==1) 769 { 770 a = k / s; // block number=a+1, a!=0 771 b = k % s; // remainder 772 // printf("a: %s, b: %s",a,b); 773 if (b == 0) 774 { 775 // that is it's the last var in the block 776 b = s; 777 a = a-1; 778 } 779 V = V + var(b)*gen(a+2); 780 } 781 // else 782 // { 783 // printf("error: the value x[k] is %s", x[k]); 784 // return(0); 785 // } 786 } 787 err = "V: " + string(V); 788 dbprint(ppl,err); 789 // printf("V: %s", string(V)); 790 N = N,V; 791 V = 0; 792 setring @R; 793 p = p - q; 794 pn = 0; 795 } 796 setring save; 797 LN[i] = simplify(N,2); 798 N = 0; 799 } 800 setring save; 801 return(LN); 735 export I; 736 return(@R); 802 737 } 803 738 example … … 809 744 list L; L[1] = M; L[2] = N; 810 745 lst2str(L); 811 def U = freegbnew(L,5); 746 def U = crs(L,5); 747 setring U; U; 748 I; 749 } 750 751 proc polylen(ideal I) 752 { 753 // returns the ideal of length of polys 754 int i; 755 intvec J; 756 number s = 0; 757 for(i=1;i<=ncols(I);i++) 758 { 759 J[i] = size(I[i]); 760 s = s + J[i]; 761 } 762 printf("the sum of length %s",s); 763 // print(s); 764 return(J); 765 } 766 767 proc freegbRing(int d) 768 "USAGE: freegbRing(d); d an integer 769 RETURN: ring 770 PURPOSE: creates a ring with d blocks of shifted original variables 771 EXAMPLE: example freegbRing; shows examples 772 " 773 { 774 // d = up to degree, will be shifted to d+1 775 if (d<1) {"bad d"; return(0);} 776 777 int ppl = printlevel-voice+2; 778 string err = ""; 779 780 int i,j,s; 781 def save = basering; 782 int D = d-1; 783 list LR = ringlist(save); 784 list L, tmp; 785 L[1] = LR[1]; // ground field 786 L[4] = LR[4]; // quotient ideal 787 tmp = LR[2]; // varnames 788 s = size(LR[2]); 789 for (i=1; i<=D; i++) 790 { 791 for (j=1; j<=s; j++) 792 { 793 tmp[i*s+j] = string(tmp[j])+"("+string(i+1)+")"; 794 } 795 } 796 for (i=1; i<=s; i++) 797 { 798 tmp[i] = string(tmp[i])+"("+string(1)+")"; 799 } 800 L[2] = tmp; 801 list OrigNames = LR[2]; 802 // ordering: d blocks of the ord on r 803 // try to get whether the ord on r is blockord itself 804 // TODO: make L(2) ordering! exponent is maximally 2 805 s = size(LR[3]); 806 if (s==2) 807 { 808 // not a blockord, 1 block + module ord 809 tmp = LR[3][s]; // module ord 810 for (i=1; i<=D; i++) 811 { 812 LR[3][s-1+i] = LR[3][1]; 813 } 814 LR[3][s+D] = tmp; 815 } 816 if (s>2) 817 { 818 // there are s-1 blocks 819 int nb = s-1; 820 tmp = LR[3][s]; // module ord 821 for (i=1; i<=D; i++) 822 { 823 for (j=1; j<=nb; j++) 824 { 825 LR[3][i*nb+j] = LR[3][j]; 826 } 827 } 828 // size(LR[3]); 829 LR[3][nb*(D+1)+1] = tmp; 830 } 831 L[3] = LR[3]; 832 def @R = ring(L); 833 // setring @R; 834 return (@R); 835 } 836 example 837 { 838 "EXAMPLE:"; echo = 2; 839 ring r = 0,(x,y,z),(dp(1),dp(2)); 840 def A = freegbRing(2); 841 setring A; 842 A; 843 } 844 845 846 proc ex_shift() 847 { 848 LIB "freegb.lib"; 849 ring r = 0,(x,y,z),(dp(1),dp(2)); 850 module M = [-1,x,y],[-7,y,y],[3,x,x]; 851 module N = [1,x,y,x],[-1,y,x,y]; 852 list L; L[1] = M; L[2] = N; 853 lst2str(L); 854 def U = crs(L,5); 855 setring U; U; 856 I; 857 poly p = I[2]; // I[8]; 858 p; 859 system("stest",p,7,7,3); // error -> the world is ok 860 poly q1 = system("stest",p,1,7,3); //ok 861 poly q6 = system("stest",p,6,7,3); //ok 862 system("btest",p,3); //ok 863 system("btest",q1,3); //ok 864 system("btest",q6,3); //ok 865 } 866 867 proc ex2() 868 { 869 option(prot); 870 LIB "freegb.lib"; 871 ring r = 0,(x,y),dp; 872 module M = [-1,x,y],[3,x,x]; // 3x^2 - xy 873 def U = freegb(M,7); 812 874 lst2str(U); 813 875 } 814 876 815 proc crs(list LM, int d) 816 "USAGE: crs(L, d); L a list of modules, d an integer 877 proc ex_nonhomog() 878 { 879 option(prot); 880 LIB "freegb.lib"; 881 ring r = 0,(x,y,h),dp; 882 list L; 883 module M; 884 M = [-1,y,y],[1,x,x,x]; // x3-y2 885 L[1] = M; 886 M = [1,x,h],[-1,h,x]; // xh-hx 887 L[2] = M; 888 M = [1,y,h],[-1,h,y]; // yh-hy 889 L[3] = M; 890 def U = freegb(L,4); 891 lst2str(U); 892 // strange elements in the basis 893 } 894 895 proc ex_nonhomog_comm() 896 { 897 option(prot); 898 LIB "freegb.lib"; 899 ring r = 0,(x,y),dp; 900 module M = [-1,y,y],[1,x,x,x]; 901 def U = freegb(M,5); 902 lst2str(U); 903 } 904 905 proc ex_nonhomog_h() 906 { 907 option(prot); 908 LIB "freegb.lib"; 909 ring r = 0,(x,y,h),(a(1,1),dp); 910 module M = [-1,y,y,h],[1,x,x,x]; // x3 - y2h 911 def U = freegb(M,6); 912 lst2str(U); 913 } 914 915 proc ex_nonhomog_h2() 916 { 917 option(prot); 918 LIB "freegb.lib"; 919 ring r = 0,(x,y,h),(dp); 920 list L; 921 module M; 922 M = [-1,y,y,h],[1,x,x,x]; // x3 - y2h 923 L[1] = M; 924 M = [1,x,h],[-1,h,x]; // xh - hx 925 L[2] = M; 926 M = [1,y,h],[-1,h,y]; // yh - hy 927 L[3] = M; 928 def U = freegbasis(L,3); 929 lst2str(U); 930 // strange answer CHECK 931 } 932 933 934 proc ex_nonhomog_3() 935 { 936 option(prot); 937 LIB "./freegb.lib"; 938 ring r = 0,(x,y,z),(dp); 939 list L; 940 module M; 941 M = [1,z,y],[-1,x]; // zy - x 942 L[1] = M; 943 M = [1,z,x],[-1,y]; // zx - y 944 L[2] = M; 945 M = [1,y,x],[-1,z]; // yx - z 946 L[3] = M; 947 lst2str(L); 948 list U = freegb(L,4); 949 lst2str(U); 950 // strange answer CHECK 951 } 952 953 proc ex_densep_2() 954 { 955 option(prot); 956 LIB "freegb.lib"; 957 ring r = (0,a,b,c),(x,y),(Dp); // deglex 958 module M = [1,x,x], [a,x,y], [b,y,x], [c,y,y]; 959 lst2str(M); 960 list U = freegb(M,5); 961 lst2str(U); 962 // a=b is important -> finite basis!!! 963 module M = [1,x,x], [a,x,y], [a,y,x], [c,y,y]; 964 lst2str(M); 965 list U = freegb(M,5); 966 lst2str(U); 967 } 968 969 970 // 1. form a new ring 971 // 2. produce shifted generators 972 // 3. compute GB 973 // 4. skip shifted elts 974 // 5. go back to orig vars, produce strings/modules 975 // 6. return the result 976 977 proc freegbold(list LM, int d) 978 "USAGE: freegbold(L, d); L a list of modules, d an integer 817 979 RETURN: ring 818 PURPOSE: create a ring and shift the ideal 819 EXAMPLE: example crs; shows examples 980 PURPOSE: compute the two-sided Groebner basis of an ideal, encoded by L in 981 the free associative algebra, up to degree d 982 EXAMPLE: example freegbold; shows examples 820 983 " 821 984 { … … 858 1021 for (j=1; j<=s; j++) 859 1022 { 860 tmp[i*s+j] = string(tmp[j])+"("+string(i )+")";1023 tmp[i*s+j] = string(tmp[j])+"("+string(i+1)+")"; 861 1024 } 862 1025 } 863 1026 for (i=1; i<=s; i++) 864 1027 { 865 tmp[i] = string(tmp[i])+"("+string( 0)+")";1028 tmp[i] = string(tmp[i])+"("+string(1)+")"; 866 1029 } 867 1030 L[2] = tmp; … … 869 1032 // ordering: d blocks of the ord on r 870 1033 // try to get whether the ord on r is blockord itself 1034 // TODO: make L(2) ordering! exponent is maximally 2 871 1035 s = size(LR[3]); 872 1036 if (s==2) … … 931 1095 for (k=2; k<=sv; k++) 932 1096 { 933 sp = sp + string(v[k])+"("+string(k- 2+i)+")*";1097 sp = sp + string(v[k])+"("+string(k-1+i)+")*"; 934 1098 } 935 1099 sp = sp + string(v[1])+";"; // coef; … … 945 1109 } 946 1110 } 1111 kill sp; 1112 // 3. compute GB 947 1113 setring @R; 948 export I; 949 return(@R); 1114 dbprint(ppl,"computing GB"); 1115 // ideal J = groebner(I); 1116 ideal J = slimgb(I); 1117 dbprint(ppl,J); 1118 // 4. skip shifted elts 1119 ideal K = select1(J,1,s); // s = size(OrigNames) 1120 dbprint(ppl,K); 1121 dbprint(ppl, "done with GB"); 1122 // K contains vars x(1),...z(1) = images of originals 1123 // 5. go back to orig vars, produce strings/modules 1124 if (K[1] == 0) 1125 { 1126 "no reasonable output, GB gives 0"; 1127 return(0); 1128 } 1129 int sk = size(K); 1130 int sp, sx, a, b; 1131 intvec x; 1132 poly p,q; 1133 poly pn; 1134 // vars in 'save' 1135 setring save; 1136 module N; 1137 list LN; 1138 vector V; 1139 poly pn; 1140 // test and skip exponents >=2 1141 setring @R; 1142 for(i=1; i<=sk; i++) 1143 { 1144 p = K[i]; 1145 while (p!=0) 1146 { 1147 q = lead(p); 1148 // "processing q:";q; 1149 x = leadexp(q); 1150 sx = size(x); 1151 for(k=1; k<=sx; k++) 1152 { 1153 if ( x[k] >= 2 ) 1154 { 1155 err = "skip: the value x[k] is " + string(x[k]); 1156 dbprint(ppl,err); 1157 // return(0); 1158 K[i] = 0; 1159 p = 0; 1160 q = 0; 1161 break; 1162 } 1163 } 1164 p = p - q; 1165 } 1166 } 1167 K = simplify(K,2); 1168 sk = size(K); 1169 for(i=1; i<=sk; i++) 1170 { 1171 // setring save; 1172 // V = 0; 1173 setring @R; 1174 p = K[i]; 1175 while (p!=0) 1176 { 1177 q = lead(p); 1178 err = "processing q:" + string(q); 1179 dbprint(ppl,err); 1180 x = leadexp(q); 1181 sx = size(x); 1182 pn = leadcoef(q); 1183 setring save; 1184 pn = imap(@R,pn); 1185 V = V + leadcoef(pn)*gen(1); 1186 for(k=1; k<=sx; k++) 1187 { 1188 if (x[k] ==1) 1189 { 1190 a = k / s; // block number=a+1, a!=0 1191 b = k % s; // remainder 1192 // printf("a: %s, b: %s",a,b); 1193 if (b == 0) 1194 { 1195 // that is it's the last var in the block 1196 b = s; 1197 a = a-1; 1198 } 1199 V = V + var(b)*gen(a+2); 1200 } 1201 // else 1202 // { 1203 // printf("error: the value x[k] is %s", x[k]); 1204 // return(0); 1205 // } 1206 } 1207 err = "V: " + string(V); 1208 dbprint(ppl,err); 1209 // printf("V: %s", string(V)); 1210 N = N,V; 1211 V = 0; 1212 setring @R; 1213 p = p - q; 1214 pn = 0; 1215 } 1216 setring save; 1217 LN[i] = simplify(N,2); 1218 N = 0; 1219 } 1220 setring save; 1221 return(LN); 950 1222 } 951 1223 example … … 957 1229 list L; L[1] = M; L[2] = N; 958 1230 lst2str(L); 959 def U = crs(L,5); 960 setring U; U; 961 I; 962 } 963 964 proc ex_shift() 965 { 966 LIB "freegb.lib"; 967 ring r = 0,(x,y,z),(dp(1),dp(2)); 968 module M = [-1,x,y],[-7,y,y],[3,x,x]; 969 module N = [1,x,y,x],[-1,y,x,y]; 970 list L; L[1] = M; L[2] = N; 971 lst2str(L); 972 def U = crs(L,5); 973 setring U; U; 974 I; 975 poly p = I[2]; // I[8]; 976 p; 977 system("stest",p,7,7,3); // error -> the world is ok 978 poly q1 = system("stest",p,1,7,3); //ok 979 poly q6 = system("stest",p,6,7,3); //ok 980 system("btest",p,3); //ok 981 system("btest",q1,3); //ok 982 system("btest",q6,3); //ok 983 } 984 985 proc ex2() 986 { 1231 def U = freegbold(L,5); 1232 lst2str(U); 1233 } 1234 1235 proc sgb(ideal I, int d) 1236 { 1237 // new code 1238 // map x_i to x_i(1) via map() 1239 //LIB "freegb.lib"; 1240 def save = basering; 1241 //int d =7;// degree 1242 int nv = nvars(save); 1243 def R = freegbRing(d); 1244 setring R; 1245 int i; 1246 ideal Imap; 1247 for (i=1; i<=nv; i++) 1248 { 1249 Imap[i] = var(i); 1250 } 1251 //ideal I = x(1)*y(2), y(1)*x(2)+z(1)*z(2); 1252 ideal I = x(1)*x(2),x(1)*y(2) + z(1)*x(2); 987 1253 option(prot); 988 LIB "freegb.lib"; 989 ring r = 0,(x,y),dp; 990 module M = [-1,x,y],[3,x,x]; // 3x^2 - xy 991 def U = freegb(M,7); 992 lst2str(U); 993 } 994 995 proc ex_nonhomog() 996 { 997 option(prot); 998 LIB "freegb.lib"; 999 ring r = 0,(x,y,h),dp; 1000 list L; 1001 module M; 1002 M = [-1,y,y],[1,x,x,x]; // x3-y2 1003 L[1] = M; 1004 M = [1,x,h],[-1,h,x]; // xh-hx 1005 L[2] = M; 1006 M = [1,y,h],[-1,h,y]; // yh-hy 1007 L[3] = M; 1008 def U = freegb(L,4); 1009 lst2str(U); 1010 // strange elements in the basis 1011 } 1012 1013 proc ex_nonhomog_comm() 1014 { 1015 option(prot); 1016 LIB "freegb.lib"; 1017 ring r = 0,(x,y),dp; 1018 module M = [-1,y,y],[1,x,x,x]; 1019 def U = freegb(M,5); 1020 lst2str(U); 1021 } 1022 1023 proc ex_nonhomog_h() 1024 { 1025 option(prot); 1026 LIB "freegb.lib"; 1027 ring r = 0,(x,y,h),(a(1,1),dp); 1028 module M = [-1,y,y,h],[1,x,x,x]; // x3 - y2h 1029 def U = freegb(M,6); 1030 lst2str(U); 1031 } 1032 1033 proc ex_nonhomog_h2() 1034 { 1035 option(prot); 1036 LIB "freegb.lib"; 1037 ring r = 0,(x,y,h),(dp); 1038 list L; 1039 module M; 1040 M = [-1,y,y,h],[1,x,x,x]; // x3 - y2h 1041 L[1] = M; 1042 M = [1,x,h],[-1,h,x]; // xh - hx 1043 L[2] = M; 1044 M = [1,y,h],[-1,h,y]; // yh - hy 1045 L[3] = M; 1046 def U = freegb(L,3); 1047 lst2str(U); 1048 // strange answer CHECK 1049 } 1050 1051 1052 proc ex_nonhomog_3() 1053 { 1054 option(prot); 1055 LIB "./freegb.lib"; 1056 ring r = 0,(x,y,z),(dp); 1057 list L; 1058 module M; 1059 M = [1,z,y],[-1,x]; // zy - x 1060 L[1] = M; 1061 M = [1,z,x],[-1,y]; // zx - y 1062 L[2] = M; 1063 M = [1,y,x],[-1,z]; // yx - z 1064 L[3] = M; 1065 lst2str(L); 1066 list U = freegb(L,4); 1067 lst2str(U); 1068 // strange answer CHECK 1069 } 1070 1071 1072 1073 proc ex_densep_2() 1074 { 1075 option(prot); 1076 LIB "freegb.lib"; 1077 ring r = (0,a,b,c),(x,y),(Dp); // deglex 1078 module M = [1,x,x], [a,x,y], [b,y,x], [c,y,y]; 1079 lst2str(M); 1080 list U = freegb(M,5); 1081 lst2str(U); 1082 // a=b is important -> finite basis!!! 1083 module M = [1,x,x], [a,x,y], [a,y,x], [c,y,y]; 1084 lst2str(M); 1085 list U = freegb(M,5); 1086 lst2str(U); 1087 } 1088 1089 1090 proc freegbRing(int d) 1091 "USAGE: freegbRing(d); d an integer 1092 RETURN: ring 1093 PURPOSE: creates a d-shifted ring 1094 EXAMPLE: example freegbRing; shows examples 1095 " 1096 { 1097 // d = up to degree, will be shifted to d+1 1098 if (d<1) {"bad d"; return(0);} 1099 1100 int ppl = printlevel-voice+2; 1101 string err = ""; 1102 1103 int i,j,s; 1104 def save = basering; 1105 int D = d-1; 1106 list LR = ringlist(save); 1107 list L, tmp; 1108 L[1] = LR[1]; // ground field 1109 L[4] = LR[4]; // quotient ideal 1110 tmp = LR[2]; // varnames 1111 s = size(LR[2]); 1112 for (i=1; i<=D; i++) 1113 { 1114 for (j=1; j<=s; j++) 1115 { 1116 tmp[i*s+j] = string(tmp[j])+"("+string(i+1)+")"; 1117 } 1118 } 1119 for (i=1; i<=s; i++) 1120 { 1121 tmp[i] = string(tmp[i])+"("+string(1)+")"; 1122 } 1123 L[2] = tmp; 1124 list OrigNames = LR[2]; 1125 // ordering: d blocks of the ord on r 1126 // try to get whether the ord on r is blockord itself 1127 // TODO: make L(2) ordering! exponent is maximally 2 1128 s = size(LR[3]); 1129 if (s==2) 1130 { 1131 // not a blockord, 1 block + module ord 1132 tmp = LR[3][s]; // module ord 1133 for (i=1; i<=D; i++) 1134 { 1135 LR[3][s-1+i] = LR[3][1]; 1136 } 1137 LR[3][s+D] = tmp; 1138 } 1139 if (s>2) 1140 { 1141 // there are s-1 blocks 1142 int nb = s-1; 1143 tmp = LR[3][s]; // module ord 1144 for (i=1; i<=D; i++) 1145 { 1146 for (j=1; j<=nb; j++) 1147 { 1148 LR[3][i*nb+j] = LR[3][j]; 1149 } 1150 } 1151 // size(LR[3]); 1152 LR[3][nb*(D+1)+1] = tmp; 1153 } 1154 L[3] = LR[3]; 1155 def @R = ring(L); 1156 // setring @R; 1157 return (@R); 1158 } 1159 example 1160 { 1161 "EXAMPLE:"; echo = 2; 1162 ring r = 0,(x,y,z),(dp(1),dp(2)); 1163 def A = freegbRing(2); 1164 setring A; 1165 A; 1166 } 1254 //option(teach); 1255 ideal J = system("freegb",I,d,nv); 1256 } 1257 1258 1167 1259 1168 1260 static proc checkCeq() … … 1256 1348 ideal J = system("freegb",I,d,3); 1257 1349 } 1350 1351 proc schur2-3() 1352 { 1353 // nonhomog: 1354 // h^4-10*h^2+9,f*e-e*f+h, h*2-e*h-2*e,h*f-f*h+2*f 1355 // homogenized with t 1356 // h^4-10*h^2*t^2+9*t^4,f*e-e*f+h*t, h*2-e*h-2*e*t,h*f-f*h+2*f*t, 1357 // t*h - h*t, t*f - f*t, t*e - e*t 1358 }
Note: See TracChangeset
for help on using the changeset viewer.