Changeset 8647dd in git


Ignore:
Timestamp:
Apr 28, 2005, 11:21:59 AM (18 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
Children:
daa83bcd8a2f618d74ab2877569d0c88d17bece7
Parents:
5bc4ee3956b1cef3f4a576f97eafb4340ddfc133
Message:
*lossen: keepring elimiated


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/ring.lib

    r5bc4ee3 r8647dd  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: ring.lib,v 1.21 2005-04-25 10:13:06 Singular Exp $";
     2version="$Id: ring.lib,v 1.22 2005-04-28 09:21:59 Singular Exp $";
    33category="General purpose";
    44info="
     
    2828///////////////////////////////////////////////////////////////////////////////
    2929
    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
     30proc changechar (string c, list #)
     31"USAGE:   changechar(c[,r]);  c=string, r=ring
     32RETURN:  ring R, obtained from the ring r [default: r=basering], by changing
     33         charstr(r) to c.
     34NOTE:    Works for qrings if map from old_char to new_char is implemented.
    3935         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 proc
    41          start with @.
    4236EXAMPLE: 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}
     58example
     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
     67proc changeord (string o, list #)
     68"USAGE:   changeord(newordstr[,r]);  newordstr=string, r=ring/qring
     69RETURN:  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.
     73NOTE:    This proc uses 'execute' or calls a procedure using 'execute'.
     74EXAMPLE: example changeord; shows an example
    4375"
    4476{
     
    4880   ideal i = ideal(@r); int @q = size(i);
    4981   if( @q!=0 )
    50       { string @s = "@newr1"; }
     82      { string @s = "Rnew1"; }
    5183   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+");";
    5486   execute("ring "+@newring);
    5587   if( @q!=0 )
     
    5890      ideal i = phi(i);
    5991      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);
    6695}
    6796example
    6897{  "EXAMPLE:"; echo = 2;
    6998   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
     107proc changevar (string vars, list #)
     108"USAGE:   changevar(vars[,r]);  vars=string, r=ring/qring
     109RETURN:  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.
     115NOTE:    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'.
     118EXAMPLE: example changevar; shows an example
    89119"
    90120{
     
    94124   ideal i = ideal(@r); int @q = size(i);
    95125   if( @q!=0 )
    96       { string @s = "@newr1"; }
     126      { string @s = "Rnew1"; }
    97127   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"; }
    151129   string @newring = @s+"=("+charstr(@r)+"),(";
    152130   if( vars[size(vars)-1]=="(" and vars[size(vars)]==")" )
     
    162140      ideal i = phi(i);
    163141      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);
    170145}
    171146example
     
    175150   qring Q = std(i);
    176151   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';
    181155}
    182156///////////////////////////////////////////////////////////////////////////////
     
    192166NOTE:    This proc is useful for defining a ring in a procedure.
    193167         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 local
    195          names of your proc start with a @.
    196168EXAMPLE: example defring; shows an example
    197169"
     
    214186proc defrings (int n, list #)
    215187"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
     188RETURN:  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)
     190NOTE:    This proc uses 'execute' or calls a procedure using 'execute'.
    220191EXAMPLE: example defrings; shows an example
    221192"
     
    226197   if (n >26)
    227198   {
    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;";
    229200   }
    230201   else
    231202   {
    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;";
    233204   }
    234205   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);
    238213}
    239214example
    240215{ "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;
    245219}
    246220///////////////////////////////////////////////////////////////////////////////
     
    248222proc defringp (int n,list #)
    249223"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
     224RETURN:  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)
     226NOTE:    This proc uses 'execute' or calls a procedure using 'execute'.
    254227EXAMPLE: example defringp; shows an example
    255228"
     
    260233   if (n >26)
    261234   {
    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;";
    263236   }
    264237   else
    265238   {
    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;";
    267240   }
    268241   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);
    273249}
    274250example
    275251{ "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;
    280255}
    281256///////////////////////////////////////////////////////////////////////////////
     
    620595///////////////////////////////////////////////////////////////////////////////
    621596
    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
     597proc ringtensor (list #)
     598"USAGE:   ringtensor(r1,r2,...); s=string, r1,r2,...=rings
     599RETURN:  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
    628602         is the tensor product of the rings r1,r2,... with ordering matrix
    629603         equal to the direct sum of the ordering matrices of r1,r2,...
    630 RETURN:  no return value
    631604NOTE:    The characteristic of the new ring will be that of r1. The names of
    632605         variables in the rings r1,r2,... should differ (if a name, say x,
     
    637610         ri to r1 is implemented)
    638611         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 proc
    640          start with @ (see the file HelpForProc)
    641612EXAMPLE: example ringtensor; shows an example
    642613"
     
    660631   }
    661632   if( @q!=0 ) { @s1 = "@newr"; }   // @q=0 iff none of the rings ri is a qring
    662    else {  @s1 = s; }
     633   else {  @s1 = "s"; }
    663634//------------------------------- create new ring -----------------------------
    664635   string @newring ="=("+charstr(#[1])+"),("+@vars[1,size(@vars)-1]+"),("
     
    677648      }
    678649      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);
    686659}
    687660example
     
    690663   ring s=0,(a,b,c),wp(1,2,3);
    691664   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; 
    694667   setring s;
    695668   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);
    701676   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;
    704678}
    705679///////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.