Changeset 4baf744 in git
- Timestamp:
- Jan 17, 2008, 10:05:04 PM (15 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 0ab7da22b1864f9d6fe30cbbbf75bf4d5fe7acd3
- Parents:
- d8b352268238b737d34c703c7b163450c8050612
- Location:
- Singular/LIB
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/freegb.lib
rd8b352 r4baf744 1 1 ////////////////////////////////////////////////////////////////////////////// 2 version="$Id: freegb.lib,v 1. 3 2007-06-24 19:13:20levandov Exp $";2 version="$Id: freegb.lib,v 1.4 2008-01-17 21:05:04 levandov Exp $"; 3 3 category="Noncommutative"; 4 4 info=" … … 351 351 // ordering: d blocks of the ord on r 352 352 // try to get whether the ord on r is blockord itself 353 // TODO: make L(2) ordering! exponent is maximally 2 353 354 s = size(LR[3]); 354 355 if (s==2) … … 551 552 } 552 553 553 proc crs(list LM, int d) 554 "USAGE: crs(L, d); L a list of modules, d an integer 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 555 563 RETURN: ring 556 PURPOSE: create a ring and shift the ideal 557 EXAMPLE: example crs; shows examples 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 558 567 " 559 568 { … … 596 605 for (j=1; j<=s; j++) 597 606 { 598 tmp[i*s+j] = string(tmp[j])+"("+string(i )+")";607 tmp[i*s+j] = string(tmp[j])+"("+string(i+1)+")"; 599 608 } 600 609 } 601 610 for (i=1; i<=s; i++) 602 611 { 603 tmp[i] = string(tmp[i])+"("+string( 0)+")";612 tmp[i] = string(tmp[i])+"("+string(1)+")"; 604 613 } 605 614 L[2] = tmp; … … 657 666 M = LM[l]; 658 667 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; 681 setring @R; 682 execute(sp); 683 setring save; 684 } 685 setring @R; 686 // "@@p:"; @@p; 687 I = I,@@p; 688 @@p = 0; 689 setring save; 690 } 691 kill sp; 692 // 3. compute GB 693 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); 802 } 803 example 804 { 805 "EXAMPLE:"; echo = 2; 806 ring r = 0,(x,y,z),(dp(1),dp(2)); 807 module M = [-1,x,y],[-7,y,y],[3,x,x]; 808 module N = [1,x,y,x],[-1,y,x,y]; 809 list L; L[1] = M; L[2] = N; 810 lst2str(L); 811 def U = freegbnew(L,5); 812 lst2str(U); 813 } 814 815 proc crs(list LM, int d) 816 "USAGE: crs(L, d); L a list of modules, d an integer 817 RETURN: ring 818 PURPOSE: create a ring and shift the ideal 819 EXAMPLE: example crs; shows examples 820 " 821 { 822 // d = up to degree, will be shifted to d+1 823 if (d<1) {"bad d"; return(0);} 824 825 int ppl = printlevel-voice+2; 826 string err = ""; 827 828 int i,j,s; 829 def save = basering; 830 // determine max no of places in the input 831 int slm = size(LM); // numbers of polys in the ideal 832 int sm; 833 intvec iv; 834 module M; 835 for (i=1; i<=slm; i++) 836 { 837 // modules, e.g. free polynomials 838 M = LM[i]; 839 sm = ncols(M); 840 for (j=1; j<=sm; j++) 841 { 842 //vectors, e.g. free monomials 843 iv = iv, size(M[j])-1; // 1 place is reserved by the coeff 844 } 845 } 846 int D = Max(iv); // max size of input words 847 if (d<D) {"bad d"; return(LM);} 848 D = D + d-1; 849 // D = d; 850 list LR = ringlist(save); 851 list L, tmp; 852 L[1] = LR[1]; // ground field 853 L[4] = LR[4]; // quotient ideal 854 tmp = LR[2]; // varnames 855 s = size(LR[2]); 856 for (i=1; i<=D; i++) 857 { 858 for (j=1; j<=s; j++) 859 { 860 tmp[i*s+j] = string(tmp[j])+"("+string(i)+")"; 861 } 862 } 863 for (i=1; i<=s; i++) 864 { 865 tmp[i] = string(tmp[i])+"("+string(0)+")"; 866 } 867 L[2] = tmp; 868 list OrigNames = LR[2]; 869 // ordering: d blocks of the ord on r 870 // try to get whether the ord on r is blockord itself 871 s = size(LR[3]); 872 if (s==2) 873 { 874 // not a blockord, 1 block + module ord 875 tmp = LR[3][s]; // module ord 876 for (i=1; i<=D; i++) 877 { 878 LR[3][s-1+i] = LR[3][1]; 879 } 880 LR[3][s+D] = tmp; 881 } 882 if (s>2) 883 { 884 // there are s-1 blocks 885 int nb = s-1; 886 tmp = LR[3][s]; // module ord 887 for (i=1; i<=D; i++) 888 { 889 for (j=1; j<=nb; j++) 890 { 891 LR[3][i*nb+j] = LR[3][j]; 892 } 893 } 894 // size(LR[3]); 895 LR[3][nb*(D+1)+1] = tmp; 896 } 897 L[3] = LR[3]; 898 def @R = ring(L); 899 setring @R; 900 ideal I; 901 poly @p; 902 s = size(OrigNames); 903 // "s:";s; 904 // convert LM to canonical vectors (no powers) 905 setring save; 906 kill M; // M was defined earlier 907 module M; 908 slm = size(LM); // numbers of polys in the ideal 909 int sv,k,l; 910 vector v; 911 // poly p; 912 string sp; 913 setring @R; 914 poly @@p=0; 915 setring save; 916 for (l=1; l<=slm; l++) 917 { 918 // modules, e.g. free polynomials 919 M = LM[l]; 920 sm = ncols(M); // in intvec iv the sizes are stored 659 921 for (i=0; i<=d-iv[l]; i++) 660 922 { -
Singular/LIB/ratgb.lib
rd8b352 r4baf744 1 1 ////////////////////////////////////////////////////////////////////////////// 2 version="$Id: ratgb.lib,v 1. 8 2007-11-09 15:56:58levandov Exp $";2 version="$Id: ratgb.lib,v 1.9 2008-01-17 21:05:04 levandov Exp $"; 3 3 category="Noncommutative"; 4 4 info=" … … 138 138 if (size(L[3]) != 3) 139 139 { 140 "note: strange ordering \n";140 "note: strange ordering"; 141 141 } 142 142 kill tmp2; list tmp2; … … 242 242 D[1,3] = K; 243 243 D[2,4] = N; 244 def S=nc_algebra(1,D);setring S; 244 def S = nc_algebra(1,D); 245 setring S; 245 246 ideal I = (k+1)*K - (n-k), (n-k+1)*N - (n+1); 246 247 int is = 2;
Note: See TracChangeset
for help on using the changeset viewer.