Changeset 3ca4229 in git for Singular/LIB/ring.lib


Ignore:
Timestamp:
Sep 12, 1997, 10:18:04 AM (27 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
9e0a6ddbec4d640f6209638d32ef74400c5c5ba7
Parents:
0fbdd16f374f7f4570da62a453e2328e4d8a4b4c
Message:
*** empty log message ***


git-svn-id: file:///usr/local/Singular/svn/trunk@715 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/ring.lib

    r0fbdd1 r3ca4229  
    1 // $Id: ring.lib,v 1.3 1997-09-12 07:40:36 Singular Exp $
     1// $Id: ring.lib,v 1.4 1997-09-12 08:18:04 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]
    1110 defring("R",c,n,v,o);  define a ring R in specified char c, n vars v, ord o
    1211 defrings(n[,p]);       define ring Sn in n vars, char 32003 [p], ord ds
    1312 defringp(n[,p]);       define ring Pn in n vars, char 32003 [p], ord dp
    1413 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
    1614 fetchall(R[,str]);     fetch all objects of ring R to basering
    1715 imapall(R[,str]);      imap all objects of ring R to basering
    1816 mapall(R,i[,str]);     map all objects of ring R via ideal i to basering
    1917 ringtensor("R",s,t,..);create ring R, tensor product of rings s,t,...
    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)
     18           (parameters in square brackets [] are optional)
    2319
    2420LIB "inout.lib";
     
    174170///////////////////////////////////////////////////////////////////////////////
    175171
    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 
    204172proc defring (string s1, string s2, int n, string s3, string s4)
    205173USAGE:   defring(s1,s2,n,s3,s4);  s1..s4=strings, n=integer
     
    301269
    302270proc extendring (string na, int n, string va, string o, list #)
    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,
     271USAGE:   extendring(na,n,va,o[iv,i,r]);  na,va,o=strings,
    379272         n,i=integers, r=ring, iv=intvec of positive integers or iv=0
    380273CREATE:  Define a ring with name `na` which extends the ring r by adding n new
     
    386279            T..Z..T (resp. T(1..n) if n>26) are taken as additional variables.
    387280            If va is a single letter followed by (, say va="x(", the new
    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
     281            variables are x(1),...,x(n)
    391282         -- The ordering is the product ordering between the ordering of r and
    392283            an ordering derived from `o` [and iv]
     
    397288            like "ds" or "dp(2),wp(1,2,3),Ds(2)" or "ds(a),dp(b),ls" if a and b
    398289            are globally (!) defined integers and if a+b+1<=n
    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
     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
    401292         -  If an intvec iv !=0 is given, iv[1],iv[2],... is taken for the 1st,
    402293            2nd,... block of o, if o contains no substring "w" or "W" i.e. no
     
    413304         If you use it in your own proc, let the local names of your proc
    414305         start with @ (see the file HelpForProc)
    415 EXAMPLE: example extendring1; shows an example
     306EXAMPLE: example extendring; shows an example
    416307{
    417308//--------------- initialization and place c/C of ordering properly -----------
     
    480371//------------------------ prepare string of new ring -------------------------
    481372   @newring = "ring "+na+"=("+charstr(@r)+"),(";
    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 
     373   if( n>26 or va[2]=="(" ) { @v = va[1]+"(1.."+string(n)+")"; }
     374   else                     { @v = A_Z(va,n); }
    492375   if( @i==0 )
    493376   {
     
    512395   ring r=0,(x,y,z),ds;
    513396   show(r);"";
    514    extendring1("S",2,"u","ds");
    515    setring r;
    516    show(S); "";
    517    extendring1("R0",2,"a,w","ds");
    518    show(R0); "";
    519397   //no intvec given, no blocksize given: blocksize is derived from no of vars
    520398   int t=5;
    521    extendring1("R1",t,"a","dp");         //t global: "dp" -> "dp(5)"
     399   extendring("R1",t,"a","dp");         //t global: "dp" -> "dp(5)"
    522400   show(R1); "";
    523    extendring1("R2",4,"T(","c,dp",1,r);    //"dp" -> "c,..,dp(4)"
     401   extendring("R2",4,"T(","c,dp",1,r);    //"dp" -> "c,..,dp(4)"
    524402   show(R2);"";
    525403
    526404   //no intvec given, blocksize given: given blocksize is used
    527    extendring1("R3",4,"T(","dp(2)",0,r);   // "dp(2)" -> "dp(2)"
     405   extendring("R3",4,"T(","dp(2)",0,r);   // "dp(2)" -> "dp(2)"
    528406   show(R3);"";
    529407
     
    534412   //ones are ignored
    535413   intvec v=3,2,3,4,1,3;
    536    extendring1("R4",10,"A","ds,ws,Dp,dp",v,0,r);
     414   extendring("R4",10,"A","ds,ws,Dp,dp",v,0,r);
    537415         //v covers 3 blocks: v[1] (=3) : no of components of ws
    538416         //next v[1] values (=v[2..4]) give weights
    539417         //remaining components of v are used for the remaining blocks
    540418   show(R4);
    541    kill S,R0,R1,R2,R3,R4;
     419   kill r,R1,R2,R3,R4;
    542420}
    543421///////////////////////////////////////////////////////////////////////////////
     
    766644}
    767645///////////////////////////////////////////////////////////////////////////////
    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 ///////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.