Changeset 9f8a0c in git
- Timestamp:
- Dec 30, 2000, 4:44:31 PM (22 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 2b4e7066de6a1ca22687a95c7411269e78fe38d8
- Parents:
- 7708934c4dd35b5ec3af10e0b6fe8671994ca033
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/inout.lib
r7708934 r9f8a0c 1 1 // (GMG/BM, last modified 22.06.96) 2 2 /////////////////////////////////////////////////////////////////////////////// 3 version="$Id: inout.lib,v 1. 19 2000-12-22 14:06:55greuel Exp $";3 version="$Id: inout.lib,v 1.20 2000-12-30 15:44:31 greuel Exp $"; 4 4 category="General purpose"; 5 5 info=" … … 8 8 PROCEDURES: 9 9 allprint(list); print list if ALLprint is defined, with pause if >0 10 dbpri(n,list); print objects of list if int n<=printlevel11 10 lprint(poly/...[,n]); display poly/... fitting to pagewidth [size n] 12 11 pmat(matrix[,n]); print form-matrix [first n chars of each colum] … … 16 15 split(string,n); split given string into lines of length n 17 16 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 19 18 pause([prompt]); stop the computation until user input 20 19 (parameters in square brackets [] are optional) … … 25 24 proc allprint (list #) 26 25 "USAGE: allprint(L); L list 27 CREATE: display L[1], L[2], ... if an integer with name ALLprint is defined, 28 29 26 DISPLAY: 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 30 29 RETURN: no return value 31 30 EXAMPLE: example allprint; shows an example … … 51 50 /////////////////////////////////////////////////////////////////////////////// 52 51 53 proc dbpri (int n ,list #)54 "USAGE: dbpri(n,L); n integer, L list55 CREATE: display L[1], L[2], ... if an integer with name printlevel is defined56 and if n<=printlevel, set printlevel to 0 if it is not defined57 RETURN: no return value58 NOTE: this is uesful to control the printing of comments or partial results59 in a procedure, e.g. for debugging a procedure.60 It is similair but not the same as the internal function dbprint61 EXAMPLE: example dbpri; shows an example62 "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 example73 { "EXAMPLE:"; echo = 2;74 ring s;75 module M=freemodule(3);76 dbpri(0,"M =",M);77 }78 ///////////////////////////////////////////////////////////////////////////////79 80 52 proc lprint 81 53 "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 54 RETURN: 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). 84 57 NOTE: id is printed columnwise, each column separated by a blank line; 85 58 hence lprint(transpose(id)); displays a matrix id in a format which 86 can be used as input to reproduce id59 can be used as input. 87 60 EXAMPLE: example lprint; shows an example 88 61 " … … 129 102 ring r= 0,(x,y,z),ds; 130 103 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)]; 137 106 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); 143 110 } 144 111 /////////////////////////////////////////////////////////////////////////////// … … 146 113 proc pmat (matrix m, list #) 147 114 "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 shown115 DISPLAY: 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 150 117 RETURN: no return value 151 118 EXAMPLE: example pmat; shows an example … … 217 184 proc rMacaulay 218 185 "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 186 RETURN: 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). 190 NOTE: This does not always work with 'cut and paste' since the character 191 \ is treated differently 226 192 EXAMPLE: example rMacaulay; shows an example 227 193 " … … 308 274 example 309 275 { "EXAMPLE:"; echo = 2; 310 // Assume there exists a file 'Macid' with the following ideal in Macaulay311 // format:"276 // Assume there exists a file 'Macid' with the following ideal in 277 // Macaulay format:" 312 278 // 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: 316 281 // string s1 = read("Macid"); 317 282 // This is equivalent to"; 318 283 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]"; 320 285 rMacaulay(s1); 321 286 // You may wish to assign s1 to a Singular ideal id: … … 324 289 execute(sid); 325 290 id; ""; 326 // The next example treatsa matrix in Macaulay format. Using the execute291 // Now treat a matrix in Macaulay format. Using the execute 327 292 // command, this could be assinged to a Singular matrix as above. 328 293 string s2 = " … … 340 305 proc show (id, list #) 341 306 "USAGE: show(id); id any object of basering or of type ring/qring 342 307 @* show(R,s); R=ring, s=string (s = name of an object belonging to R) 343 308 DISPLAY: display id/s in a compact format together with some information 344 309 RETURN: no return value 345 310 NOTE: objects of type string, int, intvec, intmat belong to any ring. 346 311 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! 350 315 EXAMPLE: example show; shows an example 351 316 " … … 537 502 538 503 proc showrecursive (id,poly p,list #) 539 "USAGE: showrecursive(id,p[ord]); id= any object of basering, p=product of504 "USAGE: showrecursive(id,p[ord]); id= any object of basering, p= product of 540 505 variables and ord=string (any allowed ordstr) 541 506 DISPLAY: 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' 545 511 RETURN: no return value 546 512 EXAMPLE: example showrecursive; shows an example … … 612 578 { "EXAMPLE:"; echo = 2; 613 579 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); 617 582 split(lprint(f)); 618 583 } … … 637 602 638 603 proc 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. 606 CREATE: a file with name `file`, write the content of the list L into it and 607 call the list `name`, keeping the list structure 642 608 RETURN: no return value 643 609 NOTE: The syntax of writelist uses and is similar to the syntax of the 644 610 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. 646 612 appends if listfile exists) a file with name listfile and stores 647 613 there the list L under the name L1. The Singular command 648 614 execute(read(\"listfile\")); assignes the content of L (stored in 649 615 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. 652 618 EXAMPLE: example writelist; shows an example 653 619 " … … 670 636 writelist("zumSpass","lustig",k); 671 637 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' 677 646 // Type help system; to get more information about the shell escape 678 647 // If your operating system does not accept the shell escape, you 679 // have to remove the just created files 'zumSpass' and 'L' directly648 // must remove the just created files 'zumSpass' and 'res_list' directly 680 649 } 681 650 /////////////////////////////////////////////////////////////////////////////// … … 684 653 "USAGE: pause([ prompt ]) prompt string 685 654 RETURN: none 686 PURPOSE: pause in the computation till user input 687 SEE ALSO: read 655 PURPOSE: interrupt the execution of commands until user input 656 NOTE: pause is useful in procedures in connection with printlevel to 657 interrupt the computation and to display intermediate results. 658 SEE ALSO: read, printlevel 688 659 EXAMPLE : example pause; shows an example 689 660 " … … 698 669 example 699 670 { "EXAMPLE:"; echo=2; 700 // can not be shown non-interactively, try the follwing commands without //671 // can only be shown interactively, try the following commands: 701 672 // pause("press <return> to continue"); 702 673 // 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.