Changeset 0fbdd1 in git for Singular/LIB/ring.lib


Ignore:
Timestamp:
Sep 12, 1997, 9:40:37 AM (27 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
3ca4229c4e4d8d84ca999ef93aec635eb84259c6
Parents:
4a81eccd72975057d29a44244958cdc9a450eb71
Message:
* hannes/greuel: all.lib: update
                 homolog.lib: changed printing
                 inout.lib: added showrec, changed show
                 ring.lib: added substitute,copyring,swapvars,extendring1
                 sing.lib: changed spectrum, T1, codim
                 standard.lib: changed help


git-svn-id: file:///usr/local/Singular/svn/trunk@709 2c84dea3-7e68-4137-9b89-c4e89433aadc
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 obachman Exp $
     1// $Id: ring.lib,v 1.3 1997-09-12 07:40:36 Singular Exp $
    22//(GMG, last modified 03.11.95)
    33///////////////////////////////////////////////////////////////////////////////
     
    88 changeord("R",o[,r]);  make a copy R of basering [ring r] with new ord o
    99 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]
    1011 defring("R",c,n,v,o);  define a ring R in specified char c, n vars v, ord o
    1112 defrings(n[,p]);       define ring Sn in n vars, char 32003 [p], ord ds
    1213 defringp(n[,p]);       define ring Pn in n vars, char 32003 [p], ord dp
    1314 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
    1416 fetchall(R[,str]);     fetch all objects of ring R to basering
    1517 imapall(R[,str]);      imap all objects of ring R to basering
    1618 mapall(R,i[,str]);     map all objects of ring R via ideal i to basering
    1719 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)
    1923
    2024LIB "inout.lib";
     
    170174///////////////////////////////////////////////////////////////////////////////
    171175
     176proc copyring (string newr,list #)
     177USAGE:   copyring(newr[,r]);  newr=string, r=ring/qring
     178CREATE:  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"
     181RETURN:  No return value
     182NOTE:    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)
     185EXAMPLE: 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}
     195example
     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
    172204proc defring (string s1, string s2, int n, string s3, string s4)
    173205USAGE:   defring(s1,s2,n,s3,s4);  s1..s4=strings, n=integer
     
    269301
    270302proc extendring (string na, int n, string va, string o, list #)
    271 USAGE:   extendring(na,n,va,o[iv,i,r]);  na,va,o=strings,
     303USAGE:   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
     305CREATE:  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]
     317RETURN:  No return value
     318NOTE:    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)
     322EXAMPLE: 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}
     361example
     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
     377proc extendring1 (string na, int n, string va, string o, list #)
     378USAGE:   extendring1(na,n,va,o[iv,i,r]);  na,va,o=strings,
    272379         n,i=integers, r=ring, iv=intvec of positive integers or iv=0
    273380CREATE:  Define a ring with name `na` which extends the ring r by adding n new
     
    279386            T..Z..T (resp. T(1..n) if n>26) are taken as additional variables.
    280387            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
    282391         -- The ordering is the product ordering between the ordering of r and
    283392            an ordering derived from `o` [and iv]
     
    288397            like "ds" or "dp(2),wp(1,2,3),Ds(2)" or "ds(a),dp(b),ls" if a and b
    289398            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
     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
    292401         -  If an intvec iv !=0 is given, iv[1],iv[2],... is taken for the 1st,
    293402            2nd,... block of o, if o contains no substring "w" or "W" i.e. no
     
    304413         If you use it in your own proc, let the local names of your proc
    305414         start with @ (see the file HelpForProc)
    306 EXAMPLE: example extendring; shows an example
     415EXAMPLE: example extendring1; shows an example
    307416{
    308417//--------------- initialization and place c/C of ordering properly -----------
     
    371480//------------------------ prepare string of new ring -------------------------
    372481   @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
    375492   if( @i==0 )
    376493   {
     
    395512   ring r=0,(x,y,z),ds;
    396513   show(r);"";
     514   extendring1("S",2,"u","ds");
     515   setring r;
     516   show(S); "";
     517   extendring1("R0",2,"a,w","ds");
     518   show(R0); "";
    397519   //no intvec given, no blocksize given: blocksize is derived from no of vars
    398520   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)"
    400522   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)"
    402524   show(R2);"";
    403525
    404526   //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)"
    406528   show(R3);"";
    407529
     
    412534   //ones are ignored
    413535   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);
    415537         //v covers 3 blocks: v[1] (=3) : no of components of ws
    416538         //next v[1] values (=v[2..4]) give weights
    417539         //remaining components of v are used for the remaining blocks
    418540   show(R4);
    419    kill r,R1,R2,R3,R4;
     541   kill S,R0,R1,R2,R3,R4;
    420542}
    421543///////////////////////////////////////////////////////////////////////////////
     
    644766}
    645767///////////////////////////////////////////////////////////////////////////////
     768
     769proc substitute (id, vars, list #)
     770USAGE:    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
     774RETURN:   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
     778EXAMPLE:  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}
     807example
     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
     825proc swapvars (id,poly p1,poly p2)
     826USAGE:    swapvars(id,p1,p2); id = object in basering which can be mapped
     827          p1,  p2 = variables which shall be interchanged
     828RETURN:   id, with p1 and p2 interchanged
     829EXAMPLE:  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}
     844example
     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.