[0fbdd1] | 1 | // $Id: ring.lib,v 1.3 1997-09-12 07:40:36 Singular Exp $ |
---|
[6f2edc] | 2 | //(GMG, last modified 03.11.95) |
---|
[3d124a7] | 3 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 4 | |
---|
[6f2edc] | 5 | LIBRARY: ring.lib PROCEDURES FOR MANIPULATING RINGS AND MAPS |
---|
[3d124a7] | 6 | |
---|
| 7 | changechar("R",c[,r]); make a copy R of basering [ring r] with new char c |
---|
| 8 | changeord("R",o[,r]); make a copy R of basering [ring r] with new ord o |
---|
| 9 | changevar("R",v[,r]); make a copy R of basering [ring r] with new vars v |
---|
[0fbdd1] | 10 | copyring("R"[,r]); make an exact copy R of basering [ring r] |
---|
[3d124a7] | 11 | defring("R",c,n,v,o); define a ring R in specified char c, n vars v, ord o |
---|
| 12 | defrings(n[,p]); define ring Sn in n vars, char 32003 [p], ord ds |
---|
| 13 | defringp(n[,p]); define ring Pn in n vars, char 32003 [p], ord dp |
---|
| 14 | extendring("R",n,v,o); extend given ring by n vars v, ord o and name it R |
---|
[0fbdd1] | 15 | extendring1("R",n,v,o); similair to extendring but different ordering |
---|
[3d124a7] | 16 | fetchall(R[,str]); fetch all objects of ring R to basering |
---|
| 17 | imapall(R[,str]); imap all objects of ring R to basering |
---|
| 18 | mapall(R,i[,str]); map all objects of ring R via ideal i to basering |
---|
| 19 | ringtensor("R",s,t,..);create ring R, tensor product of rings s,t,... |
---|
[0fbdd1] | 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) |
---|
[3d124a7] | 23 | |
---|
| 24 | LIB "inout.lib"; |
---|
| 25 | LIB "general.lib"; |
---|
| 26 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 27 | |
---|
| 28 | proc changechar (string newr, string c, list #) |
---|
| 29 | USAGE: changechar(newr,c[,r]); newr,c=strings, r=ring |
---|
| 30 | CREATE: create a new ring with name `newr` and make it the basering if r is |
---|
[6f2edc] | 31 | an existing ring [default: r=basering]. |
---|
[3d124a7] | 32 | The new ring differs from the old ring only in the characteristic. |
---|
[6f2edc] | 33 | If, say, (newr,c) = ("R","0,A") and the ring r exists, the new |
---|
[3d124a7] | 34 | basering will have name R characteristic 0 and one parameter A. |
---|
| 35 | RETURN: No return value |
---|
| 36 | NOTE: Works for qrings if map from old_char to new_char is implemented |
---|
[6f2edc] | 37 | This proc uses 'execute' or calls a procedure using 'execute'. |
---|
| 38 | If you use it in your own proc, let the local names of your proc |
---|
[3d124a7] | 39 | start with @ (see the file HelpForProc) |
---|
| 40 | EXAMPLE: example changechar; shows an example |
---|
| 41 | { |
---|
| 42 | if( size(#)==0 ) { def @r=basering; } |
---|
| 43 | if( size(#)==1 ) { def @r=#[1]; } |
---|
| 44 | setring @r; |
---|
| 45 | ideal i = ideal(@r); int @q = size(i); |
---|
[6f2edc] | 46 | if( @q!=0 ) |
---|
[3d124a7] | 47 | { string @s = "@newr1"; } |
---|
[6f2edc] | 48 | else |
---|
[3d124a7] | 49 | { string @s = newr; } |
---|
| 50 | string @newring = @s+"=("+c+"),("+varstr(@r)+"),("+ordstr(@r)+");"; |
---|
| 51 | execute("ring "+@newring); |
---|
| 52 | if( @q!=0 ) |
---|
| 53 | { |
---|
| 54 | map phi = @r,maxideal(1); |
---|
| 55 | ideal i = phi(i); |
---|
| 56 | attrib(i,"isSB",1); //*** attrib funktioniert ? |
---|
[6f2edc] | 57 | execute("qring "+newr+"=i;"); |
---|
[3d124a7] | 58 | } |
---|
| 59 | export(`newr`); |
---|
| 60 | keepring(`newr`); |
---|
| 61 | if (voice==2) { "// basering is now",newr; } |
---|
| 62 | return(); |
---|
| 63 | } |
---|
| 64 | example |
---|
| 65 | { "EXAMPLE:"; echo = 2; |
---|
| 66 | ring r=0,(x,y,u,v),(dp(2),ds); |
---|
| 67 | changechar("R","2,A"); R;""; |
---|
| 68 | changechar("R1","32003",R); R1; |
---|
| 69 | kill R,R1; |
---|
| 70 | } |
---|
| 71 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 72 | |
---|
| 73 | proc changeord (string newr, string o, list #) |
---|
| 74 | USAGE: changeord(newr,o[,r]); newr,o=strings, r=ring/qring |
---|
| 75 | CREATE: create a new ring with name `newr` and make it the basering if r is |
---|
[6f2edc] | 76 | an existing ring/qring [default: r=basering]. |
---|
[3d124a7] | 77 | The new ring differs from the old ring only in the ordering. If, say, |
---|
[6f2edc] | 78 | (newr,o) = ("R","wp(2,3),dp") and the ring r exists and has >=3 |
---|
[3d124a7] | 79 | variables, the new basering will have name R and ordering wp(2,3),dp. |
---|
| 80 | RETURN: No return value |
---|
[6f2edc] | 81 | NOTE: This proc uses 'execute' or calls a procedure using 'execute'. |
---|
| 82 | If you use it in your own proc, let the local names of your proc |
---|
[3d124a7] | 83 | start with @ (see the file HelpForProc) |
---|
| 84 | EXAMPLE: example changeord; shows an example |
---|
| 85 | { |
---|
| 86 | if( size(#)==0 ) { def @r=basering; } |
---|
| 87 | if( size(#)==1 ) { def @r=#[1]; } |
---|
| 88 | setring @r; |
---|
| 89 | ideal i = ideal(@r); int @q = size(i); |
---|
[6f2edc] | 90 | if( @q!=0 ) |
---|
[3d124a7] | 91 | { string @s = "@newr1"; } |
---|
[6f2edc] | 92 | else |
---|
[3d124a7] | 93 | { string @s = newr; } |
---|
| 94 | string @newring = @s+"=("+charstr(@r)+"),("+varstr(@r)+"),("+o+");"; |
---|
| 95 | execute("ring "+@newring); |
---|
| 96 | if( @q!=0 ) |
---|
| 97 | { |
---|
| 98 | map phi = @r,maxideal(1); |
---|
| 99 | ideal i = phi(i); |
---|
| 100 | attrib(i,"isSB",1); //*** attrib funktioniert ? |
---|
[6f2edc] | 101 | execute("qring "+newr+"=i;"); |
---|
[3d124a7] | 102 | } |
---|
| 103 | export(`newr`); |
---|
| 104 | keepring(`newr`); |
---|
| 105 | if (voice==2) { "// basering is now",newr; } |
---|
| 106 | return(); |
---|
| 107 | } |
---|
| 108 | example |
---|
| 109 | { "EXAMPLE:"; echo = 2; |
---|
| 110 | ring r=0,(x,y,u,v),(dp(2),ds); |
---|
| 111 | changeord("R","wp(2,3),dp"); R; ""; |
---|
| 112 | ideal i = x^2,y^2-u^3,v; |
---|
| 113 | qring Q = std(i); |
---|
| 114 | changeord("Q'","lp",Q); Q'; |
---|
| 115 | kill R,Q,Q'; |
---|
| 116 | } |
---|
| 117 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 118 | |
---|
| 119 | proc changevar (string newr, string vars, list #) |
---|
| 120 | USAGE: changevar(newr,vars[,r]); newr,vars=strings, r=ring/qring |
---|
| 121 | CREATE: creates a new ring with name `newr` and makes it the basering if r |
---|
[6f2edc] | 122 | is an existing ring/qring [default: r=basering]. |
---|
[3d124a7] | 123 | The new ring differs from the old ring only in the variables. If, |
---|
[6f2edc] | 124 | say, (newr,vars) = ("R","t()") and the ring r exists and has n |
---|
| 125 | variables, the new basering will have name R and variables |
---|
[3d124a7] | 126 | t(1),...,t(n). |
---|
[6f2edc] | 127 | If vars = "a,b,c,d", the new ring will have the variables a,b,c,d. |
---|
[3d124a7] | 128 | RETURN: No return value |
---|
| 129 | NOTE: This procedure is useful in connection with the procedure ringtensor, |
---|
| 130 | when a conflict between variable names must be avoided. |
---|
[6f2edc] | 131 | This proc uses 'execute' or calls a procedure using 'execute'. |
---|
| 132 | If you use it in your own proc, let the local names of your proc |
---|
[3d124a7] | 133 | start with @ (see the file HelpForProc) |
---|
| 134 | EXAMPLE: example changevar; shows an example |
---|
| 135 | { |
---|
| 136 | if( size(#)==0 ) { def @r=basering; } |
---|
| 137 | if( size(#)==1 ) { def @r=#[1]; } |
---|
| 138 | setring @r; |
---|
| 139 | ideal i = ideal(@r); int @q = size(i); |
---|
[6f2edc] | 140 | if( @q!=0 ) |
---|
[3d124a7] | 141 | { string @s = "@newr1"; } |
---|
[6f2edc] | 142 | else |
---|
[3d124a7] | 143 | { string @s = newr; } |
---|
| 144 | string @newring = @s+"=("+charstr(@r)+"),("; |
---|
| 145 | if( vars[size(vars)-1]=="(" and vars[size(vars)]==")" ) |
---|
[6f2edc] | 146 | { |
---|
| 147 | @newring = @newring+vars[1,size(vars)-2]+"(1.."+string(nvars(@r))+")"; |
---|
[3d124a7] | 148 | } |
---|
| 149 | else { @newring = @newring+vars; } |
---|
| 150 | @newring = @newring+"),("+ordstr(@r)+");"; |
---|
| 151 | execute("ring "+@newring); |
---|
| 152 | if( @q!=0 ) |
---|
| 153 | { |
---|
| 154 | map phi = @r,maxideal(1); |
---|
| 155 | ideal i = phi(i); |
---|
| 156 | attrib(i,"isSB",1); //*** attrib funktioniert ? |
---|
[6f2edc] | 157 | execute("qring "+newr+"=i;"); |
---|
[3d124a7] | 158 | } |
---|
| 159 | export(`newr`); |
---|
| 160 | keepring(`newr`); |
---|
| 161 | if (voice==2) { "// basering is now",newr; } |
---|
| 162 | return(); |
---|
| 163 | } |
---|
| 164 | example |
---|
| 165 | { "EXAMPLE:"; echo = 2; |
---|
| 166 | ring r=0,(x,y,u,v),(dp(2),ds); |
---|
| 167 | ideal i = x^2,y^2-u^3,v; |
---|
| 168 | qring Q = std(i); |
---|
| 169 | setring(r); |
---|
| 170 | changevar("R","A()"); R; ""; |
---|
| 171 | changevar("Q'","a,b,c,d",Q); Q'; |
---|
| 172 | kill R,Q,Q'; |
---|
| 173 | } |
---|
| 174 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 175 | |
---|
[0fbdd1] | 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 | |
---|
[3d124a7] | 204 | proc defring (string s1, string s2, int n, string s3, string s4) |
---|
| 205 | USAGE: defring(s1,s2,n,s3,s4); s1..s4=strings, n=integer |
---|
| 206 | CREATE: Define a ring with name 's1', characteristic 's2', ordering 's4' and |
---|
| 207 | n variables with names derived from s3 and make it the basering. |
---|
[6f2edc] | 208 | If s3 is a single letter, say s3="a", and if n<=26 then a and the |
---|
| 209 | following n-1 letters from the alphabeth (cyclic order) are taken as |
---|
| 210 | variables. If n>26 or if s3 is a single letter followed by (, say |
---|
| 211 | s3="T(", the variables are T(1),...,T(n). |
---|
[3d124a7] | 212 | RETURN: No return value |
---|
| 213 | NOTE: This proc is useful for defining a ring in a procedure. |
---|
[6f2edc] | 214 | This proc uses 'execute' or calls a procedure using 'execute'. |
---|
| 215 | If you use it in your own proc, let the local names of your proc |
---|
[3d124a7] | 216 | start with @ (see the file HelpForProc) |
---|
| 217 | EXAMPLE: example defring; shows an example |
---|
| 218 | { |
---|
| 219 | string @newring = "ring "+s1+"=("+s2+"),("; |
---|
| 220 | if( n>26 or s3[2]=="(" ) { string @v = s3[1]+"(1.."+string(n)+")"; } |
---|
| 221 | else { string @v = A_Z(s3,n); } |
---|
| 222 | @newring=@newring+@v+"),("+s4+");"; |
---|
| 223 | execute(@newring); |
---|
| 224 | export(basering); |
---|
| 225 | keepring(`s1`); |
---|
| 226 | if (voice==2) { "// basering is now:",s1; } |
---|
| 227 | return(); |
---|
| 228 | } |
---|
| 229 | example |
---|
| 230 | { "EXAMPLE:"; echo = 2; |
---|
| 231 | defring("r","0",5,"u","ls"); r; ""; |
---|
| 232 | defring("R","2,A",10,"x(","dp(3),ws(1,2,3),ds"); R; |
---|
| 233 | kill r,R; |
---|
| 234 | } |
---|
| 235 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 236 | |
---|
| 237 | proc defrings (int n, list #) |
---|
| 238 | USAGE: defrings(n,[p]); n,p integers |
---|
| 239 | CREATE: Defines a ring with name Sn, characteristic p, ordering ds and n |
---|
| 240 | variables x,y,z,a,b,...if n<=26 (resp. x(1..n) if n>26) and makes it |
---|
| 241 | the basering (default: p=32003) |
---|
| 242 | RETURN: No return value |
---|
| 243 | EXAMPLE: example defrings; shows an example |
---|
| 244 | { |
---|
| 245 | int p; |
---|
| 246 | if (size(#)==0) { p=32003; } |
---|
| 247 | else { p=#[1]; } |
---|
| 248 | if (n >26) |
---|
| 249 | { |
---|
| 250 | string s="ring S"+string(n)+"="+string(p)+",x(1.."+string(n)+"),ds;"; |
---|
| 251 | } |
---|
| 252 | else |
---|
| 253 | { |
---|
| 254 | string s="ring S"+string(n)+"="+string(p)+",("+A_Z("x",n)+"),ds;"; |
---|
| 255 | } |
---|
| 256 | execute(s); |
---|
| 257 | export basering; |
---|
| 258 | execute("keepring S"+string(n)+";"); |
---|
| 259 | if (voice==2) { "// basering is now:",s; } |
---|
| 260 | } |
---|
| 261 | example |
---|
| 262 | { "EXAMPLE:"; echo = 2; |
---|
| 263 | defrings(5,0); S5; ""; |
---|
| 264 | defrings(30); S30; |
---|
| 265 | kill S5, S30; |
---|
| 266 | } |
---|
| 267 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 268 | |
---|
| 269 | proc defringp (int n,list #) |
---|
| 270 | USAGE: defringp(n,[p]); n,p=integers |
---|
| 271 | CREATE: defines a ring with name Pn, characteristic p, ordering dp and n |
---|
| 272 | variables x,y,z,a,b,...if n<=26 (resp. x(1..n) if n>26) and makes it |
---|
| 273 | the basering (default: p=32003) |
---|
| 274 | RETURN: No return value |
---|
| 275 | EXAMPLE: example defringp; shows an example |
---|
| 276 | { |
---|
| 277 | int p; |
---|
| 278 | if (size(#)==0) { p=32003; } |
---|
| 279 | else { p=#[1]; } |
---|
| 280 | if (n >26) |
---|
| 281 | { |
---|
| 282 | string s="ring P"+string(n)+"="+string(p)+",x(1.."+string(n)+"),dp;"; |
---|
| 283 | } |
---|
| 284 | else |
---|
| 285 | { |
---|
| 286 | string s="ring P"+string(n)+"="+string(p)+",("+A_Z("x",n)+"),dp;"; |
---|
| 287 | } |
---|
| 288 | execute(s); |
---|
| 289 | export basering; |
---|
| 290 | execute("keepring P"+string(n)+";"); |
---|
| 291 | //the next comment is only shown if defringp is not called by another proc |
---|
[6f2edc] | 292 | if (voice==2) { "// basering is now:",s; } |
---|
| 293 | } |
---|
[3d124a7] | 294 | example |
---|
| 295 | { "EXAMPLE:"; echo = 2; |
---|
| 296 | defringp(5,0); P5; ""; |
---|
| 297 | defringp(30); P30; |
---|
| 298 | kill P5, P30; |
---|
| 299 | } |
---|
| 300 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 301 | |
---|
| 302 | proc extendring (string na, int n, string va, string o, list #) |
---|
[0fbdd1] | 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, |
---|
[3d124a7] | 379 | n,i=integers, r=ring, iv=intvec of positive integers or iv=0 |
---|
| 380 | CREATE: Define a ring with name `na` which extends the ring r by adding n new |
---|
| 381 | variables in front of [after, if i!=0] the old variables and make it |
---|
| 382 | the basering [default: (i,r)=(0,basering)] |
---|
| 383 | -- The characteristic is the characteristic of r |
---|
[6f2edc] | 384 | -- The new vars are derived from va. If va is a single letter, say |
---|
| 385 | va="T", and if n<=26 then T and the following n-1 letters from |
---|
| 386 | T..Z..T (resp. T(1..n) if n>26) are taken as additional variables. |
---|
| 387 | If va is a single letter followed by (, say va="x(", the new |
---|
[0fbdd1] | 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 |
---|
[3d124a7] | 391 | -- The ordering is the product ordering between the ordering of r and |
---|
| 392 | an ordering derived from `o` [and iv] |
---|
[6f2edc] | 393 | - If o contains a 'c' or a 'C' in front resp. at the end this is |
---|
[3d124a7] | 394 | taken for the whole ordering in front resp. at the end. If o does |
---|
| 395 | not contain a 'c' or a 'C' the same rule applies to ordstr(r). |
---|
| 396 | - If no intvec iv is given, or if iv=0, o may be any allowed ordstr, |
---|
| 397 | like "ds" or "dp(2),wp(1,2,3),Ds(2)" or "ds(a),dp(b),ls" if a and b |
---|
[6f2edc] | 398 | are globally (!) defined integers and if a+b+1<=n |
---|
[0fbdd1] | 399 | 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 |
---|
[3d124a7] | 401 | - If an intvec iv !=0 is given, iv[1],iv[2],... is taken for the 1st, |
---|
[6f2edc] | 402 | 2nd,... block of o, if o contains no substring "w" or "W" i.e. no |
---|
| 403 | weighted ordering (in the above case o="ds,dp,ls" and iv=a,b). |
---|
| 404 | If o contains a weighted ordering (only one (!) weighted block is |
---|
| 405 | allowed) iv[1] is taken as size for the weight-vector, the next |
---|
[3d124a7] | 406 | iv[1] values of iv are taken as weights and the remaining values of |
---|
[6f2edc] | 407 | iv as block-size for the remaining non-weighted blocks. |
---|
| 408 | e.g. o="dp,ws,Dp,ds", iv=3,2,3,4,2,5 creates the ordering |
---|
[3d124a7] | 409 | dp(2),ws(2,3,4),Dp(5),ds |
---|
| 410 | RETURN: No return value |
---|
| 411 | NOTE: This proc is useful for adding deformation parameters. |
---|
[6f2edc] | 412 | This proc uses 'execute' or calls a procedure using 'execute'. |
---|
| 413 | If you use it in your own proc, let the local names of your proc |
---|
[3d124a7] | 414 | start with @ (see the file HelpForProc) |
---|
[0fbdd1] | 415 | EXAMPLE: example extendring1; shows an example |
---|
[3d124a7] | 416 | { |
---|
| 417 | //--------------- initialization and place c/C of ordering properly ----------- |
---|
[6f2edc] | 418 | string @o1,@o2,@ro,@wstr,@v,@newring; |
---|
[3d124a7] | 419 | int @i,@w,@ii,@k; |
---|
| 420 | intvec @iv,@iw; |
---|
| 421 | if( find(o,"c")+find(o,"C") != 0) |
---|
| 422 | { |
---|
| 423 | @k=1; |
---|
| 424 | if( o[1]=="c" or o[1]=="C" ) { @o1=o[1,2]; o=o[3..size(o)]; } |
---|
| 425 | else { @o2=o[size(o)-1,2]; o=o[1..size(o)-2]; } |
---|
| 426 | } |
---|
| 427 | if( size(#)==0 ) { #[1]=0; } |
---|
| 428 | if( typeof(#[1])!="intvec" ) |
---|
| 429 | { |
---|
| 430 | if( size(#)==1 ) { @i=#[1]; def @r=basering; } |
---|
| 431 | if( size(#)==2 ) { @i=#[1]; def @r=#[2]; } |
---|
| 432 | if( o[size(o)]!=")" and find(o,",")==0 ) { o=o+"("+string(n)+")"; } |
---|
| 433 | } |
---|
| 434 | else |
---|
| 435 | { |
---|
| 436 | @iv=#[1]; |
---|
| 437 | if( size(#)==2 ) { @i=#[2]; def @r=basering; } |
---|
| 438 | if( size(#)==3 ) { @i=#[2]; def @r=#[3]; } |
---|
| 439 | if( @iv==0 && o[size(o)]!=")" && find(o,",")==0 ) {o=o+"("+string(n)+")";} |
---|
| 440 | } |
---|
| 441 | @ro=ordstr(@r); |
---|
[6f2edc] | 442 | if( @ro[1]=="c" or @ro[1]=="C" ) |
---|
[3d124a7] | 443 | { @v=@ro[1,2]; @ro=@ro[3..size(@ro)]; } |
---|
[6f2edc] | 444 | else |
---|
[3d124a7] | 445 | { @wstr=@ro[size(@ro)-1,2]; @ro=@ro[1..size(@ro)-2]; } |
---|
| 446 | if( @k==0) { @o1=@v; @o2=@wstr; } |
---|
| 447 | //----------------- prepare ordering if an intvec is given -------------------- |
---|
| 448 | if( typeof(#[1])=="intvec" and #[1]!=0 ) |
---|
| 449 | { |
---|
| 450 | @k=n; //@k counts no of vars not yet ordered |
---|
| 451 | @w=find(o,"w")+find(o,"W");o=o+" "; |
---|
[6f2edc] | 452 | if( @w!=0 ) |
---|
| 453 | { |
---|
| 454 | @wstr=o[@w..@w+1]; |
---|
[3d124a7] | 455 | o=o[1,@w-1]+"@"+o[@w+2,size(o)]; |
---|
| 456 | @iw=@iv[2..@iv[1]+1]; |
---|
| 457 | @wstr=@wstr+"("+string(@iw)+")"; |
---|
[6f2edc] | 458 | @k=@k-@iv[1]; |
---|
[3d124a7] | 459 | @iv=@iv[@iv[1]+2..size(@iv)]; |
---|
| 460 | @w=0; |
---|
| 461 | } |
---|
[6f2edc] | 462 | for( @ii=1; @ii<=size(@iv); @ii=@ii+1 ) |
---|
[3d124a7] | 463 | { |
---|
| 464 | if( find(o,",",@w+1)!=0 ) |
---|
| 465 | { |
---|
| 466 | @w=find(o,",",@w+1); |
---|
| 467 | if( o[@w-1]!="@" ) |
---|
[6f2edc] | 468 | { |
---|
| 469 | o=o[1,@w-1]+"("+string(@iv[@ii])+")"+o[@w,size(o)]; |
---|
[3d124a7] | 470 | @w=find(o,",",@w+1); |
---|
| 471 | @k=@k-@iv[@ii]; |
---|
| 472 | } |
---|
| 473 | else { @ii=@ii-1; } |
---|
| 474 | } |
---|
| 475 | } |
---|
| 476 | @w=find(o,"@"); |
---|
| 477 | if( @w!=0 ) { o=o[1,@w-1] + @wstr + o[@w+1,size(o)]; } |
---|
| 478 | if( @k>0 and o[size(o)]!=")" ) { o=o+"("+string(@k)+")"; } |
---|
| 479 | } |
---|
| 480 | //------------------------ prepare string of new ring ------------------------- |
---|
| 481 | @newring = "ring "+na+"=("+charstr(@r)+"),("; |
---|
[0fbdd1] | 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 | |
---|
[6f2edc] | 492 | if( @i==0 ) |
---|
| 493 | { |
---|
| 494 | @v=@v+","+varstr(@r); |
---|
| 495 | o=@o1+o+","+@ro+@o2; |
---|
[3d124a7] | 496 | } |
---|
[6f2edc] | 497 | else |
---|
| 498 | { |
---|
| 499 | @v=varstr(@r)+","+@v; |
---|
| 500 | o=@o1+@ro+","+o+@o2; |
---|
[3d124a7] | 501 | } |
---|
| 502 | @newring=@newring+@v+"),("+o+");"; |
---|
| 503 | //---------------------------- execute and export ----------------------------- |
---|
| 504 | execute(@newring); |
---|
| 505 | export(basering); |
---|
| 506 | keepring(`na`); |
---|
| 507 | if (voice==2) { "// basering is now",na; } |
---|
| 508 | return(); |
---|
| 509 | } |
---|
| 510 | example |
---|
| 511 | { "EXAMPLE:"; echo = 2; |
---|
| 512 | ring r=0,(x,y,z),ds; |
---|
[6f2edc] | 513 | show(r);""; |
---|
[0fbdd1] | 514 | extendring1("S",2,"u","ds"); |
---|
| 515 | setring r; |
---|
| 516 | show(S); ""; |
---|
| 517 | extendring1("R0",2,"a,w","ds"); |
---|
| 518 | show(R0); ""; |
---|
[3d124a7] | 519 | //no intvec given, no blocksize given: blocksize is derived from no of vars |
---|
[6f2edc] | 520 | int t=5; |
---|
[0fbdd1] | 521 | extendring1("R1",t,"a","dp"); //t global: "dp" -> "dp(5)" |
---|
[3d124a7] | 522 | show(R1); ""; |
---|
[0fbdd1] | 523 | extendring1("R2",4,"T(","c,dp",1,r); //"dp" -> "c,..,dp(4)" |
---|
[3d124a7] | 524 | show(R2);""; |
---|
| 525 | |
---|
| 526 | //no intvec given, blocksize given: given blocksize is used |
---|
[0fbdd1] | 527 | extendring1("R3",4,"T(","dp(2)",0,r); // "dp(2)" -> "dp(2)" |
---|
[3d124a7] | 528 | show(R3);""; |
---|
| 529 | |
---|
| 530 | //intvec given: weights and blocksize is derived from given intvec |
---|
| 531 | //(no specification of a blocksize in the given ordstr is allowed!) |
---|
| 532 | //if intvec does not cover all given blocks, the last block is used for |
---|
| 533 | //the remaining variables, if intvec has too many components, the last |
---|
| 534 | //ones are ignored |
---|
[6f2edc] | 535 | intvec v=3,2,3,4,1,3; |
---|
[0fbdd1] | 536 | extendring1("R4",10,"A","ds,ws,Dp,dp",v,0,r); |
---|
[6f2edc] | 537 | //v covers 3 blocks: v[1] (=3) : no of components of ws |
---|
[3d124a7] | 538 | //next v[1] values (=v[2..4]) give weights |
---|
| 539 | //remaining components of v are used for the remaining blocks |
---|
| 540 | show(R4); |
---|
[0fbdd1] | 541 | kill S,R0,R1,R2,R3,R4; |
---|
[3d124a7] | 542 | } |
---|
| 543 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 544 | |
---|
[6f2edc] | 545 | proc fetchall (R, list #) |
---|
[3d124a7] | 546 | USAGE: fetchall(R[,s]); R=ring/qring, s=string |
---|
| 547 | CREATE: fetch all objects of ring R (of type poly/ideal/vector/module/number/ |
---|
| 548 | matrix) into the basering. |
---|
| 549 | If no 3rd argument is present, the names are the same as in R. If, |
---|
| 550 | say, f is a poly in R and the 3rd argument is the string "R", then f |
---|
[6f2edc] | 551 | is maped to f_R etc. |
---|
[3d124a7] | 552 | RETURN: no return value |
---|
| 553 | NOTE: As fetch, this procedure maps the 1st, 2nd, ... variable of R to the |
---|
[6f2edc] | 554 | 1st, 2nd, ... variable of the basering. |
---|
[3d124a7] | 555 | The 3rd argument is useful in order to avoid conflicts of names, the |
---|
| 556 | empty string is allowed |
---|
| 557 | CAUTION: fetchall does not work inside a procedure |
---|
[6f2edc] | 558 | //***at the moment it does not work if R contains a map |
---|
[3d124a7] | 559 | EXAMPLE: example fetchall; shows an example |
---|
[6f2edc] | 560 | { |
---|
[3d124a7] | 561 | list @L@=names(R); |
---|
| 562 | int @ii@; string @s@; |
---|
| 563 | if( size(#) > 0 ) { @s@=@s@+"_"+#[1]; } |
---|
[6f2edc] | 564 | for( @ii@=size(@L@); @ii@>0; @ii@=@ii@-1 ) |
---|
| 565 | { |
---|
[3d124a7] | 566 | execute("def "+@L@[@ii@]+@s@+"=fetch(R,`@L@[@ii@]`);"); |
---|
| 567 | execute("export "+@L@[@ii@]+@s@+";"); |
---|
| 568 | } |
---|
| 569 | return(); |
---|
| 570 | } |
---|
| 571 | example |
---|
| 572 | { "EXAMPLE:"; |
---|
| 573 | "// This example is not executed since fetchall does not work in a procedure"; |
---|
| 574 | "// (and hence not in the example procedure). Just try the following commands:"; |
---|
| 575 | " ring R=0,(x,y,z),dp;"; |
---|
| 576 | " ideal j=x,y2,z2;"; |
---|
| 577 | " matrix M[2][3]=1,2,3,x,y,z;"; |
---|
| 578 | " j; print(M);"; |
---|
| 579 | " ring S=0,(a,b,c),ds;"; |
---|
| 580 | " fetchall(R); // map from R to S: x->a, y->b, z->c"; |
---|
| 581 | " names(S);"; |
---|
| 582 | " j; print(M);"; |
---|
| 583 | " fetchall(S,\"1\"); // identity map of S: copy objects, change names"; |
---|
| 584 | " names(S);"; |
---|
| 585 | " kill R,S;"; |
---|
| 586 | } |
---|
| 587 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 588 | |
---|
[6f2edc] | 589 | proc imapall (R, list #) |
---|
[3d124a7] | 590 | USAGE: imapall(R[,s]); R=ring/qring, s=string |
---|
| 591 | CREATE: map all objects of ring R (of type poly/ideal/vector/module/number/ |
---|
| 592 | matrix) into the basering, by applying imap to all objects of R. |
---|
| 593 | If no 3rd argument is present, the names are the same as in R. If, |
---|
| 594 | say, f is a poly in R and the 3rd argument is the string "R", then f |
---|
[6f2edc] | 595 | is maped to f_R etc. |
---|
[3d124a7] | 596 | RETURN: no return value |
---|
| 597 | NOTE: As imap, this procedure maps the variables of R to the variables with |
---|
| 598 | the same name in the basering, the other variables are maped to 0. |
---|
| 599 | The 3rd argument is useful in order to avoid conflicts of names, the |
---|
| 600 | empty string is allowed |
---|
| 601 | CAUTION: imapall does not work inside a procedure |
---|
[6f2edc] | 602 | //***at the moment it does not work if R contains a map |
---|
[3d124a7] | 603 | EXAMPLE: example imapall; shows an example |
---|
[6f2edc] | 604 | { |
---|
[3d124a7] | 605 | list @L@=names(R); |
---|
| 606 | int @ii@; string @s@; |
---|
| 607 | if( size(#) > 0 ) { @s@=@s@+"_"+#[1]; } |
---|
[6f2edc] | 608 | for( @ii@=size(@L@); @ii@>0; @ii@=@ii@-1 ) |
---|
| 609 | { |
---|
[3d124a7] | 610 | execute("def "+@L@[@ii@]+@s@+"=imap(R,`@L@[@ii@]`);"); |
---|
| 611 | execute("export "+@L@[@ii@]+@s@+";"); |
---|
| 612 | } |
---|
| 613 | return(); |
---|
| 614 | } |
---|
| 615 | example |
---|
| 616 | { "EXAMPLE:"; |
---|
| 617 | "// This example is not executed since imapall does not work in a procedure"; |
---|
| 618 | "// (and hence not in the example procedure). Just try the following commands:"; |
---|
| 619 | " ring R=0,(x,y,z,u),dp;"; |
---|
| 620 | " ideal j=x,y,z,u2+ux+z;"; |
---|
| 621 | " matrix M[2][3]=1,2,3,x,y,uz;"; |
---|
| 622 | " j; print(M);"; |
---|
| 623 | " ring S=0,(a,b,c,x,z,y),ds;"; |
---|
| 624 | " imapall(R); // map from R to S: x->x, y->y, z->z, u->0"; |
---|
| 625 | " names(S);"; |
---|
| 626 | " j; print(M);"; |
---|
| 627 | " imapall(S,\"1\"); // identity map of S: copy objects, change names"; |
---|
| 628 | " names(S);"; |
---|
| 629 | " kill R,S;"; |
---|
| 630 | } |
---|
| 631 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 632 | |
---|
[6f2edc] | 633 | proc mapall (R, ideal i, list #) |
---|
[3d124a7] | 634 | USAGE: mapall(R,i[,s]); R=ring/qring, i=ideal of basering, s=string |
---|
[6f2edc] | 635 | CREATE: map all objects of ring R (of type poly/ideal/vector/module/number/ |
---|
[3d124a7] | 636 | matrix, map) into the basering, by mapping the jth variable of R to |
---|
| 637 | the jth generator of the ideal i. If no 3rd argument is present, the |
---|
[6f2edc] | 638 | names are the same as in R. If, say, f is a poly in R and the 3rd |
---|
| 639 | argument is the string "R", then f is maped to f_R etc. |
---|
[3d124a7] | 640 | RETURN: no return value |
---|
| 641 | NOTE: This procedure has the same effect as defining a map, say psi, by |
---|
| 642 | map psi=R,i; and then applying psi to all objects of R. In particular, |
---|
| 643 | maps from R to some ring S are composed with psi, creating thus a map |
---|
[6f2edc] | 644 | from the basering to S. |
---|
[3d124a7] | 645 | mapall may be combined with copyring to change vars for all objects. |
---|
| 646 | The 3rd argument is useful in order to avoid conflicts of names, the |
---|
| 647 | empty string is allowed |
---|
[6f2edc] | 648 | CAUTION: mapall does not work inside a procedure |
---|
[3d124a7] | 649 | EXAMPLE: example mapall; shows an example |
---|
[6f2edc] | 650 | { |
---|
[3d124a7] | 651 | list @L@=names(R); map @psi@ = R,i; |
---|
| 652 | int @ii@; string @s@; |
---|
| 653 | if( size(#) > 0 ) { @s@=@s@+"_"+#[1]; } |
---|
[6f2edc] | 654 | for( @ii@=size(@L@); @ii@>0; @ii@=@ii@-1 ) |
---|
| 655 | { |
---|
[3d124a7] | 656 | execute("def "+@L@[@ii@]+@s@+"=@psi@(`@L@[@ii@]`);"); |
---|
| 657 | execute("export "+@L@[@ii@]+@s@+";"); |
---|
| 658 | } |
---|
| 659 | return(); |
---|
| 660 | } |
---|
| 661 | example |
---|
| 662 | { "EXAMPLE:"; |
---|
| 663 | "// This example is not executed since mapall does not work in a procedure"; |
---|
| 664 | "// (and hence not in the example procedure). Just try the following commands:"; |
---|
| 665 | " ring R=0,(x,y,z),dp;"; |
---|
| 666 | " ideal j=x,y,z;"; |
---|
| 667 | " matrix M[2][3]=1,2,3,x,y,z;"; |
---|
[6f2edc] | 668 | " map phi=R,x2,y2,z2; "; |
---|
[3d124a7] | 669 | " ring S=0,(a,b,c),ds;"; |
---|
| 670 | " ideal i=c,a,b;"; |
---|
| 671 | " mapall(R,i); // map from R to S: x->c, y->a, z->b"; |
---|
| 672 | " names(S);"; |
---|
| 673 | " j; print(M); phi; // phi is a map from R to S: x->c2, y->a2, z->b2"; |
---|
| 674 | " ideal i1=a2,a+b,1;"; |
---|
| 675 | " mapall(R,i1,\"\"); // map from R to S: x->a2, y->a+b, z->1"; |
---|
| 676 | " names(S);"; |
---|
| 677 | " j_; print(M_); phi_;"; |
---|
| 678 | " changevar(\"T\",\"x()\",R); // change vars in R and call result T"; |
---|
| 679 | " mapall(R,maxideal(1)); // identity map from R to T"; |
---|
| 680 | " names(T);"; |
---|
| 681 | " j; print(M); phi;"; |
---|
| 682 | " kill R,S,T;"; |
---|
| 683 | } |
---|
| 684 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 685 | |
---|
| 686 | proc ringtensor (string s, list #) |
---|
| 687 | USAGE: ringtensor(s,r1,r2,...); s=string, r1,r2,...=rings |
---|
| 688 | CREATE: A new base ring with name `s` if r1,r2,... are existing rings. |
---|
[6f2edc] | 689 | If, say, s = "R" and the rings r1,r2,... exist, the new ring will |
---|
| 690 | have name R, variables from all rings r1,r2,... and as monomial |
---|
[3d124a7] | 691 | ordering the block (product) ordering of r1,r2,... . Hence, R |
---|
| 692 | is the tensor product of the rings r1,r2,... with ordering matrix |
---|
| 693 | equal to the direct sum of the ordering matrices of r1,r2,... |
---|
| 694 | RETURN: no return value |
---|
| 695 | NOTE: The characteristic of the new ring will be that of r1. The names of |
---|
| 696 | variables in the rings r1,r2,... should differ (if a name, say x, |
---|
| 697 | occurs in r1 and r2, then, in the new ring r, x always refers to the |
---|
| 698 | variable with name x in r1, there is no access to x in r2). |
---|
| 699 | The procedure works also for quotient rings ri, if the characteristic |
---|
[6f2edc] | 700 | of ri is compatible with the characteristic of r1 (i.e. if imap from |
---|
[3d124a7] | 701 | ri to r1 is implemented) |
---|
[6f2edc] | 702 | This proc uses 'execute' or calls a procedure using 'execute'. |
---|
| 703 | If you use it in your own proc, let the local names of your proc |
---|
[3d124a7] | 704 | start with @ (see the file HelpForProc) |
---|
| 705 | EXAMPLE: example ringtensor; shows an example |
---|
| 706 | { |
---|
| 707 | int @ii,@q; |
---|
| 708 | int @n = size(#); |
---|
| 709 | string @vars,@order,@oi,@s1; |
---|
| 710 | //---- gather variables, orderings and ideals (of qrings) from given rings ---- |
---|
[6f2edc] | 711 | for(@ii=1; @ii<=@n; @ii=@ii+1) |
---|
[3d124a7] | 712 | { |
---|
[6f2edc] | 713 | if( ordstr(#[@ii])[1]=="C" or ordstr(#[@ii])[1]=="c" ) |
---|
[3d124a7] | 714 | { @oi=ordstr(#[@ii])[3,size(ordstr(#[@ii]))-2]; } |
---|
| 715 | else { @oi=ordstr(#[@ii])[1,size(ordstr(#[@ii]))-2]; } |
---|
| 716 | @vars = @vars+varstr(#[@ii])+","; |
---|
| 717 | @order= @order+@oi+","; |
---|
| 718 | def @r(@ii)=#[@ii]; |
---|
| 719 | setring @r(@ii); |
---|
[6f2edc] | 720 | ideal i(@ii)=ideal(@r(@ii)); |
---|
[3d124a7] | 721 | int @q(@ii)=size(i(@ii)); |
---|
| 722 | @q=@q+@q(@ii); |
---|
| 723 | } |
---|
| 724 | if( @q!=0 ) { @s1 = "@newr"; } // @q=0 iff none of the rings ri is a qring |
---|
| 725 | else { @s1 = s; } |
---|
| 726 | //------------------------------- create new ring ----------------------------- |
---|
| 727 | string @newring ="=("+charstr(#[1])+"),("+@vars[1,size(@vars)-1]+"),(" |
---|
| 728 | +@order[1,size(@order)-1]+");"; |
---|
| 729 | execute("ring "+@s1+@newring); |
---|
| 730 | //------ create ideal for new ring if one of the given rings is a qring ------- |
---|
| 731 | if( @q!=0 ) |
---|
| 732 | { |
---|
| 733 | ideal i; |
---|
[6f2edc] | 734 | for(@ii=1; @ii<=@n; @ii=@ii+1) |
---|
[3d124a7] | 735 | { |
---|
| 736 | if( @q(@ii)!=0 ) |
---|
| 737 | { |
---|
| 738 | i=i+imap(@r(@ii),i(@ii)); |
---|
| 739 | } |
---|
| 740 | } |
---|
| 741 | i=std(i); |
---|
[6f2edc] | 742 | execute("qring "+s+"=i;"); |
---|
[3d124a7] | 743 | } |
---|
| 744 | //----------------------- export and keep created ring ------------------------ |
---|
| 745 | export(`s`); |
---|
| 746 | keepring(`s`); |
---|
| 747 | if (voice==2) { "// basering is now",s; } |
---|
| 748 | return(); |
---|
| 749 | } |
---|
[6f2edc] | 750 | example |
---|
[3d124a7] | 751 | { "EXAMPLE:"; echo = 2; |
---|
| 752 | ring r=32003,(x,y,u,v),dp; |
---|
| 753 | ring s=0,(a,b,c),wp(1,2,3); |
---|
| 754 | ring t=0,x(1..5),(c,ls); |
---|
[6f2edc] | 755 | ringtensor("R",r,s,t); |
---|
[3d124a7] | 756 | type R;""; |
---|
| 757 | setring s; |
---|
| 758 | ideal i = a2+b3+c5; |
---|
| 759 | changevar("S","x,y,z"); //set S (change vars of s to x,y,z) the basering |
---|
| 760 | qring qS =std(fetch(s,i)); //create qring of S mod i (maped to S) |
---|
| 761 | changevar("T","d,e,f,g,h",t); //set T (change vars of t to d..h) the basering |
---|
| 762 | qring qT=std(d2+e2-f3); //create qring of T mod d2+e2-f3 |
---|
[6f2edc] | 763 | ringtensor("Q",s,qS,t,qT); |
---|
[3d124a7] | 764 | type Q; |
---|
| 765 | kill R,Q,S,T; |
---|
| 766 | } |
---|
| 767 | /////////////////////////////////////////////////////////////////////////////// |
---|
[0fbdd1] | 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 | /////////////////////////////////////////////////////////////////////////////// |
---|