Changeset 6fe3a0 in git for Singular/LIB/ring.lib
- Timestamp:
- Apr 25, 2005, 12:13:07 PM (19 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- 3329dd9bcf2662f9666579abea56c33dfcb530ac
- Parents:
- 8604751c5a5f572004bf8d35d4307e485b728435
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/ring.lib
r860475 r6fe3a0 1 //(GMG, last modified 03.11.95) 2 /////////////////////////////////////////////////////////////////////////////// 3 version="$Id: ring.lib,v 1.20 2005-04-15 13:42:55 Singular Exp $"; 1 /////////////////////////////////////////////////////////////////////////////// 2 version="$Id: ring.lib,v 1.21 2005-04-25 10:13:06 Singular Exp $"; 4 3 category="General purpose"; 5 4 info=" … … 183 182 /////////////////////////////////////////////////////////////////////////////// 184 183 185 proc defring (string s1, string s2, int n, string s3, string s4) 186 "USAGE: defring(s1,s2,n,s3,s4); s1..s4=strings, n=integer 187 CREATE: Define a ring with name 's1', characteristic 's2', ordering 's4' and 188 n variables with names derived from s3 and make it the basering. 189 If s3 is a single letter, say s3=\"a\", and if n<=26 then a and the 190 following n-1 letters from the alphabeth (cyclic order) are taken as 191 variables. If n>26 or if s3 is a single letter followed by (, say 192 s3=\"T(\", the variables are T(1),...,T(n). 193 RETURN: No return value 184 proc defring (string s2, int n, string s3, string s4) 185 "USAGE: defring(ch,n,va,or); ch,va,or=strings, n=integer 186 RETURN: ring R with characteristic 'ch', ordering 'or' and n variables with 187 names derived from va. 188 If va is a single letter, say va=\"a\", and if n<=26 then a and the 189 following n-1 letters from the alphabet (cyclic order) are taken as 190 variables. If n>26 or if va is a single letter followed by a bracket, 191 say va=\"T(\", the variables are T(1),...,T(n). 194 192 NOTE: This proc is useful for defining a ring in a procedure. 195 193 This proc uses 'execute' or calls a procedure using 'execute'. 196 If you use it in your own proc, let the local names of your proc197 start with@.194 If you use it in your own proc, it may be advisable to let the local 195 names of your proc start with a @. 198 196 EXAMPLE: example defring; shows an example 199 197 " 200 198 { 201 string @newring = "ring "+s1+"=("+s2+"),(";199 string @newring = "ring newring =("+s2+"),("; 202 200 if( n>26 or s3[2]=="(" ) { string @v = s3[1]+"(1.."+string(n)+")"; } 203 201 else { string @v = A_Z(s3,n); } 204 202 @newring=@newring+@v+"),("+s4+");"; 205 203 execute(@newring); 206 export(basering); 207 keepring(`s1`); 208 if (voice==2) { "// basering is now:",s1; } 209 return(); 204 return(newring); 210 205 } 211 206 example 212 207 { "EXAMPLE:"; echo = 2; 213 defring("r","0",5,"u","ls"); r; ""; 214 defring("R","2,A",10,"x(","dp(3),ws(1,2,3),ds"); R; 215 if(system("with","Namespaces")) { kill Top::R,Top::r; } 216 if (defined(R)) {kill R,r;} 208 def r=defring("0",5,"u","ls"); r; setring r;""; 209 def R=defring("2,A",10,"x(","dp(3),ws(1,2,3),ds"); R; setring R; 210 kill R,r; 217 211 } 218 212 /////////////////////////////////////////////////////////////////////////////// … … 287 281 /////////////////////////////////////////////////////////////////////////////// 288 282 289 proc extendring ( string na,int n, string va, string o, list #)290 "USAGE: extendring(n a,n,va,o[iv,i,r]); na,va,o=strings,291 n,i=integers, r=ring,iv=intvec of positive integers or iv=0292 CREATE: Define a ring with name `na` which extends the ring r by adding n new 293 variables in front of [after, if i!=0] the old variables and make it294 the basering[default: (i,r)=(0,basering)].283 proc extendring (int n, string va, string o, list #) 284 "USAGE: extendring(n,va,o[iv,i,r]); va,o=strings, n,i=integers, r=ring, 285 iv=intvec of positive integers or iv=0 286 RETURN: ring R, which extends the ring r by adding n new variables in front 287 of (resp. after, if i!=0) the old variables. 288 [default: (i,r)=(0,basering)]. 295 289 @* -- The characteristic is the characteristic of r. 296 290 @* -- The new vars are derived from va. If va is a single letter, say 297 291 va=\"T\", and if n<=26 then T and the following n-1 letters from 298 292 T..Z..T (resp. T(1..n) if n>26) are taken as additional variables. 299 If va is a single letter followed by (, say va=\"x(\", the new300 variables are x(1),...,x(n).301 @* -- The ordering is the product ordering between the ordering of r and302 anordering derived from `o` [and iv].303 @* - If o contains a 'c' or a 'C' in front resp. at the end this is304 taken for the whole ordering in front resp. at the end. If o does293 If va is a single letter followed by a bracket, say va=\"x(\", 294 the new variables are x(1),...,x(n). 295 @* -- The ordering is the product ordering of the ordering of r and of an 296 ordering derived from `o` [and iv]. 297 @* - If o contains a 'c' or a 'C' in front resp. at the end, this is 298 taken for the whole ordering in front, resp. at the end. If o does 305 299 not contain a 'c' or a 'C' the same rule applies to ordstr(r). 306 300 @* - If no intvec iv is given, or if iv=0, o may be any allowed ordstr, … … 319 313 e.g. o=\"dp,ws,Dp,ds\", iv=3,2,3,4,2,5 creates the ordering 320 314 dp(2),ws(2,3,4),Dp(5),ds 321 RETURN: No return value322 315 NOTE: This proc is useful for adding deformation parameters. 323 316 This proc uses 'execute' or calls a procedure using 'execute'. 324 If you use it in your own proc, let the local names of your proc325 start with@ (see the file HelpForProc)317 If you use it in your own proc, it may be advisable to let the local 318 names of your proc start with a @ (see the file HelpForProc) 326 319 EXAMPLE: example extendring; shows an example 327 320 " … … 391 384 } 392 385 //------------------------ prepare string of new ring ------------------------- 393 @newring = "ring "+na+"=("+charstr(@r)+"),(";386 @newring = "ring na =("+charstr(@r)+"),("; 394 387 if( n>26 or va[2]=="(" ) { @v = va[1]+"(1.."+string(n)+")"; } 395 388 else { @v = A_Z(va,n); } … … 407 400 //---------------------------- execute and export ----------------------------- 408 401 execute(@newring); 409 export(basering); 410 keepring(`na`); 411 if (voice==2) { "// basering is now",na; } 412 return(); 402 dbprint(printlevel-voice+2," 403 // 'extendring' created a new ring. 404 // To see the ring, type (if the name 'R' was assigned to the return value): 405 show(R); 406 "); 407 408 return(na); 413 409 } 414 410 example … … 416 412 ring r=0,(x,y,z),ds; 417 413 show(r);""; 418 // blocksize is derived from no of vars:414 // blocksize is derived from no of vars: 419 415 int t=5; 420 extendring("R1",t,"a","dp"); //t global: "dp" -> "dp(5)"421 show(R1); "";422 extendring("R2",4,"T(","c,dp",1,r); //"dp" -> "c,..,dp(4)"423 show(R2); "";424 425 // no intvec given, blocksize given: given blocksize is used:426 extendring("R3",4,"T(","dp(2)",0,r); // "dp(2)" -> "dp(2)"427 show(R3); "";428 429 // intvec given: weights and blocksize is derived from given intvec430 // (no specification of a blocksize in the given ordstr is allowed!)431 // if intvec does not cover all given blocks, the last block is used432 // for the remaining variables, if intvec has too many components,433 // the last ones are ignored416 def R1=extendring(t,"a","dp"); //t global: "dp" -> "dp(5)" 417 show(R1); setring R1; ""; 418 def R2=extendring(4,"T(","c,dp",1,r); //"dp" -> "c,..,dp(4)" 419 show(R2); setring R2; ""; 420 421 // no intvec given, blocksize given: given blocksize is used: 422 def R3=extendring(4,"T(","dp(2)",0,r); // "dp(2)" -> "dp(2)" 423 show(R3); setring R3; ""; 424 425 // intvec given: weights and blocksize is derived from given intvec 426 // (no specification of a blocksize in the given ordstr is allowed!) 427 // if intvec does not cover all given blocks, the last block is used 428 // for the remaining variables, if intvec has too many components, 429 // the last ones are ignored 434 430 intvec v=3,2,3,4,1,3; 435 extendring("R4",10,"A","ds,ws,Dp,dp",v,0,r);436 //v covers 3 blocks: v[1] (=3) : no of components of ws437 //next v[1] values (=v[2..4]) give weights438 //remaining components of v are used for the remaining blocks431 def R4=extendring(10,"A","ds,ws,Dp,dp",v,0,r); 432 // v covers 3 blocks: v[1] (=3) : no of components of ws 433 // next v[1] values (=v[2..4]) give weights 434 // remaining components of v are used for the remaining blocks 439 435 show(R4); 440 if(system("with","Namespaces")){kill Top::r,Top::R1,Top::R2,Top::R3,Top::R4;} 441 if (defined(r)) { kill r,R1,R2,R3,R4; } 436 kill r,R1,R2,R3,R4; 442 437 } 443 438 ///////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.