Changeset 578051 in git for Singular/LIB/freegb.lib
- Timestamp:
- Dec 18, 2017, 4:15:00 PM (6 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 909b29541ce0c334010bba6696154e22461eb5ce
- Parents:
- 9b58b3fcc6a12daf4ea426458fac85c628277f67179aaba41255e379952db14e553b6a3df355202c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/freegb.lib
r179aaba r578051 3 3 category="Noncommutative"; 4 4 info=" 5 LIBRARY: freegb.lib Compute two-sided Groebner bases in free algebras via 6 @* letterplace 5 LIBRARY: freegb.lib Compute two-sided Groebner bases in free algebras via letterplace approach 7 6 AUTHORS: Viktor Levandovskyy, viktor.levandovskyy@math.rwth-aachen.de 8 @*Grischa Studzinski, grischa.studzinski@math.rwth-aachen.de9 10 OVERVIEW: For the theory, see chapter 'Letterplace' in the SingularManual7 Grischa Studzinski, grischa.studzinski@math.rwth-aachen.de 8 9 OVERVIEW: For the theory, see chapter 'Letterplace' in the @sc{Singular} Manual 11 10 12 11 PROCEDURES: 13 makeLetterplaceRing(d); creates a ring with d blocks of shifted original 14 @* variables 15 letplaceGBasis(I); computes two-sided Groebner basis of a letterplace ideal I 16 @* up to a degree bound 17 lpNF(f,I); normal form of f with respect to ideal I 18 freeGBasis(L, n); computes two-sided Groebner basis of an ideal, encoded via 19 @* list L, up to degree n 12 makeLetterplaceRing(d); creates a ring with d blocks of shifted original variables 13 letplaceGBasis(I); computes two-sided Groebner basis of a letterplace ideal I up to a degree bound 14 lpNF(f,I); two-sided normal form of f with respect to ideal I 20 15 setLetterplaceAttributes(R,d,b); supplies ring R with the letterplace structure 21 16 freeGBasis(L, n); computes two-sided Groebner basis of an ideal, encoded via list L, up to degree n 22 17 23 18 lpMult(f,g); letterplace multiplication of letterplace polynomials 24 19 shiftPoly(p,i); compute the i-th shift of letterplace polynomial p 25 20 lpPower(f,n); natural power of a letterplace polynomial 26 lp2lstr(K, s); convert letter-place ideal to a list of modules 27 lst2str(L[, n]); convert a list (of modules) into polynomials in free algebra 28 mod2str(M[, n]); convert a module into a polynomial in free algebra 21 lieBracket(a,b[, N]); compute Lie bracket ab-ba of two letterplace polynomials 22 23 lp2lstr(K, s); convert a letterplace ideal into a list of modules 24 lst2str(L[, n]); convert a list (of modules) into polynomials in free algebra via strings 25 mod2str(M[, n]); convert a module into a polynomial in free algebra via strings 29 26 vct2str(M[, n]); convert a vector into a word in free algebra 30 lieBracket(a,b[, N]); compute Lie bracket ab-ba of two letterplace polynomials 31 serreRelations(A,z); compute the homogeneous part of Serre's relations 32 @* associated to a generalized Cartan matrix A 33 fullSerreRelations(A,N,C,P,d); compute the ideal of all Serre's relations 34 @* associated to a generalized Cartan matrix A 35 isVar(p); check whether p is a power of a single variable 27 28 serreRelations(A,z); compute the homogeneous part of Serre's relations associated to a generalized Cartan matrix A 29 fullSerreRelations(A,N,C,P,d); compute the ideal of all Serre's relations associated to a generalized Cartan matrix A 30 isVar(p); check whether p is a power of a single variable 36 31 ademRelations(i,j); compute the ideal of Adem relations for i<2j in char 0 37 32 … … 973 968 " 974 969 { 975 int use_old_mlr= 0;970 int alternativeVersion = 0; 976 971 if ( size(#)>0 ) 977 972 { 978 if (( typeof(#[1]) == "int" ) || ( typeof(#[1]) == "poly" ) ) 979 { 980 poly x = poly(#[1]); 981 if (x!=0) 982 { 983 use_old_mlr = 1; 984 } 985 } 986 } 987 if (use_old_mlr) 973 if (typeof(#[1]) == "int") 974 { 975 alternativeVersion = #[1]; 976 } 977 } 978 if (alternativeVersion == 1) 988 979 { 989 980 def @A = makeLetterplaceRing1(d); 990 981 } 991 else 992 { 993 def @A = makeLetterplaceRing2(d); 982 else { 983 if (alternativeVersion == 2) 984 { 985 def @A = makeLetterplaceRing2(d); 986 } 987 else { 988 def @A = makeLetterplaceRing4(d); 989 } 994 990 } 995 991 return(@A); … … 1205 1201 } 1206 1202 1203 static proc makeLetterplaceRing4(int d) 1204 "USAGE: makeLetterplaceRing2(d); d an integer 1205 RETURN: ring 1206 PURPOSE: creates a Letterplace ring with a Dp ordering, suitable for 1207 @* the use of non-homogeneous letterplace 1208 NOTE: the matrix for the ordering looks as follows: first row is 1,1,...,1 1209 EXAMPLE: example makeLetterplaceRing2; shows examples 1210 " 1211 { 1212 1213 // ToDo future: inherit positive weights in the orig ring 1214 // complain on nonpositive ones 1215 1216 // d = up to degree, will be shifted to d+1 1217 if (d<1) {"bad d"; return(0);} 1218 1219 int uptodeg = d; int lV = nvars(basering); 1220 1221 int ppl = printlevel-voice+2; 1222 string err = ""; 1223 1224 int i,j,s; 1225 def save = basering; 1226 int D = d-1; 1227 list LR = ringlist(save); 1228 list L, tmp, tmp2, tmp3; 1229 L[1] = LR[1]; // ground field 1230 L[4] = LR[4]; // quotient ideal 1231 tmp = LR[2]; // varnames 1232 s = size(LR[2]); 1233 for (i=1; i<=D; i++) 1234 { 1235 for (j=1; j<=s; j++) 1236 { 1237 tmp[i*s+j] = string(tmp[j])+"("+string(i+1)+")"; 1238 } 1239 } 1240 for (i=1; i<=s; i++) 1241 { 1242 tmp[i] = string(tmp[i])+"("+string(1)+")"; 1243 } 1244 L[2] = tmp; 1245 list OrigNames = LR[2]; 1246 1247 s = size(LR[3]); 1248 list ordering; 1249 ordering[1] = list("Dp",intvec(1: int(d*lV))); 1250 ordering[2] = LR[3][s]; // module ord to place at the very end 1251 LR[3] = ordering; 1252 1253 L[3] = LR[3]; 1254 attrib(L,"maxExp",1); 1255 def @R = ring(L); 1256 def @@R = setLetterplaceAttributes(@R,uptodeg,lV); 1257 return (@@R); 1258 } 1259 example 1260 { 1261 "EXAMPLE:"; echo = 2; 1262 ring r = 0,(x,y,z),(dp(1),dp(2)); 1263 def A = makeLetterplaceRing2(2); 1264 setring A; 1265 A; 1266 attrib(A,"isLetterplaceRing"); 1267 attrib(A,"uptodeg"); // degree bound 1268 attrib(A,"lV"); // number of variables in the main block 1269 } 1270 1207 1271 // P[s;sigma] approach 1208 1272 static proc makeLetterplaceRing3(int d) … … 1314 1378 attrib(A,"lV"); // number of variables in the main block 1315 1379 } 1316 1317 1318 1380 1319 1381 /* EXAMPLES: … … 2600 2662 if (i>N) 2601 2663 { 2602 ERROR("The total number of elements in input ideals must not exceed the dimension of the ground ring"); 2664 string s1="The total number of elements in input ideals"; 2665 string s2="must not exceed the dimension of the ground ring"; 2666 ERROR(s1+s2); 2603 2667 } 2604 2668 if (i < N) … … 3029 3093 */ 3030 3094 3031 //static 3032 proc lpMultX(poly f, poly g) 3095 static proc lpMultX(poly f, poly g) 3033 3096 { 3034 3097 /* multiplies two polys in a very general setting correctly */ … … 3083 3146 } 3084 3147 3085 // TODO:3086 3148 // multiply two letterplace polynomials, lpMult: done 3087 3149 // reduction/ Normalform? needs kernel stuff … … 3172 3234 //@* else there wouldn't be an dvec representation 3173 3235 3174 //Main procedure for the user3236 //Main procedure for the user 3175 3237 3176 3238 proc lpNF(poly p, ideal G) … … 3181 3243 being a Letterplace Groebner basis (no check for this will be done) 3182 3244 NOTE: Strategy: take the smallest monomial wrt ordering for reduction 3183 @*For homogenous ideals the shift does not matter3184 @*For non-homogenous ideals the first shift will be the smallest monomial3245 - For homogenous ideals the shift does not matter 3246 - For non-homogenous ideals the first shift will be the smallest monomial 3185 3247 EXAMPLE: example lpNF; shows examples 3186 3248 " … … 3189 3251 G = sort(G)[1]; 3190 3252 list L = makeDVecI(G); 3191 return(normalize(lpNormalForm 1(p,G,L)));3253 return(normalize(lpNormalForm2(p,G,L))); 3192 3254 } 3193 3255 example … … 3214 3276 RETURN: list of intvecs 3215 3277 PURPOSE: convert G into a list of intvecs, corresponding to the exponent vector 3216 @*of the leading monomials of G3278 of the leading monomials of G 3217 3279 " 3218 3280 {int i; list L; … … 3220 3282 return(L); 3221 3283 } 3222 3223 3284 3224 3285 static proc delSupZero(intvec I) … … 3247 3308 } 3248 3309 3249 3250 3310 static proc delSupZeroList(list L) 3251 3311 "USUAGE:delSupZeroList(L); L a list, containing intvecs … … 3326 3386 } 3327 3387 3328 3329 3330 //the actual normalform procedure, if a user want not to presort the ideal, just make it not static 3331 3388 //the first normal form procedure, if a user want not to presort the ideal, just make it not static 3332 3389 3333 3390 static proc lpNormalForm1(poly p, ideal G, list L) … … 3358 3415 3359 3416 3417 // new VL; called from lpNF 3418 static proc lpNormalForm2(poly pp, ideal G, list L) 3419 "USUAGE:lpNormalForm2(p,G); 3420 RETURN:poly 3421 PURPOSE:computation of the normal form of p w.r.t. G 3422 ASSUME: p is a Letterplace polynomial, G is a set of Letterplace polynomials 3423 NOTE: Taking the first possible reduction 3424 " 3425 { 3426 poly one = 1; 3427 if ( (pp == 0) || (leadmonom(pp) == one) ) { return(pp); } 3428 poly p = pp; poly q; 3429 int i; int s; intvec V; 3430 while ( (p != 0) && (leadmonom(p) != one) ) 3431 { 3432 //"entered while with p="; p; 3433 V = makeDVec(delSupZero(leadexp(p))); 3434 i = 0; 3435 s = -1; 3436 //"look for divisor"; 3437 while ( (s == -1) && (i<size(L)) ) 3438 { 3439 i = i+1; 3440 s = dShiftDiv(V, L[i])[1]; 3441 } 3442 // now, out of here: either i=size(L) and s==-1 => no reduction 3443 // otherwise: i<=size(L) and s!= -1 => reduction 3444 //"out of divisor search: s="; s; "i="; i; 3445 if (s != -1) 3446 { 3447 //"start reducing with G[i]:"; 3448 p = lpReduce(p,G[i],s); // lm-reduction 3449 //"reduced to p="; p; 3450 } 3451 else 3452 { 3453 // ie no lm-reduction possible; proceed with the tail reduction 3454 q = p-lead(p); 3455 p = lead(p); 3456 if (q!=0) 3457 { 3458 p = p + lpNormalForm2(q,G,L); 3459 } 3460 return(p); 3461 } 3462 } 3463 // out of while when p==0 or p == const 3464 return(p); 3465 } 3466 3467 3360 3468 3361 3469 … … 3521 3629 // // interface 3522 3630 3523 // proc whichshift(poly p, int numvars)3631 // static proc whichshift(poly p, int numvars) 3524 3632 // { 3525 3633 // // numvars = number of vars of the orig free algebra … … 3538 3646 3539 3647 // LIB "qhmoduli.lib"; 3540 // proc polyshift(poly p, int numvars)3648 // static proc polyshift(poly p, int numvars) 3541 3649 // { 3542 3650 // poly q = p; int i = 0; … … 3615 3723 lpMultX(a,b); // seems to work properly 3616 3724 } 3725 3726 /* THE FOLLOWING IS UNDER DEVELOPMENT 3727 // copied following from freegb_wrkcp.lib by Karim Abou Zeid on 07.04.2017: 3728 // makeLetterplaceRingElim(int d) 3729 // makeLetterplaceRingNDO(int d) 3730 // setLetterplaceAttributesElim(def R, int uptodeg, int lV) 3731 // lpElimIdeal(ideal I) 3732 // makeLetterplaceRingWt(int d, intvec W) 3733 3734 static proc makeLetterplaceRingElim(int d) 3735 "USAGE: makeLetterplaceRingElim(d); d integers 3736 RETURN: ring 3737 PURPOSE: creates a ring with an elimination ordering 3738 NOTE: the matrix for the ordering looks as follows: first row is 1,..,0,1,0,.. 3739 @* then 0,1,0,...,0,0,1,0... and so on, lastly its lp 3740 @* this ordering is only correct if only polys with same shift are compared 3741 EXAMPLE: example makeLetterplaceRingElim; shows examples 3742 " 3743 { 3744 3745 // ToDo future: inherit positive weights in the orig ring 3746 // complain on nonpositive ones 3747 3748 // d = up to degree, will be shifted to d+1 3749 if (d<1) {"bad d"; return(0);} 3750 3751 int uptodeg = d; int lV = nvars(basering); 3752 3753 int ppl = printlevel-voice+2; 3754 string err = ""; 3755 3756 int i,j,s; intvec iV,iVl; 3757 def save = basering; 3758 int D = d-1; 3759 list LR = ringlist(save); 3760 list L, tmp, tmp2, tmp3; 3761 L[1] = LR[1]; // ground field 3762 L[4] = LR[4]; // quotient ideal 3763 tmp = LR[2]; // varnames 3764 s = size(LR[2]); 3765 for (i=1; i<=D; i++) 3766 { 3767 for (j=1; j<=s; j++) 3768 { 3769 tmp[i*s+j] = string(tmp[j])+"("+string(i+1)+")"; 3770 } 3771 } 3772 for (i=1; i<=s; i++) 3773 { 3774 tmp[i] = string(tmp[i])+"("+string(1)+")"; 3775 } 3776 L[2] = tmp; 3777 L[3] = list(); 3778 list OrigNames = LR[2]; 3779 s = size(LR[3]); 3780 //creation of first block 3781 3782 if (s==2) 3783 { 3784 // not a blockord, 1 block + module ord 3785 tmp = LR[3][s]; // module ord 3786 for (i = 1; i <= lV; i++) 3787 { 3788 iV = (0: lV); 3789 iV[i] = 1; 3790 iVl = iV; 3791 for (j = 1; j <= D; j++) 3792 { iVl = iVl,iV; } 3793 L[3][i] = list("a",iVl); 3794 } 3795 // for (i=1; i<=d; i++) 3796 // { 3797 // LR[3][s-1+i] = LR[3][1]; 3798 // } 3799 // LR[3][s+D] = tmp; 3800 //iV = (1:(d*lV)); 3801 L[3][lV+1] = list("lp",(1:(d*lV))); 3802 L[3][lV+2] = tmp; 3803 } 3804 else {ERROR("Please set the ordering of basering to dp");} 3805 // if (s>2) 3806 // { 3807 // // there are s-1 blocks 3808 // int nb = s-1; 3809 // tmp = LR[3][s]; // module ord to place at the very end 3810 // tmp2 = LR[3]; tmp2 = tmp2[1..nb]; 3811 // LR[3][1] = list("a",LTO); 3812 // //tmp3[1] = list("a",intvec(1: int(d*lV))); // deg-ord, insert as the 1st 3813 // for (i=1; i<=d; i++) 3814 // { 3815 // tmp3 = tmp3 + tmp2; 3816 // } 3817 // tmp3 = tmp3 + list(tmp); 3818 // LR[3] = tmp3; 3819 // for (i=1; i<=d; i++) 3820 // { 3821 // for (j=1; j<=nb; j++) 3822 // { 3823 // // LR[3][i*nb+j+1]= LR[3][j]; 3824 // LR[3][i*nb+j+1]= tmp2[j]; 3825 // } 3826 // } 3827 // // size(LR[3]); 3828 // LR[3][(s-1)*d+2] = tmp; 3829 // LR[3] = list("a",intvec(1: int(d*lV))) + LR[3]; // deg-ord, insert as the 1st 3830 // remove everything behind nb*(D+1)+1 ? 3831 // tmp = LR[3]; 3832 // LR[3] = tmp[1..size(tmp)-1]; 3833 // } 3834 // L[3] = LR[3]; 3835 def @R = ring(L); 3836 // setring @R; 3837 // int uptodeg = d; int lV = nvars(basering); // were defined before 3838 def @@R = setLetterplaceAttributesElim(@R,uptodeg,lV); 3839 return (@@R); 3840 } 3841 example 3842 { 3843 "EXAMPLE:"; echo = 2; 3844 ring r = 0,(x,y,z),lp; 3845 def A = makeLetterplaceRingElim(2); 3846 setring A; 3847 A; 3848 attrib(A,"isLetterplaceRing"); 3849 attrib(A,"uptodeg"); // degree bound 3850 attrib(A,"lV"); // number of variables in the main block 3851 } 3852 3853 3854 3855 static proc makeLetterplaceRingNDO(int d) 3856 "USAGE: makeLetterplaceRingNDO(d); d an integer 3857 RETURN: ring 3858 PURPOSE: creates a ring with a non-degree first ordering, suitable for 3859 @* the use of non-homogeneous letterplace 3860 NOTE: the matrix for the ordering looks as follows: 3861 @* 'd' blocks of shifted original variables 3862 EXAMPLE: example makeLetterplaceRingNDO; shows examples 3863 " 3864 { 3865 3866 // ToDo future: inherit positive weights in the orig ring 3867 // complain on nonpositive ones 3868 3869 // d = up to degree, will be shifted to d+1 3870 if (d<1) {"bad d"; return(0);} 3871 3872 int uptodeg = d; int lV = nvars(basering); 3873 3874 int ppl = printlevel-voice+2; 3875 string err = ""; 3876 3877 int i,j,s; 3878 def save = basering; 3879 int D = d-1; 3880 list LR = ringlist(save); 3881 list L, tmp, tmp2, tmp3; 3882 L[1] = LR[1]; // ground field 3883 L[4] = LR[4]; // quotient ideal 3884 tmp = LR[2]; // varnames 3885 s = size(LR[2]); 3886 for (i=1; i<=D; i++) 3887 { 3888 for (j=1; j<=s; j++) 3889 { 3890 tmp[i*s+j] = string(tmp[j])+"("+string(i+1)+")"; 3891 } 3892 } 3893 for (i=1; i<=s; i++) 3894 { 3895 tmp[i] = string(tmp[i])+"("+string(1)+")"; 3896 } 3897 L[2] = tmp; 3898 list OrigNames = LR[2]; 3899 // ordering: one 1..1 a above 3900 // ordering: d blocks of the ord on r 3901 // try to get whether the ord on r is blockord itself 3902 // TODO: make L(2) ordering! exponent is maximally 2 3903 s = size(LR[3]); 3904 if (s==2) 3905 { 3906 // not a blockord, 1 block + module ord 3907 tmp = LR[3][s]; // module ord 3908 for (i=1; i<=d; i++) 3909 { 3910 LR[3][i] = LR[3][1]; 3911 } 3912 // LR[3][s+D] = tmp; 3913 LR[3][d+1] = tmp; 3914 //LR[3][1] = list("a",intvec(1: int(d*lV))); // deg-ord not wanted here 3915 } 3916 if (s>2) 3917 { 3918 // there are s-1 blocks 3919 int nb = s-1; 3920 tmp = LR[3][s]; // module ord to place at the very end 3921 tmp2 = LR[3]; tmp2 = tmp2[1..nb]; 3922 //tmp3[1] = list("a",intvec(1: int(d*lV))); // deg-ord not wanted here 3923 for (i=1; i<=d; i++) 3924 { 3925 tmp3 = tmp3 + tmp2; 3926 } 3927 tmp3 = tmp3 + list(tmp); 3928 LR[3] = tmp3; 3929 // for (i=1; i<=d; i++) 3930 // { 3931 // for (j=1; j<=nb; j++) 3932 // { 3933 // // LR[3][i*nb+j+1]= LR[3][j]; 3934 // LR[3][i*nb+j+1]= tmp2[j]; 3935 // } 3936 // } 3937 // // size(LR[3]); 3938 // LR[3][(s-1)*d+2] = tmp; 3939 // LR[3] = list("a",intvec(1: int(d*lV))) + LR[3]; // deg-ord, insert as the 1st 3940 // remove everything behind nb*(D+1)+1 ? 3941 // tmp = LR[3]; 3942 // LR[3] = tmp[1..size(tmp)-1]; 3943 } 3944 L[3] = LR[3]; 3945 def @R = ring(L); 3946 // setring @R; 3947 // int uptodeg = d; int lV = nvars(basering); // were defined before 3948 def @@R = setLetterplaceAttributes(@R,uptodeg,lV); 3949 return (@@R); 3950 } 3951 example 3952 { 3953 "EXAMPLE:"; echo = 2; 3954 ring r = 0,(x,y,z),lp; 3955 def A = makeLetterplaceRingNDO(2); 3956 setring A; 3957 A; 3958 attrib(A,"isLetterplaceRing"); 3959 attrib(A,"uptodeg"); // degree bound 3960 attrib(A,"lV"); // number of variables in the main block 3961 } 3962 3963 static proc setLetterplaceAttributesElim(def R, int uptodeg, int lV) 3964 "USAGE: setLetterplaceAttributesElim(R, d, b, eV); R a ring, b,d, eV integers 3965 RETURN: ring with special attributes set 3966 PURPOSE: sets attributes for a letterplace ring: 3967 @* 'isLetterplaceRing' = true, 'uptodeg' = d, 'lV' = b, 'eV' = eV, where 3968 @* 'uptodeg' stands for the degree bound, 3969 @* 'lV' for the number of variables in the block 0 3970 @* 'eV' for the number of elimination variables 3971 NOTE: Activate the resulting ring by using @code{setring} 3972 " 3973 { 3974 if (uptodeg*lV != nvars(R)) 3975 { 3976 ERROR("uptodeg and lV do not agree on the basering!"); 3977 } 3978 3979 3980 // Set letterplace-specific attributes for the output ring! 3981 attrib(R, "uptodeg", uptodeg); 3982 attrib(R, "lV", lV); 3983 attrib(R, "isLetterplaceRing", 1); 3984 attrib(R, "HasElimOrd", 1); 3985 return (R); 3986 } 3987 example 3988 { 3989 "EXAMPLE:"; echo = 2; 3990 ring r = 0,(x(1),y(1),x(2),y(2),x(3),y(3),x(4),y(4)),dp; 3991 def R = setLetterplaceAttributesElim(r, 4, 2, 1); setring R; 3992 attrib(R,"isLetterplaceRing"); 3993 lieBracket(x(1),y(1),2); 3994 } 3995 3996 3997 static proc lpElimIdeal(ideal I) 3998 " 3999 does not work for degree reasons (deg function does not work for lp rings -> newone!) 4000 " 4001 { 4002 def lpring = attrib(basering,"isLetterplaceRing"); 4003 def lpEO = attrib(basering,"HasElimOrd"); 4004 if ( typeof(lpring)!="int" && typeof(lpEO)!="int") 4005 { 4006 ERROR("Ring is not a lp-ring with an elimination ordering"); 4007 } 4008 4009 //int nE = attrib(basering, "eV"); 4010 4011 return(letplaceGBasis(I)); 4012 } 4013 4014 4015 static proc makeLetterplaceRingWt(int d, intvec W) 4016 "USAGE: makeLetterplaceRingWt(d,W); d an integer, W a vector of positive integers 4017 RETURN: ring 4018 PURPOSE: creates a ring with a special ordering, suitable for 4019 @* the use of non-homogeneous letterplace 4020 NOTE: the matrix for the ordering looks as follows: first row is W,W,W,... 4021 @* then there come 'd' blocks of shifted original variables 4022 EXAMPLE: example makeLetterplaceRing2; shows examples 4023 " 4024 { 4025 4026 // ToDo future: inherit positive weights in the orig ring 4027 // complain on nonpositive ones 4028 4029 // d = up to degree, will be shifted to d+1 4030 if (d<1) {"bad d"; return(0);} 4031 4032 int uptodeg = d; int lV = nvars(basering); 4033 4034 //check weightvector 4035 if (size(W) <> lV) {"bad weights"; return(0);} 4036 4037 int i; 4038 for (i = 1; i <= size(W); i++) {if (W[i] < 0) {"bad weights"; return(0);}} 4039 intvec Wt = W; 4040 for (i = 2; i <= d; i++) {Wt = Wt, W;} 4041 kill i; 4042 4043 int ppl = printlevel-voice+2; 4044 string err = ""; 4045 4046 int i,j,s; 4047 def save = basering; 4048 int D = d-1; 4049 list LR = ringlist(save); 4050 list L, tmp, tmp2, tmp3; 4051 L[1] = LR[1]; // ground field 4052 L[4] = LR[4]; // quotient ideal 4053 tmp = LR[2]; // varnames 4054 s = size(LR[2]); 4055 for (i=1; i<=D; i++) 4056 { 4057 for (j=1; j<=s; j++) 4058 { 4059 tmp[i*s+j] = string(tmp[j])+"("+string(i+1)+")"; 4060 } 4061 } 4062 for (i=1; i<=s; i++) 4063 { 4064 tmp[i] = string(tmp[i])+"("+string(1)+")"; 4065 } 4066 L[2] = tmp; 4067 list OrigNames = LR[2]; 4068 // ordering: one 1..1 a above 4069 // ordering: d blocks of the ord on r 4070 // try to get whether the ord on r is blockord itself 4071 // TODO: make L(2) ordering! exponent is maximally 2 4072 s = size(LR[3]); 4073 if (s==2) 4074 { 4075 // not a blockord, 1 block + module ord 4076 tmp = LR[3][s]; // module ord 4077 for (i=1; i<=d; i++) 4078 { 4079 LR[3][s-1+i] = LR[3][1]; 4080 } 4081 // LR[3][s+D] = tmp; 4082 LR[3][s+1+D] = tmp; 4083 LR[3][1] = list("a",Wt); // deg-ord 4084 } 4085 if (s>2) 4086 { 4087 // there are s-1 blocks 4088 int nb = s-1; 4089 tmp = LR[3][s]; // module ord to place at the very end 4090 tmp2 = LR[3]; tmp2 = tmp2[1..nb]; 4091 tmp3[1] = list("a",Wt); // deg-ord, insert as the 1st 4092 for (i=1; i<=d; i++) 4093 { 4094 tmp3 = tmp3 + tmp2; 4095 } 4096 tmp3 = tmp3 + list(tmp); 4097 LR[3] = tmp3; 4098 4099 } 4100 L[3] = LR[3]; 4101 def @R = ring(L); 4102 // setring @R; 4103 // int uptodeg = d; int lV = nvars(basering); // were defined before 4104 def @@R = setLetterplaceAttributes(@R,uptodeg,lV); 4105 return (@@R); 4106 } 4107 example 4108 { 4109 "EXAMPLE:"; echo = 2; 4110 ring r = 0,(x,y,z),(dp(1),dp(2)); 4111 def A = makeLetterplaceRingWt(2,intvec(1,2,3)); 4112 setring A; 4113 A; 4114 attrib(A,"isLetterplaceRing"); 4115 attrib(A,"uptodeg"); // degree bound 4116 attrib(A,"lV"); // number of variables in the main block 4117 } 4118 */
Note: See TracChangeset
for help on using the changeset viewer.