Changeset 6f2edc in git for Singular/LIB/ring.lib
- Timestamp:
- Apr 28, 1997, 9:27:25 PM (27 years ago)
- Branches:
- (u'spielwiese', 'd1b01e9d51ade4b46b745d3bada5c5f3696be3a8')
- Children:
- 8c5a578cc8481c8a133a58030c4c4c8227d82bb1
- Parents:
- 6d09c564c80f079b501f7187cf6984d040603849
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/ring.lib
r6d09c56 r6f2edc 1 // $Id: ring.lib,v 1. 1.1.1 1997-04-25 15:13:27obachman Exp $2 //(GMG, 95/11/3)3 /////////////////////////////////////////////////////////////////////////////// 4 5 LIBRARY: ring.lib PROCEDURES FOR MANIPULATING RINGS AND MAPS 1 // $Id: ring.lib,v 1.2 1997-04-28 19:27:25 obachman Exp $ 2 //(GMG, last modified 03.11.95) 3 /////////////////////////////////////////////////////////////////////////////// 4 5 LIBRARY: ring.lib PROCEDURES FOR MANIPULATING RINGS AND MAPS 6 6 7 7 changechar("R",c[,r]); make a copy R of basering [ring r] with new char c … … 25 25 USAGE: changechar(newr,c[,r]); newr,c=strings, r=ring 26 26 CREATE: create a new ring with name `newr` and make it the basering if r is 27 an existing ring [default: r=basering]. 27 an existing ring [default: r=basering]. 28 28 The new ring differs from the old ring only in the characteristic. 29 If, say, (newr,c) = ("R","0,A") and the ring r exists, the new 29 If, say, (newr,c) = ("R","0,A") and the ring r exists, the new 30 30 basering will have name R characteristic 0 and one parameter A. 31 31 RETURN: No return value 32 32 NOTE: Works for qrings if map from old_char to new_char is implemented 33 This proc uses 'execute' or calls a procedure using 'execute'. 34 If you use it in your own proc, let the local names of your proc 33 This proc uses 'execute' or calls a procedure using 'execute'. 34 If you use it in your own proc, let the local names of your proc 35 35 start with @ (see the file HelpForProc) 36 36 EXAMPLE: example changechar; shows an example … … 40 40 setring @r; 41 41 ideal i = ideal(@r); int @q = size(i); 42 if( @q!=0 ) 42 if( @q!=0 ) 43 43 { string @s = "@newr1"; } 44 else 44 else 45 45 { string @s = newr; } 46 46 string @newring = @s+"=("+c+"),("+varstr(@r)+"),("+ordstr(@r)+");"; … … 51 51 ideal i = phi(i); 52 52 attrib(i,"isSB",1); //*** attrib funktioniert ? 53 execute("qring "+newr+"=i;"); 53 execute("qring "+newr+"=i;"); 54 54 } 55 55 export(`newr`); … … 70 70 USAGE: changeord(newr,o[,r]); newr,o=strings, r=ring/qring 71 71 CREATE: create a new ring with name `newr` and make it the basering if r is 72 an existing ring/qring [default: r=basering]. 72 an existing ring/qring [default: r=basering]. 73 73 The new ring differs from the old ring only in the ordering. If, say, 74 (newr,o) = ("R","wp(2,3),dp") and the ring r exists and has >=3 74 (newr,o) = ("R","wp(2,3),dp") and the ring r exists and has >=3 75 75 variables, the new basering will have name R and ordering wp(2,3),dp. 76 76 RETURN: No return value 77 NOTE: This proc uses 'execute' or calls a procedure using 'execute'. 78 If you use it in your own proc, let the local names of your proc 77 NOTE: This proc uses 'execute' or calls a procedure using 'execute'. 78 If you use it in your own proc, let the local names of your proc 79 79 start with @ (see the file HelpForProc) 80 80 EXAMPLE: example changeord; shows an example … … 84 84 setring @r; 85 85 ideal i = ideal(@r); int @q = size(i); 86 if( @q!=0 ) 86 if( @q!=0 ) 87 87 { string @s = "@newr1"; } 88 else 88 else 89 89 { string @s = newr; } 90 90 string @newring = @s+"=("+charstr(@r)+"),("+varstr(@r)+"),("+o+");"; … … 95 95 ideal i = phi(i); 96 96 attrib(i,"isSB",1); //*** attrib funktioniert ? 97 execute("qring "+newr+"=i;"); 97 execute("qring "+newr+"=i;"); 98 98 } 99 99 export(`newr`); … … 116 116 USAGE: changevar(newr,vars[,r]); newr,vars=strings, r=ring/qring 117 117 CREATE: creates a new ring with name `newr` and makes it the basering if r 118 is an existing ring/qring [default: r=basering]. 118 is an existing ring/qring [default: r=basering]. 119 119 The new ring differs from the old ring only in the variables. If, 120 say, (newr,vars) = ("R","t()") and the ring r exists and has n 121 variables, the new basering will have name R and variables 120 say, (newr,vars) = ("R","t()") and the ring r exists and has n 121 variables, the new basering will have name R and variables 122 122 t(1),...,t(n). 123 If vars = "a,b,c,d", the new ring will have the variables a,b,c,d. 123 If vars = "a,b,c,d", the new ring will have the variables a,b,c,d. 124 124 RETURN: No return value 125 125 NOTE: This procedure is useful in connection with the procedure ringtensor, 126 126 when a conflict between variable names must be avoided. 127 This proc uses 'execute' or calls a procedure using 'execute'. 128 If you use it in your own proc, let the local names of your proc 127 This proc uses 'execute' or calls a procedure using 'execute'. 128 If you use it in your own proc, let the local names of your proc 129 129 start with @ (see the file HelpForProc) 130 130 EXAMPLE: example changevar; shows an example … … 134 134 setring @r; 135 135 ideal i = ideal(@r); int @q = size(i); 136 if( @q!=0 ) 136 if( @q!=0 ) 137 137 { string @s = "@newr1"; } 138 else 138 else 139 139 { string @s = newr; } 140 140 string @newring = @s+"=("+charstr(@r)+"),("; 141 141 if( vars[size(vars)-1]=="(" and vars[size(vars)]==")" ) 142 { 143 @newring = @newring+vars[1,size(vars)-2]+"(1.."+string(nvars(@r))+")"; 142 { 143 @newring = @newring+vars[1,size(vars)-2]+"(1.."+string(nvars(@r))+")"; 144 144 } 145 145 else { @newring = @newring+vars; } … … 151 151 ideal i = phi(i); 152 152 attrib(i,"isSB",1); //*** attrib funktioniert ? 153 execute("qring "+newr+"=i;"); 153 execute("qring "+newr+"=i;"); 154 154 } 155 155 export(`newr`); … … 174 174 CREATE: Define a ring with name 's1', characteristic 's2', ordering 's4' and 175 175 n variables with names derived from s3 and make it the basering. 176 If s3 is a single letter, say s3="a", and if n<=26 then a and the 177 following n-1 letters from the alphabeth (cyclic order) are taken as 178 variables. If n>26 or if s3 is a single letter followed by (, say 179 s3="T(", the variables are T(1),...,T(n). 176 If s3 is a single letter, say s3="a", and if n<=26 then a and the 177 following n-1 letters from the alphabeth (cyclic order) are taken as 178 variables. If n>26 or if s3 is a single letter followed by (, say 179 s3="T(", the variables are T(1),...,T(n). 180 180 RETURN: No return value 181 181 NOTE: This proc is useful for defining a ring in a procedure. 182 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 182 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 184 start with @ (see the file HelpForProc) 185 185 EXAMPLE: example defring; shows an example … … 258 258 execute("keepring P"+string(n)+";"); 259 259 //the next comment is only shown if defringp is not called by another proc 260 if (voice==2) { "// basering is now:",s; } 261 } 260 if (voice==2) { "// basering is now:",s; } 261 } 262 262 example 263 263 { "EXAMPLE:"; echo = 2; … … 269 269 270 270 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, 271 USAGE: extendring(na,n,va,o[iv,i,r]); na,va,o=strings, 272 272 n,i=integers, r=ring, iv=intvec of positive integers or iv=0 273 273 CREATE: Define a ring with name `na` which extends the ring r by adding n new … … 275 275 the basering [default: (i,r)=(0,basering)] 276 276 -- The characteristic is the characteristic of r 277 -- The new vars are derived from va. If va is a single letter, say 278 va="T", and if n<=26 then T and the following n-1 letters from 279 T..Z..T (resp. T(1..n) if n>26) are taken as additional variables. 280 If va is a single letter followed by (, say va="x(", the new 277 -- The new vars are derived from va. If va is a single letter, say 278 va="T", and if n<=26 then T and the following n-1 letters from 279 T..Z..T (resp. T(1..n) if n>26) are taken as additional variables. 280 If va is a single letter followed by (, say va="x(", the new 281 281 variables are x(1),...,x(n) 282 282 -- The ordering is the product ordering between the ordering of r and 283 283 an ordering derived from `o` [and iv] 284 - If o contains a 'c' or a 'C' in front resp. at the end this is 284 - If o contains a 'c' or a 'C' in front resp. at the end this is 285 285 taken for the whole ordering in front resp. at the end. If o does 286 286 not contain a 'c' or a 'C' the same rule applies to ordstr(r). 287 287 - If no intvec iv is given, or if iv=0, o may be any allowed ordstr, 288 288 like "ds" or "dp(2),wp(1,2,3),Ds(2)" or "ds(a),dp(b),ls" if a and b 289 are globally (!) defined integers and if a+b+1<=n 290 If, however, a and b are local to a proc calling extendring, the 291 intvec iv must be used to let extendring know the values of a and b 289 are globally (!) defined integers and if a+b+1<=n 290 If, however, a and b are local to a proc calling extendring, the 291 intvec iv must be used to let extendring know the values of a and b 292 292 - If an intvec iv !=0 is given, iv[1],iv[2],... is taken for the 1st, 293 2nd,... block of o, if o contains no substring "w" or "W" i.e. no 294 weighted ordering (in the above case o="ds,dp,ls" and iv=a,b). 295 If o contains a weighted ordering (only one (!) weighted block is 296 allowed) iv[1] is taken as size for the weight-vector, the next 293 2nd,... block of o, if o contains no substring "w" or "W" i.e. no 294 weighted ordering (in the above case o="ds,dp,ls" and iv=a,b). 295 If o contains a weighted ordering (only one (!) weighted block is 296 allowed) iv[1] is taken as size for the weight-vector, the next 297 297 iv[1] values of iv are taken as weights and the remaining values of 298 iv as block-size for the remaining non-weighted blocks. 299 e.g. o="dp,ws,Dp,ds", iv=3,2,3,4,2,5 creates the ordering 298 iv as block-size for the remaining non-weighted blocks. 299 e.g. o="dp,ws,Dp,ds", iv=3,2,3,4,2,5 creates the ordering 300 300 dp(2),ws(2,3,4),Dp(5),ds 301 301 RETURN: No return value 302 302 NOTE: This proc is useful for adding deformation parameters. 303 This proc uses 'execute' or calls a procedure using 'execute'. 304 If you use it in your own proc, let the local names of your proc 303 This proc uses 'execute' or calls a procedure using 'execute'. 304 If you use it in your own proc, let the local names of your proc 305 305 start with @ (see the file HelpForProc) 306 306 EXAMPLE: example extendring; shows an example 307 307 { 308 308 //--------------- initialization and place c/C of ordering properly ----------- 309 string @o1,@o2,@ro,@wstr,@v,@newring; 309 string @o1,@o2,@ro,@wstr,@v,@newring; 310 310 int @i,@w,@ii,@k; 311 311 intvec @iv,@iw; … … 331 331 } 332 332 @ro=ordstr(@r); 333 if( @ro[1]=="c" or @ro[1]=="C" ) 333 if( @ro[1]=="c" or @ro[1]=="C" ) 334 334 { @v=@ro[1,2]; @ro=@ro[3..size(@ro)]; } 335 else 335 else 336 336 { @wstr=@ro[size(@ro)-1,2]; @ro=@ro[1..size(@ro)-2]; } 337 337 if( @k==0) { @o1=@v; @o2=@wstr; } … … 341 341 @k=n; //@k counts no of vars not yet ordered 342 342 @w=find(o,"w")+find(o,"W");o=o+" "; 343 if( @w!=0 ) 344 { 345 @wstr=o[@w..@w+1]; 343 if( @w!=0 ) 344 { 345 @wstr=o[@w..@w+1]; 346 346 o=o[1,@w-1]+"@"+o[@w+2,size(o)]; 347 347 @iw=@iv[2..@iv[1]+1]; 348 348 @wstr=@wstr+"("+string(@iw)+")"; 349 @k=@k-@iv[1]; 349 @k=@k-@iv[1]; 350 350 @iv=@iv[@iv[1]+2..size(@iv)]; 351 351 @w=0; 352 352 } 353 for( @ii=1; @ii<=size(@iv); @ii ++)353 for( @ii=1; @ii<=size(@iv); @ii=@ii+1 ) 354 354 { 355 355 if( find(o,",",@w+1)!=0 ) … … 357 357 @w=find(o,",",@w+1); 358 358 if( o[@w-1]!="@" ) 359 { 360 o=o[1,@w-1]+"("+string(@iv[@ii])+")"+o[@w,size(o)]; 359 { 360 o=o[1,@w-1]+"("+string(@iv[@ii])+")"+o[@w,size(o)]; 361 361 @w=find(o,",",@w+1); 362 362 @k=@k-@iv[@ii]; … … 373 373 if( n>26 or va[2]=="(" ) { @v = va[1]+"(1.."+string(n)+")"; } 374 374 else { @v = A_Z(va,n); } 375 if( @i==0 ) 376 { 377 @v=@v+","+varstr(@r); 378 o=@o1+o+","+@ro+@o2; 379 } 380 else 381 { 382 @v=varstr(@r)+","+@v; 383 o=@o1+@ro+","+o+@o2; 375 if( @i==0 ) 376 { 377 @v=@v+","+varstr(@r); 378 o=@o1+o+","+@ro+@o2; 379 } 380 else 381 { 382 @v=varstr(@r)+","+@v; 383 o=@o1+@ro+","+o+@o2; 384 384 } 385 385 @newring=@newring+@v+"),("+o+");"; … … 394 394 { "EXAMPLE:"; echo = 2; 395 395 ring r=0,(x,y,z),ds; 396 show(r);""; 396 show(r);""; 397 397 //no intvec given, no blocksize given: blocksize is derived from no of vars 398 int t=5; 398 int t=5; 399 399 extendring("R1",t,"a","dp"); //t global: "dp" -> "dp(5)" 400 400 show(R1); ""; … … 411 411 //the remaining variables, if intvec has too many components, the last 412 412 //ones are ignored 413 intvec v=3,2,3,4,1,3; 414 extendring("R4",10,"A","ds,ws,Dp,dp",v,0,r); 415 //v covers 3 blocks: v[1] (=3) : no of components of ws 413 intvec v=3,2,3,4,1,3; 414 extendring("R4",10,"A","ds,ws,Dp,dp",v,0,r); 415 //v covers 3 blocks: v[1] (=3) : no of components of ws 416 416 //next v[1] values (=v[2..4]) give weights 417 417 //remaining components of v are used for the remaining blocks … … 421 421 /////////////////////////////////////////////////////////////////////////////// 422 422 423 proc fetchall (R, list #) 423 proc fetchall (R, list #) 424 424 USAGE: fetchall(R[,s]); R=ring/qring, s=string 425 425 CREATE: fetch all objects of ring R (of type poly/ideal/vector/module/number/ … … 427 427 If no 3rd argument is present, the names are the same as in R. If, 428 428 say, f is a poly in R and the 3rd argument is the string "R", then f 429 is maped to f_R etc. 429 is maped to f_R etc. 430 430 RETURN: no return value 431 431 NOTE: As fetch, this procedure maps the 1st, 2nd, ... variable of R to the 432 1st, 2nd, ... variable of the basering. 432 1st, 2nd, ... variable of the basering. 433 433 The 3rd argument is useful in order to avoid conflicts of names, the 434 434 empty string is allowed 435 435 CAUTION: fetchall does not work inside a procedure 436 //***at the moment it does not work if R contains a map 436 //***at the moment it does not work if R contains a map 437 437 EXAMPLE: example fetchall; shows an example 438 { 438 { 439 439 list @L@=names(R); 440 440 int @ii@; string @s@; 441 441 if( size(#) > 0 ) { @s@=@s@+"_"+#[1]; } 442 for( @ii@=size(@L@); @ii@>0; @ii@ --)443 { 442 for( @ii@=size(@L@); @ii@>0; @ii@=@ii@-1 ) 443 { 444 444 execute("def "+@L@[@ii@]+@s@+"=fetch(R,`@L@[@ii@]`);"); 445 445 execute("export "+@L@[@ii@]+@s@+";"); … … 465 465 /////////////////////////////////////////////////////////////////////////////// 466 466 467 proc imapall (R, list #) 467 proc imapall (R, list #) 468 468 USAGE: imapall(R[,s]); R=ring/qring, s=string 469 469 CREATE: map all objects of ring R (of type poly/ideal/vector/module/number/ … … 471 471 If no 3rd argument is present, the names are the same as in R. If, 472 472 say, f is a poly in R and the 3rd argument is the string "R", then f 473 is maped to f_R etc. 473 is maped to f_R etc. 474 474 RETURN: no return value 475 475 NOTE: As imap, this procedure maps the variables of R to the variables with … … 478 478 empty string is allowed 479 479 CAUTION: imapall does not work inside a procedure 480 //***at the moment it does not work if R contains a map 480 //***at the moment it does not work if R contains a map 481 481 EXAMPLE: example imapall; shows an example 482 { 482 { 483 483 list @L@=names(R); 484 484 int @ii@; string @s@; 485 485 if( size(#) > 0 ) { @s@=@s@+"_"+#[1]; } 486 for( @ii@=size(@L@); @ii@>0; @ii@ --)487 { 486 for( @ii@=size(@L@); @ii@>0; @ii@=@ii@-1 ) 487 { 488 488 execute("def "+@L@[@ii@]+@s@+"=imap(R,`@L@[@ii@]`);"); 489 489 execute("export "+@L@[@ii@]+@s@+";"); … … 509 509 /////////////////////////////////////////////////////////////////////////////// 510 510 511 proc mapall (R, ideal i, list #) 511 proc mapall (R, ideal i, list #) 512 512 USAGE: mapall(R,i[,s]); R=ring/qring, i=ideal of basering, s=string 513 CREATE: map all objects of ring R (of type poly/ideal/vector/module/number/ 513 CREATE: map all objects of ring R (of type poly/ideal/vector/module/number/ 514 514 matrix, map) into the basering, by mapping the jth variable of R to 515 515 the jth generator of the ideal i. If no 3rd argument is present, the 516 names are the same as in R. If, say, f is a poly in R and the 3rd 517 argument is the string "R", then f is maped to f_R etc. 516 names are the same as in R. If, say, f is a poly in R and the 3rd 517 argument is the string "R", then f is maped to f_R etc. 518 518 RETURN: no return value 519 519 NOTE: This procedure has the same effect as defining a map, say psi, by 520 520 map psi=R,i; and then applying psi to all objects of R. In particular, 521 521 maps from R to some ring S are composed with psi, creating thus a map 522 from the basering to S. 522 from the basering to S. 523 523 mapall may be combined with copyring to change vars for all objects. 524 524 The 3rd argument is useful in order to avoid conflicts of names, the 525 525 empty string is allowed 526 CAUTION: mapall does not work inside a procedure 526 CAUTION: mapall does not work inside a procedure 527 527 EXAMPLE: example mapall; shows an example 528 { 528 { 529 529 list @L@=names(R); map @psi@ = R,i; 530 530 int @ii@; string @s@; 531 531 if( size(#) > 0 ) { @s@=@s@+"_"+#[1]; } 532 for( @ii@=size(@L@); @ii@>0; @ii@ --)533 { 532 for( @ii@=size(@L@); @ii@>0; @ii@=@ii@-1 ) 533 { 534 534 execute("def "+@L@[@ii@]+@s@+"=@psi@(`@L@[@ii@]`);"); 535 535 execute("export "+@L@[@ii@]+@s@+";"); … … 544 544 " ideal j=x,y,z;"; 545 545 " matrix M[2][3]=1,2,3,x,y,z;"; 546 " map phi=R,x2,y2,z2; "; 546 " map phi=R,x2,y2,z2; "; 547 547 " ring S=0,(a,b,c),ds;"; 548 548 " ideal i=c,a,b;"; … … 565 565 USAGE: ringtensor(s,r1,r2,...); s=string, r1,r2,...=rings 566 566 CREATE: A new base ring with name `s` if r1,r2,... are existing rings. 567 If, say, s = "R" and the rings r1,r2,... exist, the new ring will 568 have name R, variables from all rings r1,r2,... and as monomial 567 If, say, s = "R" and the rings r1,r2,... exist, the new ring will 568 have name R, variables from all rings r1,r2,... and as monomial 569 569 ordering the block (product) ordering of r1,r2,... . Hence, R 570 570 is the tensor product of the rings r1,r2,... with ordering matrix … … 576 576 variable with name x in r1, there is no access to x in r2). 577 577 The procedure works also for quotient rings ri, if the characteristic 578 of ri is compatible with the characteristic of r1 (i.e. if imap from 578 of ri is compatible with the characteristic of r1 (i.e. if imap from 579 579 ri to r1 is implemented) 580 This proc uses 'execute' or calls a procedure using 'execute'. 581 If you use it in your own proc, let the local names of your proc 580 This proc uses 'execute' or calls a procedure using 'execute'. 581 If you use it in your own proc, let the local names of your proc 582 582 start with @ (see the file HelpForProc) 583 583 EXAMPLE: example ringtensor; shows an example … … 587 587 string @vars,@order,@oi,@s1; 588 588 //---- gather variables, orderings and ideals (of qrings) from given rings ---- 589 for(@ii=1; @ii<=@n; @ii ++)590 { 591 if( ordstr(#[@ii])[1]=="C" or ordstr(#[@ii])[1]=="c" ) 589 for(@ii=1; @ii<=@n; @ii=@ii+1) 590 { 591 if( ordstr(#[@ii])[1]=="C" or ordstr(#[@ii])[1]=="c" ) 592 592 { @oi=ordstr(#[@ii])[3,size(ordstr(#[@ii]))-2]; } 593 593 else { @oi=ordstr(#[@ii])[1,size(ordstr(#[@ii]))-2]; } … … 596 596 def @r(@ii)=#[@ii]; 597 597 setring @r(@ii); 598 ideal i(@ii)=ideal(@r(@ii)); 598 ideal i(@ii)=ideal(@r(@ii)); 599 599 int @q(@ii)=size(i(@ii)); 600 600 @q=@q+@q(@ii); … … 610 610 { 611 611 ideal i; 612 for(@ii=1; @ii<=@n; @ii ++)612 for(@ii=1; @ii<=@n; @ii=@ii+1) 613 613 { 614 614 if( @q(@ii)!=0 ) … … 618 618 } 619 619 i=std(i); 620 execute("qring "+s+"=i;"); 620 execute("qring "+s+"=i;"); 621 621 } 622 622 //----------------------- export and keep created ring ------------------------ … … 626 626 return(); 627 627 } 628 example 628 example 629 629 { "EXAMPLE:"; echo = 2; 630 630 ring r=32003,(x,y,u,v),dp; 631 631 ring s=0,(a,b,c),wp(1,2,3); 632 632 ring t=0,x(1..5),(c,ls); 633 ringtensor("R",r,s,t); 633 ringtensor("R",r,s,t); 634 634 type R;""; 635 635 setring s; … … 639 639 changevar("T","d,e,f,g,h",t); //set T (change vars of t to d..h) the basering 640 640 qring qT=std(d2+e2-f3); //create qring of T mod d2+e2-f3 641 ringtensor("Q",s,qS,t,qT); 641 ringtensor("Q",s,qS,t,qT); 642 642 type Q; 643 643 kill R,Q,S,T;
Note: See TracChangeset
for help on using the changeset viewer.