Changeset 9f8a0c in git for Singular/LIB/inout.lib


Ignore:
Timestamp:
Dec 30, 2000, 4:44:31 PM (23 years ago)
Author:
Gert-Martin Greuel <greuel@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
2b4e7066de6a1ca22687a95c7411269e78fe38d8
Parents:
7708934c4dd35b5ec3af10e0b6fe8671994ca033
Message:
* GMG: dbpri entfernt, da ueberhlot durch dbprint
*      example in lprint, rMacaulay, split verkleinert
*      Beschreibung von writelist und pause verbessert und ergaenzt


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/inout.lib

    r7708934 r9f8a0c  
    11// (GMG/BM, last modified 22.06.96)
    22///////////////////////////////////////////////////////////////////////////////
    3 version="$Id: inout.lib,v 1.19 2000-12-22 14:06:55 greuel Exp $";
     3version="$Id: inout.lib,v 1.20 2000-12-30 15:44:31 greuel Exp $";
    44category="General purpose";
    55info="
     
    88PROCEDURES:
    99 allprint(list);        print list if ALLprint is defined, with pause if >0
    10  dbpri(n,list);         print objects of list if int n<=printlevel
    1110 lprint(poly/...[,n]);  display poly/... fitting to pagewidth [size n]
    1211 pmat(matrix[,n]);      print form-matrix [first n chars of each colum]
     
    1615 split(string,n);       split given string into lines of length n
    1716 tab(n);                string of n space tabs
    18  writelist(fil,nam,L);  write the list L into a file `fil` and call it `nam`
     17 writelist(...);        write a list into a file and keep the list structure
    1918 pause([prompt]);       stop the computation until user input
    2019           (parameters in square brackets [] are optional)
     
    2524proc allprint (list #)
    2625"USAGE:   allprint(L);  L list
    27 CREATE:  display L[1], L[2], ... if an integer with name ALLprint is defined,
    28          makes \"pause\",   if ALLprint > 0
    29          listvar(matrix), if ALLprint = 2
     26DISPLAY: prints L[1], L[2], ... if an integer with name ALLprint is defined.
     27@*       makes \"pause\",   if ALLprint > 0
     28@*       listvar(matrix), if ALLprint = 2
    3029RETURN:  no return value
    3130EXAMPLE: example allprint; shows an example
     
    5150///////////////////////////////////////////////////////////////////////////////
    5251
    53 proc dbpri (int n ,list #)
    54 "USAGE:   dbpri(n,L);  n integer, L list
    55 CREATE:  display L[1], L[2], ... if an integer with name printlevel is defined
    56          and if n<=printlevel, set printlevel to 0 if it is not defined
    57 RETURN:  no return value
    58 NOTE:    this is uesful to control the printing of comments or partial results
    59          in a procedure, e.g. for debugging a procedure.
    60          It is similair but not the same as the internal function dbprint
    61 EXAMPLE: example dbpri; shows an example
    62 "
    63 {
    64    int i;
    65    if( defined(printlevel)==0 ) { int printlevel; export printlevel; }
    66    if( n<=printlevel )
    67    {
    68       for( i=1; i<=size(#); i=i+1 ) {  print(#[i]); }
    69    }
    70    return();
    71 }
    72 example
    73 { "EXAMPLE:"; echo = 2;
    74    ring s;
    75    module M=freemodule(3);
    76    dbpri(0,"M =",M);
    77 }
    78 ///////////////////////////////////////////////////////////////////////////////
    79 
    8052proc lprint
    8153"USAGE:   lprint(id[,n]);  id poly/ideal/vector/module/matrix, n integer
    82 RETURN:  string of id in a format fitting into lines of size n; if only one
    83          argument is present, n = pagewidth
     54RETURN:  string of id in a format fitting into lines of size n, such that no
     55         monomial gests destroyed, i.e. the new line starts with + or -;
     56         (default: n = pagewidth).
    8457NOTE:    id is printed columnwise, each column separated by a blank line;
    8558         hence lprint(transpose(id)); displays a matrix id in a format which
    86          can be used as input to reproduce id
     59         can be used as input.
    8760EXAMPLE: example lprint; shows an example
    8861"
     
    129102   ring r= 0,(x,y,z),ds;
    130103   poly f=((x+y)*(x-y)*(x+z)*(y+z)^2);
    131    short = 0;    // no short output, use * and ^
    132    lprint(f,40); newline;
    133    ideal i = f^2,x-y,(x+y)^2*f;
    134    short = 1;    // short output, omit * and ^
    135    lprint(i); newline;
    136    module m = [f^2,x-y,(x+y)^2*f],[0,x-y,f^2];
     104   lprint(f,40);
     105   module m = [f*(x-y)],[0,f*(x-y)];
    137106   string s=lprint(m); s;"";
    138    // the following commands show how to use the string s=lprint(m) (defined
    139    // above) as input in order to reproduce m (by defining m1):
    140    execute("matrix M[2][3]="+s+";");
    141    module m1 = transpose(M);
    142    m-m1;
     107   execute("matrix M[2][2]="+s+";");      //use the string s as input
     108   module m1 = transpose(M);              //should be the same as m
     109   print(m-m1);
    143110}
    144111///////////////////////////////////////////////////////////////////////////////
     
    146113proc pmat (matrix m, list #)
    147114"USAGE:   pmat(M,[n]);  M matrix, n integer
    148 CREATE:  display M in array format if it fits into pagewidth, no return value;
    149          if n is given, only the first n characters of each colum are shown
     115DISPLAY: display M in array format if it fits into pagewidth; if n is given,
     116         only the first n characters of each colum are shown
    150117RETURN:  no return value
    151118EXAMPLE: example pmat; shows an example
     
    217184proc rMacaulay
    218185"USAGE:   rMacaulay(s[,n]);  s string, n integer
    219 RETURN:  a string which should be readable by Singular if s is a string read
    220          by Singular from a file which was produced by Macaulay_1 (='Macaulay
    221          classic'). If a second argument is present the first n lines of the
    222          file are deleted (which is useful if the file was prodeuced e.g. by
    223          the putstd command of Macaulay)
    224 NOTE:    This does not always work with 'cut and paste' since, coming
    225          from the screen, the character \ is treated differently
     186RETURN:  A string which should be readable by Singular if s is a string which
     187         was produced by Macaulay. If a second argument is present the first
     188         n lines of the file are deleted (which is useful if the file was
     189         produced e.g. by the putstd command of Macaulay).
     190NOTE:    This does not always work with 'cut and paste' since the character
     191         \ is treated differently
    226192EXAMPLE: example rMacaulay; shows an example
    227193"
     
    308274example
    309275{  "EXAMPLE:"; echo = 2;
    310    // Assume there exists a file 'Macid' with the following ideal in Macaulay
    311    // format:"
     276   // Assume there exists a file 'Macid' with the following ideal in
     277   // Macaulay format:"
    312278   // x[0]3-101/74x[0]2x[1]+7371x[0]x[1]2-13/83x[1]3-x[0]2x[2] \
    313    //     -4/71x[0]x[1]x[2]-65/64x[1]2x[2]-49/111x[0]x[2]2-x[1]x[2]2 \
    314    //     -747x[2]3+6072x[0]2x[3]
    315    // You can read this file into Singular and assign it to the string s1 by:
     279   //     -4/71x[0]x[1]x[2]
     280   // Read this file into Singular and assign it to the string s1 by:
    316281   // string s1 = read("Macid");
    317282   // This is equivalent to";
    318283   string s1 =
    319    "x[0]3-101/74x[0]2x[1]+7371x[0]x[1]2-13/83x[1]3-x[0]2x[2]-4/71x[0]x[1]x[2]-65/64x[1]2x[2]-49/111x[0]x[2]2-x[1]x[2]2-747x[2]3+6072x[0]2x[3]";
     284   "x[0]3-101/74x[0]2x[1]+7371x[0]x[1]2-13/83x[1]3-x[0]2x[2]-4/71x[0]x[1]x[2]";
    320285   rMacaulay(s1);
    321286   // You may wish to assign s1 to a Singular ideal id:
     
    324289   execute(sid);
    325290   id; "";
    326    // The next example treats a matrix in Macaulay format. Using the execute
     291   // Now treat a matrix in Macaulay format. Using the execute
    327292   // command, this could be assinged to a Singular matrix as above.
    328293   string s2 = "
     
    340305proc show (id, list #)
    341306"USAGE:   show(id);   id any object of basering or of type ring/qring
    342          show(R,s);  R=ring, s=string (s = name of an object belonging to R)
     307@*       show(R,s);  R=ring, s=string (s = name of an object belonging to R)
    343308DISPLAY: display id/s in a compact format together with some information
    344309RETURN:  no return value
    345310NOTE:    objects of type string, int, intvec, intmat belong to any ring.
    346311         id may be a ring or a qring. In this case the minimal polynomial is
    347          displayed, and, for a qring, also the defining ideal
    348          id may be of type list but the list must not contain a ring
    349 CAUTION: show(R,s) does not work inside a procedure
     312         displayed, and, for a qring, also the defining ideal.
     313         id may be of type list but the list must not contain a ring.
     314@*       show(R,s) does not work inside a procedure!
    350315EXAMPLE: example show; shows an example
    351316"
     
    537502
    538503proc showrecursive (id,poly p,list #)
    539 "USAGE:   showrecursive(id,p[ord]); id=any object of basering, p=product of
     504"USAGE:   showrecursive(id,p[ord]); id= any object of basering, p= product of
    540505         variables and ord=string (any allowed ordstr)
    541506DISPLAY: display 'id' in a recursive format as a polynomial in the variables
    542          occuring in p with coefficients in the remaining variables. Do this
    543          by mapping in a ring with parameters [and ordering 'ord', if a 3rd
    544          argument is present (default: ord=\"dp\")] and applying procedure 'show'
     507         occuring in p with coefficients in the remaining variables. This is
     508         done by mapping to a ring with parameters [and ordering 'ord',
     509         if a 3rd argument is present (default: ord=\"dp\")] and applying
     510         procedure 'show'
    545511RETURN:  no return value
    546512EXAMPLE: example showrecursive; shows an example
     
    612578{  "EXAMPLE:"; echo = 2;
    613579   ring r= 0,(x,y,z),ds;
    614    poly f = (x+y+z)^9;
    615    split(string(f),40);
    616    string s=split(lprint(f,40),40); s;
     580   poly f = (x+y+z)^4;
     581   split(string(f),50);
    617582   split(lprint(f));
    618583}
     
    637602
    638603proc writelist (string fil, string nam, list L)
    639 "USAGE:   writelist(fil,nam,L);  fil,nam=strings (file-name, list-name), L=list
    640 CREATE:  a file with name `fil`, write the content of the list L into it and
    641          call the list `nam`.
     604"USAGE:   writelist(file,name,L);  file,name strings (file-name, list-name),
     605          L a list.
     606CREATE:  a file with name `file`, write the content of the list L into it and
     607         call the list `name`, keeping the list structure
    642608RETURN:  no return value
    643609NOTE:    The syntax of writelist uses and is similar to the syntax of the
    644610         write command of Singular which does not manage lists properly.
    645          If, say, (fil,nam) = (\"listfile\",\"L1\"),  writelist creates (resp.
     611         If (file,name) = (\"listfile\",\"L1\"),  writelist creates (resp.
    646612         appends if listfile exists) a file with name listfile and stores
    647613         there the list L under the name L1. The Singular command
    648614         execute(read(\"listfile\")); assignes the content of L (stored in
    649615         listfile) to a list L1.
    650          On a UNIX system, overwrite an existing file if fil=\">...\", resp.
    651          append if fil=\">>...\".
     616@*       On a UNIX system, write(\">file\",...) overwrites an existing file
     617         `file` while write(\"file\",...) and write(\">>file\",...) append.
    652618EXAMPLE: example writelist; shows an example
    653619"
     
    670636   writelist("zumSpass","lustig",k);
    671637   read("zumSpass");
    672    list L=res(i,0);       //resolution of the maximal ideal
    673    writelist("L","L",L);
    674    read("L");
    675    system("sh","/bin/rm L zumSpass");
    676    // Under UNIX, this removes the files 'L' and 'zumSpass'
     638   list L=res(i,0);                    //resolution of the ideal i
     639   writelist("res_list","res-name",L); "";
     640   read("res_list");                   
     641   // execute(read("res_list")); would create a list with name res-name,
     642   // which is the resolution of i (the same content as L)
     643
     644   system("sh","/bin/rm res_list zumSpass");
     645   // Under UNIX, this removes the files 'res_list' and 'zumSpass'
    677646   // Type help system; to get more information about the shell escape
    678647   // If your operating system does not accept the shell escape, you
    679    // have to remove the just created files 'zumSpass' and 'L' directly
     648   // must remove the just created files 'zumSpass' and 'res_list' directly
    680649}
    681650///////////////////////////////////////////////////////////////////////////////
     
    684653"USAGE:    pause([ prompt ])  prompt string
    685654RETURN:   none
    686 PURPOSE:  pause in the computation till user input
    687 SEE ALSO: read
     655PURPOSE:  interrupt the execution of commands until user input
     656NOTE:     pause is useful in procedures in connection with printlevel to
     657          interrupt the computation and to display intermediate results.
     658SEE ALSO: read, printlevel
    688659EXAMPLE : example pause; shows an example
    689660"
     
    698669example
    699670{ "EXAMPLE:"; echo=2;
    700   // cannot be shown non-interactively, try the follwing commands without //
     671  // can only be shown interactively, try the following commands:
    701672  // pause("press <return> to continue");
    702673  // pause();
    703 }
     674  // In the following pocedure TTT, xxx is printed and the execution of
     675  // TTT is stopped until the return-key is pressed, if printlevel>0.
     676  // xxx may be any result of a previous computation or a comment, etc:
     677  //
     678  // proc TTT
     679  // { int pp = printlevel-voice+2;  //pp=0 if printlevel=0 and if TTT is
     680  //    ....                         //not called from another procedure
     681  //    if( pp>0 )
     682  //    {
     683  //       print( xxx );
     684  //       pause("press <return> to continue");
     685  //    }
     686  //     ....
     687  // }
     688}
     689///////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.