Changeset 11dddeb in git for Singular/LIB/poly.lib
- Timestamp:
- Feb 23, 2004, 11:19:13 AM (20 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- dd8844f86c84ceb5f72e448153ac7a2d0daf5a00
- Parents:
- c229324983bbffba788eee2e34c2f5428261bb0f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/poly.lib
rc22932 r11dddeb 1 1 /////////////////////////////////////////////////////////////////////////////// 2 version="$Id: poly.lib,v 1.3 3 2001-01-16 13:48:36Singular Exp $";2 version="$Id: poly.lib,v 1.34 2004-02-23 10:19:13 Singular Exp $"; 3 3 category="General purpose"; 4 4 info=" … … 13 13 is_zero(poly/...); int, =1 resp. =0 if coker(input) is 0 resp. not 14 14 lcm(ideal); lcm of given generators of ideal 15 maxcoef(poly/...); maximal length of coefficient occur ing in poly/...15 maxcoef(poly/...); maximal length of coefficient occurring in poly/... 16 16 maxdeg(poly/...); int/intmat = degree/s of terms of maximal order 17 17 maxdeg1(poly/...); int = [weighted] maximal degree of input … … 25 25 mod2id(M,iv); conversion of a module M to an ideal 26 26 id2mod(i,iv); conversion inverse to mod2id 27 substitute(I,...) substitute in I variables by polynomials 27 28 subrInterred(i1,i2,iv);interred w.r.t. a subset of variables 29 hilbPoly( I) Hilbert polynomial of basering/I 28 30 (parameters in square brackets [] are optional) 29 31 "; … … 32 34 LIB "ring.lib"; 33 35 /////////////////////////////////////////////////////////////////////////////// 34 36 static proc bino(int a, int b) 37 { 38 //computes binomial var(1)+a over b 39 int i; 40 if(b==0){return(1);} 41 poly p=(var(1)+a)/b; 42 for(i=1;i<=b-1;i++) 43 { 44 p=p*(var(1)+a-i)/i; 45 } 46 return(p); 47 } 48 49 proc hilbPoly(ideal I) 50 "USAGE: hilbPoly(I) I a homogeneous ideal 51 RETURN: the Hilbert polynomial of basering/I as an intvec v=v_0,...,v_r 52 such that the Hilbert polynomial is (v_0+v_1*t+...v_r*t^r)/r! 53 EXAMPLE: example hilbPoly; shows an example 54 " 55 { 56 def R=basering; 57 if(!attrib(I,"isSB")){I=std(I);} 58 intvec v=hilb(I,2); 59 int s=dim(I); 60 intvec hp; 61 if(s==0){return(hp);} 62 int d=size(v)-2; 63 ring S=0,t,dp; 64 poly p=v[1+d]*bino(s-1-d,s-1); 65 int i; 66 for(i=1;i<=d;i++) 67 { 68 p=p+v[d-i+1]*bino(s-1-d+i,s-1); 69 } 70 int n=1; 71 for(i=2;i<=s-1;i++){n=n*i;} 72 p=n*p; 73 for(i=1;i<=s;i++) 74 { 75 hp[i]=int(leadcoef(p[s-i+1])); 76 } 77 setring R; 78 return(hp); 79 } 80 example 81 { "EXAMPLE:"; echo = 2; 82 ring r = 0,(b,c,t,h),dp; 83 ideal I= 84 bct-t2h+2th2+h3, 85 bt3-ct3-t4+b2th+c2th-2bt2h+2ct2h+2t3h-bch2-2bth2+2cth2+2th3, 86 b2c2+bt2h-ct2h-t3h+b2h2+2bch2+c2h2-2bth2+2cth2+t2h2-2bh3+2ch3+2th3+3h4, 87 c2t3+ct4-c3th-2c2t2h-2ct3h-t4h+bc2h2-2c2th2-bt2h2+4t3h2+2bth3-2cth3-t2h3 88 +bh4-6th4-2h5; 89 hilbPoly(I); 90 } 91 92 /////////////////////////////////////////////////////////////////////////////// 93 proc substitute (I,list #) 94 "USAGE: - case 1: typeof(#[1])==poly: 95 substitute (I,v,f[,v1,f1,v2,f2,...]); I object of basering which 96 can be mapped, v,v1,v2,.. ring variables, f,f1,f2,... poly 97 @* - case 2: typeof(#[1])==ideal: 98 substitute1 (I,v,f); I object of basering which can be mapped, 99 v ideal of ring variables, f ideal 100 RETURN: object of same type as I, 101 @* - case 1: ring variable v,v1,v2,... substituted by polynomials 102 f,f1,f2,..., in this order 103 @* - case 2: ring variables in v substituted by polynomials in f: 104 v[i] is substituted by f[i], i=1,...,i=min(size(v),ncols(f)) 105 NOTE: this procedure extends the built-in command subst which substitutes 106 ring variables only by monomials 107 EXAMPLE: example substitute; shows an example 108 " 109 110 { 111 def bas = basering; 112 ideal m = maxideal(1); 113 int i,ii; 114 if(typeof(#[1])=="poly") 115 { 116 poly v = #[1]; 117 poly f = #[2]; 118 map phi = bas,m; 119 def J = I; 120 for (ii=1; ii<=size(#) - 1; ii=ii+2) 121 { 122 m = maxideal(1); 123 i=rvar(#[ii]); 124 m[i] = #[ii+1]; 125 phi = bas,m; 126 J = phi(J); 127 } 128 return(J); 129 } 130 if(typeof(#[1])=="ideal") 131 { 132 ideal v = #[1]; 133 ideal f = #[2]; 134 int mi = size(v); 135 if(ncols(f)<mi) 136 { 137 mi = ncols(f); 138 } 139 m[rvar(v[1])]=f[1]; 140 map phi = bas,m; 141 def J = phi(I); 142 for (ii=2; ii<=mi; ii++) 143 { 144 m = maxideal(1); 145 m[rvar(v[ii])]=f[ii]; 146 phi = bas,m; 147 J = phi(J); 148 } 149 return(J); 150 } 151 } 152 example 153 { "EXAMPLE:"; echo = 2; 154 ring r = 0,(b,c,t),dp; 155 ideal I = -bc+4b2c2t,bc2t-5b2c; 156 substitute(I,c,b+c,t,0,b,b-1); 157 ideal v = c,t,b; 158 ideal f = b+c,0,b-1; 159 substitute(I,v,f); 160 } 161 /////////////////////////////////////////////////////////////////////////////// 35 162 proc cyclic (int n) 36 163 "USAGE: cyclic(n); n integer … … 278 405 (maxdeg of each var is 1). 279 406 Of type int if id is of type poly, of type intmat else 280 NOTE: proc maxdeg1 returns 1 integer, the absolut maximum; moreover, it has407 NOTE: proc maxdeg1 returns 1 integer, the absolute maximum; moreover, it has 281 408 an option for computing weighted degrees 282 409 EXAMPLE: example maxdeg; shows examples … … 317 444 example 318 445 { "EXAMPLE:"; echo = 2; 319 ring r = 0,(x,y,z),wp( -1,-2,-3);446 ring r = 0,(x,y,z),wp(1,2,3); 320 447 poly f = x+y2+z3; 321 448 deg(f); //deg; returns weighted degree (in case of 1 block)! … … 397 524 example 398 525 { "EXAMPLE:"; echo = 2; 399 ring r = 0,(x,y,z),wp( -1,-2,-3);526 ring r = 0,(x,y,z),wp(1,2,3); 400 527 poly f = x+y2+z3; 401 528 deg(f); //deg returns weighted degree (in case of 1 block)! … … 404 531 maxdeg1(f,v); //weighted maximal degree 405 532 matrix m[2][2]=f+x10,1,0,f^2; 406 maxdeg1(m,v); //absolut weighted maximal degree533 maxdeg1(m,v); //absolute weighted maximal degree 407 534 } 408 535 /////////////////////////////////////////////////////////////////////////////// … … 413 540 (mindeg of each variable is 1) of type int if id of type poly, else 414 541 of type intmat. 415 NOTE: proc mindeg1 returns one integer, the absolut minimum; moreover it542 NOTE: proc mindeg1 returns one integer, the absolute minimum; moreover it 416 543 has an option for computing weighted degrees. 417 544 EXAMPLE: example mindeg; shows examples … … 539 666 mindeg1(f,v); // computes minimal weighted degree 540 667 matrix m[2][2]=x10,1,0,f^2; 541 mindeg1(m,1..3); // computes absolut minimum of weighted degrees668 mindeg1(m,1..3); // computes absolute minimum of weighted degrees 542 669 } 543 670 /////////////////////////////////////////////////////////////////////////////// … … 611 738 612 739 proc lcm (id, list #) 613 "USAGE: lcm(p[,q]); p int/intve q a list of integers or740 "USAGE: lcm(p[,q]); p int/intvec q a list of integers or 614 741 p poly/ideal q a list of polynomials 615 742 RETURN: the least common multiple of the common entries of p and q: … … 897 1024 l[2]=their coefficients after interreduction 898 1025 l[3]=l[1]*l[2] 899 PU POSE: Do interred only w.r.t. a subset of variables.1026 PURPOSE: Do interred only w.r.t. a subset of variables. 900 1027 The procedure returns an interreduced system of generators of 901 1028 sm considered as a k[t_1,..,t_s]-submodule of the free module
Note: See TracChangeset
for help on using the changeset viewer.