Changeset 6fe3a0 in git for Singular/LIB/ring.lib


Ignore:
Timestamp:
Apr 25, 2005, 12:13:07 PM (19 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
3329dd9bcf2662f9666579abea56c33dfcb530ac
Parents:
8604751c5a5f572004bf8d35d4307e485b728435
Message:
*hannes/lossen: new libs, new tests


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/ring.lib

    r860475 r6fe3a0  
    1 //(GMG, last modified 03.11.95)
    2 ///////////////////////////////////////////////////////////////////////////////
    3 version="$Id: ring.lib,v 1.20 2005-04-15 13:42:55 Singular Exp $";
     1///////////////////////////////////////////////////////////////////////////////
     2version="$Id: ring.lib,v 1.21 2005-04-25 10:13:06 Singular Exp $";
    43category="General purpose";
    54info="
     
    183182///////////////////////////////////////////////////////////////////////////////
    184183
    185 proc defring (string s1, string s2, int n, string s3, string s4)
    186 "USAGE:   defring(s1,s2,n,s3,s4);  s1..s4=strings, n=integer
    187 CREATE:  Define a ring with name 's1', characteristic 's2', ordering 's4' and
    188          n variables with names derived from s3 and make it the basering.
    189          If s3 is a single letter, say s3=\"a\", and if n<=26 then a and the
    190          following n-1 letters from the alphabeth (cyclic order) are taken as
    191          variables. If n>26 or if s3 is a single letter followed by (, say
    192          s3=\"T(\", the variables are T(1),...,T(n).
    193 RETURN:  No return value
     184proc defring (string s2, int n, string s3, string s4)
     185"USAGE:   defring(ch,n,va,or);  ch,va,or=strings, n=integer
     186RETURN:  ring R with characteristic 'ch', ordering 'or' and n variables with
     187         names derived from va.
     188         If va is a single letter, say va=\"a\", and if n<=26 then a and the
     189         following n-1 letters from the alphabet (cyclic order) are taken as
     190         variables. If n>26 or if va is a single letter followed by a bracket,
     191         say va=\"T(\", the variables are T(1),...,T(n).
    194192NOTE:    This proc is useful for defining a ring in a procedure.
    195193         This proc uses 'execute' or calls a procedure using 'execute'.
    196          If you use it in your own proc, let the local names of your proc
    197          start with @.
     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 @.
    198196EXAMPLE: example defring; shows an example
    199197"
    200198{
    201    string @newring = "ring "+s1+"=("+s2+"),(";
     199   string @newring = "ring newring =("+s2+"),(";
    202200   if( n>26 or s3[2]=="(" ) { string @v = s3[1]+"(1.."+string(n)+")"; }
    203201   else { string @v = A_Z(s3,n); }
    204202   @newring=@newring+@v+"),("+s4+");";
    205203   execute(@newring);
    206    export(basering);
    207    keepring(`s1`);
    208    if (voice==2) { "// basering is now:",s1; }
    209    return();
     204   return(newring);
    210205}
    211206example
    212207{ "EXAMPLE:"; echo = 2;
    213    defring("r","0",5,"u","ls"); r; "";
    214    defring("R","2,A",10,"x(","dp(3),ws(1,2,3),ds"); R;
    215    if(system("with","Namespaces")) { kill Top::R,Top::r; }
    216    if (defined(R)) {kill R,r;}
     208   def r=defring("0",5,"u","ls"); r; setring r;"";
     209   def R=defring("2,A",10,"x(","dp(3),ws(1,2,3),ds"); R; setring R;
     210   kill R,r;
    217211}
    218212///////////////////////////////////////////////////////////////////////////////
     
    287281///////////////////////////////////////////////////////////////////////////////
    288282
    289 proc extendring (string na, int n, string va, string o, list #)
    290 "USAGE:   extendring(na,n,va,o[iv,i,r]);  na,va,o=strings,
    291          n,i=integers, r=ring, iv=intvec of positive integers or iv=0
    292 CREATE:  Define a ring with name `na` which extends the ring r by adding n new
    293          variables in front of [after, if i!=0] the old variables and make it
    294          the basering [default: (i,r)=(0,basering)].
     283proc extendring (int n, string va, string o, list #)
     284"USAGE:   extendring(n,va,o[iv,i,r]);  va,o=strings, n,i=integers, r=ring,
     285          iv=intvec of positive integers or iv=0
     286RETURN:  ring R, which extends the ring r by adding n new variables in front
     287         of (resp. after, if i!=0) the old variables.
     288         [default: (i,r)=(0,basering)].
    295289@*       -- The characteristic is the characteristic of r.
    296290@*       -- The new vars are derived from va. If va is a single letter, say
    297291            va=\"T\", and if n<=26 then T and the following n-1 letters from
    298292            T..Z..T (resp. T(1..n) if n>26) are taken as additional variables.
    299             If va is a single letter followed by (, say va=\"x(\", the new
    300             variables are x(1),...,x(n).
    301 @*       -- The ordering is the product ordering between the ordering of r and
    302             an ordering derived from `o` [and iv].
    303 @*        -  If o contains a 'c' or a 'C' in front resp. at the end this is
    304             taken for the whole ordering in front resp. at the end. If o does
     293            If va is a single letter followed by a bracket, say va=\"x(\",
     294            the new variables are x(1),...,x(n).
     295@*       -- The ordering is the product ordering of the ordering of r and of an
     296            ordering derived from `o` [and iv].
     297@*        -  If o contains a 'c' or a 'C' in front resp. at the end, this is
     298            taken for the whole ordering in front, resp. at the end. If o does
    305299            not contain a 'c' or a 'C' the same rule applies to ordstr(r).
    306300@*        -  If no intvec iv is given, or if iv=0, o may be any allowed ordstr,
     
    319313            e.g. o=\"dp,ws,Dp,ds\", iv=3,2,3,4,2,5 creates the ordering
    320314            dp(2),ws(2,3,4),Dp(5),ds
    321 RETURN:  No return value
    322315NOTE:    This proc is useful for adding deformation parameters.
    323316         This proc uses 'execute' or calls a procedure using 'execute'.
    324          If you use it in your own proc, let the local names of your proc
    325          start with @ (see the file HelpForProc)
     317         If you use it in your own proc, it may be advisable to let the local
     318         names of your proc start with a @ (see the file HelpForProc)
    326319EXAMPLE: example extendring; shows an example
    327320"
     
    391384   }
    392385//------------------------ prepare string of new ring -------------------------
    393    @newring = "ring "+na+"=("+charstr(@r)+"),(";
     386   @newring = "ring na =("+charstr(@r)+"),(";
    394387   if( n>26 or va[2]=="(" ) { @v = va[1]+"(1.."+string(n)+")"; }
    395388   else                     { @v = A_Z(va,n); }
     
    407400//---------------------------- execute and export -----------------------------
    408401   execute(@newring);
    409    export(basering);
    410    keepring(`na`);
    411    if (voice==2) { "// basering is now",na; }
    412    return();
     402   dbprint(printlevel-voice+2,"
     403// 'extendring' created a new ring.
     404// To see the ring, type (if the name 'R' was assigned to the return value):
     405     show(R);
     406");
     407
     408   return(na);
    413409}
    414410example
     
    416412   ring r=0,(x,y,z),ds;
    417413   show(r);"";
    418    //blocksize is derived from no of vars:
     414   // blocksize is derived from no of vars:
    419415   int t=5;
    420    extendring("R1",t,"a","dp");         //t global: "dp" -> "dp(5)"
    421    show(R1); "";
    422    extendring("R2",4,"T(","c,dp",1,r);    //"dp" -> "c,..,dp(4)"
    423    show(R2);"";
    424 
    425    //no intvec given, blocksize given: given blocksize is used:
    426    extendring("R3",4,"T(","dp(2)",0,r);   // "dp(2)" -> "dp(2)"
    427    show(R3);"";
    428 
    429    //intvec given: weights and blocksize is derived from given intvec
    430    //(no specification of a blocksize in the given ordstr is allowed!)
    431    //if intvec does not cover all given blocks, the last block is used
    432    //for the remaining variables, if intvec has too many components,
    433    //the last ones are ignored
     416   def R1=extendring(t,"a","dp");         //t global: "dp" -> "dp(5)"
     417   show(R1); setring R1; "";
     418   def R2=extendring(4,"T(","c,dp",1,r);    //"dp" -> "c,..,dp(4)"
     419   show(R2); setring R2; "";
     420
     421   // no intvec given, blocksize given: given blocksize is used:
     422   def R3=extendring(4,"T(","dp(2)",0,r);   // "dp(2)" -> "dp(2)"
     423   show(R3); setring R3; "";
     424
     425   // intvec given: weights and blocksize is derived from given intvec
     426   // (no specification of a blocksize in the given ordstr is allowed!)
     427   // if intvec does not cover all given blocks, the last block is used
     428   // for the remaining variables, if intvec has too many components,
     429   // the last ones are ignored
    434430   intvec v=3,2,3,4,1,3;
    435    extendring("R4",10,"A","ds,ws,Dp,dp",v,0,r);
    436          //v covers 3 blocks: v[1] (=3) : no of components of ws
    437          //next v[1] values (=v[2..4]) give weights
    438          //remaining components of v are used for the remaining blocks
     431   def R4=extendring(10,"A","ds,ws,Dp,dp",v,0,r);
     432   // v covers 3 blocks: v[1] (=3) : no of components of ws
     433   // next v[1] values (=v[2..4]) give weights
     434   // remaining components of v are used for the remaining blocks
    439435   show(R4);
    440    if(system("with","Namespaces")){kill Top::r,Top::R1,Top::R2,Top::R3,Top::R4;}
    441    if (defined(r)) { kill r,R1,R2,R3,R4; }
     436   kill r,R1,R2,R3,R4;
    442437}
    443438///////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.