Changeset 654a23 in git
- Timestamp:
- Jul 23, 2015, 2:48:14 PM (8 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- 74fe3587102ed73b3858258975abbe6d63139abf
- Parents:
- 8d7ca03d4444afafa6c2111db95d65216b93ad464132ee2e5b539d15463dcf3db09fbf9aa7c00877
- Files:
-
- 4 deleted
- 70 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/classify_aeq.lib
r8d7ca0 r654a23 7 7 AUTHORS: Faira Kanwal Janjua fairakanwaljanjua@gmail.com 8 8 Gerhard Pfister pfister@mathematik.uni-kl.de 9 Khawar Mehmood khawar1073@gmail.com NEU 9 10 10 11 OVERVIEW: A library for classifying the simple singularities … … 22 23 [4] Bruce, J.W.,Gaffney, T.J.: Simple singularities of mappings (C, 0) ->(C2,0). 23 24 J. London Math. Soc. (2) 26 (1982), 465-474. 24 25 [5] Ishikawa,G; Janeczko,S.: The Complex Symplectic Moduli Spaces of Unimodal Parametric Plane Curve NEU Singularities. Insitute of Mathematics of the Polish Academy of Sciences,Preprint 664(2006) 25 26 PROCEDURES: 26 27 sagbiAlg(G); Compute the Sagbi-basis of the Algebra. … … 662 663 663 664 //////////////////////////////////////////////////////////////////////////////// 664 proc sagbiAlg(ideal I )665 proc sagbiAlg(ideal I,list #) 665 666 "USAGE": sagbiAlg(I); I ideal 666 667 RETURN: An ideal.The sagbi bases of I. … … 676 677 677 678 if(size(I)==0){return(I);} 678 int b=ConductorBound(I); 679 680 // int b=200; 679 if(size(#)==0) 680 { 681 int b=ConductorBound(I); 682 // int b=200; 681 683 // b=correctBound(I,b); 684 } 685 else 686 { 687 int b=#[1]; 688 } 682 689 ideal S=interReduceSagbi(I,b) ; 683 690 // b=correctBound(S,b); … … 699 706 return(S); 700 707 } 701 702 708 example 703 709 { … … 709 715 sagbiAlg(I); 710 716 } 711 717 //////////////////////////////////////////////////////////////////////////////// NEU 718 proc reducedSagbiAlg(ideal I,list #) 719 { 720 721 I=sagbiAlg(I,#); 722 intvec L=semiGroup(I)[3]; 723 if(size(#)==0) 724 { 725 int b=findConductor(L); 726 } 727 else 728 { 729 int b=#[1]; 730 } 731 int i; 732 poly q; 733 for(i=1;i<=size(I);i++) 734 { 735 q=I[i]-lead(I[i]); 736 q=sagbiNF(q,I,b); 737 I[i]=lead(I[i])+q; 738 } 739 return(I); 740 } 741 example 742 { 743 "EXAMPLE:"; echo=2; 744 ring R=0,t,ds; 745 ideal I=t4+2t9,t9+t10+19/18t11-3t12+t13-t14; 746 reducedSagbiAlg(I); 747 } 748 //////////////////////////////////////////////////////////////////////////////// NEU 749 proc classifyAEQunimodal(ideal I) 750 "USAGE": classifyAEQunimodal(I); I ideal generated by 2 polynomials 751 RETURN: An ideal.Ideal is one of the singularity in the list of Ishikawa and Jenczko [5] 752 EXAMPLE: example classifyAEQunimodal; shows an example 753 " 754 { 755 def R=basering; 756 ring @S=0,t,ds; 757 ideal I=fetch(R,I); 758 ideal J; 759 poly g; 760 if(size(I)>=3){ERROR("not a plane curve");} 761 I=simplify(I,2); //deletes zeroâs i I 762 I=simplify(I,1); //creates monic generators in I 763 if(ord(I[1])>ord(I[2])){poly q=I[2];I[2]=I[1];I[1]=q;} 764 if((ord(I[1])>=6)||(ord(I[1])<=3)){return("not in the unimodal list");} 765 //compute estimate of the term with the modulus 766 int c=ord(sagbiNF(I[2],ideal(I[1]),10)); 767 if(c==10) 768 { 769 if(ord(I[1])!=4){return("not in the unimodal list");} 770 c=ord(I[2][2])+2; 771 } 772 else 773 { 774 c=0; 775 intvec v=ord(I[1]),ord(I[2]); 776 if(v==intvec(5,6)){c=14;} 777 if(v==intvec(5,7)){c=18;} 778 if(v==intvec(5,8)){c=22;} 779 if(v==intvec(4,9)){c=19;} 780 if(v==intvec(4,11)){c=25;} 781 if(c==0){return("not in the unimodal list");} 782 } 783 while(size(I[1])>1) 784 { 785 I=jet(subst(I,t,t-number(1)/number(ord(I[1]))*leadcoef(I[1][2])*t^(ord(I[1][2])-ord(I[1])+1)),c); 786 } 787 ideal G=I; 788 G[2]=sagbiNF(G[2],ideal(G[1]),c); 789 ideal M=sagbiMod(diff(G,t),G); 790 list K=semiMod(M,G); 791 792 if(K[1]==intvec(4,9)) 793 { 794 if(K[4]==intvec(3,8)){J=t4,t9;} 795 if(K[4]==intvec(3,8,22)){J=t4,t9+t19;} 796 if(K[4]==intvec(3,8,18)){J=t4,t9+t15;} 797 if(K[4]==intvec(3,8,14)){J=t4,t9+t11;} 798 if(K[4]==intvec(3,8,13)) 799 { 800 G=reducedSagbiAlg(G,15); 801 if(ord(G[2][4])==14) 802 { 803 //kill the term t14 by some transformation 804 G=subst(G,t,t-leadcoef(G[2][4])/9*t^6); 805 G=jet(G,15); 806 G[1]=sagbiNF(G[1],ideal(G[2]),15); 807 //arrange the first element to be t4 808 while(size(G[1])>1) 809 { 810 G=subst(G,t,t-1/4*(G[1]-lead(G[1]))/t^3); 811 G=jet(G,15); 812 } 813 } 814 G[2]=sagbiNF(G[2],ideal(G[1]),15); 815 //arrange the coefficient of t10 to become 1 816 number m=leadcoef(G[2]-lead(G[2])); 817 G[2]=m^9*subst(G[2],t,1/m*t); 818 J=G; 819 } 820 if(K[4]==intvec(3,8,13,18)) 821 { 822 G=reducedSagbiAlg(G,11); 823 number m=leadcoef(G[2]-lead(G[2])); 824 G[2]=m^9*subst(G[2],t,1/m*t); 825 J=G; 826 } 827 } 828 if(K[1]==intvec(4,11)) 829 { 830 if(K[4]==intvec(3,10)){J=t4,t11;} 831 if(K[4]==intvec(3,10,28)){J=t4,t11+t25;} 832 if(K[4]==intvec(3,10,24)){J=t4,t11+t21;} 833 if(K[4]==intvec(3,10,20)){J=t4,t11+t17;} 834 if(K[4]==intvec(3,10,16)) 835 { 836 G=reducedSagbiAlg(G,14); 837 number m=leadcoef(G[2]-lead(G[2])); 838 number l=leadcoef(G[2][3]); 839 //lambda^2=l^2/m^3 840 J=G; 841 } 842 if(K[4]==intvec(3,10,17)) 843 { 844 G=reducedSagbiAlg(G,21); 845 if(ord(G[2][4])==18) 846 { 847 //kill the term t18 by some transformation 848 G=subst(G,t,t-leadcoef(G[2][4])/11*t^8); 849 G=jet(G,21); 850 G[1]=sagbiNF(G[1],ideal(G[2]),21); 851 //arrange the first element to be t4 852 while(size(G[1])>1) 853 { 854 G=subst(G,t,t-1/4*(G[1]-lead(G[1]))/t^3); 855 G=jet(G,21); 856 } 857 } 858 G[2]=sagbiNF(G[2],ideal(G[1]),21); 859 //arrange the coefficient of t14 to become 1 860 number m=leadcoef(G[2]-lead(G[2])); 861 number l=leadcoef(G[2][4]); 862 //lambda^2=l^3/m^10 863 J=G; 864 865 866 } 867 if(K[4]==intvec(3,10,17,24)) 868 { 869 G=reducedSagbiAlg(G,18); 870 //arrange the coefficient of t14 to become 1 871 number m=leadcoef(G[2]-lead(G[2])); 872 G[2]=t11+t14+leadcoef(G[2][3])/m^2*t17; 873 J=G; 874 } 875 } 876 if((size(K[1])==3)&&(K[1][1]==4)&&(K[1][2]==10)) 877 { 878 int l=(K[1][3]-19) div 2; 879 G=reducedSagbiAlg(G,2*l+12); 880 number m=leadcoef(G[2]-lead(G[2])); 881 number s=leadcoef(G[2][3]); 882 //lambda^(2l-1)=s^(2l-1)/m^(2l+1) 883 J=G; 884 } 885 if(K[1]==intvec(5,6)) 886 { 887 if(K[4]==intvec(4,5)){J=t5,t6;} 888 if(K[4]==intvec(4,5,18)){J=t5,t6+t14;} 889 if(K[4]==intvec(4,5,13)){J=t5,t6+t9;} 890 if(K[4]==intvec(4,5,12)) 891 { 892 G=reducedSagbiAlg(G,9); 893 if(ord(G[2][2])==7) 894 { 895 //kill the term t7 by some transformation 896 G=subst(G,t,t-leadcoef(G[2][2])/6*t^2); 897 G=jet(G,10); 898 G[1]=sagbiNF(G[1],ideal(G[2]),9); 899 //arrange the first element to be t4 900 while(size(G[1])>1) 901 { 902 G=subst(G,t,t-1/5*(G[1]-lead(G[1]))/t^4); 903 G=jet(G,9); 904 } 905 } 906 G[2]=sagbiNF(G[2],ideal(G[1]),9); 907 //arrange the coefficient of t8 to become 1 908 number m=leadcoef(G[2]-lead(G[2])); 909 number l=leadcoef(G[2][3]); 910 //lambda^2=l^2/m^3 911 J=G; 912 913 } 914 } 915 if(K[1]==intvec(5,7)) 916 { 917 if(K[4]==intvec(4,6)){J=t5,t7;} 918 if(K[4]==intvec(4,6,22)){J=t5,t7+t18;} 919 if(K[4]==intvec(4,6,17)){J=t5,t7+t13;} 920 if(K[4]==intvec(4,6,12)) 921 { 922 G=reducedSagbiAlg(G,11); 923 if(ord(G[2][3])==9) 924 { 925 //kill the term t9 by some transformation 926 G=subst(G,t,t-leadcoef(G[2][3])/7*t^3); 927 G=jet(G,11); 928 G[1]=sagbiNF(G[1],ideal(G[2]),11); 929 //arrange the first element to be t4 930 while(size(G[1])>1) 931 { 932 G=subst(G,t,t-1/5*(G[1]-lead(G[1]))/t^4); 933 G=jet(G,11); 934 } 935 } 936 G[2]=sagbiNF(G[2],ideal(G[1]),11); 937 //arrange the coefficient of t8 to become 1 938 number m=leadcoef(G[2]-lead(G[2])); 939 G[2]=m^7*subst(G[2],t,1/m*t); 940 J=G; 941 } 942 if(K[4]==intvec(4,6,15)) 943 { 944 G=reducedSagbiAlg(G,14); 945 if(ord(G[2][2])==9) 946 { 947 //kill the term t9 by some transformation 948 G=subst(G,t,t-leadcoef(G[2][2])/7*t^3); 949 G=jet(G,14); 950 G[1]=sagbiNF(G[1],ideal(G[2]),14); 951 //arrange the first element to be t4 952 while(size(G[1])>1) 953 { 954 G=subst(G,t,t-1/5*(G[1]-lead(G[1]))/t^4); 955 G=jet(G,14); 956 } 957 } 958 G[2]=sagbiNF(G[2],ideal(G[1]),14); 959 //arrange the coefficient of t11 to become 1 960 number m=leadcoef(G[2]-lead(G[2])); 961 number l=leadcoef(G[2][3]); 962 //lambda^2=l^2/m^3 963 J=G; 964 } 965 966 } 967 if(K[1]==intvec(5,8)) 968 { 969 if(K[4]==intvec(4,7)){J=t5,t8;} 970 if(K[4]==intvec(4,7,26)){J=t5,t8+t22;} 971 if(K[4]==intvec(4,7,21)){J=t5,t8+t17;} 972 if(K[4]==intvec(4,7,13)) 973 { 974 G=reducedSagbiAlg(G,12); 975 if(ord(G[2][3])==11) 976 { 977 //kill the term t11 by some transformation 978 G=subst(G,t,t-leadcoef(G[2][3])/8*t^4); 979 G=jet(G,12); 980 G[1]=sagbiNF(G[1],ideal(G[2]),12); 981 //arrange the first element to be t4 982 while(size(G[1])>1) 983 { 984 G=subst(G,t,t-1/5*(G[1]-lead(G[1]))/t^4); 985 G=jet(G,12); 986 } 987 } 988 G[2]=sagbiNF(G[2],ideal(G[1]),12); 989 //arrange the coefficient of t9 to become 1 990 number m=leadcoef(G[2]-lead(G[2])); 991 G[2]=m^8*subst(G[2],t,1/m*t); 992 J=G; 993 } 994 995 if(K[4]==intvec(4,7,16)) 996 { 997 G=reducedSagbiAlg(G,14); 998 if(ord(G[2][2])==11) 999 { 1000 //kill the term t11 by some transformation 1001 G=subst(G,t,t-leadcoef(G[2][2])/8*t^4); 1002 G=jet(G,14); 1003 G[1]=sagbiNF(G[1],ideal(G[2]),14); 1004 //arrange the first element to be t4 1005 while(size(G[1])>1) 1006 { 1007 G=subst(G,t,t-1/5*(G[1]-lead(G[1]))/t^4); 1008 G=jet(G,14); 1009 } 1010 } 1011 G[2]=sagbiNF(G[2],ideal(G[1]),14); 1012 //arrange the coefficient of t12 to become 1 1013 number m=leadcoef(G[2]-lead(G[2])); 1014 number l=leadcoef(G[2][3]); 1015 //lambda^2=l^2/m^3 1016 J=G; 1017 1018 } 1019 if(K[4]==intvec(4,7,18)) 1020 { 1021 G=reducedSagbiAlg(G,17); 1022 if(ord(G[2][2])==11) 1023 { 1024 //kill the term t11 by some transformation 1025 G=subst(G,t,t-leadcoef(G[2][2])/8*t^4); 1026 G=jet(G,17); 1027 G[1]=sagbiNF(G[1],ideal(G[2]),17); 1028 //arrange the first element to be t4 1029 while(size(G[1])>1) 1030 { 1031 G=subst(G,t,t-1/5*(G[1]-lead(G[1]))/t^4); 1032 G=jet(G,17); 1033 } 1034 } 1035 G[2]=sagbiNF(G[2],ideal(G[1]),17); 1036 //arrange the coefficient of t12 to become 1 1037 number m=leadcoef(G[2]-lead(G[2])); 1038 number l=leadcoef(G[2][3]); 1039 //lambda^2=l^2/m^3 1040 J=G; 1041 } 1042 } 1043 setring R; 1044 ideal J=fetch(@S,J); 1045 if(size(J)==0) 1046 { 1047 return("not in the unimodal list"); 1048 } 1049 return(J); 1050 } 1051 example 1052 { 1053 "EXAMPLE:"; echo=2; 1054 ring R=0,t,ds; 1055 ideal I=t4,9t9+18t10+38t11-216t12+144t13-288t14; 1056 classifyAEQunimodal(I); 1057 I=t4,9t9+18t10+40t11-216t12+144t13-288t14; 1058 classifyAEQunimodal(I); 1059 I=t4,t11+t12+3t14+2t15+7t16+7t17; 1060 classifyAEQunimodal(I); 1061 I=t4,t11+t14+25/22t17+3t18+4t21; 1062 classifyAEQunimodal(I); 1063 I=t5,t6+2t7+t8+3t9; 1064 classifyAEQunimodal(I); 1065 I=t5,t7+3t8+3t9+5t10; 1066 classifyAEQunimodal(I); 1067 I=t5,t7+3t11+3t12+5t13; 1068 classifyAEQunimodal(I); 1069 I=t5,t8+3t9+5t10+2t11+3t12+5t13; 1070 classifyAEQunimodal(I); 1071 I=t5,t8+5t11+3t12+7t13+5t14; 1072 classifyAEQunimodal(I); 1073 I=t5,t8+5t11+7t13+5t14+7t15+2t16+8t17; 1074 classifyAEQunimodal(I); 1075 I=subst(I,t,t+t2); 1076 classifyAEQunimodal(I); 1077 I=t4+2t5+3t6+5t7+t8,9t9+18t10+40t11-216t12+144t13-288t14; 1078 classifyAEQunimodal(I); 1079 } 1080 //////////////////////////////////////////////////////////////////////////////// NEU 1081 proc computeModulus(poly p) 1082 "USAGE": computeModulus(p); p monic poly with 3 or 4 monomials 1083 RETURN: A polynomial with first and second coefficient 1 1084 EXAMPLE: computeModulus; shows an example 1085 ASSUME: the basering has one vearable and one parameter 1086 " 1087 { 1088 def R=basering; 1089 int a1=ord(p); 1090 int a2=ord(p-lead(p)); 1091 number m=leadcoef(p-lead(p)); 1092 1093 poly q=par(1)^(a2-a1)-1/m; 1094 ring S=(0,a),t,ds; 1095 number m=fetch(R,m); 1096 minpoly=par(1)^(a2-a1)-1/m; 1097 poly p=fetch(R,p); 1098 p=1/par(1)^a1*subst(p,var(1),par(1)*var(1)); 1099 setring R; 1100 p=imap(S,p); 1101 return(list(p,q)); 1102 } 1103 example 1104 { 1105 "EXAMPLE:"; echo=2; 1106 ring R=(0,a),t,ds; 1107 poly p=t8-395/16t14+4931/32t17; 1108 computeModulus(p); 1109 p=t8+3t12-395/16t14; 1110 computeModulus(p); 1111 p=t8-395/16t14+4931/32t17; 1112 computeModulus(p); 1113 1114 } 1115 1116 //////////////////////////////////////////////////////////////////////////////// NEU 1117 static proc n_thRoot(poly p,int n, int b) 1118 { 1119 //computes the n-th root of 1+p up to order b 1120 //assumes that p(0)=0 1121 poly s=1; 1122 poly q=jet(p,b); 1123 if(q==0){return(s);} 1124 int i; 1125 for(i=1;i<=b;i++) 1126 { 1127 s=s+bino(n,i)*q; 1128 q=jet(q*p,b); 1129 } 1130 return(jet(s,b)); 1131 } 1132 //////////////////////////////////////////////////////////////////////////////// NEU 1133 static proc bino(number n, int i) 1134 { 1135 //computes the i-th binomial coefficient of 1/n 1136 if(i==0){return(1);} 1137 return(bino(n,i-1)*(1/n-i+1)/i); 1138 } 712 1139 //////////////////////////////////////////////////////////////////////////////// 713 1140 proc sagbiMod(ideal I,ideal G) … … 1283 1710 execute 1284 1711 ("ring T=("+charstr(br)+",x(1),z(1..n)),(x(2),y(1..m)),dp;"); 1285 execute 1286 ("ring R=("+charstr(br)+"),(x(1..2),y(1..m),z(1..n)),(lp(m+2),dp(n));"); 1712 execute 1713 ("ring R=("+charstr(br)+"),(x(1..2),y(1..m),z(1..n)),(lp(2),dp(m),dp(n));"); 1714 1287 1715 map phi = br,x(1); 1288 1716 ideal P = phi(G1); … … 1305 1733 M[size(M)+1]=check-x(2); 1306 1734 check=check*keep; 1735 1307 1736 option(redSB); 1308 1737 M=std(M); 1309 1738 int j,s; 1739 1310 1740 for(i=1;i<=size(M);i++) 1311 1741 { … … 1342 1772 f=sagbiNFMODO(f,G,I,b); 1343 1773 } 1344 return( f+sagbiNFMOD(p-lead(p),G,I,b));1774 return(lead(f)+sagbiNFMOD(p-lead(p),G,I,b)); 1345 1775 } 1346 1776 //////////////////////////////////////////////////////////////////////////////// -
Singular/LIB/crypto.lib
r8d7ca0 r654a23 69 69 merkle_hellman_transformation(list knapsack, int key, int mod1 generates a hard knapsack for the Merkle-Hellman Kryptosystem for a given easy knapsack , a multiplicator key and a modulus mod1 70 70 merkle_hellman_encryption(list knapsack, list message) encrypts a message with the Merkle-Hellman Kryptosystem, using a hard knapsack and a message encoded as binary list 71 merkle_hellman_decryption(list knapsack, int key, int mod1, int message) decrypts a message with the multiplicative Merkle-Hellman Kryptosystem, using the hard knapsack, the key, the modulus mod1 and the message encoded as integer 71 merkle_hellman_decryption(list knapsack, int key, int mod1, int message) decrypts a message with the multiplicative Merkle-Hellman Kryptosystem, using the hard knapsack, the key, the modulus mod1 and the message encoded as integer 72 72 super_increasing_knapsack(int ksize) Creates the smallest super-increasing knapsack of given size ksize 73 73 h_increasing_knapsack(int ksize, int h) Creates the smallest h-increasing knapsack of given size ksize and h … … 1272 1272 if((k mod 2)==0) 1273 1273 { 1274 resu=ellipticMult(N,a,b,P,k /2);1274 resu=ellipticMult(N,a,b,P,k div 2); 1275 1275 return(ellipticAdd(N,a,b,resu,resu)); 1276 1276 } -
Singular/LIB/gmssing.lib
r8d7ca0 r654a23 110 110 111 111 M=transpose(simplify(M,2)); 112 I= M[1];112 I=ideal(M[1]); 113 113 attrib(I,"isSB",1); 114 114 M=M[2..ncols(M)]; -
Singular/LIB/gradedModules.lib
r8d7ca0 r654a23 31 31 grsum(M,N) direct sum of two graded modules coker(M) + coker(N) 32 32 grpower(M,p) direct p-th power of graded module coker(M) 33 grtranspose(M) un-ordered graded transpose of map M 33 grtranspose(M) un-ordered graded transpose of map M 34 34 grgens(M) try to compute submodule generators of coker(M) 35 35 grpres(F) presentation of submodule generated by columns of F … … 51 51 mappingcone(M,N) mapping cone? 52 52 grlifting3(A,B) RND! chain lifting? probably wrong one 53 mappingcone3(A,B) mapping cone3? 53 mappingcone3(A,B) mapping cone3? 54 54 grrange(M) get the row-weightings 55 55 grneg(A) graded object given by -A 56 56 matrixpres(a) matrix presentation of direct sum of Omega^{a[i]}(i) 57 57 "; 58 58 59 59 // grisequal(A,B) check whether A is exactly eqal to B? TODO: isomorphic! 60 60 … … 86 86 87 87 v = -v; // NOTE: due to Mathematical meanings of Singular data 88 88 89 89 90 90 int lst = v[1]; 91 int cnt = 1; 91 int cnt = 1; 92 92 93 93 string p = R; … … 95 95 96 96 int k, d; 97 for (k = 2; k <= n; k++ ) 97 for (k = 2; k <= n; k++ ) 98 98 { 99 99 d = v[k]; 100 100 if( d == lst ) { cnt = cnt + 1; } 101 else 101 else 102 102 { 103 103 if (cnt > 1){ p = p + "^" + string(cnt); } … … 120 120 def E = grtwist(2, 0); 121 121 def v = grrange(E); // grdeg(E); 122 grsumstr("", v ); 122 grsumstr("", v ); 123 123 } 124 124 … … 180 180 { 181 181 int n = size(N); ASSUME(0, n > 0); 182 182 183 183 string msg1 = ""; 184 184 if( size(R) >= 2 ) … … 186 186 msg1 = msg1 + "(let R:="+R+")"; 187 187 R = "R"; // !!! 188 } 188 } 189 189 msg1 = msg1 + ": " ; 190 190 191 191 192 192 193 193 list arr; arr[n] = list(); 194 194 int exact = (1==1); 195 195 196 196 int i = 1; 197 197 198 198 ASSUME(1, grtest(N[i])); 199 199 200 200 string dst = grsumstr(R, grrange(N[i])); 201 201 string src = grsumstr(R, grdeg(N[i])); 202 202 203 203 arr[i] = list(dst, src); 204 204 205 205 i = i + 1; 206 206 207 207 while( i <= n ) 208 208 { 209 209 ASSUME(1, grtest(N[i])); 210 210 211 211 dst = grsumstr(R, grrange(N[i])); 212 212 213 213 if( exact && (src != dst) ) 214 214 { … … 218 218 219 219 src = grsumstr(R, grdeg(N[i])); 220 220 221 221 arr[i] = list(dst, src); 222 222 … … 236 236 msg = msg + newline + arr[i][1] + " <-- "+o+"_" + string(i) + " --"; 237 237 }; 238 238 239 239 msg = msg + newline + arr[n][2]; 240 msg = msg + ", given by maps: "; 240 msg = msg + ", given by maps: "; 241 241 } else 242 242 { 243 243 // print(arr); 244 244 245 msg = msg + "-object collection"; 245 msg = msg + "-object collection"; 246 246 o = "o"; 247 247 248 248 // for( i = 1; i <= n; i++ ) 249 249 // { 250 250 // msg = msg + newline + arr[i][1] + " <-- "+o+"_" + string(i) + " -- " + arr[i][2]; 251 // }; 252 msg = msg + ", given by the following maps (named here as "+o+"_[1 .. "+string(n)+"]): "; 251 // }; 252 msg = msg + ", given by the following maps (named here as "+o+"_[1 .. "+string(n)+"]): "; 253 253 } 254 254 … … 257 257 258 258 for( i = 1; i <= size(N); i++ ) 259 { 259 { 260 260 print( o+"_" + string(i) + " :" ); 261 grview( N[i] ); 261 grview( N[i] ); 262 262 }; 263 263 … … 268 268 269 269 ASSUME(1, grtest(N) ); 270 270 271 271 msg = msg + " homomorphism"; 272 272 if( size(R) >= 2 ) … … 280 280 intvec gr = grrange(N); // grading weights? 281 281 string dst = grsumstr(R, gr); 282 282 283 283 intvec G = grdeg(N); 284 284 string src = grsumstr(R, G); 285 285 286 286 if( ncols(N) == 0 ) 287 287 { 288 288 src = "0"; 289 } 289 } 290 290 291 291 lst = msg; 292 292 293 if( (size(lst) + size(dst) + size(src) + 4) > 80 ) 294 { 293 if( (size(lst) + size(dst) + size(src) + 4) > 80 ) 294 { 295 295 if( (size(lst) + size(dst)) > 80 ) { msg = msg + newline; lst = ""; } 296 296 … … 312 312 // lst = lst + ", given by "; 313 313 314 314 315 315 int nc = ncols(N); int nr = nrows(N); 316 316 … … 323 323 { 324 324 ASSUME(0, nc > 0); 325 325 326 326 matrix M = module(N); 327 327 328 328 int r,c; 329 329 int d = 1; // number of extra cols/rows for extra info around the central degree(N) block in D … … 361 361 } 362 362 363 } else 364 { 363 } else 364 { 365 365 msg = msg + "a matrix"; 366 366 } 367 367 368 print(msg + ", with degrees: " ); 369 draw(D, d); // print it nicely! 368 print(msg + ", with degrees: " ); 369 draw(D, d); // print it nicely! 370 370 } 371 371 } … … 462 462 " 463 463 { 464 ASSUME(1, grtest(M) ); 465 464 ASSUME(1, grtest(M) ); 465 466 466 if ( typeof(attrib(M, "degHomog")) == "intvec" ) 467 467 { … … 469 469 470 470 if( size(t) == 0 ){ return (t); } // ZERO! 471 471 472 472 ASSUME(2, ncols(M) == size(t) ); 473 473 return (t); … … 629 629 "Input degrees: "; grview(I); 630 630 631 def RR = grres(I, 0, 1); list L = RR; 631 def RR = grres(I, 0, 1); list L = RR; 632 632 633 633 " = Non-minimal betti numbers: "; print(betti(L, 0), "betti"); … … 830 830 831 831 ring r=32003,(x,y,z),dp; 832 832 833 833 grview( grtwists ( intvec(-4, 1, 6 )) ); 834 834 … … 843 843 " 844 844 { 845 ASSUME(0, a > 0); 845 ASSUME(0, a > 0); 846 846 def Z = grtwists( intvec(d:a) ); // will set the rank as well 847 847 // ASSUME(2, grisequal(Z, grpower( grshift(grzero(), d), a ) )); // optional check … … 931 931 932 932 def SS = grobj(S, c, dc); 933 933 934 934 ASSUME(0, size( grrange(SS) ) == (size(a) + size(b)) ); 935 935 ASSUME(0, size( grdeg(SS) ) == (size(da) + size(db)) ); 936 936 ASSUME(0, ncols( SS ) == size( grdeg(SS) ) ); 937 937 ASSUME(0, nrows( SS ) == size( grrange(SS) ) ); 938 938 939 939 return(SS); 940 940 } … … 984 984 { 985 985 ASSUME(1, grtest(M) ); 986 987 986 987 988 988 989 989 intvec a = grrange(M); … … 993 993 { 994 994 "!! Warning: shifting '0 <- 0' leaves it as it unchanged!"; 995 return (M); 996 } 997 995 return (M); 996 } 997 998 998 a = a - intvec(d:size(a)); 999 999 t = t - intvec(d:size(t)); … … 1056 1056 { 1057 1057 ASSUME(0, size(w) >= nrows(A) ); 1058 1058 1059 1059 module M = module(A); 1060 1060 … … 1063 1063 1064 1064 intvec @ww = 0:0; 1065 1065 1066 1066 if( size(#) > 0 ) 1067 1067 { 1068 1068 ASSUME(0, typeof(#[1]) == "intvec" ); 1069 1069 1070 1070 @ww = intvec( #[1] ); 1071 1071 … … 1077 1077 } 1078 1078 } 1079 1079 1080 1080 ASSUME(0, size(@ww) == ncols(M) ); 1081 1081 } … … 1091 1091 M = freemodule(0); 1092 1092 } 1093 1093 1094 1094 attrib( M, "rank", size(w) ); 1095 1095 attrib( M, "isHomog", w ); 1096 1096 1097 1097 // ASSUME(0, /* PROBLEM WITH ZERO COLUMNS / THEIR DEGREES! */ (ncols(M) == 0) ); 1098 1098 } 1099 1099 } 1100 1100 1101 1101 // type(@ww); type(M); 1102 1102 1103 1103 ASSUME(0, size(@ww) == ncols(M) ); // ?! 1104 1104 1105 1105 attrib(M, "degHomog", @ww); 1106 1106 … … 1132 1132 grview( grobj( freemodule(0), intvec(1,2,3) ) ); 1133 1133 1134 matrix z1[0][3]; grview( grobj( z1, 0:0, intvec(1,2,3) ) ); 1134 matrix z1[0][3]; grview( grobj( z1, 0:0, intvec(1,2,3) ) ); 1135 1135 grview( grobj( freemodule(0), 0:0, intvec(1,2,3) ) ); 1136 1136 1137 1137 matrix z0[0][0]; grview( grobj( z0, 0:0 ) ); 1138 1138 grview( grobj( freemodule(0), 0:0 ) ); 1139 1140 1139 1140 1141 1141 1142 1142 } … … 1145 1145 "USAGE: grtest(M[,b]), anyting M, optionally int b 1146 1146 RETURN: 1 if M is a valid graded object, 0 otherwise 1147 PURPOSE: validate a graded object. Print an invalid object message if b is not given 1147 PURPOSE: validate a graded object. Print an invalid object message if b is not given 1148 1148 NOTE: M should be an ideal or module or matrix, with weighting attribute 1149 1149 'isHomog' and optionally total graded degrees attribute 'degHomog'. … … 1169 1169 if ( nrows(N) != size(gr) ) 1170 1170 { 1171 if(b) { " ? grtest: Input has wrong number of rows!"; }; 1171 if(b) { " ? grtest: Input has wrong number of rows!"; }; 1172 1172 return (0); 1173 1173 }; … … 1177 1177 return(1); 1178 1178 } 1179 1179 1180 1180 // if( attrib(N, "rank") != size(gr) ){ return (0); } // wrong rank :( 1181 1181 … … 1189 1189 return (1); 1190 1190 } 1191 1191 1192 1192 if ( ncols(N) != size(T) ) 1193 1193 { 1194 if(b) { " ? grtest: Input has wrong number of cols!"; }; 1194 if(b) { " ? grtest: Input has wrong number of cols!"; }; 1195 1195 return (0); 1196 1196 }; 1197 1197 1198 1198 int k = nvars(basering) + 1; // index of mod. column in the leadexp 1199 1199 … … 1259 1259 { 1260 1260 ASSUME(0, d >= 0 ); 1261 1261 1262 1262 if( d == 0 ) { return (A); } 1263 1263 1264 1264 if( ncols(A) == 0 ) 1265 1265 { 1266 1266 matrix B[nrows(A) + d][0]; 1267 return (B); 1268 } 1269 1267 return (B); 1268 } 1269 1270 1270 module T; T[d] = 0; 1271 1271 T = T, module(transpose(A)); … … 1281 1281 matrix m[0][2]; 1282 1282 type( align(m, 3) ); 1283 } 1283 } 1284 1284 1285 1285 … … 1302 1302 module A = grobj( module([x+y, x, 0, 0], [0, x+y, y, 0]), intvec(0,0,0,1) ); 1303 1303 grview(A); 1304 1304 1305 1305 module B = grgroebner(A); 1306 1306 grview(B); … … 1324 1324 ring r=32003,(x,y,z),dp; 1325 1325 1326 module A = grgroebner( grobj( module([x+y, x, 0, 3], [0, x+y, y, 2], [y, y, z, 1]), intvec(0,0,0,1) ) ); 1326 module A = grgroebner( grobj( module([x+y, x, 0, 3], [0, x+y, y, 2], [y, y, z, 1]), intvec(0,0,0,1) ) ); 1327 1327 grview(A); 1328 1328 1329 1329 grview(grsyz(A)); 1330 1331 module X = grgroebner( grobj( module([x]), intvec(2) ) ); 1330 1331 module X = grgroebner( grobj( module([x]), intvec(2) ) ); 1332 1332 grview(X); 1333 1333 1334 1334 // syzygy module should be zero! 1335 1335 grview(grsyz(X)); 1336 1337 1336 1337 1338 1338 } 1339 1339 … … 1351 1351 intvec a = grdeg(A); 1352 1352 intvec b = grrange(B); 1353 1353 1354 1354 ASSUME(0, (size(a) == size(b)) && (a == b)); // == for intvec :( 1355 1355 … … 1361 1361 ring r=32003,(x,y,z),dp; 1362 1362 1363 module A = grobj( module([x+y, x, 0, 3], [0, x+y, y, 2], [y, y, z, 1]), intvec(0,0,0,1) ); 1363 module A = grobj( module([x+y, x, 0, 3], [0, x+y, y, 2], [y, y, z, 1]), intvec(0,0,0,1) ); 1364 1364 grview(A); 1365 1365 1366 1366 A = grgroebner(A); 1367 1367 grview(A); 1368 1368 1369 1369 module B = grsyz(A); 1370 1370 grview(B); 1371 1371 print(B); 1372 1372 1373 1373 module D = grprod( A, B ); 1374 1374 grview(D); … … 1384 1384 "USAGE: grres(M, l[, b]), graded object M, int l, int b 1385 1385 RETURN: graded resolution = list of graded objects 1386 PURPOSE: compute graded resolution of M (of length l) and minimise it if b was given 1386 PURPOSE: compute graded resolution of M (of length l) and minimise it if b was given 1387 1387 EXAMPLE: example grres; shows an example 1388 1388 " … … 1392 1392 1393 1393 intvec v = grrange(A); 1394 1394 1395 1395 int b = (size(#) > 0); 1396 1396 if(b) { list r = res(A, l, #[1]); } else { list r = res(A, l); } 1397 1397 1398 1398 l = size(r); 1399 1399 1400 1400 int i; 1401 1401 1402 1402 for ( i = 1; i <= l; i++ ) 1403 1403 { … … 1411 1411 r[i] = grobj(r[i], v); v = grdeg(r[i]); 1412 1412 } 1413 1413 1414 1414 i = i-1; 1415 1415 … … 1421 1421 ring r=32003,(x,y,z),dp; 1422 1422 1423 module A = grobj( module([x+y, x, 0, 3], [0, x+y, y, 2], [y, y, z, 1]), intvec(0,0,0,1) ); 1423 module A = grobj( module([x+y, x, 0, 3], [0, x+y, y, 2], [y, y, z, 1]), intvec(0,0,0,1) ); 1424 1424 grview(A); 1425 1425 1426 1426 module B = grgroebner(A); 1427 1427 grview(B); … … 1438 1438 RETURN: graded object 1439 1439 PURPOSE: graded transpose of M 1440 NOTE: no reordering is performend by this procedure 1440 NOTE: no reordering is performend by this procedure 1441 1441 EXAMPLE: example grtranspose; shows an example 1442 1442 " … … 1457 1457 1458 1458 module K = grsyz( L ); grview(K); 1459 1459 1460 1460 1461 1461 // Corner cases: 0 <- 0! … … 1463 1463 grview( grtranspose( Z ) ); 1464 1464 1465 1465 1466 1466 // Corner cases: * <- 0 1467 1467 matrix M1[3][0]; 1468 1468 1469 1469 module Z1 = grobj( M1, intvec(-1, 0, 1) ); grview(Z1); 1470 1470 grview( grtranspose( Z1 ) ); 1471 1472 1471 1472 1473 1473 // Corner cases: 0 <- * 1474 1474 matrix M2[0][3]; … … 1476 1476 module Z2 = grobj( M2, 0:0, intvec(-1, 0, 1) ); grview(Z2); 1477 1477 grview( grtranspose( Z2 ) ); 1478 1478 1479 1479 } 1480 1480 … … 1482 1482 proc grgens(def M) 1483 1483 "USAGE: grgens(M), graded object M (map) 1484 RETURN: graded object 1484 RETURN: graded object 1485 1485 PURPOSE: try compute graded generators of coker(M) and return them as columns 1486 1486 of a graded map. … … 1492 1492 1493 1493 module N = grtranspose( grsyz( grtranspose(M) ) ); 1494 1494 1495 1495 // ASSUME(3, grisequal( grgroebner(M), grgroebner( grpres( N ) ) ) ); // FIXME: not always true!? 1496 1496 1497 1497 return ( N ); 1498 1498 } … … 1505 1505 1506 1506 module N = grgens(M); 1507 1507 1508 1508 grview( N ); print(N); // fine == M 1509 1509 1510 1510 1511 module A = grobj( module([x+y, x, 0, 3], [0, x+y, y, 2], [y, y, z, 1]), intvec(0,0,0,1) ); 1511 module A = grobj( module([x+y, x, 0, 3], [0, x+y, y, 2], [y, y, z, 1]), intvec(0,0,0,1) ); 1512 1512 1513 1513 A = grgroebner(A); grview(A); … … 1518 1518 1519 1519 grview( grgens( grzero() ) ); 1520 1520 1521 1521 } 1522 1522 … … 1534 1534 1535 1535 // ASSUME(3, grisequal( M, grgens( N ) ) ); 1536 1536 1537 1537 return ( N ); 1538 1538 } … … 1545 1545 grview(A); 1546 1546 1547 "graded transpose: "; def B = grtranspose(A); grview( B ); print(B); 1547 "graded transpose: "; def B = grtranspose(A); grview( B ); print(B); 1548 1548 1549 1549 "... syzygy: "; def C = grsyz(B); grview(C); … … 1553 1553 "... and back to presentation: "; def E = grsyz( D ); grview(E); print(E); 1554 1554 1555 def F = grgens( E ); grview(F); print(F); 1555 def F = grgens( E ); grview(F); print(F); 1556 1556 def G = grpres( F ); grview(G); print(G); 1557 1557 1558 1558 1559 1559 def M = grtwists( intvec(-2, 0, 4, 4) ); grview(M); 1560 1560 1561 1561 def N = grgens(M); grview( N ); print(N); 1562 1563 def L = grpres( N ); grview( L ); print(L); 1562 1563 def L = grpres( N ); grview( L ); print(L); 1564 1564 } 1565 1565 … … 1652 1652 module N; 1653 1653 1654 if(i>n) 1654 if(i>n) 1655 1655 { // no middle part 1656 1656 if(a[1]>0) … … 1659 1659 1660 1660 if(a[n+1]>0) 1661 { N=grsum(N,grtwist(a[n+1],-1));} 1662 } 1661 { N=grsum(N,grtwist(a[n+1],-1));} 1662 } 1663 1663 else 1664 1664 { N=grtwist(a[n+1],-1);} 1665 1666 return (N); // grorder(N)); 1665 1666 return (N); // grorder(N)); 1667 1667 } 1668 else // i <= n: middle part is present, a_i != 0 1668 else // i <= n: middle part is present, a_i != 0 1669 1669 { // a = a1 ... | i:2, a_2 ..... i: n, a_n | .... i: n+1a_(n+1) 1670 1670 j = i - 1; … … 1697 1697 1698 1698 1699 return ((N)); // return (grorder(N)); 1699 return ((N)); // return (grorder(N)); 1700 1700 } 1701 1701 } … … 1704 1704 ring r = 32003,(x(0..4)),dp; 1705 1705 1706 def N1 = KeneshlouMatrixPresentation(intvec(2,0,0,0,0)); 1706 def N1 = KeneshlouMatrixPresentation(intvec(2,0,0,0,0)); 1707 1707 grview(N1); 1708 1708 … … 1738 1738 ASSUME(1, grtest(B)); 1739 1739 ASSUME(0, grrange(A)==grrange(B)); 1740 1740 1741 1741 intvec v = grrange(A); 1742 1742 intvec w=grdeg(A),grdeg(B); … … 1746 1746 { "EXAMPLE:"; echo = 2; 1747 1747 ring r; 1748 1748 1749 1749 module R=grobj(module([x,y,z]),intvec(0:3)); 1750 1750 grview(R); … … 1771 1771 // matrix U; 1772 1772 matrix L =lift(A,B/*,U*/); // module(B*U) = module(matrix(A)*L) 1773 1773 1774 1774 return(grobj(L, grdeg(A), grdeg(B))); 1775 1775 } … … 1782 1782 1783 1783 1784 module D=grobj(module([y,0,z],[x2+y2,z,0]),intvec(0,1,0)); 1784 module D=grobj(module([y,0,z],[x2+y2,z,0]),intvec(0,1,0)); 1785 1785 grview(D); 1786 1786 … … 1788 1788 grview(G); 1789 1789 1790 ASSUME(0, grisequal( grprod(D, G), P) ); 1790 ASSUME(0, grisequal( grprod(D, G), P) ); 1791 1791 } 1792 1792 … … 1807 1807 1808 1808 module Z = grobj(freemodule(0),intvec(0:0),intvec(0:0)); 1809 1809 1810 1810 grrange(Z); 1811 1811 grdeg(Z); 1812 1812 1813 1813 grview(Z); 1814 1814 … … 1838 1838 grtranspose( grprod( N, alpha1 ) ) ) 1839 1839 ) ); // alpha0! 1840 1840 1841 1841 } 1842 1842 example … … 1899 1899 1900 1900 ASSUME(0, t >= 2); 1901 1901 1902 1902 list P; 1903 1903 1904 1904 "t: ", t; 1905 1905 1906 1906 P[1]= grrndmap( rM[1], rN[1] ); // alpha1 1907 1907 1908 if(t==2){return(P[1]);} 1909 1908 if(t==2){return(P[1]);} 1909 1910 1910 for(k=2; k<=t; k++) 1911 1911 { 1912 P[k] = grlift( grprod(P[k-1],rM[k]), rN[k] ); 1913 grview(P[k]); 1914 1915 } 1916 1912 P[k] = grlift( grprod(P[k-1],rM[k]), rN[k] ); 1913 grview(P[k]); 1914 1915 } 1916 1917 1917 return(P); 1918 1918 1919 1919 } 1920 1920 example … … 1923 1923 ring r=32003,(x,y,z),dp; 1924 1924 1925 module P=grobj(module([xy,0,xz]),intvec(0,1,0)); 1925 module P=grobj(module([xy,0,xz]),intvec(0,1,0)); 1926 1926 grview(P); 1927 1927 1928 module D=grobj(module([y,0,z],[x2+y2,z,0]),intvec(0,1,0)); 1928 module D=grobj(module([y,0,z],[x2+y2,z,0]),intvec(0,1,0)); 1929 1929 grview(D); 1930 1930 … … 1937 1937 module D=grobj(module([y,0,z],[x2+y2,z,0], [z3, xy, xy2]),intvec(0,1,0)); 1938 1938 D = grgroebner(D); 1939 grview( grres(D, 0)); 1939 grview( grres(D, 0)); 1940 1940 1941 1941 def G=grlifting(D, D); … … 1951 1951 def M = KeneshlouMatrixPresentation(intvec(0,0,1,0)); 1952 1952 grview( grres(M, 0) ); 1953 1953 1954 1954 // module N = grshift(kos[3], 1); // psi, Syz_2(K(1)) 1955 1955 def N = KeneshlouMatrixPresentation(intvec(0,1,0,0)); … … 1966 1966 proc mappingcone(M,N) 1967 1967 "USAGE: mappingcone(M,N), M,N graded objects 1968 RETURN: chain complex (as a list) 1968 RETURN: chain complex (as a list) 1969 1969 PURPOSE: construct a free resolution of the cokernel of a random map between Img(M), and Img(N). 1970 1970 EXAMPLE: example mappingcone; shows an example … … 2026 2026 2027 2027 // correct 2028 proc grrndmap(def S, def D, list #) 2028 proc grrndmap(def S, def D, list #) 2029 2029 "USAGE: grrndmap(S,D), graded objects S and D 2030 2030 RETURN: graded object … … 2092 2092 // 0<---M<----F0<----F1<----F2<----F3<---- 2093 2093 // |p1 |p2 2094 // 2094 // 2095 2095 // 0<---N<----G0<----G1<----G2<----G3<---- 2096 2096 // B(g1) g2 g3 2097 // 2097 // 2098 2098 proc grlifting2(A,B) 2099 2099 "USAGE: grlifting2(A,B), graded objects A and B (matrices defining maps) 2100 RETURN: map of chain complexes (as a list) 2100 RETURN: map of chain complexes (as a list) 2101 2101 PURPOSE: construct a map of chain complexes between free resolution of 2102 2102 M=coker(A) and N=coker(B). … … 2127 2127 P[1]=grrndmap2(A,B); 2128 2128 2129 // A(or B)=0 2129 // A(or B)=0 2130 2130 if(t==1){return(P[1])}; 2131 2131 2132 2132 for(k=2;k<=t;k++) 2133 2133 { … … 2161 2161 def T=grlifting2(DD,PP); T; 2162 2162 2163 // def Z=grlifting2(P,D); Z; // WRONG!!! 2164 2163 // def Z=grlifting2(P,D); Z; // WRONG!!! 2164 2165 2165 } 2166 2166 … … 2171 2171 proc mappingcone2(A,B) 2172 2172 "USAGE: mappingcone2(A,B), graded objects A and B (matrices defining maps) 2173 RETURN: chain complex (as a list) 2173 RETURN: chain complex (as a list) 2174 2174 PURPOSE: construct the free resolution of a cokernel of a random map between M=coker(A), and N=coker(B) 2175 2175 EXAMPLE: example mappingcone2; … … 2234 2234 */ 2235 2235 2236 proc grlifting3(A,B) 2236 proc grlifting3(A,B) 2237 2237 "TODO: grlifting4 was newer and had more documentation than this proc, but was removed... Please verify and update! 2238 2238 " … … 2247 2247 list rN = grres(B,0,1); 2248 2248 print( betti(rN), "betti"); 2249 2249 2250 2250 int i,j,k; 2251 2251 … … 2260 2260 } 2261 2261 int t=min(i,j); 2262 2262 2263 2263 list P; 2264 2264 2265 2265 "t: ", t; 2266 2266 // grview(rM[t]); grview(rN[t]); 2267 2267 2268 2268 P[t]= grrndmap2(rM[t],rN[t]); 2269 2269 grview(P[t]); … … 2312 2312 //def I=KeneshlouMatrixPresentation(intvec(2,3,0,6,2)); 2313 2313 //def J=KeneshlouMatrixPresentation(intvec(4,0,1,2,1)); 2314 //def N=grlifting3(I,J); grview(N); 2314 //def N=grlifting3(I,J); grview(N); 2315 2315 } 2316 2316 … … 2318 2318 "USAGE: grneg(A), graded object A 2319 2319 RETURN: graded object 2320 PURPOSE: graded map defined by -A 2320 PURPOSE: graded map defined by -A 2321 2321 EXAMPLE: example grneg; shows an example 2322 2322 " … … 2341 2341 proc mappingcone3(A,B) 2342 2342 "USAGE: mappingcone3(A,B), graded objects A and B (matrices defining maps) 2343 RETURN: chain complex (as a list) 2343 RETURN: chain complex (as a list) 2344 2344 PURPOSE: construct a free resolution of the cokernel of a random map between M=coker(A), and N=coker(B) 2345 2345 EXAMPLE: example mappingcone3; shows an example … … 2376 2376 2377 2377 T[i]=grtranspose(D); 2378 2378 2379 2379 kill A, B, C, D, v, w, r, s, zero; 2380 2380 } … … 2394 2394 def F=grlifting3(A,T); grview(F); 2395 2395 2396 // BUG in the proc 2396 // BUG in the proc 2397 2397 def G=mappingcone3(A,T); grview(G); 2398 2398 … … 2403 2403 ideal P=groebner(flatten(U[2])); 2404 2404 resolution L=mres(P,0); 2405 print(betti(L),"betti"); 2405 print(betti(L),"betti"); 2406 2406 */ 2407 2407 … … 2421 2421 def I=KeneshlouMatrixPresentation(intvec(2,3,0,6,2)); 2422 2422 def J=KeneshlouMatrixPresentation(intvec(4,0,1,2,1)); 2423 // def N=grlifting3(I,J); 2423 // def N=grlifting3(I,J); 2424 2424 // 2nd module does not lie in the first: 2425 2425 // def NN=mappingcone3(I,J); // ???????? … … 2458 2458 module N; 2459 2459 2460 if(i>n) 2460 if(i>n) 2461 2461 { // no middle part 2462 2462 if(a[1]>0) … … 2465 2465 2466 2466 if(a[n+1]>0) 2467 { N=grsum(N,grtwist(a[n+1],0));} 2468 } 2467 { N=grsum(N,grtwist(a[n+1],0));} 2468 } 2469 2469 else 2470 2470 { N=grtwist(a[n+1],0);} 2471 2472 return (N); // grorder(N)); 2471 2472 return (N); // grorder(N)); 2473 2473 } 2474 2474 2475 else // i <= n: middle part is present, a_i != 0 2475 else // i <= n: middle part is present, a_i != 0 2476 2476 { // a = a1 ... | i:2, a_2 ..... i: n, a_n | .... i: n+1a_(n+1) 2477 2477 module I = maxideal(1); … … 2505 2505 2506 2506 2507 return ((N)); // return (grorder(N)); 2507 return ((N)); // return (grorder(N)); 2508 2508 } 2509 2509 } … … 2518 2518 grview(S); 2519 2519 2520 def N1 = matrixpres(intvec(2,0,0,0,0)); 2520 def N1 = matrixpres(intvec(2,0,0,0,0)); 2521 2521 grview(N1); 2522 2522 -
Singular/LIB/grobcov.lib
r8d7ca0 r654a23 1 1 // 2 version="version grobcov.lib 4.0.1.2 Jan_2015 "; // $Id$ 2 version="version grobcov.lib 4.0.2.0 Jul_2015 "; // $Id$ 3 // version L; July_2015; 3 4 category="General purpose"; 4 5 info=" … … 54 55 Groebner Cover, and new theoretical developments have been done. 55 56 57 The actual version also includes a routine (ConsLevels) 58 for computing the canonical form of a constructible set, given as a 59 union of locally closed sets. It is used in the new version for the 60 computation of loci and envelops. It determines the canonical locally closed 61 level sets of a constructuble. They will be described in a forthcoming paper: 62 63 J.M. Brunat, A. Montes, 64 \"Computing the canonical representation of constructible sets\". 65 Submited to Mathematics in Computer Science. July 2015. 66 56 67 A new set of routines (locus, locusdg, locusto) has been included to 57 68 compute loci of points. The routines are used in the Dynamic … … 69 80 \''Envelops in Dynamic Geometry using the Groebner cover\''. 70 81 71 The actual version also includes two routines (AddCons and AddconsP) 72 for computing the canonical form of a constructible set, given as a 73 union of locally closed sets. They are used in the new version for the 74 computation of loci and envelops. It determines the canonical locally closed 75 level sets of a constructuble. They will be described in a forthcoming paper: 76 77 A. Montes, J.M. Brunat, 78 \"Canonical representations of constructible sets\". 79 80 This version was finished on 31/01/2015 82 83 This version was finished on 31/07/2015 81 84 82 85 NOTATIONS: All given and determined polynomials and ideals are in the … … 85 88 @* grobcov, cgsdr, 86 89 @* generate the global rings 87 @* Grobcov::@R (Q[a][x]),88 @* Grobcov::@P (Q[a]),89 @* Grobcov::@RP (Q[x,a])90 @* @R (Q[a][x]), 91 @* @P (Q[a]), 92 @* @RP (Q[x,a]) 90 93 @* that are used inside and killed before the output. 91 @* If you want to use some internal routine you must92 @* create before the above rings by calling setglobalrings();93 @* because some of the internal routines use these rings.94 @* The call to the basic routines grobcov, cgsdr will95 @* kill these rings.96 94 97 95 PROCEDURES: … … 109 107 (the own routine of 2010 that is no more used). 110 108 Now, KSW algorithm is used. 111 112 setglobalrings(); Generates the global rings @R, @P and @PR that113 are respectively the rings Q[a][x], Q[a], Q[x,a]. (a=parameters,114 x=variables) It is called inside each of the fundamental115 routines of the library: grobcov, cgsdr, locus, locusdg and116 killed before the output.117 109 118 110 pdivi(f,F); Performs a pseudodivision of a parametric polynomial … … 138 130 the bases are computed, and one can obtain the full 139 131 representation using extend. 132 133 ConsLevels(L); Given a list L of locally closed sets, it returns the canonical levels 134 of the constructible set of the union of them, as well as the levels 135 of the complement. It is described in the paper 136 137 J.M. Brunat, A. Montes, 138 \"Computing the canonical representation of constructible sets\". 139 Submited to Mathematics in Computer Science. July 2015. 140 140 141 141 locus(G); Special routine for determining the geometrical locus of points … … 178 178 \''Envelops in Dynamic Geometry using the Gr\"obner cover\''. 179 179 180 181 180 envelopdg(ev); Is a special routine to determine the 'Relevant' components 182 181 of the envelop of a family of curves to be used in Dynamic Geometry. 183 182 It must be called to the output of envelop(F,C). 184 183 185 locusto(L); Transforms the output of locus, locusdg, envelop and 184 locusto(L); Transforms the output of locus, locusdg, envelop and envelopdg 186 185 into a string that can be reed from different computational systems. 187 186 188 AddCons(L); Uses the routine AddConsP. Given a set of locally closed sets as189 difference of of varieties (does not need to be in C-representation)190 it returns the canonical P-representation of the constructible set191 formed by the union of them. The result is formed by a set of embedded,192 disjoint, locally closed sets (levels).193 194 AddConsP(L); Given a set of locally closed P-components, it returns the195 canonical P-representation of the constructible set196 formed by the union of them, consisting of a set of embedded,197 disjoint locally closed sets (levels).198 The routines AddCons and AddConsP and the canonical structure199 of the constructible sets will be described in a forthcoming paper.200 201 A. Montes, J.M. Brunat,202 \"Canonical representations of constructible sets\".203 187 204 188 SEE ALSO: compregb_lib … … 228 212 // Uses KSW algorithm for cgsdr 229 213 // Final data: 21-11-2013 230 // Release K: (public) 231 // Updated locus: 8-1-2015 232 // Updated AddConsP and AddCons: 8-1-2015 233 // Reformed many routines, examples and helps: 8-1-2015 214 // Release L: (public) 215 // New routine ConsLevels: 10-7-2015 216 // Updated locus: 10-7-2015 (uses Conslevels) 234 217 // New routines for computing the envelop of a family of curves: 22-1-2015 235 // Final data: 22- 1-2015218 // Final data: 22-7-2015 236 219 237 220 //*************Auxiliary routines************** … … 297 280 if (size(l)==1 and i==1){return(L);} 298 281 // L=l[1]; 299 if(i==1) 300 { 301 for(j=2;j<=size(l);j++) 302 { 303 L[j-1]=l[j]; 304 } 305 } 306 else 282 if(i>1) 307 283 { 308 284 for(j=1;j<=i-1;j++) 309 285 { 310 L[ j]=l[j];311 } 312 for(j=i+1;j<=size(l);j++)313 {314 L[j-1]=l[j];315 }286 L[size(L)+1]=l[j]; 287 } 288 } 289 for(j=i+1;j<=size(l);j++) 290 { 291 L[size(L)+1]=l[j]; 316 292 } 317 293 return(L); … … 773 749 //} 774 750 775 proc setglobalrings() 776 "USAGE: setglobalrings(); 777 No arguments 778 RETURN: After its call the rings @R=Q[a][x], @P=Q[a], @RP=Q[x,a] are 779 defined as global variables. (a=parameters, x=variables) 780 NOTE: It is called internally by many basic routines of the 781 library grobcov, cgsdr, extend, pdivi, pnormalf, locus, locusdg, 782 envelop, envelopdg, and killed before the output. 783 The user does not need to call it, except when it is interested 784 in using some internal routine of the library that 785 uses these rings. 786 The basering R, must be of the form Q[a][x], (a=parameters, 787 x=variables), and should be defined previously. 788 KEYWORDS: ring, rings 789 EXAMPLE: setglobalrings; shows an example" 751 static proc setglobalrings() 752 // "USAGE: setglobalrings(); 753 // No arguments 754 // RETURN: After its call the rings Grobcov::@R=Q[a][x], Grobcov::@P=Q[a], 755 // Grobcov::@RP=Q[x,a] are defined as global variables. 756 // (a=parameters, x=variables) 757 // NOTE: It is called internally by many basic routines of the 758 // library grobcov, cgsdr, extend, pdivi, pnormalf, locus, locusdg, 759 // envelop, envelopdg, and killed before the output. 760 // The user does not need to call it, except when it is interested 761 // in using some internal routine of the library that 762 // uses these rings. 763 // The basering R, must be of the form Q[a][x], (a=parameters, 764 // x=variables), and should be defined previously. 765 // KEYWORDS: ring, rings 766 // EXAMPLE: setglobalrings; shows an example" 790 767 { 791 768 if (defined(@P)) … … 810 787 setring(RR); 811 788 }; 812 example813 {814 "EXAMPLE:"; echo = 2;815 ring R=(0,a,b),(x,y,z),dp;816 setglobalrings();817 818 819 820 821 ringlist(Grobcov::@R);822 ringlist(Grobcov::@P);823 ringlist(Grobcov::@RP);824 }789 // example 790 // { 791 // "EXAMPLE:"; echo = 2; 792 // ring R=(0,a,b),(x,y,z),dp; 793 // setglobalrings(); 794 // " ";"R=";R; 795 // " ";"Grobcov::@R=";Grobcov::@R; 796 // " ";"Grobcov::@P=";Grobcov::@P; 797 // " ";"Grobcov::@RP=";Grobcov::@RP; 798 // " "; "ringlist(Grobcov::@R)="; ringlist(Grobcov::@R); 799 // " "; "ringlist(Grobcov::@P)="; ringlist(Grobcov::@P); 800 // " "; "ringlist(Grobcov::@RP)="; ringlist(Grobcov::@RP); 801 // } 825 802 826 803 // cld : clears denominators of an ideal and normalizes to content 1 … … 1515 1492 } 1516 1493 } 1494 //"T_abans="; prep; 1517 1495 if (size(prep)==0){prep=list(list(ideal(1),list(ideal(1))));} 1496 //"T_Prep="; prep; 1497 //def Lout=CompleteA(prep,prep); 1498 //"T_Lout="; Lout; 1518 1499 return(prep); 1519 1500 } … … 3934 3915 3935 3916 //********************* End KapurSunWang ************************* 3917 3918 //********************* Begin ConsLevels *************************** 3919 3920 static proc zeroone(int n) 3921 { 3922 list L; list L2; 3923 intvec e; intvec e2; intvec e3; 3924 int j; 3925 if(n==1) 3926 { 3927 e[1]=0; 3928 L[1]=e; 3929 e[1]=1; 3930 L[2]=e; 3931 return(L); 3932 } 3933 if(n>1) 3934 { 3935 L=zeroone(n-1); 3936 for(j=1;j<=size(L);j++) 3937 { 3938 e2=L[j]; 3939 e3=e2; 3940 e3[size(e3)+1]=0; 3941 L2[size(L2)+1]=e3; 3942 e3=e2; 3943 e3[size(e3)+1]=1; 3944 L2[size(L2)+1]=e3; 3945 } 3946 } 3947 return(L2); 3948 } 3949 3950 // Auxiliary routine 3951 // subsets: the list of subsets of (1,..n) 3952 static proc subsets(int n) 3953 { 3954 list L; list L1; 3955 int i; int j; 3956 L=zeroone(n); 3957 intvec e; intvec e1; 3958 for(i=1;i<=size(L);i++) 3959 { 3960 e=L[i]; 3961 kill e1; intvec e1; 3962 for(j=1;j<=n;j++) 3963 { 3964 if(e[n+1-j]==1) 3965 { 3966 if(e1==intvec(0)){e1[1]=j;} 3967 else{e1[size(e1)+1]=j}; 3968 } 3969 } 3970 L1[i]=e1; 3971 } 3972 return(L1); 3973 } 3974 3975 // Input a list A of locally closed sets in C-rep 3976 // Output a list B of a simplified list of A 3977 static proc SimplifyUnion(list A) 3978 { 3979 int i; int j; 3980 list L=A; 3981 int n=size(L); 3982 if(n<2){return(A);} 3983 for(i=1;i<=size(L);i++) 3984 { 3985 for(j=1;j<=size(L);j++) 3986 { 3987 if(i != j) 3988 { 3989 if(equalideals(L[i][2],L[j][1])==1) 3990 { 3991 L[i][2]=L[j][2]; 3992 } 3993 } 3994 } 3995 } 3996 ideal T=ideal(1); 3997 intvec v; 3998 for(i=1;i<=size(L);i++) 3999 { 4000 if(equalideals(L[i][2],ideal(1))) 4001 { 4002 v[size(v)+1]=i; 4003 T=intersect(T,L[i][1]); 4004 } 4005 } 4006 if(size(v)>0) 4007 { 4008 for(i=1; i<=size(v);i++) 4009 { 4010 j=v[size(v)+1-i]; 4011 L=elimfromlist(L, j); 4012 } 4013 } 4014 if(equalideals(T,ideal(1))==0){L[size(L)+1]=list(std(T),ideal(1))}; 4015 //string("T_n=",n," new n0",size(L)); 4016 return(L); 4017 } 4018 4019 // Input: list(A) 4020 // A is a list of locally closed sets in Crep. A=[[P1,Q1],[P2,Q2],..,[Pr,Qr]] 4021 // whose union is a constructible set from 4022 // Output list [Lev,C]: 4023 // where Lev is the Crep of the canonical first level of A, and 4024 // C is the complement of the first level Lev wrt to the closure of A. The elements are given in Crep, 4025 static proc FirstLevel(list A) 4026 { 4027 int n=size(A); 4028 list T=zeroone(n); 4029 ideal P; ideal Q; 4030 list Cb; ideal Cc=ideal(1); 4031 int i; int j; 4032 intvec t; 4033 ideal Z=ideal(1); 4034 list C; 4035 for(i=1;i<=size(A);i++) 4036 { 4037 Z=intersect(Z,A[i][1]); 4038 } 4039 for(i=2; i<=size(T);i++) 4040 { 4041 t=T[i]; 4042 P=ideal(1); Q=ideal(0); 4043 for(j=1;j<=n;j++) 4044 { 4045 if(t[n+1-j]==1) 4046 { 4047 Q=Q+A[j][2]; 4048 } 4049 else 4050 { 4051 P=intersect(P,A[j][1]); 4052 } 4053 } 4054 //"T_Q="; Q; "T_P="; P; 4055 Cb=Crep(Q,P); 4056 //"T_Cb="; Cb; 4057 if(Cb[1][1]<>1) 4058 { 4059 C[size(C)+1]=Cb; 4060 Cc=intersect(Cc,Cb[1]); 4061 } 4062 } 4063 list Lev=list(Z,Cc); //Crep(Z,Cc); 4064 if(size(C)>1){C=SimplifyUnion(C);} 4065 return(list(Lev,C)); 4066 } 4067 4068 // Input: list(A) 4069 // A is a list of locally closed sets in Crep. A=[[P1,Q1],[P2,Q2],..,[Pr,Qr]] 4070 // whose union is a constructible set from which the algorithm computes its canonical form. 4071 // Output: 4072 // list [L,C] where 4073 // where L is the list of canonical levels of A, 4074 // and C is the list of canonical levels of the complement of A wrt to the closure of A. 4075 // All locally closed sets are given in Crep. 4076 // L=[[1,[p1,p2],[3,[p3,p4],..,[2r-1,[p_{2r-1},p_2r]]]] is the list of levels of A in Crep. 4077 // C=[[2,p2,p3],[4,[p4,p5],..,[2s,[p_{2s},p_{2s+1}]]] is the list of levels of C, 4078 // the complement of S wrt the closure of A, in Crep. 4079 proc ConsLevels(list A) 4080 "USAGE: ConsLevels(A); 4081 A is a list of locally closed sets in Crep. A=[[P1,Q1],[P2,Q2],..,[Pr,Qr]] 4082 whose union is a constructible set from which the algorithm computes its 4083 canonical form. 4084 RETURN: A list with two elements: [L,C] 4085 where L is the list of canonical levels of A, and C is the list of canonical 4086 levels of the 4087 complement of A wrt to the closure of A. 4088 All locally closed sets are given in Crep. 4089 L=[[1,[p1,p2],[3,[p3,p4],..,[2r-1,[p_{2r-1},p_2r]]]] 4090 C=[[2,p2,p3],[4,[p4,p5],..,[2s,[p_{2s},p_{2s+1}]]] 4091 NOTE: The basering R, must be of the form Q[a] 4092 KEYWORDS: locally closed set, constructible set 4093 EXAMPLE: ConsLevels; shows an example" 4094 { 4095 list L; list C; int i; 4096 list B; list T; 4097 for(i=1; i<=size(A);i++) 4098 { 4099 T=Crep(A[i][1],A[i][2]); 4100 B[size(B)+1]=T; 4101 } 4102 int level=0; 4103 list K; 4104 while(size(B)>0) 4105 { 4106 level++; 4107 K=FirstLevel(B); 4108 if(level mod 2==1){L[size(L)+1]=list(level,K[1]);} 4109 else{C[size(C)+1]=list(level,K[1]);} 4110 //"T_L="; L; 4111 //"T_C="; C; 4112 B=K[2]; 4113 //"T_size(B)="; size(B); 4114 } 4115 return(list(L,C)); 4116 } 4117 example 4118 { "EXAMPLE:"; echo = 2; 4119 // Example of ConsLevels with nice geometrical interpretetion and 2 levels 4120 4121 if (defined(R)){kill R;} 4122 if (defined(@P)){kill @P; kill @R; kill @RP;} 4123 4124 ring R=0,(x,y,z),lp; 4125 short=0; 4126 ideal P1=x*(x^2+y^2+z^2-1); 4127 ideal Q1=z,x^2+y^2-1; 4128 ideal P2=y,x^2+z^2-1; 4129 ideal Q2=z*(z+1),y,x*(x+1); 4130 4131 list Cr1=Crep(P1,Q1); 4132 list Cr2=Crep(P2,Q2); 4133 4134 list L=list(Cr1,Cr2); 4135 L; 4136 // ConsLevels(L)= 4137 ConsLevels(L); 4138 4139 //---------------------------------------------------------------------- 4140 // Begin Problem S93 4141 // Automatic theorem proving 4142 // Generalized Steiner-Lehmus Theorem 4143 // A.Montes, T.Recio 4144 4145 // Bisector of A(-1,0) = Bisector of B(1,0) varying C(a,b) 4146 4147 if(defined(R1)){kill R1;} 4148 ring R1=(0,a,b),(x1,y1,x2,y2,p,r),dp; 4149 ideal S93=(a+1)^2+b^2-(p+1)^2, 4150 (a-1)^2+b^2-(1-r)^2, 4151 a*y1-b*x1-y1+b, 4152 a*y2-b*x2+y2-b, 4153 -2*y1+b*x1-(a+p)*y1+b, 4154 2*y2+b*x2-(a+r)*y2-b, 4155 (x1+1)^2+y1^2-(x2-1)^2-y2^2; 4156 4157 short=0; 4158 def GC93=grobcov(S93,"nonnull",ideal(b),"rep",1); 4159 //"grobcov(S93,'nonnull',ideal(b),"rep",1)="; GC93; 4160 4161 list L0; 4162 for(int i=1;i<=size(GC93);i++) 4163 { 4164 L0[size(L0)+1]=GC93[i][3]; 4165 } 4166 4167 def GC93ab=grobcov(S93,"nonnull",ideal(a*b),"rep",1); 4168 4169 ring RR=0,(a,b),lp; 4170 4171 list L1; 4172 L1=imap(R1,L0); 4173 // L1=Total elements of the grobcov(S93,'nonnull',ideal(b),'rep',1) to be added= 4174 L1; 4175 4176 // Adding all the elements of grobcov(S93,'nonnull',ideal(b),'rep',1)= 4177 ConsLevels(L1); 4178 } 4179 4180 //**************************** End ConsLevels ****************** 3936 4181 3937 4182 //******************** Begin locus ****************************** … … 4522 4767 locus(grobcov(S)); 4523 4768 kill R; 4524 "********************************************";4769 //******************************************** 4525 4770 4526 4771 ring R=(0,x,y),(x1,x2),dp; … … 4611 4856 locusdg(locus(grobcov(S96))); 4612 4857 kill R; 4613 "********************************************";4858 //******************************************** 4614 4859 ring R=(0,a,b),(x4,x3,x2,x1),dp; 4615 4860 ideal S=(x1-3)^2+(x2-1)^2-9, … … 4622 4867 locusdg(locus(grobcov(S))); 4623 4868 kill R; 4624 "********************************************";4869 //******************************************** 4625 4870 4626 4871 ring R=(0,x,y),(x1,x2),dp; … … 4633 4878 } 4634 4879 4635 // locusto: Transforms the output of locus to a string that4636 // can be read bydifferent computational systems.4880 // locusto: Transforms the output of locus, locusdg, envelop and envelopdg 4881 // into a string that can be reed from different computational systems. 4637 4882 // input: 4638 4883 // list L: The output of locus … … 4717 4962 locusto(locusdg(locus(grobcov(S)))); 4718 4963 kill R; 4719 "********************************************";4964 //******************************************** 4720 4965 4721 4966 // 1. Take a fixed line l: x1-y1=0 and consider … … 4737 4982 locusto(envelopdg(envelop(F,C))); 4738 4983 kill R; 4739 "********************************************";4984 //******************************************** 4740 4985 4741 4986 // Steiner Deltoid … … 4804 5049 return(d); 4805 5050 } 4806 4807 // // locusdgto: Transforms the output of locusdg to a string that4808 // // can be read by different computational systems.4809 // // input:4810 // // list L: The output of locus4811 // // output:4812 // // string s: The output of locus converted to a string readable by other programs4813 // // Outputs only the relevant dynamical geometry components.4814 // // Without unnecessary parenthesis4815 // proc locusdgto(list LL)4816 // "USAGE: locusdgto(L);4817 // The argument must be the output of locusdg of a parametrical ideal4818 // It transforms the output into a string in standard form4819 // readable in many languages (Geogebra).4820 // RETURN: The locusdg in string standard form4821 // NOTE: It can only be called after computing the locusdg(grobcov(F)) of the4822 // parametrical ideal.4823 // The basering R, must be of the form Q[a,b,..][x,y,..].4824 // KEYWORDS: geometrical locus, locus, loci.4825 // EXAMPLE: locusdgto; shows an example"4826 // {4827 // int i; int j; int k; int short0=short; int ojo;4828 // int te=0;4829 // short=0;4830 // if(size(LL)==0){ojo=1; list L;}4831 // else4832 // {4833 // def L=LL;4834 // }4835 // string s="["; string sf="]"; string st=s+sf;4836 // if(size(L)==0){return(st);}4837 // ideal p;4838 // ideal q;4839 // for(i=1;i<=size(L);i++)4840 // {4841 // if(L[i][3]=="Relevant")4842 // {4843 // s=string(s,"[[");4844 // for (j=1;j<=size(L[i][1]);j++)4845 // {4846 // s=string(s,L[i][1][j],",");4847 // }4848 // s[size(s)]="]";4849 // s=string(s,",[");4850 // for(j=1;j<=size(L[i][2]);j++)4851 // {4852 // s=string(s,"[");4853 // for(k=1;k<=size(L[i][2][j]);k++)4854 // {4855 // s=string(s,L[i][2][j][k],",");4856 // }4857 // s[size(s)]="]";4858 // s=string(s,",");4859 // }4860 // s[size(s)]="]";4861 // s=string(s,"]");4862 // s[size(s)]="]";4863 // s=string(s,",");4864 // }4865 // }4866 // if(s=="["){s="[]";}4867 // else{s[size(s)]="]";}4868 // short=short0;4869 // return(s);4870 // }4871 // example4872 // {"EXAMPLE:"; echo = 2;4873 // ring R=(0,a,b),(x,y),dp;4874 // short=0;4875 // ideal S96=x^2+y^2-4,(b-2)*x-a*y+2*a,(a-x)^2+(b-y)^2-1;4876 // "System="; S96; " ";4877 // "locusdgto(locusdg(grobcov(S96)))=";4878 // locusdgto(locusdg(grobcov(S96)));4879 // }4880 5051 4881 5052 static proc norspec(ideal F) … … 4898 5069 exportto(Top,@RP); // global ring K[x,a] with product order 4899 5070 setring(RR); 4900 4901 5071 } 4902 5072 … … 5059 5229 } 5060 5230 5061 //********************* End locus ****************************5062 5063 //********************* Begin AddCons **********************5064 5065 // Input: L1,L2: lists of components with common top5066 // Output L: list of the union of L1 and L2.5067 static proc Add2ComWithCommonTop(list L1, list L2)5068 {5069 int i; int j; ideal pij; list L; list Lp; list PR; int k;5070 for(i=1;i<=size(L1[2]);i++)5071 {5072 for(j=1;j<=size(L2[2]);j++)5073 {5074 pij=std(L1[2][i]+L2[2][j]);5075 PR=minGTZ(pij);5076 for(k=1;k<=size(PR);k++)5077 {5078 Lp[size(Lp)+1]=PR[k];5079 }5080 }5081 }5082 for(i=1; i<=size(Lp);i++)5083 {5084 for(j=i+1;j<=size(Lp);j++)5085 {5086 if(idcontains(Lp[i],Lp[j])) {Lp=delete(Lp,j);}5087 }5088 for(j=1;j<i;j++)5089 {5090 if(idcontains(Lp[i],Lp[j])){Lp=delete(Lp,j); j=j-1; i=i-1;}5091 }5092 }5093 L[1]=L1[1];5094 L[2]=Lp;5095 return(L);5096 }5097 5098 // Input: L list od P-rep of components to be added. L[i]=[p_i,[p_{i1},...p_{ir_i}]]5099 // Output: lists A,B,L5100 // where no top in the lists are repeated5101 // A: list of components with higher tops5102 // B: list of components with lower tops5103 // L1: A,B5104 static proc SepareAB(list L)5105 {5106 int i; int j; list Ln=L;5107 for(i=1;i<=size(Ln);i++)5108 {5109 for(j=i+1;j<=size(Ln);j++)5110 {5111 if (equalideals(Ln[j][1],Ln[i][1]))5112 {5113 Ln[i]=Add2ComWithCommonTop(Ln[i],Ln[j]);5114 Ln=delete(Ln,j);5115 j=j-1;5116 }5117 }5118 }5119 list A; list B; int clas; list T; list L1;5120 for(i=1;i<=size(Ln);i++)5121 {5122 j=1;5123 clas=0;5124 while((clas==0) and (j<=size(Ln)))5125 {5126 if(j!=i)5127 {5128 if(idcontains(Ln[i][1],Ln[j][1]) ) {B[size(B)+1]=Ln[i]; clas=1;}5129 }5130 j++;5131 }5132 if(clas==0) {A[size(A)+1]=Ln[i];}5133 }5134 L1=A; for(j=1;j<=size(B);j++){L1[size(L1)+1]=B[j];}5135 T[1]=A; T[2]=B; T[3]=L1;5136 return(T);5137 }5138 5139 // Input:5140 // A1: list of high set of P-reps to be completed by the remaining P-reps5141 // L1: the list A1, completed with the list of lower P-reps.5142 // Output:5143 // A: list A1 completed with all possible parts of the remaining parts of L1 with the5144 // condition of building locally closed sets.5145 static proc CompleteA(list A1,list L1)5146 {5147 int modif; int i; int j; int k; int l;5148 ideal pij; ideal pk; ideal pijkl; ideal pkl;5149 int n; list nl; int te; int clas; list vvv; list AAA;5150 list Lp; int m; ideal Pij;5151 list A0;5152 modif=1;5153 list A=A1;5154 while(modif==1)5155 {5156 modif=0;5157 A0=A;5158 for(i=1;i<=size(A);i++)5159 {5160 for(j=1;j<=size(A[i][2]); j++)5161 {5162 pij=A[i][2][j];5163 for(k=1;k<=size(L1);k++)5164 {5165 if(k!=i)5166 {5167 pk=L1[k][1];5168 if(idcontains(pij,pk)==1)5169 {5170 te=0;5171 kill nl;5172 list nl; l=1;5173 while((te==0) and (l<=size(L1[k][2])))5174 {5175 pkl=L1[k][2][l];5176 if((equalideals(pij,pkl)==1) or (idcontains(pij,pkl)==1)) {te=1;}5177 l++;5178 } // end while ((te=0) and (l>...5179 //"T_te="; te; pause();5180 if(te==0)5181 {5182 modif=1;5183 kill Pij; ideal Pij=1;5184 for(l=1; l<=size(L1[k][2]);l++)5185 {5186 pkl=L1[k][2][l];5187 pijkl=std(pij+pkl);5188 Pij=intersect(Pij,pijkl);5189 }5190 kill Lp; list Lp;5191 Lp=minGTZ(Pij);5192 for(m=1;m<=size(Lp);m++)5193 {5194 nl[size(nl)+1]=Lp[m];5195 }5196 A[i][2]=delete(A[i][2], j);5197 for(n=1;n<=size(nl);n++)5198 {5199 A[i][2][size(A[i][2])+1]=nl[n];5200 }5201 } // end if(te==0)5202 } // end if(idcontains(pij,pk)==1)5203 } // end if (k!=i)5204 } // end for k5205 } // end for j5206 kill vvv; list vvv;5207 if(modif==1)5208 // Select the maximal ideals of the set A[I][2][j]5209 {5210 kill nl; list nl;5211 nl=selectminideals(A[i][2]);5212 kill AAA; list AAA;5213 for(j=1;j<=size(nl);j++)5214 {5215 AAA[size(AAA)+1]=A[i][2][nl[j]];5216 }5217 A[i][2]=AAA;5218 } // end if(modif=1)5219 } // end for i5220 modif=1-equallistsAall(A,A0);5221 } // end while(modif==1)5222 return(A);5223 }5224 5225 // Input:5226 // A: list of the top P-reps of one level5227 // B: list of remaining lower P-reps that have not yeen be possible to add5228 // Output:5229 // Bn: list B where the elements that are completely included in A are removed and the parts that are5230 // included in A also.5231 static proc ReduceB(list A,list B)5232 {5233 int i; int j; list nl; list Bn; int te; int k; int elim;5234 ideal pC; ideal pD; ideal pCD; ideal pBC; list nB; int j0;5235 for(i=1;i<=size(B);i++)5236 {5237 j=1; te=0;5238 while((te==0) and (j<=size(A)))5239 {5240 if(idcontains(B[i][1],A[j][1])){te=1; j0=j;}5241 else{j++;}5242 }5243 pD=B[i][2][1];5244 for(k=2;k<=size(B[i][2]);k++){pD=intersect(pD,B[i][2][k]);}5245 pC=A[j0][2][1];5246 for(k=2;k<=size(A[j0][2]);k++) {pC=intersect(pC,A[j0][2][k]);}5247 pCD=std(pD+pC);5248 pBC=std(B[i][1]+pC);5249 elim=0;5250 if(idcontains(pBC,pCD)){elim=1;} // B=delfromlist(B,i);i=i-1;5251 else5252 {5253 nB=Prep(pBC,pCD);5254 if(equalideals(nB[1][1],ideal(1))==0)5255 {5256 for(k=1;k<=size(nB);k++){Bn[size(Bn)+1]=nB[k];}5257 }5258 }5259 } // end for i5260 return(Bn);5261 }5262 5263 // AddConsP: given a set of components of locally closed sets in P-representation, it builds the5264 // canonical P-representation of the corresponding constructible set, of its union,5265 // including levels it they are.5266 proc AddConsP(list L)5267 "USAGE: AddConsP(L)5268 Input L: list of components in P-rep to be added5269 [ [[p_1,[p_11,..,p_1,r1]],..[p_k,[p_k1,..,p_kr_k]] ]5270 RETURN:5271 list of lists of levels of the different locally closed sets of5272 the canonical P-rep of the constructible.5273 [ [level_1,[ [Comp_11,..Comp_1r_1] ] ], .. ,5274 [level_s,[ [Comp_s1,..Comp_sr_1] ]5275 ]5276 where level_i=i, Comp_ij=[ p_i,[p_i1,..,p_it_i] ] is a prime component.5277 NOTE: Operates in a ring R=Q[u_1,..,u_m]5278 KEYWORDS: Constructible set, Canoncial form5279 EXAMPLE: AddConsP; shows an example"5280 {5281 list LL; list A; list B; list L1; list T; int level=0; list h;5282 LL=L; int i;5283 while(size(LL)!=0)5284 {5285 level++;5286 L1=SepareAB(LL);5287 A=L1[1]; B=L1[2]; LL=L1[3];5288 A=CompleteA(A,LL);5289 for(i=1;i<=size(A);i++)5290 {5291 LL[i]=A[i];5292 }5293 h[1]=level; h[2]=A;5294 T[size(T)+1]=h;5295 LL=ReduceB(A,B);5296 }5297 return(T);5298 }5299 example5300 {5301 "EXAMPLE:"; echo = 2;5302 if (defined(Grobcov::@P)){kill Grobcov::@P; kill Grobcov::@R; kill Grobcov::@RP;}5303 ring R=0,(x,y,z),lp;5304 short=0;5305 5306 ideal P1=x;5307 ideal Q1=x,y;5308 ideal P2=y;5309 ideal Q2=y,z;5310 5311 list L=list(Prep(P1,Q1)[1],Prep(P2,Q2)[1]);5312 L;5313 AddConsP(L);5314 }5315 5316 // AddCons: given a set of locally closed sets by pairs of ideal, it builds the5317 // canonical P-representation of the corresponding constructible set, of its union,5318 // including levels it they are.5319 // It makes a call to AddConsP after transforming the input.5320 // Input list of lists of pairs of ideals representing locally colsed sets:5321 // L= [ [E1,N1], .. , [E_s,N_s] ]5322 // Output: The canonical frepresentation of the constructible set union of the V(E_i) \ V(N_i)5323 // T=[ [level_1,[ [p_1,[p_11,..,p_1s_1]],.., [p_k,[p_k1,..,p_ks_k]] ]],, .. , [level_r,[.. ]] ]5324 proc AddCons(list L)5325 "USAGE: AddCons(L)5326 Calls internally AddConsP and allows a different input.5327 Input L: list of pairs of of ideals [ [P_1,Q_1], .., [Pr,Qr] ]5328 representing a set of locally closed setsV(P_i) \ V(Q_i)5329 to be added.5330 RETURN:5331 list of lists of levels of the different locally closed sets of5332 the canonical P-rep of the constructible.5333 [ [level_1,[ [Comp_11,..Comp_1r_1] ] ], .. ,5334 [level_s,[ [Comp_s1,..Comp_sr_1] ]5335 ]5336 where level_i=i, Comp_ij=[ p_i,[p_i1,..,p_it_i] ] is a prime component.5337 NOTE: Operates in a ring R=Q[u_1,..,u_m]5338 KEYWORDS: Constructible set, Canoncial form5339 EXAMPLE: AddCons; shows an example"5340 {5341 int i; list H; list P; int j;5342 for(i=1;i<=size(L);i++)5343 {5344 P=Prep(L[i][1],L[i][2]);5345 for(j=1;j<=size(P);j++)5346 {5347 H[size(H)+1]=P[j];5348 }5349 }5350 return(AddConsP(H));5351 }5352 example5353 {5354 "EXAMPLE:"; echo = 2;5355 if (defined(Grobcov::@P)){kill Grobcov::@P; kill Grobcov::@R; kill Grobcov::@RP;}5356 ring R=0,(x,y,z),lp;5357 short=0;5358 5359 ideal P1=x;5360 ideal Q1=x,y;5361 ideal P2=y;5362 ideal Q2=y,z;5363 5364 list L=list(list(P1,Q1), list(P2,Q2) );5365 L;5366 5367 AddCons(L);5368 }5369 5370 5231 // AddLocus: auxilliary routine for locus0 that computes the components of the constructible: 5371 5232 // Input: the list of locally closed sets to be added, each with its type as third argument … … 5397 5258 } 5398 5259 } 5399 L3= AddConsP(L1);5260 L3=LocusConsLevels(L1); 5400 5261 list L4; int level; 5401 5262 ideal p1; ideal pp1; int t; int k; int k0; string typ; list l4; … … 5426 5287 } 5427 5288 5428 //********************* End AddCons ********************** 5429 ; 5289 // Input L: list of components in P-rep to be added 5290 // [ [[p_1,[p_11,..,p_1,r1]],..[p_k,[p_k1,..,p_kr_k]] ] 5291 // Output: 5292 // list of lists of levels of the different locally closed sets of 5293 // the canonical P-rep of the constructible. 5294 // [ [level_1,[ [Comp_11,..Comp_1r_1] ] ], .. , 5295 // [level_s,[ [Comp_s1,..Comp_sr_1] ] 5296 // ] 5297 // where level_i=i, Comp_ij=[ p_i,[p_i1,..,p_it_i] ] is a prime component. 5298 // LocusConsLevels: given a set of components of locally closed sets in P-representation, it builds the 5299 // canonical P-representation of the corresponding constructible set of its union, 5300 // including levels it they are. 5301 static proc LocusConsLevels(list L) 5302 { 5303 list Lc; list Sc; 5304 int i; 5305 for(i=1;i<=size(L);i++) 5306 { 5307 Sc=PtoCrep(list(L[i])); 5308 Lc[size(Lc)+1]=Sc; 5309 } 5310 list S=ConsLevels(Lc)[1]; 5311 list Sout; 5312 list Lev; 5313 for(i=1;i<=size(S);i++) 5314 { 5315 Lev=list(i,Prep(S[i][2][1],S[i][2][2])); 5316 Sout[size(Sout)+1]=Lev; 5317 } 5318 return(Sout); 5319 } 5320 5321 //********************* End locus **************************** 5322 -
Singular/LIB/grwalk.lib
r4132ee r654a23 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 … … 274 274 string ord_str = OSCTW[2]; 275 275 intvec curr_weight = OSCTW[3]; /* original weight vector */ 276 intvec target_weight = OSCTW[4]; /* t erget weight vector */276 intvec target_weight = OSCTW[4]; /* target weight vector */ 277 277 kill OSCTW; 278 278 option(redSB); … … 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; … … 299 299 //** compute a Groebner basis of I w.r.t. lp. 300 300 ring r = 32003,(z,y,x), lp; 301 ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; 302 gwalk(I); 301 ideal I = zy2+yx2+yx+3, 302 z3x+y3+zyx-yx2-yx-3, 303 z2yx3-y5+z2yx2+y3x2+y2x3+y3x+y2x2+3z2x+3y2+3yx, 304 zyx5+y6-y4x2-y3x3+2zyx4-y4x-y3x2+zyx3-3z2yx+3zx3-3y3-3y2x+3zx2, 305 yx7-y7+y5x2+y4x3+3yx6+y5x+y4x2+3yx5-6zyx3+yx4+3x5+3y4+3y3x-6zyx2+6x4+3x3-9zx; 306 gwalk(I,0,1); 303 307 } 304 308 … … 346 350 } 347 351 348 proc fwalk(ideal Go, list #)349 "SYNTAX: fwalk(ideal i );350 fwalk(ideal i, int vec v, intvec w);352 proc fwalk(ideal Go, int reduction, int printout, list #) 353 "SYNTAX: fwalk(ideal i,int reductioin); 354 fwalk(ideal i, int reduction intvec v, intvec w); 351 355 TYPE: ideal 352 356 PURPOSE: compute the standard basis of the ideal w.r.t. the … … 372 376 373 377 ideal G = fetch(xR, Go); 374 G = system("Mfwalk", G, curr_weight, target_weight );378 G = system("Mfwalk", G, curr_weight, target_weight, reduction, printout); 375 379 376 380 setring xR; … … 387 391 ring r = 32003,(z,y,x), lp; 388 392 ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; 389 fwalk(I); 393 int reduction = 1; 394 int printout = 1; 395 fwalk(I,reduction,printout); 390 396 } 391 397 … … 437 443 } 438 444 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);445 proc pwalk(ideal Go, int n1, int n2, int reduction, int printout, list #) 446 "SYNTAX: pwalk(int d, ideal i, int n1, int n2, int reduction, int printout); 447 pwalk(int d, ideal i, int n1, int n2, int reduction, int printout, intvec v, intvec w); 442 448 TYPE: ideal 443 449 PURPOSE: compute the standard basis of the ideal, calculated via … … 477 483 ideal G = fetch(xR, Go); 478 484 479 G = system("Mpwalk", G, n1, n2, curr_weight, target_weight,nP);480 485 G = system("Mpwalk",G,n1,n2,curr_weight,target_weight,nP,reduction,printout); 486 481 487 setring xR; 482 //kill Go; 488 //kill Go; //unused 483 489 484 490 keepring basering; … … 492 498 ring r = 32003,(z,y,x), lp; 493 499 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); 500 int reduction = 1; 501 int printout = 2; 502 pwalk(I,2,2,reduction,printout); 498 503 } 499 504 -
Singular/LIB/modstd.lib
r8d7ca0 r654a23 283 283 * (same as size(reduce(I_reduce, G_reduce))). 284 284 * Uses parallelization. */ 285 static proc reduce_parallel( ideal I_reduce, idealG_reduce)285 static proc reduce_parallel(def I_reduce, def G_reduce) 286 286 { 287 287 exportto(Modstd, I_reduce); -
Singular/LIB/modwalk.lib
-
Property
mode
changed from
100644
to100755
r4132ee r654a23 16 16 17 17 PROCEDURES: 18 modWalk(ideal,int,int[,int,int,int,int]); standard basis conversion of I using modular methods (chinese remainder) 18 19 modWalk(I,#); standard basis conversion of I by Groebner Walk using modular methods 20 modrWalk(I,radius,pertdeg,#); standard basis conversion of I by Random Walk using modular methods 21 modfWalk(I,#); standard basis conversion of I by Fractal Walk using modular methods 22 modfrWalk(I,radius,#); standard basis conversion of I by Random Fractal Walk using modular methods 19 23 "; 20 24 21 LIB "poly.lib";22 LIB "ring.lib";23 LIB "parallel.lib";24 25 LIB "rwalk.lib"; 25 26 LIB "grwalk.lib"; 26 LIB "modstd.lib"; 27 28 29 //////////////////////////////////////////////////////////////////////////////// 30 31 static proc modpWalk(def II, int p, int variant, list #) 32 "USAGE: modpWalk(I,p,#); I ideal, p integer, variant integer 33 ASSUME: If size(#) > 0, then 34 #[1] is an intvec describing the current weight vector 35 #[2] is an intvec describing the target weight vector 36 RETURN: ideal - a standard basis of I mod p, integer - p 37 NOTE: The procedure computes a standard basis of the ideal I modulo p and 38 fetches the result to the basering. 39 EXAMPLE: example modpWalk; shows an example 40 " 41 { 42 option(redSB); 43 int k,nvar@r; 44 def R0 = basering; 45 string ordstr_R0 = ordstr(R0); 46 list rl = ringlist(R0); 47 int sizerl = size(rl); 48 int neg = 1 - attrib(R0,"global"); 49 if(typeof(II) == "ideal") 50 { 51 ideal I = II; 27 LIB "modular.lib"; 28 29 proc modWalk(ideal I, list #) 30 "USAGE: modWalk(I, [, v, w]); I ideal, v intvec, w intvec 31 RETURN: a standard basis of I 32 NOTE: The procedure computes a standard basis of I (over the rational 33 numbers) by using modular methods. 34 SEE ALSO: modular 35 EXAMPLE: example modWalk; shows an example" 36 { 37 /* read optional parameter */ 38 if (size(#) > 0) { 39 if (size(#) == 1) { 40 intvec w = #[1]; 41 } 42 if (size(#) == 2) { 43 intvec v = #[1]; 44 intvec w = #[2]; 45 } 46 if (size(#) > 2 || typeof(#[1]) != "intvec") { 47 ERROR("wrong optional parameter"); 48 } 49 } 50 51 /* save options */ 52 intvec opt = option(get); 53 option(redSB); 54 55 /* set additional parameters */ 56 int reduction = 1; 57 int printout = 0; 58 59 /* call modular() */ 60 if (size(#) > 0) { 61 I = modular("gwalk", list(I,reduction,printout,#)); 62 } 63 else { 64 I = modular("gwalk", list(I,reduction,printout)); 65 } 66 67 /* return the result */ 68 attrib(I, "isSB", 1); 69 option(set, opt); 70 return(I); 71 } 72 example 73 { 74 "EXAMPLE:"; 75 echo = 2; 76 ring R1 = 0, (x,y,z,t), dp; 77 ideal I = 3x3+x2+1, 11y5+y3+2, 5z4+z2+4; 78 I = std(I); 79 ring R2 = 0, (x,y,z,t), lp; 80 ideal I = fetch(R1, I); 81 ideal J = modWalk(I); 82 J; 83 } 84 85 proc modrWalk(ideal I, int radius, int pertdeg, list #) 86 "USAGE: modrWalk(I, radius, pertdeg[, v, w]); 87 I ideal, radius int, pertdeg int, v intvec, w intvec 88 RETURN: a standard basis of I 89 NOTE: The procedure computes a standard basis of I (over the rational 90 numbers) by using modular methods. 91 SEE ALSO: modular 92 EXAMPLE: example modrWalk; shows an example" 93 { 94 /* read optional parameter */ 95 if (size(#) > 0) { 96 if (size(#) == 1) { 97 intvec w = #[1]; 98 } 99 if (size(#) == 2) { 100 intvec v = #[1]; 101 intvec w = #[2]; 102 } 103 if (size(#) > 2 || typeof(#[1]) != "intvec") { 104 ERROR("wrong optional parameter"); 105 } 106 } 107 108 /* save options */ 109 intvec opt = option(get); 110 option(redSB); 111 112 /* set additional parameters */ 113 int reduction = 1; 114 int printout = 0; 115 116 /* call modular() */ 117 if (size(#) > 0) { 118 I = modular("rwalk", list(I,radius,pertdeg,reduction,printout,#)); 119 } 120 else { 121 I = modular("rwalk", list(I,radius,pertdeg,reduction,printout)); 122 } 123 124 /* return the result */ 125 attrib(I, "isSB", 1); 126 option(set, opt); 127 return(I); 128 } 129 example 130 { 131 "EXAMPLE:"; 132 echo = 2; 133 ring R1 = 0, (x,y,z,t), dp; 134 ideal I = 3x3+x2+1, 11y5+y3+2, 5z4+z2+4; 135 I = std(I); 136 ring R2 = 0, (x,y,z,t), lp; 137 ideal I = fetch(R1, I); 52 138 int radius = 2; 53 int pert_deg = 2; 54 } 55 if(typeof(II) == "list" && typeof(II[1]) == "ideal") 56 { 57 ideal I = II[1]; 58 if(size(II) == 2) 59 { 60 int radius = II[2]; 61 int pert_deg = 2; 62 } 63 if(size(II) == 3) 64 { 65 int radius = II[2]; 66 int pert_deg = II[3]; 67 } 68 } 69 rl[1] = p; 70 int h = homog(I); 71 def @r = ring(rl); 72 setring @r; 73 ideal i = fetch(R0,I); 74 string order; 75 if(system("nblocks") <= 2) 76 { 77 if(find(ordstr_R0, "M") + find(ordstr_R0, "lp") + find(ordstr_R0, "rp") <= 0) 78 { 79 order = "simple"; 80 } 81 } 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 //------------------------- compute a standard basis mod p ----------------------------- 109 110 if(variant == 1) 111 { 112 if(size(#)>0) 113 { 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); 120 } 121 } 122 if(variant == 2) 123 { 124 if(size(#) == 2) 125 { 126 i = gwalk(i,#); 127 } 128 else 129 { 130 i = gwalk(i); 131 } 132 } 133 if(variant == 3) 134 { 135 if(size(#) == 2) 136 { 137 i = frandwalk(i,radius,#); 138 } 139 else 140 { 141 i = frandwalk(i,radius); 142 } 143 } 144 if(variant == 4) 145 { 146 if(size(#) == 2) 147 { 148 i=fwalk(i,#); 149 } 150 else 151 { 152 i=fwalk(i); 153 } 154 } 155 if(variant == 5) 156 { 157 if(size(#) == 2) 158 { 159 i=prwalk(i,radius,pert_deg,pert_deg,#); 160 } 161 else 162 { 163 i=prwalk(i,radius,pert_deg,pert_deg); 164 } 165 } 166 if(variant == 6) 167 { 168 if(size(#) == 2) 169 { 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 } 193 setring R0; 194 return(list(fetch(@r,i),p)); 195 } 196 example 197 { 198 "EXAMPLE:"; echo = 2; 199 option(redSB); 200 201 int p = 181; 202 intvec a = 2,1,3,4; 203 intvec b = 1,9,1,1; 204 ring ra = 0,x(1..4),(a(a),lp); 205 ideal I = std(cyclic(4)); 206 ring rb = 0,x(1..4),(a(b),lp); 207 ideal I = imap(ra,I); 208 modpWalk(I,p,1,a,b); 209 std(I); 210 } 211 212 //////////////////////////////////////////////////////////////////////////////// 213 214 proc modWalk(def II, int variant, list #) 215 "USAGE: modWalk(II); II ideal or list(ideal,int) 216 ASSUME: If variant = 217 @* - 1 the Random Walk algorithm with radius II[2] is applied 218 to II[1] if II = list(ideal, int). It is applied to II with radius 2 219 if II is an ideal. 220 @* - 2, the Groebner Walk algorithm is applied to II[1] or to II, respectively. 221 @* - 3, the Fractal Walk algorithm with random element is applied to II[1] or II, 222 respectively. 223 @* - 4, the Fractal Walk algorithm is applied to II[1] or II, respectively. 224 @* - 5, the Perturbation Walk algorithm with random element is applied to II[1] 225 or II, respectively, with radius II[3] and perturbation degree II[2]. 226 @* - 6, the Perturbation Walk algorithm is applied to II[1] or II, respectively, 227 with perturbation degree II[3]. 228 If size(#) > 0, then # contains either 1, 2 or 4 integers such that 229 @* - #[1] is the number of available processors for the computation, 230 @* - #[2] is an optional parameter for the exactness of the computation, 231 if #[2] = 1, the procedure computes a standard basis for sure, 232 @* - #[3] is the number of primes until the first lifting, 233 @* - #[4] is the constant number of primes between two liftings until 234 the computation stops. 235 RETURN: a standard basis of I if no warning appears. 236 NOTE: The procedure converts a standard basis of I (over the rational 237 numbers) from the ordering \"a(v),lp\", "dp\" or \"Dp\" to the ordering 238 \"(a(w),lp\" or \"a(1,0,...,0),lp\" by using modular methods. 239 By default the procedure computes a standard basis of I for sure, but 240 if the optional parameter #[2] = 0, it computes a standard basis of I 241 with high probability. 242 EXAMPLE: example modWalk; shows an example 243 " 244 { 245 int TT = timer; 246 int RT = rtimer; 247 int i,j,pTest,sizeTest,weighted,n1; 248 bigint N; 249 250 def R0 = basering; 251 list rl = ringlist(R0); 252 if((npars(R0) > 0) || (rl[1] > 0)) 253 { 254 ERROR("Characteristic of basering should be zero, basering should have no parameters."); 255 } 256 257 if(typeof(II) == "ideal") 258 { 259 ideal I = II; 260 kill II; 261 list II; 262 II[1] = I; 263 II[2] = 2; 264 II[3] = 2; 265 } 266 else 267 { 268 if(typeof(II) == "list" && typeof(II[1]) == "ideal") 269 { 270 ideal I = II[1]; 271 if(size(II) == 1) 272 { 273 II[2] = 2; 274 II[3] = 2; 275 } 276 if(size(II) == 2) 277 { 278 II[3] = 2; 279 } 280 281 } 282 else 283 { 284 ERROR("Unexpected type of input."); 285 } 286 } 287 288 //-------------------- Initialize optional parameters ------------------------ 289 n1 = system("--cpus"); 290 if(size(#) == 0) 291 { 292 int exactness = 1; 293 int n2 = 10; 294 int n3 = 10; 295 } 296 else 297 { 298 if(size(#) == 1) 299 { 300 if(typeof(#[1]) == "int") 301 { 302 if(#[1] < n1) 303 { 304 n1 = #[1]; 305 } 306 int exactness = 1; 307 if(n1 >= 10) 308 { 309 int n2 = n1 + 1; 310 int n3 = n1; 311 } 312 else 313 { 314 int n2 = 10; 315 int n3 = 10; 316 } 317 } 318 else 319 { 320 ERROR("Unexpected type of input."); 321 } 322 } 323 if(size(#) == 2) 324 { 325 if(typeof(#[1]) == "int" && typeof(#[2]) == "int") 326 { 327 if(#[1] < n1) 328 { 329 n1 = #[1]; 330 } 331 int exactness = #[2]; 332 if(n1 >= 10) 333 { 334 int n2 = n1 + 1; 335 int n3 = n1; 336 } 337 else 338 { 339 int n2 = 10; 340 int n3 = 10; 341 } 342 } 343 else 344 { 345 if(typeof(#[1]) == "intvec" && typeof(#[2]) == "intvec") 346 { 347 intvec curr_weight = #[1]; 348 intvec target_weight = #[2]; 349 weighted = 1; 350 int n2 = 10; 351 int n3 = 10; 352 int exactness = 1; 353 } 354 else 355 { 356 ERROR("Unexpected type of input."); 357 } 358 } 359 } 360 if(size(#) == 3) 361 { 362 if(typeof(#[1]) == "intvec" && typeof(#[2]) == "intvec" && typeof(#[3]) == "int") 363 { 364 intvec curr_weight = #[1]; 365 intvec target_weight = #[2]; 366 weighted = 1; 367 n1 = #[3]; 368 int n2 = 10; 369 int n3 = 10; 370 int exactness = 1; 371 } 372 else 373 { 374 ERROR("Unexpected type of input."); 375 } 376 } 377 if(size(#) == 4) 378 { 379 if(typeof(#[1]) == "intvec" && typeof(#[2]) == "intvec" && typeof(#[3]) == "int" 380 && typeof(#[4]) == "int") 381 { 382 intvec curr_weight = #[1]; 383 intvec target_weight = #[2]; 384 weighted = 1; 385 if(#[1] < n1) 386 { 387 n1 = #[3]; 388 } 389 int exactness = #[4]; 390 if(n1 >= 10) 391 { 392 int n2 = n1 + 1; 393 int n3 = n1; 394 } 395 else 396 { 397 int n2 = 10; 398 int n3 = 10; 399 } 400 } 401 else 402 { 403 if(typeof(#[1]) == "int" && typeof(#[2]) == "int" && typeof(#[3]) == "int" && typeof(#[4]) == "int") 404 { 405 if(#[1] < n1) 406 { 407 n1 = #[1]; 408 } 409 int exactness = #[2]; 410 if(n1 >= #[3]) 411 { 412 int n2 = n1 + 1; 413 } 414 else 415 { 416 int n2 = #[3]; 417 } 418 if(n1 >= #[4]) 419 { 420 int n3 = n1; 421 } 422 else 423 { 424 int n3 = #[4]; 425 } 426 } 427 else 428 { 429 ERROR("Unexpected type of input."); 430 } 431 } 432 } 433 if(size(#) == 6) 434 { 435 if(typeof(#[1]) == "intvec" && typeof(#[2]) == "intvec" && typeof(#[3]) == "int" && typeof(#[4]) == "int" && typeof(#[5]) == "int" && typeof(#[6]) == "int") 436 { 437 intvec curr_weight = #[1]; 438 intvec target_weight = #[2]; 439 weighted = 1; 440 if(#[3] < n1) 441 { 442 n1 = #[3]; 443 } 444 int exactness = #[4]; 445 if(n1 >= #[5]) 446 { 447 int n2 = n1 + 1; 448 } 449 else 450 { 451 int n2 = #[5]; 452 } 453 if(n1 >= #[6]) 454 { 455 int n3 = n1; 456 } 457 else 458 { 459 int n3 = #[6]; 460 } 461 } 462 else 463 { 464 ERROR("Expected list(intvec,intvec,int,int,int,int) as optional parameter list."); 465 } 466 } 467 if(size(#) == 1 || size(#) == 5 || size(#) > 6) 468 { 469 ERROR("Expected 0,2,3,4 or 5 optional arguments."); 470 } 471 } 472 if(printlevel >= 10) 473 { 474 "n1 = "+string(n1)+", n2 = "+string(n2)+", n3 = "+string(n3)+", exactness = "+string(exactness); 475 } 476 477 //------------------------- Save current options ----------------------------- 478 intvec opt = option(get); 479 //option(redSB); 480 481 //-------------------- Initialize the list of primes ------------------------- 482 int tt = timer; 483 int rt = rtimer; 484 int en = 2134567879; 485 int an = 1000000000; 486 intvec L = primeList(I,n2); 487 if(n2 > 4) 488 { 489 // L[5] = prime(random(an,en)); 490 } 491 if(printlevel >= 10) 492 { 493 "CPU-time for primeList: "+string(timer-tt)+" seconds."; 494 "Real-time for primeList: "+string(rtimer-rt)+" seconds."; 495 } 496 int h = homog(I); 497 list P,T1,T2,LL,Arguments,PP; 498 ideal J,K,H; 499 500 //------------------- parallelized Groebner Walk in positive characteristic -------------------- 501 502 if(weighted) 503 { 504 for(i=1; i<=size(L); i++) 505 { 506 Arguments[i] = list(II,L[i],variant,list(curr_weight,target_weight)); 507 } 508 } 509 else 510 { 511 for(i=1; i<=size(L); i++) 512 { 513 Arguments[i] = list(II,L[i],variant); 514 } 515 } 516 P = parallelWaitAll("modpWalk",Arguments); 517 for(i=1; i<=size(P); i++) 518 { 519 T1[i] = P[i][1]; 520 T2[i] = bigint(P[i][2]); 521 } 522 523 while(1) 524 { 525 LL = deleteUnluckyPrimes(T1,T2,h); 526 T1 = LL[1]; 527 T2 = LL[2]; 528 //------------------- Now all leading ideals are the same -------------------- 529 //------------------- Lift results to basering via farey --------------------- 530 531 tt = timer; rt = rtimer; 532 N = T2[1]; 533 for(i=2; i<=size(T2); i++) 534 { 535 N = N*T2[i]; 536 } 537 H = chinrem(T1,T2); 538 J = parallelFarey(H,N,n1); 539 //J=farey(H,N); 540 if(printlevel >= 10) 541 { 542 "CPU-time for lifting-process is "+string(timer - tt)+" seconds."; 543 "Real-time for lifting-process is "+string(rtimer - rt)+" seconds."; 544 } 545 546 //---------------- Test if we already have a standard basis of I -------------- 547 548 tt = timer; rt = rtimer; 549 pTest = pTestSB(I,J,L,variant); 550 //pTest = primeTestSB(I,J,L,variant); 551 if(printlevel >= 10) 552 { 553 "CPU-time for pTest is "+string(timer - tt)+" seconds."; 554 "Real-time for pTest is "+string(rtimer - rt)+" seconds."; 555 } 556 if(pTest) 557 { 558 if(printlevel >= 10) 559 { 560 "CPU-time for computation without final tests is "+string(timer - TT)+" seconds."; 561 "Real-time for computation without final tests is "+string(rtimer - RT)+" seconds."; 562 } 563 attrib(J,"isSB",1); 564 if(exactness == 0) 565 { 566 option(set, opt); 567 return(J); 568 } 569 else 570 { 571 tt = timer; 572 rt = rtimer; 573 sizeTest = 1 - isIdealIncluded(I,J,n1); 574 if(printlevel >= 10) 575 { 576 "CPU-time for checking if I subset <G> is "+string(timer - tt)+" seconds."; 577 "Real-time for checking if I subset <G> is "+string(rtimer - rt)+" seconds."; 578 } 579 if(sizeTest == 0) 580 { 581 tt = timer; 582 rt = rtimer; 583 K = std(J); 584 if(printlevel >= 10) 585 { 586 "CPU-time for last std-computation is "+string(timer - tt)+" seconds."; 587 "Real-time for last std-computation is "+string(rtimer - rt)+" seconds."; 588 } 589 if(size(reduce(K,J)) == 0) 590 { 591 option(set, opt); 592 return(J); 593 } 594 } 595 } 596 } 597 //-------------- We do not already have a standard basis of I, therefore do the main computation for more primes -------------- 598 599 T1 = H; 600 T2 = N; 601 j = size(L)+1; 602 tt = timer; rt = rtimer; 603 L = primeList(I,n3,L,n1); 604 if(printlevel >= 10) 605 { 606 "CPU-time for primeList: "+string(timer-tt)+" seconds."; 607 "Real-time for primeList: "+string(rtimer-rt)+" seconds."; 608 } 609 Arguments = list(); 610 PP = list(); 611 if(weighted) 612 { 613 for(i=j; i<=size(L); i++) 614 { 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)); 617 } 618 } 619 else 620 { 621 for(i=j; i<=size(L); i++) 622 { 623 //Arguments[i-j+1] = list(II,L[i],variant); 624 Arguments[size(Arguments)+1] = list(II,L[i],variant); 625 } 626 } 627 PP = parallelWaitAll("modpWalk",Arguments); 628 if(printlevel >= 10) 629 { 630 "parallel modpWalk"; 631 } 632 for(i=1; i<=size(PP); i++) 633 { 634 //P[size(P) + 1] = PP[i]; 635 T1[size(T1) + 1] = PP[i][1]; 636 T2[size(T2) + 1] = bigint(PP[i][2]); 637 } 638 } 639 if(printlevel >= 10) 640 { 641 "CPU-time for computation with final tests is "+string(timer - TT)+" seconds."; 642 "Real-time for computation with final tests is "+string(rtimer - RT)+" seconds."; 643 } 644 } 645 646 example 647 { 648 "EXAMPLE:"; 649 echo = 2; 650 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 dp 653 ideal J = modWalk(I,1); 654 J; 655 } 656 657 //////////////////////////////////////////////////////////////////////////////// 658 static proc isIdealIncluded(ideal I, ideal J, int n1) 659 "USAGE: isIdealIncluded(I,J,int n1); I ideal, J ideal, n1 integer 660 " 661 { 662 if(n1 > 1) 663 { 664 int k; 665 list args,results; 666 for(k=1; k<=size(I); k++) 667 { 668 args[k] = list(ideal(I[k]),J,1); 669 } 670 results = parallelWaitAll("reduce",args); 671 for(k=1; k<=size(results); k++) 672 { 673 if(results[k] == 0) 674 { 675 return(1); 676 } 677 } 678 return(0); 679 } 680 else 681 { 682 if(reduce(I,J,1) == 0) 683 { 684 return(1); 685 } 686 else 687 { 688 return(0); 689 } 690 } 691 } 692 693 //////////////////////////////////////////////////////////////////////////////// 694 static proc parallelChinrem(list T1, list T2, int n1) 695 "USAGE: parallelChinrem(T1,T2); T1 list of ideals, T2 list of primes, n1 integer" 696 { 697 int i,j,k; 698 699 ideal H,J; 700 701 list arguments_chinrem,results_chinrem; 702 for(i=1; i<=size(T1); i++) 703 { 704 J = ideal(T1[i]); 705 attrib(J,"isSB",1); 706 arguments_chinrem[size(arguments_chinrem)+1] = list(list(J),T2); 707 } 708 results_chinrem = parallelWaitAll("chinrem",arguments_chinrem); 709 for(j=1; j <= size(results_chinrem); j++) 710 { 711 J = results_chinrem[j]; 712 attrib(J,"isSB",1); 713 if(isIdealIncluded(J,H,n1) == 0) 714 { 715 if(H == 0) 716 { 717 H = J; 718 } 719 else 720 { 721 H = H,J; 722 } 723 } 724 } 725 return(H); 726 } 727 728 //////////////////////////////////////////////////////////////////////////////// 729 static proc parallelFarey(ideal H, bigint N, int n1) 730 "USAGE: parallelFarey(H,N,n1); H ideal, N bigint, n1 integer 731 " 732 { 733 int i,j; 734 int ii = 1; 735 list arguments_farey,results_farey; 736 for(i=1; i<=size(H); i++) 737 { 738 for(j=1; j<=size(H[i]); j++) 739 { 740 arguments_farey[size(arguments_farey)+1] = list(H[i][j],N); 741 } 742 } 743 results_farey = parallelWaitAll("farey",arguments_farey); 744 ideal J,K; 745 poly f_farey; 746 while(ii<=size(results_farey)) 747 { 748 for(i=1; i<=size(H); i++) 749 { 750 f_farey = 0; 751 for(j=1; j<=size(H[i]); j++) 752 { 753 f_farey = f_farey + results_farey[ii][1]; 754 ii++; 755 } 756 K = ideal(f_farey); 757 attrib(K,"isSB",1); 758 attrib(J,"isSB",1); 759 if(isIdealIncluded(K,J,n1) == 0) 760 { 761 if(J == 0) 762 { 763 J = K; 764 } 765 else 766 { 767 J = J,K; 768 } 769 } 770 } 771 } 772 return(J); 773 } 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 } 974 //////////////////////////////////////////////////////////////////////////////// 975 static proc mixedTest() 976 "USAGE: mixedTest(); 977 RETURN: 1 if ordering of basering is mixed, 0 else 978 EXAMPLE: example mixedTest(); shows an example 979 " 980 { 981 int i,p,m; 982 for(i = 1; i <= nvars(basering); i++) 983 { 984 if(var(i) > 1) 985 { 986 p++; 987 } 988 else 989 { 990 m++; 991 } 992 } 993 if((p > 0) && (m > 0)) { return(1); } 994 return(0); 995 } 996 example 997 { "EXAMPLE:"; echo = 2; 998 ring R1 = 0,(x,y,z),dp; 999 mixedTest(); 1000 ring R2 = 31,(x(1..4),y(1..3)),(ds(4),lp(3)); 1001 mixedTest(); 1002 ring R3 = 181,x(1..9),(dp(5),lp(4)); 1003 mixedTest(); 1004 } 139 int pertdeg = 3; 140 ideal J = modrWalk(I,radius,pertdeg); 141 J; 142 } 143 144 proc modfWalk(ideal I, list #) 145 "USAGE: modfWalk(I, [, v, w]); I ideal, v intvec, w intvec 146 RETURN: a standard basis of I 147 NOTE: The procedure computes a standard basis of I (over the rational 148 numbers) by using modular methods. 149 SEE ALSO: modular 150 EXAMPLE: example modfWalk; shows an example" 151 { 152 /* read optional parameter */ 153 if (size(#) > 0) { 154 if (size(#) == 1) { 155 intvec w = #[1]; 156 } 157 if (size(#) == 2) { 158 intvec v = #[1]; 159 intvec w = #[2]; 160 } 161 if (size(#) > 2 || typeof(#[1]) != "intvec") { 162 ERROR("wrong optional parameter"); 163 } 164 } 165 166 /* save options */ 167 intvec opt = option(get); 168 option(redSB); 169 170 /* set additional parameters */ 171 int reduction = 1; 172 int printout = 0; 173 174 /* call modular() */ 175 if (size(#) > 0) { 176 I = modular("fwalk", list(I,reduction,printout,#)); 177 } 178 else { 179 I = modular("fwalk", list(I,reduction,printout)); 180 } 181 182 /* return the result */ 183 attrib(I, "isSB", 1); 184 option(set, opt); 185 return(I); 186 } 187 example 188 { 189 "EXAMPLE:"; 190 echo = 2; 191 ring R1 = 0, (x,y,z,t), dp; 192 ideal I = 3x3+x2+1, 11y5+y3+2, 5z4+z2+4; 193 I = std(I); 194 ring R2 = 0, (x,y,z,t), lp; 195 ideal I = fetch(R1, I); 196 ideal J = modfWalk(I); 197 J; 198 } 199 200 proc modfrWalk(ideal I, int radius, list #) 201 "USAGE: modfrWalk(I, radius [, v, w]); I ideal, radius int, v intvec, w intvec 202 RETURN: a standard basis of I 203 NOTE: The procedure computes a standard basis of I (over the rational 204 numbers) by using modular methods. 205 SEE ALSO: modular 206 EXAMPLE: example modfrWalk; shows an example" 207 { 208 /* read optional parameter */ 209 if (size(#) > 0) { 210 if (size(#) == 1) { 211 intvec w = #[1]; 212 } 213 if (size(#) == 2) { 214 intvec v = #[1]; 215 intvec w = #[2]; 216 } 217 if (size(#) > 2 || typeof(#[1]) != "intvec") { 218 ERROR("wrong optional parameter"); 219 } 220 } 221 222 /* save options */ 223 intvec opt = option(get); 224 option(redSB); 225 226 /* set additional parameters */ 227 int reduction = 1; 228 int printout = 0; 229 230 /* call modular() */ 231 if (size(#) > 0) { 232 I = modular("frandwalk", list(I,radius,reduction,printout,#)); 233 } 234 else { 235 I = modular("frandwalk", list(I,radius,reduction,printout)); 236 } 237 238 /* return the result */ 239 attrib(I, "isSB", 1); 240 option(set, opt); 241 return(I); 242 } 243 example 244 { 245 "EXAMPLE:"; 246 echo = 2; 247 ring R1 = 0, (x,y,z,t), dp; 248 ideal I = 3x3+x2+1, 11y5+y3+2, 5z4+z2+4; 249 I = std(I); 250 ring R2 = 0, (x,y,z,t), lp; 251 ideal I = fetch(R1, I); 252 int radius = 2; 253 ideal J = modfrWalk(I,radius); 254 J; 255 } -
Property
mode
changed from
-
Singular/LIB/ncfactor.lib
r8d7ca0 r654a23 6498 6498 def Firstweyl = nc_algebra(1,1); 6499 6499 setring Firstweyl; 6500 ideal M = 0:nvars(@r);6500 ideal M = ideal(0:nvars(@r)); 6501 6501 M[varnumX]=var(2); 6502 6502 M[varnumD]=var(1); -
Singular/LIB/nctools.lib
r8d7ca0 r654a23 1597 1597 matrix U = UpOneMatrix(N); 1598 1598 if (size(ideal(C-U)) <> 0) { return(notW); } // lt(xy)<>lt(yx) 1599 ideal I = D;1599 ideal I = ideal(D); 1600 1600 if (size(I) <> n) { return(notW); } // not n entries<>0 1601 1601 I = simplify(I,4+2); -
Singular/LIB/nfmodstd.lib
r8d7ca0 r654a23 524 524 I; 525 525 } 526 527 ////////////////////////////////////////////////////////////////////////////// 528 529 /* 530 Benchmark Problems from 531 532 Boku, Decker, Fieker, Steenpass: Groebner Bases over Algebraic Number 533 Fields. 534 535 // 1 536 ring R = (0,a), (x,y,z), dp; 537 minpoly = (a^2+1); 538 poly f1 = (a+8)*x^2*y^2+5*x*y^3+(-a+3)*x^3*z 539 +x^2*y*z; 540 poly f2 = x^5+2*y^3*z^2+13*y^2*z^3+5*y*z^4; 541 poly f3 = 8*x^3+(a+12)*y^3+x*z^2+3; 542 poly f4 = (-a+7)*x^2*y^4+y^3*z^3+18*y^3*z^2; 543 ideal I1 = f1,f2,f3,f4; 544 545 // 2 546 ring R = (0,a), (x,y,z), dp; 547 minpoly = (a^5+a^2+2); 548 poly f1 = 2*x*y^4*z^2+(a-1)*x^2*y^3*z 549 +(2*a)*x*y*z^2+7*y^3+(7*a+1); 550 poly f2 = 2*x^2*y^4*z+(a)*x^2*y*z^2-x*y^2*z^2 551 +(2*a+3)*x^2*y*z-12*x+(12*a)*y; 552 poly f3 = (2*a)*y^5*z+x^2*y^2*z-x*y^3*z 553 +(-a)*x*y^3+y^4+2*y^2*z; 554 poly f4 = (3*a)*x*y^4*z^3+(a+1)*x^2*y^2*z 555 -x*y^3*z+4*y^3*z^2+(3*a)*x*y*z^3 556 +4*z^2-x+(a)*y; 557 ideal I2 = f1,f2,f3,f4; 558 559 // 3a 560 ring R = (0,a), (v,w,x,y,z), dp; 561 minpoly = (a^7-7*a+3); 562 poly f1 = (a)*v+(a-1)*w+x+(a+2)*y+z; 563 poly f2 = v*w+(a-1)*w*x+(a+2)*v*y+x*y+(a)*y*z; 564 poly f3 = (a)*v*w*x+(a+5)*w*x*y+(a)*v*w*z 565 +(a+2)*v*y*z+(a)*x*y*z; 566 poly f4 = (a-11)*v*w*x*y+(a+5)*v*w*x*z 567 +(a)*v*w*y*z+(a)*v*x*y*z 568 +(a)*w*x*y*z; 569 poly f5 = (a+3)*v*w*x*y*z+(a+23); 570 ideal I3a = f1,f2,f3,f4,f5; 571 572 // 3b 573 ring R = (0,a), (u,v,w,x,y,z), dp; 574 minpoly = (a^7-7*a+3); 575 poly f1 = (a)*u+(a+2)*v+w+x+y+z; 576 poly f2 = u*v+v*w+w*x+x*y+(a+3)*u*z+y*z; 577 poly f3 = u*v*w+v*w*x+(a+1)*w*x*y+u*v*z+u*y*z 578 +x*y*z; 579 poly f4 = (a-1)*u*v*w*x+v*w*x*y+u*v*w*z 580 +u*v*y*z+u*x*y*z+w*x*y*z; 581 poly f5 = u*v*w*x*y+(a+1)*u*v*w*x*z+u*v*w*y*z 582 +u*v*x*y*z+u*w*x*y*z+v*w*x*y*z; 583 poly f6 = u*v*w*x*y*z+(-a+2); 584 ideal I3b = f1,f2,f3,f4,f5,f6; 585 586 // 4 587 ring R = (0,a), (w,x,y,z), dp; 588 minpoly = (a^6+a^5+a^4+a^3+a^2+a+1); 589 poly f1 = (a+5)*w^3*x^2*y+(a-3)*w^2*x^3*y 590 +(a+7)*w*x^2*y^2; 591 poly f2 = (a)*w^5+(a+3)*w*x^2*y^2 592 +(a^2+11)*x^2*y^2*z; 593 poly f3 = (a+7)*w^3+12*x^3+4*w*x*y+(a)*z^3; 594 poly f4 = 3*w^3+(a-4)*x^3+x*y^2; 595 ideal I4 = f1,f2,f3,f4; 596 597 // 5 598 ring R = (0,a), (w,x,y,z), dp; 599 minpoly = (a^12-5*a^11+24*a^10-115*a^9+551*a^8 600 -2640*a^7+12649*a^6-2640*a^5+551*a^4 601 -115*a^3+24*a^2-5*a+1); 602 poly f1 = (2*a+3)*w*x^4*y^2+(a+1)*w^2*x^3*y*z 603 +2*w*x*y^2*z^3+(7*a-1)*x^3*z^4; 604 poly f2 = 2*w^2*x^4*y+w^2*x*y^2*z^2 605 +(-a)*w*x^2*y^2*z^2 606 +(a+11)*w^2*x*y*z^3-12*w*z^6 607 +12*x*z^6; 608 poly f3 = 2*x^5*y+w^2*x^2*y*z-w*x^3*y*z 609 -w*x^3*z^2+(a)*x^4*z^2+2*x^2*y*z^3; 610 poly f4 = 3*w*x^4*y^3+w^2*x^2*y*z^3 611 -w*x^3*y*z^3+(a+4)*x^3*y^2*z^3 612 +3*w*x*y^3*z^3+(4*a)*y^2*z^6-w*z^7 613 +x*z^7; 614 ideal I5 = f1,f2,f3,f4; 615 616 // 6 617 ring R = (0,a), (u,v,w,x,y,z), dp; 618 minpoly = (a^2+5*a+1); 619 poly f1 = u+v+w+x+y+z+(a); 620 poly f2 = u*v+v*w+w*x+x*y+y*z+(a)*u+(a)*z; 621 poly f3 = u*v*w+v*w*x+w*x*y+x*y*z+(a)*u*v 622 +(a)*u*z+(a)*y*z; 623 poly f4 = u*v*w*x+v*w*x*y+w*x*y*z+(a)*u*v*w 624 +(a)*u*v*z+(a)*u*y*z+(a)*x*y*z; 625 poly f5 = u*v*w*x*y+v*w*x*y*z+(a)*u*v*w*x 626 +(a)*u*v*w*z+(a)*u*v*y*z+(a)*u*x*y*z 627 +(a)*w*x*y*z; 628 poly f6 = u*v*w*x*y*z+(a)*u*v*w*x*y 629 +(a)*u*v*w*x*z+(a)*u*v*w*y*z 630 +(a)*u*v*x*y*z+(a)*u*w*x*y*z 631 +(a)*v*w*x*y*z; 632 poly f7 = (a)*u*v*w*x*y*z-1; 633 ideal I6 = f1,f2,f3,f4,f5,f6,f7; 634 635 // 7 636 ring R = (0,a), (w,x,y,z), dp; 637 minpoly = (a^8-16*a^7+19*a^6-a^5-5*a^4+13*a^3 638 -9*a^2+13*a+17); 639 poly f1 = (-a^2-1)*x^2*y+2*w*x*z-2*w 640 +(a^2+1)*y; 641 poly f2 = (a^3-a-3)*w^3*y+4*w*x^2*y+4*w^2*x*z 642 +2*x^3*z+(a)*w^2-10*x^2+4*w*y-10*x*z 643 +(2*a^2+a); 644 poly f3 = (a^2+a+11)*x*y*z+w*z^2-w-2*y; 645 poly f4 = -w*y^3+4*x*y^2*z+4*w*y*z^2+2*x*z^3 646 +(2*a^3+a^2)*w*y+4*y^2-10*x*z-10*z^2 647 +(3*a^2+5); 648 ideal I7 = f1,f2,f3,f4; 649 650 // 8 651 ring R = (0,a), (t,u,v,w,x,y,z), dp; 652 minpoly = (a^7+10*a^5+5*a^3+10*a+1); 653 poly f1 = v*x+w*y-x*z-w-y; 654 poly f2 = v*w-u*x+x*y-w*z+v+x+z; 655 poly f3 = t*w-w^2+x^2-t; 656 poly f4 = (-a)*v^2-u*y+y^2-v*z-z^2+u; 657 poly f5 = t*v+v*w+(-a^2-a-5)*x*y-t*z+w*z+v+x+z 658 +(a+1); 659 poly f6 = t*u+u*w+(-a-11)*v*x-t*y+w*y-x*z-t-u 660 +w+y; 661 poly f7 = w^2*y^3-w*x*y^3+x^2*y^3+w^2*y^2*z 662 -w*x*y^2*z+x^2*y^2*z+w^2*y*z^2 663 -w*x*y*z^2+x^2*y*z^2+w^2*z^3-w*x*z^3 664 +x^2*z^3; 665 poly f8 = t^2*u^3+t^2*u^2*v+t^2*u*v^2+t^2*v^3 666 -t*u^3*x-t*u^2*v*x-t*u*v^2*x-t*v^3*x 667 +u^3*x^2+u^2*v*x^2+u*v^2*x^2 668 +v^3*x^2; 669 ideal I8 = f1,f2,f3,f4,f5,f6,f7,f8; 670 */ -
Singular/LIB/primdec.lib
r8d7ca0 r654a23 874 874 int uytrewq; 875 875 int nva = nvars(basering); 876 int @k,@s,@n,@k1, zz;876 int @k,@s,@n,@k1,@zz; 877 877 list primary,lres0,lres1,act,@lh,@wh; 878 878 map phi,psi,phi1,psi1; … … 1055 1055 { 1056 1056 poly randp; 1057 for( zz=1;zz<nvars(basering);zz++)1057 for(@zz=1;@zz<nvars(basering);@zz++) 1058 1058 { 1059 1059 randp=randp 1060 +(random(0,5)*par(1)^2+random(0,5)*par(1)+random(0,5))*var( zz);1060 +(random(0,5)*par(1)^2+random(0,5)*par(1)+random(0,5))*var(@zz); 1061 1061 } 1062 1062 randp=randp+var(nvars(basering)); … … 1068 1068 if (size(primary[2*@k])==0) 1069 1069 { 1070 for( zz=1;zz<size(primary[2*@k-1])-1;zz++)1070 for(@zz=1;@zz<size(primary[2*@k-1])-1;@zz++) 1071 1071 { 1072 1072 attrib(primary[2*@k-1],"isSB",1); 1073 if(vdim(primary[2*@k-1])==deg(primary[2*@k-1][ zz]))1073 if(vdim(primary[2*@k-1])==deg(primary[2*@k-1][@zz])) 1074 1074 { 1075 1075 primary[2*@k]=primary[2*@k-1]; … … 1099 1099 if(deg(lead(primary[2*@k-1][@n]))==1) 1100 1100 { 1101 for( zz=1;zz<=nva;zz++)1101 for(@zz=1;@zz<=nva;@zz++) 1102 1102 { 1103 if(lead(primary[2*@k-1][@n])/var( zz)!=0)1103 if(lead(primary[2*@k-1][@n])/var(@zz)!=0) 1104 1104 { 1105 jmap1[ zz]=-1/leadcoef(primary[2*@k-1][@n])*primary[2*@k-1][@n]1105 jmap1[@zz]=-1/leadcoef(primary[2*@k-1][@n])*primary[2*@k-1][@n] 1106 1106 +2/leadcoef(primary[2*@k-1][@n])*lead(primary[2*@k-1][@n]); 1107 jmap2[ zz]=primary[2*@k-1][@n];1108 @qht[@n]=var( zz);1107 jmap2[@zz]=primary[2*@k-1][@n]; 1108 @qht[@n]=var(@zz); 1109 1109 } 1110 1110 } … … 3413 3413 3414 3414 ideal jkeep=@j; 3415 if( ordstr(@P)[1]=="w")3415 if((ordstr(@P)[1]=="w")&&(size(ringlist(@P)[3])==2)) // weighted ordering 3416 3416 { 3417 3417 list gnir_l=ringlist(gnir); … … 9023 9023 int uytrewq; 9024 9024 int nva = nvars(basering); 9025 int @k,@s,@n,@k1, zz;9025 int @k,@s,@n,@k1,@zz; 9026 9026 list primary,lres0,lres1,act,@lh,@wh; 9027 9027 map phi,psi,phi1,psi1; … … 9206 9206 { 9207 9207 poly randp; 9208 for( zz=1;zz<nvars(basering);zz++)9208 for(@zz=1;@zz<nvars(basering);@zz++) 9209 9209 { 9210 9210 randp=randp 9211 +(random(0,5)*par(1)^2+random(0,5)*par(1)+random(0,5))*var( zz);9211 +(random(0,5)*par(1)^2+random(0,5)*par(1)+random(0,5))*var(@zz); 9212 9212 } 9213 9213 randp=randp+var(nvars(basering)); … … 9219 9219 if (size(primary[2*@k])==0) 9220 9220 { 9221 for( zz=1;zz<size(primary[2*@k-1])-1;zz++)9221 for(@zz=1;@zz<size(primary[2*@k-1])-1;@zz++) 9222 9222 { 9223 9223 attrib(primary[2*@k-1],"isSB",1); 9224 if(vdim(primary[2*@k-1])==deg(primary[2*@k-1][ zz]))9224 if(vdim(primary[2*@k-1])==deg(primary[2*@k-1][@zz])) 9225 9225 { 9226 9226 primary[2*@k]=primary[2*@k-1]; … … 9250 9250 if(deg(lead(primary[2*@k-1][@n]))==1) 9251 9251 { 9252 for( zz=1;zz<=nva;zz++)9252 for(@zz=1;@zz<=nva;@zz++) 9253 9253 { 9254 if(lead(primary[2*@k-1][@n])/var( zz)!=0)9254 if(lead(primary[2*@k-1][@n])/var(@zz)!=0) 9255 9255 { 9256 jmap1[ zz]=-1/leadcoef(primary[2*@k-1][@n])*primary[2*@k-1][@n]9256 jmap1[@zz]=-1/leadcoef(primary[2*@k-1][@n])*primary[2*@k-1][@n] 9257 9257 +2/leadcoef(primary[2*@k-1][@n])*lead(primary[2*@k-1][@n]); 9258 jmap2[ zz]=primary[2*@k-1][@n];9259 @qht[@n]=var( zz);9258 jmap2[@zz]=primary[2*@k-1][@n]; 9259 @qht[@n]=var(@zz); 9260 9260 } 9261 9261 } -
Singular/LIB/rwalk.lib
-
Property
mode
changed from
100644
to100755
r4132ee r654a23 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/surf.lib
r8d7ca0 r654a23 274 274 275 275 string surf_call; i = 0; 276 276 277 277 if (isWindows()) 278 278 { … … 303 303 else 304 304 { 305 surf_call = "surfer"; 305 surf_call = "surfer"; 306 306 surf_call = surf_call + " " + l + " >/dev/null 2>&1"; 307 307 "Close window to exit from `surfer`."; 308 308 i = system("sh", surf_call); 309 310 if ( (i != 0) && isMacOSX() ) 309 310 if ( (i != 0) && isMacOSX() ) 311 311 { 312 312 "*!* Sorry: calling `surfer` failed ['"+surf_call+"']" + newline 313 313 + " (The shell returned the error code " + string(i) + "." + newline 314 + "But since we are on Mac OS X, let us try to open SURFER.app instead..." + newline 314 + "But since we are on Mac OS X, let us try to open SURFER.app instead..." + newline 315 315 + "Appropriate SURFER.app is available for instance at http://www.mathematik.uni-kl.de/~motsak/files/SURFER.dmg"; 316 316 317 317 // fallback, will only work if SURFER.app is available (e.g. in /Applications) 318 318 // get SURFER.app e.g. from http://www.mathematik.uni-kl.de/~motsak/files/SURFER.dmg 319 319 // note that the newer (Java-based) variant of Surfer may not support command line usage yet :( 320 320 321 321 surf_call = "open -a SURFER -W --args -t -s"; 322 322 surf_call = surf_call + " " + l + " >/dev/null 2>&1"; … … 324 324 i = system("sh", surf_call); 325 325 } 326 327 328 326 327 328 329 329 } 330 330 system("sh", "/bin/rm " + l); … … 381 381 { 382 382 string s = system("uname"); 383 383 384 384 for (int i = 1; i <= size(s)-2; i = i + 1) 385 385 { -
Singular/LIB/swalk.lib
-
Property
mode
changed from
100644
to100755
-
Property
mode
changed from
-
Singular/Makefile.am
r8d7ca0 r654a23 98 98 mmalloc.h \ 99 99 mod_lib.h \ 100 omSingularConfig.h \101 100 links/ndbm.h \ 102 101 newstruct.h \ -
Singular/blackbox.cc
r8d7ca0 r654a23 54 54 BOOLEAN blackbox_default_serialize(blackbox */*b*/, void */*d*/, si_link /*f*/) 55 55 { 56 WerrorS("blackbox_serialize is not implemented"); 56 57 return TRUE; 57 58 } … … 59 60 BOOLEAN blackbox_default_deserialize(blackbox **/*b*/, void **/*d*/, si_link /*f*/) 60 61 { 62 WerrorS("blackbox_deserialize is not implemented"); 61 63 return TRUE; 62 64 } -
Singular/cntrlc.cc
r8d7ca0 r654a23 5 5 * ABSTRACT - interupt handling 6 6 */ 7 #include <kernel/mod2.h>8 9 /* includes */10 #ifdef DecAlpha_OSF111 #define _XOPEN_SOURCE_EXTENDED12 #endif /* MP3-Y2 0.022UF */13 14 #include <omalloc/omalloc.h>15 16 #include <reporter/si_signals.h>17 #include <Singular/fevoices.h>18 19 #include <Singular/tok.h>20 #include <Singular/ipshell.h>21 void sig_chld_hdl(int sig); /*#include <Singular/links/ssiLink.h>*/22 #include <Singular/cntrlc.h>23 #include <Singular/feOpt.h>24 #include <Singular/misc_ip.h>25 #include <Singular/links/silink.h>26 #include <Singular/links/ssiLink.h>27 28 7 #include <stdio.h> 29 8 #include <stddef.h> … … 33 12 #include <sys/types.h> 34 13 #include <sys/wait.h> 14 15 #include <kernel/mod2.h> 16 17 #include <omalloc/omalloc.h> 18 19 #include <reporter/si_signals.h> 20 #include <Singular/fevoices.h> 21 22 #include <Singular/tok.h> 23 #include <Singular/ipshell.h> 24 #include <Singular/cntrlc.h> 25 #include <Singular/feOpt.h> 26 #include <Singular/misc_ip.h> 27 #include <Singular/links/silink.h> 28 #include <Singular/links/ssiLink.h> 35 29 36 30 /* undef, if you don't want GDB to come up on error */ … … 352 346 if (feOptValue(FE_OPT_EMACS) == NULL) 353 347 { 354 fputs("abort after this command(a), abort immediately(r), print backtrace(b), continue(c) or quit Singular(q) ?",stderr);fflush(stderr); 348 fputs("abort after this command(a), abort immediately(r), print backtrace(b), continue(c) or quit Singular(q) ?",stderr); 349 fflush(stderr);fflush(stdin); 355 350 c = fgetc(stdin); 356 351 } … … 371 366 fputs("** Warning: Singular should be restarted as soon as possible **\n",stderr); 372 367 fflush(stderr); 368 extern void my_yy_flush(); 369 my_yy_flush(); 370 currentVoice=feInitStdin(NULL); 373 371 longjmp(si_start_jmpbuf,1); 374 372 } -
Singular/dyn_modules/gfanlib/bbcone.cc
r8d7ca0 r654a23 1739 1739 } 1740 1740 1741 1741 #if 0 1742 BOOLEAN bbcone_serialize(blackbox *b, void *d, si_link f) 1743 { 1744 ssiInfo *dd = (ssiInfo *)f->data; 1745 sleftv l; 1746 memset(&l,0,sizeof(l)); 1747 l.rtyp=STRING_CMD; 1748 l.data=(void*)"cone"; 1749 f->m->Write(f, &l); 1750 gfan::ZCone *Z=((gfan::ZCone*) d; 1751 /* AMBIENT_DIM */ fprintf(dd->f_write("%d ",Z->ambientDimension()); 1752 /* FACETS or INEQUALITIES */ fprintf(dd->f_write("%d ",Z->areFacetsKnown()); 1753 gfan::ZMatrix i=Z->getInequalities(); 1754 .... 1755 /* LINEAR_SPAN or EQUATIONS */ fprintf(dd->f_write("%d ",Z->areImpliedEquationsKnown()); 1756 gfan::ZMatrix e=Z->getEquations(); 1757 .... 1758 /* RAYS */ 1759 gfan::ZMatrix r=Z->extremeRays(); 1760 .... 1761 /* LINEALITY_SPACE */ 1762 gfan::ZMatrix l=Z->generatorsOfLinealitySpace(); 1763 .... 1764 return FALSE; 1765 } 1766 BOOLEAN bbcone_deserialize(blackbox **b, void **d, si_link f) 1767 { 1768 ssiInfo *dd = (ssiInfo *)f->data; 1769 gfan::ZCone *Z; 1770 /* AMBIENT_DIM */ = s_readint(dd->f_read); 1771 /* areFacetsKnown: */ = s_readint(dd->f_read); 1772 if (areFacetsKnown) 1773 ....FACETS 1774 else 1775 ....INEQUALITIES 1776 /* areImpliedEquationsKnown*/ = s_readint(dd->f_read); 1777 if(areImpliedEquationsKnown) 1778 ....EQUATIONS 1779 else 1780 ...LINEAR_SPAN 1781 ...RAYS 1782 ...LINEALITY_SPACE 1783 *d=Z; 1784 return FALSE; 1785 } 1786 #endif 1742 1787 void bbcone_setup(SModulFunctions* p) 1743 1788 { … … 1753 1798 b->blackbox_Assign=bbcone_Assign; 1754 1799 b->blackbox_Op2=bbcone_Op2; 1800 //b->blackbox_serialize=bbcone_serialize; 1801 //b->blackbox_deserialize=bbcone_deserialize; 1755 1802 p->iiAddCproc("","coneViaInequalities",FALSE,coneViaNormals); 1756 1803 p->iiAddCproc("","coneViaPoints",FALSE,coneViaRays); -
Singular/dyn_modules/singmathic/singmathic.cc
r8d7ca0 r654a23 468 468 result->rtyp=NONE; 469 469 470 if (arg == NULL || arg->next != NULL || 470 if (arg == NULL || arg->next != NULL || 471 471 ((arg->Typ() != IDEAL_CMD) &&(arg->Typ() != MODUL_CMD))){ 472 472 WerrorS("Syntax: mathicgb(<ideal>/<module>)"); -
Singular/dyn_modules/syzextra/mod_main.cc
r8d7ca0 r654a23 82 82 for (int j=0; j<l; j++) 83 83 if (id->m[j] != NULL && p_GetComp(id->m[j], r) > 0) 84 return TRUE; 84 return TRUE; 85 85 86 86 return FALSE; // rank: 1, only zero or no entries? can be an ideal OR module... BUT in the use-case should better be an ideal! … … 91 91 92 92 93 93 94 94 95 95 static inline void NoReturn(leftv& res) … … 1550 1550 const int iLimit = r->typ[pos].data.is.limit; 1551 1551 const ideal F = r->typ[pos].data.is.F; 1552 1552 1553 1553 ideal FF = id_Copy(F, r); 1554 1554 -
Singular/extra.cc
r8d7ca0 r654a23 3794 3794 } 3795 3795 else 3796 #endif 3796 #endif 3797 3797 /*==================== Error =================*/ 3798 3798 Werror( "(extended) system(\"%s\",...) %s", sys_cmd, feNotImplemented ); -
Singular/fevoices.cc
r8d7ca0 r654a23 17 17 #include <Singular/subexpr.h> 18 18 #include <Singular/ipshell.h> 19 #include <Singular/sdb.h> 19 20 20 21 #include <stdlib.h> -
Singular/ipassign.cc
r8d7ca0 r654a23 844 844 if (res->data!=NULL) idDelete((ideal*)&res->data); 845 845 matrix m=(matrix)a->CopyD(MATRIX_CMD); 846 if (TEST_V_ALLWARN) 847 if (MATROWS(m)>1) 848 Warn("assign matrix with %d rows to an ideal in >>%s<<",MATROWS(m),my_yylinebuf); 846 849 IDELEMS((ideal)m)=MATROWS(m)*MATCOLS(m); 847 850 ((ideal)m)->rank=1; -
Singular/ipshell.cc
r8d7ca0 r654a23 65 65 #include <Singular/subexpr.h> 66 66 #include <Singular/fevoices.h> 67 #include <Singular/sdb.h> 67 68 68 69 #include <math.h> … … 1029 1030 void iiDebug() 1030 1031 { 1032 #ifdef HAVE_SDB 1033 sdb_flags=1; 1034 #endif 1031 1035 Print("\n-- break point in %s --\n",VoiceName()); 1032 1036 if (iiDebugMarker) VoiceBackTrack(); -
Singular/misc_ip.cc
r8d7ca0 r654a23 716 716 } while (v!=NULL); 717 717 718 #ifdef OM_SINGULAR_CONFIG_H719 718 // set global variable to show memory usage 720 719 extern int om_sing_opt_show_mem; 721 720 if (BVERBOSE(V_SHOW_MEM)) om_sing_opt_show_mem = 1; 722 721 else om_sing_opt_show_mem = 0; 723 #endif724 722 725 723 return FALSE; … … 1095 1093 #endif // HAVE_SIMPLEIPC 1096 1094 fe_reset_input_mode(); 1095 monitor(NULL,0); 1097 1096 #ifdef PAGE_TEST 1098 1097 mmEndStat(); -
Singular/scanner.cc
r8d7ca0 r654a23 2330 2330 //yy_flush_buffer((YY_BUFFER_STATE)oldb); 2331 2331 } 2332 2333 void my_yy_flush() { YY_FLUSH_BUFFER;BEGIN(0); } 2334 -
Singular/scanner.ll
r8d7ca0 r654a23 380 380 //yy_flush_buffer((YY_BUFFER_STATE)oldb); 381 381 } 382 383 void my_yy_flush() { YY_FLUSH_BUFFER;BEGIN(0); } -
Singular/sdb.cc
r8d7ca0 r654a23 244 244 "p <var> - display type and value of the variable <var>\n" 245 245 "q <flags> - quit debugger, set debugger flags(0,1,2)\n" 246 " 0: stop debug, 1:continue, 2: throw an error, return to toplevel\n" 246 247 "Q - quit Singular\n"); 247 248 int i; -
Singular/test.cc
r8d7ca0 r654a23 194 194 #include <Singular/links/ndbm.h> 195 195 #include <Singular/newstruct.h> 196 #include <Singular/omSingularConfig.h>197 196 #include <Singular/pcv.h> 198 197 #include <Singular/links/pipeLink.h> -
Singular/tesths.cc
r8d7ca0 r654a23 146 146 { 147 147 if (feOptValue(FE_OPT_SORT)) On(SW_USE_NTL_SORT); 148 #ifdef HAVE_SDB149 sdb_flags = 0;150 #endif151 148 dup2(1,2); 152 149 /* alternative: -
Singular/walk.cc
-
Property
mode
changed from
100644
to100755
r4132ee r654a23 16 16 17 17 //#define TEST_OVERFLOW 18 //#define CHECK_IDEAL 19 //#define CHECK_IDEAL_MWALK 18 19 #define CHECK_IDEAL_MWALK //to print intermediate results 20 20 21 21 //#define NEXT_VECTORS_CC 22 //#define PRINT_VECTORS //to print vectors (sigma, tau, omega) 22 #define PRINT_VECTORS //to print weight vectors 23 23 24 24 #define INVEPS_SMALL_IN_FRACTAL //to choose the small invers of epsilon … … 27 27 28 28 #define FIRST_STEP_FRACTAL // to define the first step of the fractal 29 //#define MSTDCC_FRACTAL // apply Buchberger alg to compute a red GB, if 30 // tau doesn't stay in the correct cone 29 #define MSTDCC_FRACTAL // apply Buchberger alg to compute a red GB, if tau doesn't stay in the correct cone 31 30 32 31 //#define TIME_TEST // print the used time of each subroutine … … 42 41 #include <Singular/ipshell.h> 43 42 #include <Singular/ipconv.h> 43 #include <coeffs/ffields.h> 44 44 #include <coeffs/coeffs.h> 45 45 #include <Singular/subexpr.h> 46 #include <polys/templates/p_Procs.h> 46 47 47 48 #include <polys/monomials/maps.h> … … 120 121 ************************************/ 121 122 // unused 122 #if 0 123 /* 123 124 static void initSSpecialCC (ideal F, ideal Q, ideal P,kStrategy strat) 124 125 { … … 268 269 #endif 269 270 } 270 #endif 271 */ 271 272 272 273 /***************** … … 277 278 int j; 278 279 kStrategy strat = new skStrategy; 279 280 // if (TEST_OPT_PROT) 281 // { 282 // writeTime("start InterRed:"); 283 // mflush(); 284 // } 285 //strat->syzComp = 0; 280 /* 281 if (TEST_OPT_PROT) 282 { 283 writeTime("start InterRed:"); 284 mflush(); 285 } 286 strat->syzComp = 0; 287 */ 286 288 strat->kHEdgeFound = (currRing->ppNoether) != NULL; 287 289 strat->kNoether=pCopy((currRing->ppNoether)); … … 346 348 strat->fromQ = NULL; 347 349 } 348 // if (TEST_OPT_PROT) 349 // { 350 // writeTime("end Interred:"); 351 // mflush(); 352 // } 350 /* 351 if (TEST_OPT_PROT) 352 { 353 writeTime("end Interred:"); 354 mflush(); 355 } 356 */ 353 357 ideal shdl=strat->Shdl; 354 358 idSkipZeroes(shdl); … … 358 362 } 359 363 360 //unused 361 #if 0 364 #ifdef TIME_TEST 362 365 static void TimeString(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd, 363 366 clock_t tlf,clock_t tred, clock_t tnw, int step) … … 397 400 ((((double) xtextra)/1000000)/totm)*100); 398 401 } 399 #endif 400 401 //unused 402 #if 0 402 403 403 static void TimeStringFractal(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd, 404 404 clock_t textra, clock_t tlf,clock_t tred, clock_t tnw) … … 442 442 } 443 443 #endif 444 444 /* 445 445 #if defined(CHECK_IDEAL_MWALK) || defined(ENDWALKS) 446 446 static void headidString(ideal L, char* st) … … 496 496 } 497 497 #endif 498 498 */ 499 499 500 500 static void ivString(intvec* iv, const char* ch) … … 510 510 } 511 511 512 //unused 513 #if 0 512 #ifdef PRINT_VECTORS 514 513 static void MivString(intvec* iva, intvec* ivb, intvec* ivc) 515 514 { … … 558 557 } 559 558 return p0; 559 } 560 561 /***************************************************************************** 562 * compute the gcd of the entries of the vectors curr_weight and diff_weight * 563 *****************************************************************************/ 564 static int simplify_gcd(intvec* curr_weight, intvec* diff_weight) 565 { 566 int j; 567 int nRing = currRing->N; 568 int gcd_tmp = (*curr_weight)[0]; 569 for (j=1; j<nRing; j++) 570 { 571 gcd_tmp = gcd(gcd_tmp, (*curr_weight)[j]); 572 if(gcd_tmp == 1) 573 { 574 break; 575 } 576 } 577 if(gcd_tmp != 1) 578 { 579 for (j=0; j<nRing; j++) 580 { 581 gcd_tmp = gcd(gcd_tmp, (*diff_weight)[j]); 582 if(gcd_tmp == 1) 583 { 584 break; 585 } 586 } 587 } 588 return gcd_tmp; 560 589 } 561 590 … … 774 803 for(i=nG-1; i>=0; i--) 775 804 { 776 mi = MpolyInitialForm(G->m[i], iv); 777 gi = G->m[i]; 778 805 mi = pHead(MpolyInitialForm(G->m[i], iv)); 806 //Print("\n **// test_w_in_ConeCC: lm(initial)= %s \n",pString(mi)); 807 gi = pHead(G->m[i]); 808 //Print("\n **// test_w_in_ConeCC: lm(ideal)= %s \n",pString(gi)); 779 809 if(mi == NULL) 780 810 { … … 953 983 } 954 984 955 /***************************************************************************** 956 * create a weight matrix order as intvec of an extra weight vector (a(iv), lp)*957 ****************************************************************************** /985 /********************************************************************************* 986 * create a weight matrix order as intvec of an extra weight vector (a(iv),M(iw)) * 987 **********************************************************************************/ 958 988 intvec* MivMatrixOrderRefine(intvec* iv, intvec* iw) 959 989 { 960 assume( iv->length() == iw->length());961 int i, nR = iv->length();962 990 assume((iv->length())*(iv->length()) == iw->length()); 991 int i,j, nR = iv->length(); 992 963 993 intvec* ivm = new intvec(nR*nR); 964 994 … … 966 996 { 967 997 (*ivm)[i] = (*iv)[i]; 968 (*ivm)[i+nR] = (*iw)[i]; 969 } 970 for(i=2; i<nR; i++) 971 { 972 (*ivm)[i*nR+i-2] = 1; 998 } 999 for(i=1; i<nR; i++) 1000 { 1001 for(j=0; j<nR; j++) 1002 { 1003 (*ivm)[j+i*nR] = (*iw)[j+i*nR]; 1004 } 973 1005 } 974 1006 return ivm; … … 1005 1037 * print the max total degree and the max coefficient of G * 1006 1038 *****************************************************************************/ 1007 #if 0 1039 /* 1008 1040 static void checkComplexity(ideal G, char* cG) 1009 1041 { … … 1046 1078 PrintLn(); 1047 1079 } 1048 #endif 1080 */ 1049 1081 1050 1082 /***************************************************************************** … … 1068 1100 intvec* v_null = new intvec(nV); 1069 1101 1070 1071 1102 // Check that the perturbed degree is valid 1072 1103 if(pdeg > nV || pdeg <= 0) … … 1082 1113 } 1083 1114 mpz_t *pert_vector = (mpz_t*)omAlloc(nV*sizeof(mpz_t)); 1084 //mpz_t *pert_vector1 = (mpz_t*)omAlloc(nV*sizeof(mpz_t));1115 mpz_t *pert_vector1 = (mpz_t*)omAlloc(nV*sizeof(mpz_t)); 1085 1116 1086 1117 for(i=0; i<nV; i++) 1087 1118 { 1088 1119 mpz_init_set_si(pert_vector[i], (*ivtarget)[i]); 1089 //mpz_init_set_si(pert_vector1[i], (*ivtarget)[i]);1120 mpz_init_set_si(pert_vector1[i], (*ivtarget)[i]); 1090 1121 } 1091 1122 // Calculate max1 = Max(A2)+Max(A3)+...+Max(Apdeg), … … 1167 1198 } 1168 1199 } 1200 1201 // 2147483647 is max. integer representation in SINGULAR 1202 mpz_t sing_int; 1203 mpz_init_set_ui(sing_int, 2147483647); 1204 1205 mpz_t check_int; 1206 mpz_init_set_ui(check_int, 100000); 1207 1169 1208 mpz_t ztemp; 1170 1209 mpz_init(ztemp); … … 1186 1225 } 1187 1226 1188 intvec *pert_vector1= new intvec(nV);1189 j = 0;1190 1227 for(i=0; i<nV; i++) 1191 1228 { 1192 (* pert_vector1)[i] = mpz_get_si(pert_vector[i]); 1193 (* pert_vector1)[i] = 0.1*(* pert_vector1)[i]; 1194 (* pert_vector1)[i] = floor((* pert_vector1)[i] + 0.5); 1195 if((* pert_vector1)[i] == 0) 1196 { 1197 j++; 1198 } 1199 } 1200 if(j > nV - 1) 1201 { 1202 // Print("\n// MPertVectors: geaenderter vector gleich Null! \n"); 1203 delete pert_vector1; 1204 goto CHECK_OVERFLOW; 1205 } 1206 1207 // check that the perturbed weight vector lies in the Groebner cone 1208 if(test_w_in_ConeCC(G,pert_vector1) != 0) 1209 { 1210 // Print("\n// MPertVectors: geaenderter vector liegt in Groebnerkegel! \n"); 1229 if(mpz_cmp(pert_vector[i], check_int)>=0) 1230 { 1231 for(j=0; j<nV; j++) 1232 { 1233 mpz_fdiv_q_ui(pert_vector1[j], pert_vector[j], 100); 1234 } 1235 } 1236 } 1237 1238 intvec* result = new intvec(nV); 1239 1240 int ntrue=0; 1241 1242 for(i=0; i<nV; i++) 1243 { 1244 (*result)[i] = mpz_get_si(pert_vector1[i]); 1245 if(mpz_cmp(pert_vector1[i], sing_int)>=0) 1246 { 1247 ntrue++; 1248 } 1249 } 1250 if(ntrue > 0 || test_w_in_ConeCC(G,result)==0) 1251 { 1252 ntrue=0; 1211 1253 for(i=0; i<nV; i++) 1212 1254 { 1213 mpz_set_si(pert_vector[i], (*pert_vector1)[i]); 1214 } 1215 } 1216 else 1217 { 1218 //Print("\n// MpertVectors: geaenderter vector liegt nicht in Groebnerkegel! \n"); 1219 } 1220 delete pert_vector1; 1221 1222 CHECK_OVERFLOW: 1223 intvec* result = new intvec(nV); 1224 1225 /* 2147483647 is max. integer representation in SINGULAR */ 1226 mpz_t sing_int; 1227 mpz_init_set_ui(sing_int, 2147483647); 1228 1229 int ntrue=0; 1230 for(i=0; i<nV; i++) 1231 { 1232 (*result)[i] = mpz_get_si(pert_vector[i]); 1233 if(mpz_cmp(pert_vector[i], sing_int)>=0) 1234 { 1235 ntrue++; 1236 if(Overflow_Error == FALSE) 1237 { 1238 Overflow_Error = TRUE; 1239 PrintS("\n// ** OVERFLOW in \"MPertvectors\": "); 1240 mpz_out_str( stdout, 10, pert_vector[i]); 1241 PrintS(" is greater than 2147483647 (max. integer representation)"); 1242 Print("\n// So vector[%d] := %d is wrong!!", i+1, (*result)[i]); 1243 } 1244 } 1245 } 1246 1247 if(Overflow_Error == TRUE) 1248 { 1249 ivString(result, "pert_vector"); 1250 Print("\n// %d element(s) of it is overflow!!", ntrue); 1255 (*result)[i] = mpz_get_si(pert_vector[i]); 1256 if(mpz_cmp(pert_vector[i], sing_int)>=0) 1257 { 1258 ntrue++; 1259 if(Overflow_Error == FALSE) 1260 { 1261 Overflow_Error = TRUE; 1262 PrintS("\n// ** OVERFLOW in \"MPertvectors\": "); 1263 mpz_out_str( stdout, 10, pert_vector[i]); 1264 PrintS(" is greater than 2147483647 (max. integer representation)"); 1265 Print("\n// So vector[%d] := %d is wrong!!", i+1, (*result)[i]); 1266 } 1267 } 1268 } 1269 1270 if(Overflow_Error == TRUE) 1271 { 1272 ivString(result, "pert_vector"); 1273 Print("\n// %d element(s) of it is overflow!!", ntrue); 1274 } 1251 1275 } 1252 1276 1253 1277 mpz_clear(ztemp); 1254 1278 mpz_clear(sing_int); 1279 mpz_clear(check_int); 1255 1280 omFree(pert_vector); 1256 //omFree(pert_vector1);1281 omFree(pert_vector1); 1257 1282 mpz_clear(tot_deg); 1258 1283 mpz_clear(maxdeg); … … 1456 1481 1457 1482 //unused 1458 #if 0 1483 /* 1459 1484 static intvec* MatrixOrderdp(int nV) 1460 1485 { … … 1472 1497 return(ivM); 1473 1498 } 1474 #endif 1499 */ 1475 1500 1476 1501 intvec* MivUnit(int nV) … … 1549 1574 mpz_cdiv_q_ui(inveps, inveps, nV); 1550 1575 } 1551 // PrintS("\n// choose the \"small\" inverse epsilon!");1576 // choose the small inverse epsilon 1552 1577 #endif 1553 1578 … … 1583 1608 1584 1609 for(j=0; j<nV; j++) 1585 1610 { 1586 1611 mpz_init_set(pert_vector[i*nV+j],ivtemp[j]); 1587 1588 } 1589 1590 / * 2147483647 is max. integer representation in SINGULAR */1612 } 1613 } 1614 1615 // 2147483647 is max. integer representation in SINGULAR 1591 1616 mpz_t sing_int; 1592 1617 mpz_init_set_ui(sing_int, 2147483647); … … 1611 1636 mpz_divexact(pert_vector[i], pert_vector[i], ztmp); 1612 1637 (* result)[i] = mpz_get_si(pert_vector[i]); 1613 }1614 1615 j = 0;1616 for(i=0; i<nV; i++)1617 {1618 (* result1)[i] = mpz_get_si(pert_vector[i]);1619 (* result1)[i] = 0.1*(* result1)[i];1620 (* result1)[i] = floor((* result1)[i] + 0.5);1621 if((* result1)[i] == 0)1622 {1623 j++;1624 }1625 }1626 if(j > nV - 1)1627 {1628 // Print("\n// MfPertwalk: geaenderter vector gleich Null! \n");1629 delete result1;1630 goto CHECK_OVERFLOW;1631 }1632 1633 // check that the perturbed weight vector lies in the Groebner cone1634 if(test_w_in_ConeCC(G,result1) != 0)1635 {1636 // Print("\n// MfPertwalk: geaenderter vector liegt in Groebnerkegel! \n");1637 delete result;1638 result = result1;1639 for(i=0; i<nV; i++)1640 {1641 mpz_set_si(pert_vector[i], (*result1)[i]);1642 }1643 }1644 else1645 {1646 delete result1;1647 // Print("\n// Mfpertwalk: geaenderter vector liegt nicht in Groebnerkegel! \n");1648 1638 } 1649 1639 … … 1685 1675 while(p!=NULL) 1686 1676 { 1687 p_Setm(p,currRing); pIter(p); 1677 p_Setm(p,currRing); 1678 pIter(p); 1688 1679 } 1689 1680 } … … 1768 1759 1769 1760 //unused 1770 #if 0 1761 /* 1771 1762 static void checkidealCC(ideal G, char* Ch) 1772 1763 { … … 1794 1785 PrintLn(); 1795 1786 } 1796 #endif 1787 */ 1797 1788 1798 1789 //unused 1799 #if 0 1790 /* 1800 1791 static void HeadidString(ideal L, char* st) 1801 1792 { … … 1809 1800 Print(" %s;\n", pString(pHead(L->m[nL]))); 1810 1801 } 1811 #endif 1812 1802 1803 */ 1813 1804 static inline int MivComp(intvec* iva, intvec* ivb) 1814 1805 { … … 1859 1850 } 1860 1851 1852 1853 /************************************************************** 1854 * Look for the position of the smallest absolut value in vec * 1855 **************************************************************/ 1856 static int MivAbsMaxArg(intvec* vec) 1857 { 1858 int k = MivAbsMax(vec); 1859 int i=0; 1860 while(1) 1861 { 1862 if((*vec)[i] == k || (*vec)[i] == -k) 1863 { 1864 break; 1865 } 1866 i++; 1867 } 1868 return i; 1869 } 1870 1871 1861 1872 /********************************************************************** 1862 1873 * Compute a next weight vector between curr_weight and target_weight * 1863 1874 * with respect to an ideal <G>. * 1864 1875 **********************************************************************/ 1876 /* 1865 1877 static intvec* MwalkNextWeightCC(intvec* curr_weight, intvec* target_weight, 1866 1878 ideal G) … … 1873 1885 1874 1886 int nRing = currRing->N; 1875 int checkRed, j, kkk,nG = IDELEMS(G);1887 int checkRed, j, nG = IDELEMS(G); 1876 1888 intvec* ivtemp; 1877 1889 … … 1911 1923 mpz_init(dcw); 1912 1924 1913 //int tn0, tn1, tz1, ncmp, gcd_tmp, ntmp;1914 1925 int gcd_tmp; 1915 1926 intvec* diff_weight = MivSub(target_weight, curr_weight); … … 1917 1928 intvec* diff_weight1 = MivSub(target_weight, curr_weight); 1918 1929 poly g; 1919 //poly g, gw; 1930 1920 1931 for (j=0; j<nG; j++) 1921 1932 { … … 1934 1945 mpz_set_si(MwWd, MivDotProduct(ivtemp, curr_weight)); 1935 1946 mpz_sub(s_zaehler, deg_w0_p1, MwWd); 1936 1937 1947 if(mpz_cmp(s_zaehler, t_null) != 0) 1938 1948 { 1939 1949 mpz_set_si(MwWd, MivDotProduct(ivtemp, diff_weight)); 1940 1950 mpz_sub(s_nenner, MwWd, deg_d0_p1); 1941 1942 1951 // check for 0 < s <= 1 1943 1952 if( (mpz_cmp(s_zaehler,t_null) > 0 && … … 1979 1988 } 1980 1989 } 1981 //Print("\n// Alloc Size = %d \n", nRing*sizeof(mpz_t));1990 //Print("\n// Alloc Size = %d \n", nRing*sizeof(mpz_t)); 1982 1991 mpz_t *vec=(mpz_t*)omAlloc(nRing*sizeof(mpz_t)); 1983 1992 1984 1993 1985 // there is no 0<t<1 and define the next weight vector that is equal to the current weight vector 1994 // there is no 0<t<1 and define the next weight vector that is equal 1995 // to the current weight vector 1986 1996 if(mpz_cmp(t_nenner, t_null) == 0) 1987 1997 { 1988 1989 Print("\n//MwalkNextWeightCC: t_nenner ist Null!");1990 1998 #ifndef SING_NDEBUG 1999 Print("\n//MwalkNextWeightCC: t_nenner=0\n"); 2000 #endif 1991 2001 delete diff_weight; 1992 2002 diff_weight = ivCopy(curr_weight);//take memory … … 2054 2064 #endif 2055 2065 2056 // BOOLEAN isdwpos; 2057 2058 // construct a new weight vector 2066 // construct a new weight vector and check whether vec[j] is overflow, 2067 // i.e. vec[j] > 2^31. 2068 // If vec[j] doesn't overflow, define a weight vector. Otherwise, 2069 // report that overflow appears. In the second case, test whether the 2070 // the correctness of the new vector plays an important role 2071 2059 2072 for (j=0; j<nRing; j++) 2060 2073 { … … 2100 2113 } 2101 2114 } 2102 2115 // reduce the vector with the gcd 2116 if(mpz_cmp_si(ggt,1) != 0) 2117 { 2118 for (j=0; j<nRing; j++) 2119 { 2120 mpz_divexact(vec[j], vec[j], ggt); 2121 } 2122 } 2103 2123 #ifdef NEXT_VECTORS_CC 2104 2124 PrintS("\n// gcd of elements of the vector: "); … … 2106 2126 #endif 2107 2127 2108 /**********************************************************************2109 * construct a new weight vector and check whether vec[j] is overflow, *2110 * i.e. vec[j] > 2^31. *2111 * If vec[j] doesn't overflow, define a weight vector. Otherwise, *2112 * report that overflow appears. In the second case, test whether the *2113 * the correctness of the new vector plays an important role *2114 **********************************************************************/2115 kkk=0;2116 2128 for(j=0; j<nRing; j++) 2117 2129 { 2118 2130 if(mpz_cmp(vec[j], sing_int_half) >= 0) 2119 2131 { 2120 2132 goto REDUCTION; 2121 2122 2133 } 2134 } 2123 2135 checkRed = 1; 2124 2136 for (j=0; j<nRing; j++) … … 2129 2141 2130 2142 REDUCTION: 2143 checkRed = 1; 2131 2144 for (j=0; j<nRing; j++) 2132 2145 { 2133 (*diff_weight)[j] = mpz_get_si(vec[j]); 2134 } 2135 while(MivAbsMax(diff_weight) >= 5) 2136 { 2137 for (j=0; j<nRing; j++) 2138 { 2139 if(mpz_cmp_si(ggt,1)==0) 2140 { 2141 (*diff_weight1)[j] = floor(0.1*(*diff_weight)[j] + 0.5); 2142 // Print("\n// vector[%d] = %d \n",j+1, (*diff_weight1)[j]); 2143 } 2144 else 2145 { 2146 mpz_divexact(vec[j], vec[j], ggt); 2147 (*diff_weight1)[j] = floor(0.1*(*diff_weight)[j] + 0.5); 2148 // Print("\n// vector[%d] = %d \n",j+1, (*diff_weight1)[j]); 2149 } 2150 /* 2151 if((*diff_weight1)[j] == 0) 2152 { 2153 kkk = kkk + 1; 2154 } 2155 */ 2156 } 2157 2158 2159 /* 2160 if(kkk > nRing - 1) 2161 { 2162 // diff_weight was reduced to zero 2163 // Print("\n // MwalkNextWeightCC: geaenderter Vector gleich Null! \n"); 2164 goto TEST_OVERFLOW; 2165 } 2166 */ 2167 2168 if(test_w_in_ConeCC(G,diff_weight1) != 0) 2169 { 2170 Print("\n// MwalkNextWeightCC: geaenderter vector liegt in Groebnerkegel! \n"); 2171 for (j=0; j<nRing; j++) 2172 { 2173 (*diff_weight)[j] = (*diff_weight1)[j]; 2174 } 2175 if(MivAbsMax(diff_weight) < 5) 2176 { 2177 checkRed = 1; 2178 goto SIMPLIFY_GCD; 2179 } 2180 } 2181 else 2182 { 2183 // Print("\n// MwalkNextWeightCC: geaenderter vector liegt nicht in Groebnerkegel! \n"); 2184 break; 2185 } 2146 (*diff_weight1)[j] = mpz_get_si(vec[j]); 2147 } 2148 while(test_w_in_ConeCC(G,diff_weight1)) 2149 { 2150 for(j=0; j<nRing; j++) 2151 { 2152 (*diff_weight)[j] = (*diff_weight1)[j]; 2153 mpz_set_si(vec[j], (*diff_weight)[j]); 2154 } 2155 for(j=0; j<nRing; j++) 2156 { 2157 (*diff_weight1)[j] = floor(0.1*(*diff_weight)[j] + 0.5); 2158 } 2159 } 2160 if(MivAbsMax(diff_weight)>10000) 2161 { 2162 for(j=0; j<nRing; j++) 2163 { 2164 (*diff_weight1)[j] = (*diff_weight)[j]; 2165 } 2166 j = 0; 2167 while(test_w_in_ConeCC(G,diff_weight1)) 2168 { 2169 (*diff_weight)[j] = (*diff_weight1)[j]; 2170 mpz_set_si(vec[j], (*diff_weight)[j]); 2171 j = MivAbsMaxArg(diff_weight1); 2172 (*diff_weight1)[j] = floor(0.1*(*diff_weight1)[j] + 0.5); 2173 } 2174 goto SIMPLIFY_GCD; 2186 2175 } 2187 2176 … … 2222 2211 mpz_clear(t_null); 2223 2212 2224 2225 2226 2213 if(Overflow_Error == FALSE) 2227 2214 { 2228 2215 Overflow_Error = nError; 2229 2216 } 2230 rComplete(currRing);2231 for( kkk=0; kkk<IDELEMS(G);kkk++)2232 { 2233 poly p=G->m[ kkk];2217 rComplete(currRing); 2218 for(j=0; j<IDELEMS(G); j++) 2219 { 2220 poly p=G->m[j]; 2234 2221 while(p!=NULL) 2235 2222 { … … 2240 2227 return diff_weight; 2241 2228 } 2229 */ 2230 /********************************************************************** 2231 * Compute a next weight vector between curr_weight and target_weight * 2232 * with respect to an ideal <G>. * 2233 **********************************************************************/ 2234 static intvec* MwalkNextWeightCC(intvec* curr_weight, intvec* target_weight, 2235 ideal G) 2236 { 2237 BOOLEAN nError = Overflow_Error; 2238 Overflow_Error = FALSE; 2239 2240 assume(currRing != NULL && curr_weight != NULL && 2241 target_weight != NULL && G != NULL); 2242 2243 int nRing = currRing->N; 2244 int checkRed, j, nG = IDELEMS(G); 2245 intvec* ivtemp; 2246 2247 mpz_t t_zaehler, t_nenner; 2248 mpz_init(t_zaehler); 2249 mpz_init(t_nenner); 2250 2251 mpz_t s_zaehler, s_nenner, temp, MwWd; 2252 mpz_init(s_zaehler); 2253 mpz_init(s_nenner); 2254 mpz_init(temp); 2255 mpz_init(MwWd); 2256 2257 mpz_t sing_int; 2258 mpz_init(sing_int); 2259 mpz_set_si(sing_int, 2147483647); 2260 2261 mpz_t sing_int_half; 2262 mpz_init(sing_int_half); 2263 mpz_set_si(sing_int_half, 3*(1073741824/2)); 2264 2265 mpz_t deg_w0_p1, deg_d0_p1; 2266 mpz_init(deg_w0_p1); 2267 mpz_init(deg_d0_p1); 2268 2269 mpz_t sztn, sntz; 2270 mpz_init(sztn); 2271 mpz_init(sntz); 2272 2273 mpz_t t_null; 2274 mpz_init(t_null); 2275 2276 mpz_t ggt; 2277 mpz_init(ggt); 2278 2279 mpz_t dcw; 2280 mpz_init(dcw); 2281 2282 int gcd_tmp; 2283 //intvec* diff_weight = MivSub(target_weight, curr_weight); 2284 2285 intvec* diff_weight1 = new intvec(nRing); //MivSub(target_weight, curr_weight); 2286 poly g; 2287 2288 // reduce the size of the entries of the current weight vector 2289 if(TEST_OPT_REDSB) 2290 { 2291 for (j=0; j<nRing; j++) 2292 { 2293 (*diff_weight1)[j] = (*curr_weight)[j]; 2294 } 2295 while(MivAbsMax(diff_weight1)>10000 && test_w_in_ConeCC(G,diff_weight1)==1) 2296 { 2297 for(j=0; j<nRing; j++) 2298 { 2299 (*curr_weight)[j] = (*diff_weight1)[j]; 2300 } 2301 for(j=0; j<nRing; j++) 2302 { 2303 (*diff_weight1)[j] = floor(0.1*(*diff_weight1)[j] + 0.5); 2304 } 2305 } 2306 2307 if(MivAbsMax(curr_weight)>100000) 2308 { 2309 for(j=0; j<nRing; j++) 2310 { 2311 (*diff_weight1)[j] = (*curr_weight)[j]; 2312 } 2313 j = 0; 2314 while(test_w_in_ConeCC(G,diff_weight1)==1 && MivAbsMax(diff_weight1)>1000) 2315 { 2316 (*curr_weight)[j] = (*diff_weight1)[j]; 2317 j = MivAbsMaxArg(diff_weight1); 2318 (*diff_weight1)[j] = floor(0.1*(*diff_weight1)[j] + 0.5); 2319 } 2320 } 2321 2322 } 2323 intvec* diff_weight = MivSub(target_weight, curr_weight); 2324 2325 // compute a suitable next weight vector 2326 for (j=0; j<nG; j++) 2327 { 2328 g = G->m[j]; 2329 if (g != NULL) 2330 { 2331 ivtemp = MExpPol(g); 2332 mpz_set_si(deg_w0_p1, MivDotProduct(ivtemp, curr_weight)); 2333 mpz_set_si(deg_d0_p1, MivDotProduct(ivtemp, diff_weight)); 2334 delete ivtemp; 2335 2336 pIter(g); 2337 while (g != NULL) 2338 { 2339 ivtemp = MExpPol(g); 2340 mpz_set_si(MwWd, MivDotProduct(ivtemp, curr_weight)); 2341 mpz_sub(s_zaehler, deg_w0_p1, MwWd); 2342 if(mpz_cmp(s_zaehler, t_null) != 0) 2343 { 2344 mpz_set_si(MwWd, MivDotProduct(ivtemp, diff_weight)); 2345 mpz_sub(s_nenner, MwWd, deg_d0_p1); 2346 // check for 0 < s <= 1 2347 if( (mpz_cmp(s_zaehler,t_null) > 0 && 2348 mpz_cmp(s_nenner, s_zaehler)>=0) || 2349 (mpz_cmp(s_zaehler, t_null) < 0 && 2350 mpz_cmp(s_nenner, s_zaehler)<=0)) 2351 { 2352 // make both positive 2353 if (mpz_cmp(s_zaehler, t_null) < 0) 2354 { 2355 mpz_neg(s_zaehler, s_zaehler); 2356 mpz_neg(s_nenner, s_nenner); 2357 } 2358 2359 //compute a simple fraction of s 2360 cancel(s_zaehler, s_nenner); 2361 2362 if(mpz_cmp(t_nenner, t_null) != 0) 2363 { 2364 mpz_mul(sztn, s_zaehler, t_nenner); 2365 mpz_mul(sntz, s_nenner, t_zaehler); 2366 2367 if(mpz_cmp(sztn,sntz) < 0) 2368 { 2369 mpz_add(t_nenner, t_null, s_nenner); 2370 mpz_add(t_zaehler,t_null, s_zaehler); 2371 } 2372 } 2373 else 2374 { 2375 mpz_add(t_nenner, t_null, s_nenner); 2376 mpz_add(t_zaehler,t_null, s_zaehler); 2377 } 2378 } 2379 } 2380 pIter(g); 2381 delete ivtemp; 2382 } 2383 } 2384 } 2385 //Print("\n// Alloc Size = %d \n", nRing*sizeof(mpz_t)); 2386 mpz_t *vec=(mpz_t*)omAlloc(nRing*sizeof(mpz_t)); 2387 2388 2389 // there is no 0<t<1 and define the next weight vector that is equal 2390 // to the current weight vector 2391 if(mpz_cmp(t_nenner, t_null) == 0) 2392 { 2393 #ifndef SING_NDEBUG 2394 Print("\n//MwalkNextWeightCC: t_nenner=0\n"); 2395 #endif 2396 delete diff_weight; 2397 diff_weight = ivCopy(curr_weight);//take memory 2398 goto FINISH; 2399 } 2400 2401 // define the target vector as the next weight vector, if t = 1 2402 if(mpz_cmp_si(t_nenner, 1)==0 && mpz_cmp_si(t_zaehler,1)==0) 2403 { 2404 delete diff_weight; 2405 diff_weight = ivCopy(target_weight); //this takes memory 2406 goto FINISH; 2407 } 2408 2409 //checkRed = 0; 2410 2411 SIMPLIFY_GCD: 2412 2413 // simplify the vectors curr_weight and diff_weight (C-int) 2414 gcd_tmp = (*curr_weight)[0]; 2415 2416 for (j=1; j<nRing; j++) 2417 { 2418 gcd_tmp = gcd(gcd_tmp, (*curr_weight)[j]); 2419 if(gcd_tmp == 1) 2420 { 2421 break; 2422 } 2423 } 2424 if(gcd_tmp != 1) 2425 { 2426 for (j=0; j<nRing; j++) 2427 { 2428 gcd_tmp = gcd(gcd_tmp, (*diff_weight)[j]); 2429 if(gcd_tmp == 1) 2430 { 2431 break; 2432 } 2433 } 2434 } 2435 if(gcd_tmp != 1) 2436 { 2437 for (j=0; j<nRing; j++) 2438 { 2439 (*curr_weight)[j] = (*curr_weight)[j]/gcd_tmp; 2440 (*diff_weight)[j] = (*diff_weight)[j]/gcd_tmp; 2441 } 2442 } 2443 if(checkRed > 0) 2444 { 2445 for (j=0; j<nRing; j++) 2446 { 2447 mpz_set_si(vec[j], (*diff_weight)[j]); 2448 } 2449 goto TEST_OVERFLOW; 2450 } 2451 2452 #ifdef NEXT_VECTORS_CC 2453 Print("\n// gcd of the weight vectors (current and target) = %d", gcd_tmp); 2454 ivString(curr_weight, "new cw"); 2455 ivString(diff_weight, "new dw"); 2456 2457 PrintS("\n// t_zaehler: "); mpz_out_str( stdout, 10, t_zaehler); 2458 PrintS(", t_nenner: "); mpz_out_str( stdout, 10, t_nenner); 2459 #endif 2460 2461 // construct a new weight vector and check whether vec[j] is overflow, i.e. vec[j] > 2^31. 2462 // If vec[j] doesn't overflow, define a weight vector. Otherwise, report that overflow 2463 // appears. In the second case, test whether the the correctness of the new vector plays 2464 // an important role 2465 2466 for (j=0; j<nRing; j++) 2467 { 2468 mpz_set_si(dcw, (*curr_weight)[j]); 2469 mpz_mul(s_nenner, t_nenner, dcw); 2470 2471 if( (*diff_weight)[j]>0) 2472 { 2473 mpz_mul_ui(s_zaehler, t_zaehler, (*diff_weight)[j]); 2474 } 2475 else 2476 { 2477 mpz_mul_ui(s_zaehler, t_zaehler, -(*diff_weight)[j]); 2478 mpz_neg(s_zaehler, s_zaehler); 2479 } 2480 mpz_add(sntz, s_nenner, s_zaehler); 2481 mpz_init_set(vec[j], sntz); 2482 2483 #ifdef NEXT_VECTORS_CC 2484 Print("\n// j = %d ==> ", j); 2485 PrintS("("); 2486 mpz_out_str( stdout, 10, t_nenner); 2487 Print(" * %d)", (*curr_weight)[j]); 2488 Print(" + ("); mpz_out_str( stdout, 10, t_zaehler); 2489 Print(" * %d) = ", (*diff_weight)[j]); 2490 mpz_out_str( stdout, 10, s_nenner); 2491 PrintS(" + "); 2492 mpz_out_str( stdout, 10, s_zaehler); 2493 PrintS(" = "); mpz_out_str( stdout, 10, sntz); 2494 Print(" ==> vector[%d]: ", j); mpz_out_str(stdout, 10, vec[j]); 2495 #endif 2496 2497 if(j==0) 2498 { 2499 mpz_set(ggt, sntz); 2500 } 2501 else 2502 { 2503 if(mpz_cmp_si(ggt,1) != 0) 2504 { 2505 mpz_gcd(ggt, ggt, sntz); 2506 } 2507 } 2508 } 2509 // reduce the vector with the gcd 2510 if(mpz_cmp_si(ggt,1) != 0) 2511 { 2512 for (j=0; j<nRing; j++) 2513 { 2514 mpz_divexact(vec[j], vec[j], ggt); 2515 } 2516 } 2517 #ifdef NEXT_VECTORS_CC 2518 PrintS("\n// gcd of elements of the vector: "); 2519 mpz_out_str( stdout, 10, ggt); 2520 #endif 2521 2522 for (j=0; j<nRing; j++) 2523 { 2524 (*diff_weight)[j] = mpz_get_si(vec[j]); 2525 } 2526 2527 TEST_OVERFLOW: 2528 2529 for (j=0; j<nRing; j++) 2530 { 2531 if(mpz_cmp(vec[j], sing_int)>=0) 2532 { 2533 if(Overflow_Error == FALSE) 2534 { 2535 Overflow_Error = TRUE; 2536 PrintS("\n// ** OVERFLOW in \"MwalkNextWeightCC\": "); 2537 mpz_out_str( stdout, 10, vec[j]); 2538 PrintS(" is greater than 2147483647 (max. integer representation)\n"); 2539 Print("// So vector[%d] := %d is wrong!!\n",j+1, vec[j]);// vec[j] is mpz_t 2540 } 2541 } 2542 } 2543 2544 FINISH: 2545 delete diff_weight1; 2546 mpz_clear(t_zaehler); 2547 mpz_clear(t_nenner); 2548 mpz_clear(s_zaehler); 2549 mpz_clear(s_nenner); 2550 mpz_clear(sntz); 2551 mpz_clear(sztn); 2552 mpz_clear(temp); 2553 mpz_clear(MwWd); 2554 mpz_clear(deg_w0_p1); 2555 mpz_clear(deg_d0_p1); 2556 mpz_clear(ggt); 2557 omFree(vec); 2558 mpz_clear(sing_int_half); 2559 mpz_clear(sing_int); 2560 mpz_clear(dcw); 2561 mpz_clear(t_null); 2562 2563 if(Overflow_Error == FALSE) 2564 { 2565 Overflow_Error = nError; 2566 } 2567 rComplete(currRing); 2568 for(j=0; j<IDELEMS(G); j++) 2569 { 2570 poly p=G->m[j]; 2571 while(p!=NULL) 2572 { 2573 p_Setm(p,currRing); 2574 pIter(p); 2575 } 2576 } 2577 return diff_weight; 2578 } 2579 2242 2580 2243 2581 /********************************************************************** … … 2271 2609 } 2272 2610 2273 /************************************************************** 2611 /******************************************************************** 2274 2612 * define and execute a new ring which order is (a(vb),a(va),lp,C) * 2275 * ************************************************************/ 2276 #if 0 2277 // unused 2613 * ******************************************************************/ 2278 2614 static void VMrHomogeneous(intvec* va, intvec* vb) 2279 2615 { … … 2353 2689 rChangeCurrRing(r); 2354 2690 } 2355 #endif 2691 2356 2692 2357 2693 /************************************************************** … … 2428 2764 } 2429 2765 2430 static ring VMrDefault1(intvec* va)2431 {2432 2433 if ((currRing->ppNoether)!=NULL)2434 {2435 pDelete(&(currRing->ppNoether));2436 }2437 if (((sLastPrinted.rtyp>BEGIN_RING) && (sLastPrinted.rtyp<END_RING)) ||2438 ((sLastPrinted.rtyp==LIST_CMD)&&(lRingDependend((lists)sLastPrinted.data))))2439 {2440 sLastPrinted.CleanUp();2441 }2442 2443 ring r = (ring) omAlloc0Bin(sip_sring_bin);2444 int i, nv = currRing->N;2445 2446 r->cf = currRing->cf;2447 r->N = currRing->N;2448 2449 int nb = 4;2450 2451 //names2452 char* Q; // In order to avoid the corrupted memory, do not change.2453 r->names = (char **) omAlloc0(nv * sizeof(char_ptr));2454 for(i=0; i<nv; i++)2455 {2456 Q = currRing->names[i];2457 r->names[i] = omStrDup(Q);2458 }2459 2460 /*weights: entries for 3 blocks: NULL Made:???*/2461 r->wvhdl = (int **)omAlloc0(nb * sizeof(int_ptr));2462 r->wvhdl[0] = (int*) omAlloc(nv*sizeof(int));2463 for(i=0; i<nv; i++)2464 r->wvhdl[0][i] = (*va)[i];2465 2466 /* order: a,lp,C,0 */2467 r->order = (int *) omAlloc(nb * sizeof(int *));2468 r->block0 = (int *)omAlloc0(nb * sizeof(int *));2469 r->block1 = (int *)omAlloc0(nb * sizeof(int *));2470 2471 // ringorder a for the first block: var 1..nv2472 r->order[0] = ringorder_a;2473 r->block0[0] = 1;2474 r->block1[0] = nv;2475 2476 // ringorder lp for the second block: var 1..nv2477 r->order[1] = ringorder_lp;2478 r->block0[1] = 1;2479 r->block1[1] = nv;2480 2481 // ringorder C for the third block2482 // it is very important within "idLift",2483 // especially, by ring syz_ring=rCurrRingAssure_SyzComp();2484 // therefore, nb must be (nBlocks(currRing) + 1)2485 r->order[2] = ringorder_C;2486 2487 // the last block: everything is 02488 r->order[3] = 0;2489 2490 // polynomial ring2491 r->OrdSgn = 1;2492 2493 // complete ring intializations2494 2495 rComplete(r);2496 2497 //rChangeCurrRing(r);2498 return r;2499 }2500 2501 2766 /**************************************************************** 2502 2767 * define and execute a new ring with ordering (a(va),Wp(vb),C) * 2503 2768 * **************************************************************/ 2504 2505 2769 static ring VMrRefine(intvec* va, intvec* vb) 2506 2770 { … … 2576 2840 2577 2841 // complete ring intializations 2578 2842 2579 2843 rComplete(r); 2580 2844 … … 2806 3070 } 2807 3071 2808 2809 /* define a ring with parameters und change to it */ 2810 /* DefRingPar and DefRingParlp corrupt still memory */ 3072 /*************************************************** 3073 * define a ring with parameters und change to it * 3074 * DefRingPar and DefRingParlp corrupt still memory * 3075 ****************************************************/ 2811 3076 static void DefRingPar(intvec* va) 2812 3077 { … … 2956 3221 } 2957 3222 2958 //unused 2959 /************************************************************** 2960 * check wheather one or more components of a vector are zero * 2961 **************************************************************/ 2962 #if 0 3223 /************************************************************* 3224 * check whether one or more components of a vector are zero * 3225 *************************************************************/ 2963 3226 static int isNolVector(intvec* hilb) 2964 3227 { … … 2973 3236 return 0; 2974 3237 } 2975 #endif 3238 3239 /************************************************************* 3240 * check whether one or more components of a vector are <= 0 * 3241 *************************************************************/ 3242 static int isNegNolVector(intvec* hilb) 3243 { 3244 int i; 3245 for(i=hilb->length()-1; i>=0; i--) 3246 { 3247 if((* hilb)[i]<=0) 3248 { 3249 return 1; 3250 } 3251 } 3252 return 0; 3253 } 3254 3255 /************************************************************************** 3256 * Gomega is the initial ideal of G w. r. t. the current weight vector * 3257 * curr_weight. Check whether curr_weight lies on a border of the Groebner * 3258 * cone, i. e. check whether a monomial is divisible by a leading monomial * 3259 ***************************************************************************/ 3260 static ideal middleOfCone(ideal G, ideal Gomega) 3261 { 3262 BOOLEAN middle = FALSE; 3263 int i,j,N = IDELEMS(Gomega); 3264 poly p,lm,factor1,factor2; 3265 3266 ideal Go = idCopy(G); 3267 3268 // check whether leading monomials of G and Gomega coincide 3269 // and return NULL if not 3270 for(i=0; i<N; i++) 3271 { 3272 if(!pIsConstant(pSub(pCopy(Gomega->m[i]),pCopy(pHead(G->m[i]))))) 3273 { 3274 idDelete(&Go); 3275 return NULL; 3276 } 3277 } 3278 for(i=0; i<N; i++) 3279 { 3280 for(j=0; j<N; j++) 3281 { 3282 if(i!=j) 3283 { 3284 p = pCopy(Gomega->m[i]); 3285 lm = pCopy(Gomega->m[j]); 3286 pIter(p); 3287 while(p!=NULL) 3288 { 3289 if(pDivisibleBy(lm,p)) 3290 { 3291 if(middle == FALSE) 3292 { 3293 middle = TRUE; 3294 } 3295 factor1 = singclap_pdivide(pHead(p),lm,currRing); 3296 factor2 = pMult(pCopy(factor1),pCopy(Go->m[j])); 3297 pDelete(&factor1); 3298 Go->m[i] = pAdd((Go->m[i]),pNeg(pCopy(factor2))); 3299 pDelete(&factor2); 3300 } 3301 pIter(p); 3302 } 3303 pDelete(&lm); 3304 pDelete(&p); 3305 } 3306 } 3307 } 3308 3309 if(middle == TRUE) 3310 { 3311 return Go; 3312 } 3313 idDelete(&Go); 3314 return NULL; 3315 } 2976 3316 2977 3317 /****************************** Februar 2002 **************************** … … 3104 3444 { 3105 3445 Print("\n// ring r%d_%d = %s;\n", tp_deg, nwalk, rString(currRing)); 3446 /* 3106 3447 idElements(Gomega, "Gw"); 3107 3448 headidString(Gomega, "Gw"); 3449 */ 3108 3450 } 3109 3451 #endif … … 3128 3470 else 3129 3471 { -
Property
mode
changed from