Changeset 0fbdd1 in git for Singular/LIB/ring.lib
- Timestamp:
- Sep 12, 1997, 9:40:37 AM (26 years ago)
- Branches:
- (u'spielwiese', 'e7cc1ebecb61be8b9ca6c18016352af89940b21a')
- Children:
- 3ca4229c4e4d8d84ca999ef93aec635eb84259c6
- Parents:
- 4a81eccd72975057d29a44244958cdc9a450eb71
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/ring.lib
r4a81ec r0fbdd1 1 // $Id: ring.lib,v 1. 2 1997-04-28 19:27:25 obachmanExp $1 // $Id: ring.lib,v 1.3 1997-09-12 07:40:36 Singular Exp $ 2 2 //(GMG, last modified 03.11.95) 3 3 /////////////////////////////////////////////////////////////////////////////// … … 8 8 changeord("R",o[,r]); make a copy R of basering [ring r] with new ord o 9 9 changevar("R",v[,r]); make a copy R of basering [ring r] with new vars v 10 copyring("R"[,r]); make an exact copy R of basering [ring r] 10 11 defring("R",c,n,v,o); define a ring R in specified char c, n vars v, ord o 11 12 defrings(n[,p]); define ring Sn in n vars, char 32003 [p], ord ds 12 13 defringp(n[,p]); define ring Pn in n vars, char 32003 [p], ord dp 13 14 extendring("R",n,v,o); extend given ring by n vars v, ord o and name it R 15 extendring1("R",n,v,o); similair to extendring but different ordering 14 16 fetchall(R[,str]); fetch all objects of ring R to basering 15 17 imapall(R[,str]); imap all objects of ring R to basering 16 18 mapall(R,i[,str]); map all objects of ring R via ideal i to basering 17 19 ringtensor("R",s,t,..);create ring R, tensor product of rings s,t,... 18 (parameters in square brackets [] are optional) 20 substitute(id,p,list); substitute in id i-th factor of p by i-th poly of list 21 swapvars(id,p1,p2); return id with variables p1 and p2 interchanged 22 (parameters in square brackets [] are optional) 19 23 20 24 LIB "inout.lib"; … … 170 174 /////////////////////////////////////////////////////////////////////////////// 171 175 176 proc copyring (string newr,list #) 177 USAGE: copyring(newr[,r]); newr=string, r=ring/qring 178 CREATE: create a new ring with name `newr` and make it the basering if r is 179 an existing ring [default: r=basering]. 180 The new ring is a copy of r but with a new name R1 if, say, newr="R1" 181 RETURN: No return value 182 NOTE: This proc uses 'execute' or calls a procedure using 'execute'. 183 If you use it in your own proc, let the local names of your proc 184 start with @ (see the file HelpForProc) 185 EXAMPLE: example copyring; shows an example 186 { 187 if( size(#)==0 ) { def @r=basering; } 188 if( size(#)==1 ) { def @r=#[1]; } 189 string @o=ordstr(@r); 190 changeord(newr,@o,@r); 191 keepring(basering); 192 if (voice==2) { "// basering is now",newr; } 193 return(); 194 } 195 example 196 { "EXAMPLE:"; echo = 2; 197 ring r=0,(x,y,u,v),(dp(2),ds); 198 copyring("R"); R;""; 199 copyring("R1",r); R1; 200 kill R,R1; 201 } 202 /////////////////////////////////////////////////////////////////////////////// 203 172 204 proc defring (string s1, string s2, int n, string s3, string s4) 173 205 USAGE: defring(s1,s2,n,s3,s4); s1..s4=strings, n=integer … … 269 301 270 302 proc extendring (string na, int n, string va, string o, list #) 271 USAGE: extendring(na,n,va,o[iv,i,r]); na,va,o=strings, 303 USAGE: extendring(na,n,va,o[,i,r]); na,va,o=strings (name, new vars, 304 ordering of the new ring), n,i=integers, r=ring 305 CREATE: Define a ring with name `na` which extends the ring r by adding n new 306 variables in front of [after, if i!=0] the old variables and make it 307 the basering [default: (i,r)=(0,basering)] 308 -- The characteristic is the characteristic of r 309 -- The new vars are derived from va. If va is a single letter, say 310 va="T", and if n<=26 then T and the following n-1 letters from 311 T..Z..T (resp. T(1..n) if n>26) are taken as additional variables. 312 If va is a single letter followed by (, say va="x(", the new 313 variables are x(1),...,x(n). 314 If va is a string that contains a comma (e.g. "x,z,u,w"), the 315 comma-separated symbols are taken as new variables 316 -- The ordering is the ordering given by `o` [any allowed ordstr] 317 RETURN: No return value 318 NOTE: This proc is useful for adding deformation parameters. 319 This proc uses 'execute' or calls a procedure using 'execute'. 320 If you use it in your own proc, let the local names of your proc 321 start with @ (see the file HelpForProc) 322 EXAMPLE: example extendring; shows an example 323 { 324 //--------------- initialization and place c/C of ordering properly ----------- 325 string @v,@newring; 326 int @i; 327 if( size(#)==0 ) { #[1]=0; def @r=basering; } 328 else 329 { 330 if( size(#)==1 ) { @i=#[1]; def @r=basering; } 331 if( size(#)==2 ) { @i=#[1]; def @r=#[2]; } 332 } 333 //------------------------ prepare string of new ring ------------------------- 334 @newring = "ring "+na+"=("+charstr(@r)+"),("; 335 if( find(va,",") != 0 ) 336 { @v = va; } 337 else 338 { 339 if( n>26 or va[2]=="(" ) 340 { @v = va[1]+"(1.."+string(n)+")"; } 341 else 342 { @v = A_Z(va,n); } 343 } 344 345 if( @i==0 ) 346 { 347 @v=@v+","+varstr(@r); 348 } 349 else 350 { 351 @v=varstr(@r)+","+@v; 352 } 353 @newring=@newring+@v+"),("+o+");"; 354 //---------------------------- execute and export ----------------------------- 355 execute(@newring); 356 export(basering); 357 keepring(basering); 358 if (voice==2) { "// basering is now",basering; } 359 return(); 360 } 361 example 362 { "EXAMPLE:"; echo = 2; 363 ring r=0,(x,y,z),ds; 364 show(r);""; 365 extendring("R0",2,"u","ds"); 366 show(R0); ""; 367 extendring("R1",2,"a,w","ds(2),dp"); 368 show(R1); ""; 369 extendring("R2",5,"b","dp"); 370 show(R2); ""; 371 extendring("R3",4,"T()","c,dp",1,r); 372 show(R3);""; 373 kill R0,R1,R2,R3; 374 } 375 /////////////////////////////////////////////////////////////////////////////// 376 377 proc extendring1 (string na, int n, string va, string o, list #) 378 USAGE: extendring1(na,n,va,o[iv,i,r]); na,va,o=strings, 272 379 n,i=integers, r=ring, iv=intvec of positive integers or iv=0 273 380 CREATE: Define a ring with name `na` which extends the ring r by adding n new … … 279 386 T..Z..T (resp. T(1..n) if n>26) are taken as additional variables. 280 387 If va is a single letter followed by (, say va="x(", the new 281 variables are x(1),...,x(n) 388 variables are x(1),...,x(n). 389 If va is a string that contains a comma (e.g. "x,z,u,w"), the 390 comma-separated symbols are taken as new variables 282 391 -- The ordering is the product ordering between the ordering of r and 283 392 an ordering derived from `o` [and iv] … … 288 397 like "ds" or "dp(2),wp(1,2,3),Ds(2)" or "ds(a),dp(b),ls" if a and b 289 398 are globally (!) defined integers and if a+b+1<=n 290 If, however, a and b are local to a proc calling extendring , the291 intvec iv must be used to let extendring know the values of a andb399 If, however, a and b are local to a proc calling extendring1, the 400 intvec iv must be used to let extendring1 know the values of a, b 292 401 - If an intvec iv !=0 is given, iv[1],iv[2],... is taken for the 1st, 293 402 2nd,... block of o, if o contains no substring "w" or "W" i.e. no … … 304 413 If you use it in your own proc, let the local names of your proc 305 414 start with @ (see the file HelpForProc) 306 EXAMPLE: example extendring ; shows an example415 EXAMPLE: example extendring1; shows an example 307 416 { 308 417 //--------------- initialization and place c/C of ordering properly ----------- … … 371 480 //------------------------ prepare string of new ring ------------------------- 372 481 @newring = "ring "+na+"=("+charstr(@r)+"),("; 373 if( n>26 or va[2]=="(" ) { @v = va[1]+"(1.."+string(n)+")"; } 374 else { @v = A_Z(va,n); } 482 if( find(va,",") != 0 ) 483 { @v = va; } 484 else 485 { 486 if( n>26 or va[2]=="(" ) 487 { @v = va[1]+"(1.."+string(n)+")"; } 488 else 489 { @v = A_Z(va,n); } 490 } 491 375 492 if( @i==0 ) 376 493 { … … 395 512 ring r=0,(x,y,z),ds; 396 513 show(r);""; 514 extendring1("S",2,"u","ds"); 515 setring r; 516 show(S); ""; 517 extendring1("R0",2,"a,w","ds"); 518 show(R0); ""; 397 519 //no intvec given, no blocksize given: blocksize is derived from no of vars 398 520 int t=5; 399 extendring ("R1",t,"a","dp"); //t global: "dp" -> "dp(5)"521 extendring1("R1",t,"a","dp"); //t global: "dp" -> "dp(5)" 400 522 show(R1); ""; 401 extendring ("R2",4,"T(","c,dp",1,r); //"dp" -> "c,..,dp(4)"523 extendring1("R2",4,"T(","c,dp",1,r); //"dp" -> "c,..,dp(4)" 402 524 show(R2);""; 403 525 404 526 //no intvec given, blocksize given: given blocksize is used 405 extendring ("R3",4,"T(","dp(2)",0,r); // "dp(2)" -> "dp(2)"527 extendring1("R3",4,"T(","dp(2)",0,r); // "dp(2)" -> "dp(2)" 406 528 show(R3);""; 407 529 … … 412 534 //ones are ignored 413 535 intvec v=3,2,3,4,1,3; 414 extendring ("R4",10,"A","ds,ws,Dp,dp",v,0,r);536 extendring1("R4",10,"A","ds,ws,Dp,dp",v,0,r); 415 537 //v covers 3 blocks: v[1] (=3) : no of components of ws 416 538 //next v[1] values (=v[2..4]) give weights 417 539 //remaining components of v are used for the remaining blocks 418 540 show(R4); 419 kill r,R1,R2,R3,R4;541 kill S,R0,R1,R2,R3,R4; 420 542 } 421 543 /////////////////////////////////////////////////////////////////////////////// … … 644 766 } 645 767 /////////////////////////////////////////////////////////////////////////////// 768 769 proc substitute (id, vars, list #) 770 USAGE: substitute(id,vars,li); id = object in basering which can be mapped, 771 vars = ideal expression which must be a list of variables 772 (not counting zeroes and costant factors), 773 li = list of ideal expressions 774 RETURN: id, with i-th entry of vars substituted by i-th polynomial of the 775 ideal (say, conli) obtained by concatenatin of the lists in li; 776 if conli has less polys than size(vars), the last element of conli 777 substitutes the remaining variables in vars 778 EXAMPLE: example substitute; shows an example 779 { 780 int ii,jj,k; 781 def P = basering; 782 int n = nvars(P); 783 ideal va = simplify(vars,3); 784 int sa = size(va); 785 ideal all = #[1..size(#)]; 786 int na = ncols(all); 787 ideal m = maxideal(1); 788 for( jj=1; jj<=sa; jj++) 789 { 790 if( size(va[jj]) > 1) 791 { 792 "// object to be substituted must be a variable"; 793 return(); 794 } 795 for( ii=1; ii<=n; ii++ ) 796 { 797 if( va[jj]/var(ii) != 0 ) 798 { 799 if( jj <= na ) { m[ii] = all[jj]; } 800 else { m[ii] = all[na]; } 801 } 802 } 803 } 804 map phi = P,m; 805 return(phi(id)); 806 } 807 example 808 { "EXAMPLE:"; echo=2; 809 ring r=0,(a,b,t,s,u,v,x,y),ds; 810 poly f=b+y+ax+sx+vy2+ux; 811 ideal vars = a,y,b; 812 ideal subs = t4,1,y+t; 813 // the following commands all define the substitution: 814 // a -> t4, y -> 1, b -> y+t 815 substitute(f,vars,subs); 816 substitute(f,vars,t4,1,y+t); 817 substitute(f,ideal(a)+y+b,t4,1,y+t); 818 // substitute all variables in vars by 1: 819 substitute(f,vars,1); 820 // substitute all variables by 1, except those in vars: 821 substitute(f,substitute(maxideal(1),vars,0),1); 822 } 823 /////////////////////////////////////////////////////////////////////////////// 824 825 proc swapvars (id,poly p1,poly p2) 826 USAGE: swapvars(id,p1,p2); id = object in basering which can be mapped 827 p1, p2 = variables which shall be interchanged 828 RETURN: id, with p1 and p2 interchanged 829 EXAMPLE: example swapvars; shows an example 830 { 831 def bR = basering; 832 execute " ring @newR = ("+charstr(bR)+"),("+varstr(bR)+",@t),dp;"; 833 def id = imap(bR,id); 834 poly p1 = imap(bR,p1); 835 poly p2 = imap(bR,p2); 836 id = substitute(id,p2,@t); 837 id = substitute(id,p1,p2); 838 id = substitute(id,@t,p1); 839 setring bR; 840 id = imap(@newR,id); 841 return(id); 842 } 843 } 844 example 845 { "EXAMPLE:"; echo=2; 846 ring r; 847 poly f = x5+y3+z2; 848 swapvars(f,x,y); 849 } 850 ///////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.