Changeset 8647dd in git
- Timestamp:
- Apr 28, 2005, 11:21:59 AM (18 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
- Children:
- daa83bcd8a2f618d74ab2877569d0c88d17bece7
- Parents:
- 5bc4ee3956b1cef3f4a576f97eafb4340ddfc133
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/ring.lib
r5bc4ee3 r8647dd 1 1 /////////////////////////////////////////////////////////////////////////////// 2 version="$Id: ring.lib,v 1.2 1 2005-04-25 10:13:06Singular Exp $";2 version="$Id: ring.lib,v 1.22 2005-04-28 09:21:59 Singular Exp $"; 3 3 category="General purpose"; 4 4 info=" … … 28 28 /////////////////////////////////////////////////////////////////////////////// 29 29 30 proc changechar (string newr, string c, list #) 31 "USAGE: changechar(newr,c[,r]); newr,c=strings, r=ring 32 CREATE: create a new ring with name `newr` and make it the basering if r is 33 an existing ring [default: r=basering]. 34 The new ring differs from the old ring only in the characteristic. 35 If, say, (newr,c) = (\"R\",\"0,A\") and the ring r exists, the new 36 basering will have name R, characteristic 0 and one parameter A. 37 RETURN: No return value 38 NOTE: Works for qrings if map from old_char to new_char is implemented 30 proc changechar (string c, list #) 31 "USAGE: changechar(c[,r]); c=string, r=ring 32 RETURN: ring R, obtained from the ring r [default: r=basering], by changing 33 charstr(r) to c. 34 NOTE: Works for qrings if map from old_char to new_char is implemented. 39 35 This proc uses 'execute' or calls a procedure using 'execute'. 40 If you use it in your own proc, let the local names of your proc41 start with @.42 36 EXAMPLE: example changechar; shows an example 37 " 38 { 39 if( size(#)==0 ) { def @r=basering; } 40 if(( size(#)==1 ) and (typeof(#[1])=="ring")) { def @r=#[1]; } 41 setring @r; 42 ideal i = ideal(@r); int @q = size(i); 43 if( @q!=0 ) 44 { string @s = "Rnew1"; } 45 else 46 { string @s = "Rnew"; } 47 string @newring = @s+"=("+c+"),("+varstr(@r)+"),("+ordstr(@r)+");"; 48 execute("ring "+@newring); 49 if( @q!=0 ) 50 { 51 map phi = @r,maxideal(1); 52 ideal i = phi(i); 53 attrib(i,"isSB",1); //*** attrib funktioniert ? 54 qring Rnew=i; 55 } 56 return(Rnew); 57 } 58 example 59 { "EXAMPLE:"; echo = 2; 60 ring r=0,(x,y,u,v),(dp(2),ds); 61 def R=changechar("2,A"); R;""; 62 def R1=changechar("32003",R); R1; 63 kill R,R1; 64 } 65 /////////////////////////////////////////////////////////////////////////////// 66 67 proc changeord (string o, list #) 68 "USAGE: changeord(newordstr[,r]); newordstr=string, r=ring/qring 69 RETURN: ring R, obtained from the ring r [default: r=basering], by changing 70 ordstr(r) to newordstr. If, say, newordstr=(\"R\",\"wp(2,3),dp\") and 71 if the ring r exists and has >=3 variables, the ring R will be 72 equipped with the monomial ordering wp(2,3),dp. 73 NOTE: This proc uses 'execute' or calls a procedure using 'execute'. 74 EXAMPLE: example changeord; shows an example 43 75 " 44 76 { … … 48 80 ideal i = ideal(@r); int @q = size(i); 49 81 if( @q!=0 ) 50 { string @s = " @newr1"; }82 { string @s = "Rnew1"; } 51 83 else 52 { string @s = newr; }53 string @newring = @s+"=("+c +"),("+varstr(@r)+"),("+ordstr(@r)+");";84 { string @s = "Rnew"; } 85 string @newring = @s+"=("+charstr(@r)+"),("+varstr(@r)+"),("+o+");"; 54 86 execute("ring "+@newring); 55 87 if( @q!=0 ) … … 58 90 ideal i = phi(i); 59 91 attrib(i,"isSB",1); //*** attrib funktioniert ? 60 execute("qring "+newr+"=i;"); 61 } 62 export(`newr`); 63 keepring(`newr`); 64 if (voice==2) { "// basering is now",newr; } 65 return(); 92 qring Rnew=i; 93 } 94 return(Rnew); 66 95 } 67 96 example 68 97 { "EXAMPLE:"; echo = 2; 69 98 ring r=0,(x,y,u,v),(dp(2),ds); 70 changechar("R","2,A"); R;""; 71 changechar("R1","32003",R); R1; 72 if(system("with","Namespaces")) { kill Top::R,Top::R1; } 73 if (defined(R)) {kill R,R1;} 74 } 75 /////////////////////////////////////////////////////////////////////////////// 76 77 proc changeord (string newr, string o, list #) 78 "USAGE: changeord(newr,o[,r]); newr,o=strings, r=ring/qring 79 CREATE: create a new ring with name `newr` and make it the basering if r is 80 an existing ring/qring [default: r=basering]. 81 The new ring differs from the old ring only in the ordering. If, say, 82 (newr,o) = (\"R\",\"wp(2,3),dp\") and the ring r exists and has >=3 83 variables, the new basering will have name R and ordering wp(2,3),dp. 84 RETURN: No return value 85 NOTE: This proc uses 'execute' or calls a procedure using 'execute'. 86 If you use it in your own proc, let the local names of your proc 87 start with @. 88 EXAMPLE: example changeord; shows an example 99 def R=changeord("wp(2,3),dp"); R; ""; 100 ideal i = x^2,y^2-u^3,v; 101 qring Q = std(i); 102 def Q'=changeord("lp",Q); Q'; 103 kill R,Q,Q'; 104 } 105 /////////////////////////////////////////////////////////////////////////////// 106 107 proc changevar (string vars, list #) 108 "USAGE: changevar(vars[,r]); vars=string, r=ring/qring 109 RETURN: ring R, obtained from the ring r [default: r=basering], by changing 110 varstr(r) according to the value of vars. 111 If, say, vars = \"t()\" and the ring r exists and has n 112 variables, the new basering will have name R and variables 113 t(1),...,t(n). 114 If vars = \"a,b,c,d\", the new ring will have the variables a,b,c,d. 115 NOTE: This procedure is useful in connection with the procedure ringtensor, 116 when a conflict between variable names must be avoided. 117 This proc uses 'execute' or calls a procedure using 'execute'. 118 EXAMPLE: example changevar; shows an example 89 119 " 90 120 { … … 94 124 ideal i = ideal(@r); int @q = size(i); 95 125 if( @q!=0 ) 96 { string @s = " @newr1"; }126 { string @s = "Rnew1"; } 97 127 else 98 { string @s = newr; } 99 string @newring = @s+"=("+charstr(@r)+"),("+varstr(@r)+"),("+o+");"; 100 execute("ring "+@newring); 101 if( @q!=0 ) 102 { 103 map phi = @r,maxideal(1); 104 ideal i = phi(i); 105 attrib(i,"isSB",1); //*** attrib funktioniert ? 106 execute("qring "+newr+"=i;"); 107 } 108 export(`newr`); 109 keepring(`newr`); 110 if (voice==2) { "// basering is now",newr; } 111 return(); 112 } 113 example 114 { "EXAMPLE:"; echo = 2; 115 ring r=0,(x,y,u,v),(dp(2),ds); 116 changeord("R","wp(2,3),dp"); R; ""; 117 ideal i = x^2,y^2-u^3,v; 118 qring Q = std(i); 119 changeord("Q'","lp",Q); Q'; 120 if(system("with","Namespaces")) { kill Top::R,Top::Q,Top::Q'; } 121 if (defined(R)) {kill R,Q,Q';} 122 } 123 /////////////////////////////////////////////////////////////////////////////// 124 125 proc changevar (string newr, string vars, list #) 126 "USAGE: changevar(newr,vars[,r]); newr,vars=strings, r=ring/qring 127 CREATE: creates a new ring with name `newr` and makes it the basering if r 128 is an existing ring/qring [default: r=basering]. 129 The new ring differs from the old ring only in the variables. If, 130 say, (newr,vars) = (\"R\",\"t()\") and the ring r exists and has n 131 variables, the new basering will have name R and variables 132 t(1),...,t(n). 133 If vars = \"a,b,c,d\", the new ring will have the variables a,b,c,d. 134 RETURN: No return value 135 NOTE: This procedure is useful in connection with the procedure ringtensor, 136 when a conflict between variable names must be avoided. 137 This proc uses 'execute' or calls a procedure using 'execute'. 138 If you use it in your own proc, let the local names of your proc 139 start with @. 140 EXAMPLE: example changevar; shows an example 141 " 142 { 143 if( size(#)==0 ) { def @r=basering; } 144 if( size(#)==1 ) { def @r=#[1]; } 145 setring @r; 146 ideal i = ideal(@r); int @q = size(i); 147 if( @q!=0 ) 148 { string @s = "@newr1"; } 149 else 150 { string @s = newr; } 128 { string @s = "Rnew"; } 151 129 string @newring = @s+"=("+charstr(@r)+"),("; 152 130 if( vars[size(vars)-1]=="(" and vars[size(vars)]==")" ) … … 162 140 ideal i = phi(i); 163 141 attrib(i,"isSB",1); //*** attrib funktioniert ? 164 execute("qring "+newr+"=i;"); 165 } 166 export(`newr`); 167 keepring(`newr`); 168 if (voice==2) { "// basering is now",newr; } 169 return(); 142 qring Rnew=i; 143 } 144 return(Rnew); 170 145 } 171 146 example … … 175 150 qring Q = std(i); 176 151 setring(r); 177 changevar("R","A()"); R; ""; 178 changevar("Q'","a,b,c,d",Q); Q'; 179 if(system("with","Namespaces")) { kill Top::R,Top::Q,Top::Q'; } 180 if (defined(R)) {kill R,Q,Q';} 152 def R=changevar("A()"); R; ""; 153 def Q'=changevar("a,b,c,d",Q); Q'; 154 kill R,Q,Q'; 181 155 } 182 156 /////////////////////////////////////////////////////////////////////////////// … … 192 166 NOTE: This proc is useful for defining a ring in a procedure. 193 167 This proc uses 'execute' or calls a procedure using 'execute'. 194 If you use it in your own proc, it may be advisable to let the local195 names of your proc start with a @.196 168 EXAMPLE: example defring; shows an example 197 169 " … … 214 186 proc defrings (int n, list #) 215 187 "USAGE: defrings(n,[p]); n,p integers 216 CREATE: Defines a ring with name Sn, characteristic p, ordering ds and n 217 variables x,y,z,a,b,...if n<=26 (resp. x(1..n) if n>26) and makes it 218 the basering (default: p=32003) 219 RETURN: No return value 188 RETURN: ring R with characteristic p [default: p=32003], ordering ds and n 189 variables x,y,z,a,b,...if n<=26 (resp. x(1..n) if n>26) 190 NOTE: This proc uses 'execute' or calls a procedure using 'execute'. 220 191 EXAMPLE: example defrings; shows an example 221 192 " … … 226 197 if (n >26) 227 198 { 228 string s="ring S "+string(n)+"="+string(p)+",x(1.."+string(n)+"),ds;";199 string s="ring S ="+string(p)+",x(1.."+string(n)+"),ds;"; 229 200 } 230 201 else 231 202 { 232 string s="ring S "+string(n)+"="+string(p)+",("+A_Z("x",n)+"),ds;";203 string s="ring S ="+string(p)+",("+A_Z("x",n)+"),ds;"; 233 204 } 234 205 execute(s); 235 export basering; 236 execute("keepring S"+string(n)+";"); 237 if (voice==2) { "// basering is now:",s; } 206 dbprint(printlevel-voice+2," 207 // 'defrings' created a ring. To see the ring, type (if the name R was 208 // assigned to the return value): 209 show R; 210 // To make the ring the active basering, type 211 setring R; "); 212 return(S); 238 213 } 239 214 example 240 215 { "EXAMPLE:"; echo = 2; 241 defrings(5,0); S5; ""; 242 defrings(30); S30; 243 if(system("with","Namespaces")) { kill Top::S5,Top::S30; } 244 if (defined(R)) {kill S5,S30;} 216 def S5=defrings(5,0); S5; ""; 217 def S30=defrings(30); S30; 218 kill S5,S30; 245 219 } 246 220 /////////////////////////////////////////////////////////////////////////////// … … 248 222 proc defringp (int n,list #) 249 223 "USAGE: defringp(n,[p]); n,p=integers 250 CREATE: defines a ring with name Pn, characteristic p, ordering dp and n 251 variables x,y,z,a,b,...if n<=26 (resp. x(1..n) if n>26) and makes it 252 the basering (default: p=32003) 253 RETURN: No return value 224 RETURN: ring R with characteristic p [default: p=32003], ordering dp and n 225 variables x,y,z,a,b,...if n<=26 (resp. x(1..n) if n>26) 226 NOTE: This proc uses 'execute' or calls a procedure using 'execute'. 254 227 EXAMPLE: example defringp; shows an example 255 228 " … … 260 233 if (n >26) 261 234 { 262 string s="ring P "+string(n)+"="+string(p)+",x(1.."+string(n)+"),dp;";235 string s="ring P="+string(p)+",x(1.."+string(n)+"),dp;"; 263 236 } 264 237 else 265 238 { 266 string s="ring P "+string(n)+"="+string(p)+",("+A_Z("x",n)+"),dp;";239 string s="ring P="+string(p)+",("+A_Z("x",n)+"),dp;"; 267 240 } 268 241 execute(s); 269 export basering; 270 execute("keepring P"+string(n)+";"); 271 //the next comment is only shown if defringp is not called by another proc 272 if (voice==2) { "// basering is now:",s; } 242 dbprint(printlevel-voice+2," 243 // 'defringp' created a ring. To see the ring, type (if the name R was 244 // assigned to the return value): 245 show R; 246 // To make the ring the active basering, type 247 setring R; "); 248 return(P); 273 249 } 274 250 example 275 251 { "EXAMPLE:"; echo = 2; 276 defringp(5,0); P5; ""; 277 defringp(30); P30; 278 if(system("with","Namespaces")) { kill Top::P5,Top::P30; } 279 if (defined(R)) {kill P5,P30;} 252 def P5=defringp(5,0); P5; ""; 253 def P30=defringp(30); P30; 254 kill P5,P30; 280 255 } 281 256 /////////////////////////////////////////////////////////////////////////////// … … 620 595 /////////////////////////////////////////////////////////////////////////////// 621 596 622 proc ringtensor (string s, list #) 623 "USAGE: ringtensor(s,r1,r2,...); s=string, r1,r2,...=rings 624 CREATE: A new base ring with name `s` if r1,r2,... are existing rings. 625 If, say, s = \"R\" and the rings r1,r2,... exist, the new ring will 626 have name R, variables from all rings r1,r2,... and as monomial 627 ordering the block (product) ordering of r1,r2,... . Hence, R 597 proc ringtensor (list #) 598 "USAGE: ringtensor(r1,r2,...); s=string, r1,r2,...=rings 599 RETURN: ring R whose variables are the variables from all rings r1,r2,... 600 and whose monomial ordering is the block (product) ordering of the 601 respective monomial orderings of r1,r2,... . Hence, R 628 602 is the tensor product of the rings r1,r2,... with ordering matrix 629 603 equal to the direct sum of the ordering matrices of r1,r2,... 630 RETURN: no return value631 604 NOTE: The characteristic of the new ring will be that of r1. The names of 632 605 variables in the rings r1,r2,... should differ (if a name, say x, … … 637 610 ri to r1 is implemented) 638 611 This proc uses 'execute' or calls a procedure using 'execute'. 639 If you use it in your own proc, let the local names of your proc640 start with @ (see the file HelpForProc)641 612 EXAMPLE: example ringtensor; shows an example 642 613 " … … 660 631 } 661 632 if( @q!=0 ) { @s1 = "@newr"; } // @q=0 iff none of the rings ri is a qring 662 else { @s1 = s; }633 else { @s1 = "s"; } 663 634 //------------------------------- create new ring ----------------------------- 664 635 string @newring ="=("+charstr(#[1])+"),("+@vars[1,size(@vars)-1]+"),(" … … 677 648 } 678 649 i=std(i); 679 execute("qring "+s+"=i;"); 680 } 681 //----------------------- export and keep created ring ------------------------ 682 export(`s`); 683 keepring(`s`); 684 if (voice==2) { "// basering is now",s; } 685 return(); 650 qring s=i; 651 } 652 dbprint(printlevel-voice+2," 653 // 'ringtensor' created a ring. To see the ring, type (if the name R was 654 // assigned to the return value): 655 show R; 656 // To make the ring the active basering, type 657 setring R; "); 658 return(s); 686 659 } 687 660 example … … 690 663 ring s=0,(a,b,c),wp(1,2,3); 691 664 ring t=0,x(1..5),(c,ls); 692 ringtensor("R",r,s,t);693 type R; 665 def R=ringtensor(r,s,t); 666 type R; 694 667 setring s; 695 668 ideal i = a2+b3+c5; 696 changevar("S","x,y,z"); //change vars of sand make S the basering 697 qring qS =std(fetch(s,i)); //create qring of S mod i (maped to S) 698 changevar("T","d,e,f,g,h",t); //change vars of t and make T the basering 699 qring qT=std(d2+e2-f3); //create qring of T mod d2+e2-f3 700 ringtensor("Q",s,qS,t,qT); 669 def S=changevar("x,y,z"); //change vars of s 670 setring S; 671 qring qS =std(fetch(s,i)); //create qring of S mod i (maped to S) 672 def T=changevar("d,e,f,g,h",t); //change vars of t 673 setring T; 674 qring qT=std(d2+e2-f3); //create qring of T mod d2+e2-f3 675 def Q=ringtensor(s,qS,t,qT); 701 676 type Q; 702 if(system("with","Namespaces")){kill Top::Q,Top::R,Top::S,Top::T;} 703 if (defined(R)) { kill R,S,T,Q; } 677 kill R,S,T,Q; 704 678 } 705 679 ///////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.