inout_lib.tex 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. @c ---content LibInfo---
  2. @comment This file was generated by doc2tex.pl from d2t_singular/inout_lib.doc
  3. @comment DO NOT EDIT DIRECTLY, BUT EDIT d2t_singular/inout_lib.doc INSTEAD
  4. @c library version: (1.21.2.5,2002/06/12)
  5. @c library file: ../Singular/LIB/inout.lib
  6. @cindex inout.lib
  7. @cindex inout_lib
  8. @table @asis
  9. @item @strong{Library:}
  10. inout.lib
  11. @item @strong{Purpose:}
  12. Printing and Manipulating In- and Output
  13. @end table
  14. @strong{Procedures:}
  15. @menu
  16. * allprint:: print list if ALLprint is defined, with pause if >0
  17. * lprint:: display poly/... fitting to pagewidth [size n]
  18. * pmat:: print form-matrix [first n chars of each column]
  19. * rMacaulay:: read Macaulay_1 output and return its Singular format
  20. * show:: display any object in a compact format
  21. * showrecursive:: display id recursively with respect to variables in p
  22. * split:: split given string into lines of length n
  23. * tab:: string of n space tabs
  24. * writelist:: write a list into a file and keep the list structure
  25. * pause:: stop the computation until user input
  26. @end menu
  27. @c ---end content LibInfo---
  28. @c ------------------- allprint -------------
  29. @node allprint, lprint,, inout_lib
  30. @subsubsection allprint
  31. @cindex allprint
  32. @c ---content allprint---
  33. Procedure from library @code{inout.lib} (@pxref{inout_lib}).
  34. @table @asis
  35. @item @strong{Usage:}
  36. allprint(L); L list
  37. @item @strong{Display:}
  38. prints L[1], L[2], ... if an integer with name ALLprint is defined.
  39. @* makes "pause", if ALLprint > 0
  40. @* listvar(matrix), if ALLprint = 2
  41. @item @strong{Return:}
  42. no return value
  43. @end table
  44. @strong{Example:}
  45. @smallexample
  46. @c computed example allprint d2t_singular/inout_lib.doc:51
  47. LIB "inout.lib";
  48. ring S;
  49. matrix M=matrix(freemodule(2),3,3);
  50. int ALLprint; export ALLprint;
  51. @expansion{} // ** `ALLprint` is already global
  52. allprint("M =",M);
  53. @expansion{} M =
  54. @expansion{} 1,0,0,
  55. @expansion{} 0,1,0,
  56. @expansion{} 0,0,0
  57. kill ALLprint;
  58. @c end example allprint d2t_singular/inout_lib.doc:51
  59. @end smallexample
  60. @c ---end content allprint---
  61. @c ------------------- lprint -------------
  62. @node lprint, pmat, allprint, inout_lib
  63. @subsubsection lprint
  64. @cindex lprint
  65. @c ---content lprint---
  66. Procedure from library @code{inout.lib} (@pxref{inout_lib}).
  67. @table @asis
  68. @item @strong{Usage:}
  69. lprint(id[,n]); id poly/ideal/vector/module/matrix, n integer
  70. @item @strong{Return:}
  71. string of id in a format fitting into lines of size n, such that no
  72. monomial is destroyed, i.e. the new line starts with + or -;
  73. (default: n = pagewidth).
  74. @item @strong{Note:}
  75. id is printed columnwise, each column separated by a blank line;
  76. hence lprint(transpose(id)); displays a matrix id in a format which
  77. can be used as input.
  78. @end table
  79. @strong{Example:}
  80. @smallexample
  81. @c computed example lprint d2t_singular/inout_lib.doc:86
  82. LIB "inout.lib";
  83. ring r= 0,(x,y,z),ds;
  84. poly f=((x+y)*(x-y)*(x+z)*(y+z)^2);
  85. lprint(f,40);
  86. @expansion{} x3y2-xy4+2x3yz+x2y2z-2xy3z-y4z+x3z2
  87. @expansion{} +2x2yz2-xy2z2-2y3z2+x2z3-y2z3
  88. module m = [f*(x-y)],[0,f*(x-y)];
  89. string s=lprint(m); s;"";
  90. @expansion{} x4y2-x3y3-x2y4+xy5+2x4yz-x3y2z-3x2y3z+xy4z+y5z+x4z2+x3yz2-3x2y2z2-xy3z2
  91. @expansion{} +2y4z2+x3z3-x2yz3-xy2z3+y3z3,
  92. @expansion{} 0,
  93. @expansion{}
  94. @expansion{} 0,
  95. @expansion{} x4y2-x3y3-x2y4+xy5+2x4yz-x3y2z-3x2y3z+xy4z+y5z+x4z2+x3yz2-3x2y2z2-xy3z2
  96. @expansion{} +2y4z2+x3z3-x2yz3-xy2z3+y3z3
  97. @expansion{}
  98. execute("matrix M[2][2]="+s+";"); //use the string s as input
  99. module m1 = transpose(M); //should be the same as m
  100. print(m-m1);
  101. @expansion{} 0,0,
  102. @expansion{} 0,0
  103. @c end example lprint d2t_singular/inout_lib.doc:86
  104. @end smallexample
  105. @c ---end content lprint---
  106. @c ------------------- pmat -------------
  107. @node pmat, rMacaulay, lprint, inout_lib
  108. @subsubsection pmat
  109. @cindex pmat
  110. @c ---content pmat---
  111. Procedure from library @code{inout.lib} (@pxref{inout_lib}).
  112. @table @asis
  113. @item @strong{Usage:}
  114. pmat(M,[n]); M matrix, n integer
  115. @item @strong{Display:}
  116. display M in array format if it fits into pagewidth; if n is given,
  117. only the first n characters of each column are shown
  118. @item @strong{Return:}
  119. no return value
  120. @end table
  121. @strong{Example:}
  122. @smallexample
  123. @c computed example pmat d2t_singular/inout_lib.doc:121
  124. LIB "inout.lib";
  125. ring r=0,(x,y,z),ls;
  126. ideal i= x,z+3y,x+y,z;
  127. matrix m[3][3]=i^2;
  128. pmat(m);
  129. @expansion{} x2, xz+3xy, xy+x2,
  130. @expansion{} xz, z2+6yz+9y2, yz+3y2+xz+3xy,
  131. @expansion{} z2+3yz, y2+2xy+x2, yz+xz
  132. pmat(m,3);
  133. @expansion{} x2 xz+ xy+
  134. @expansion{} xz z2+ yz+
  135. @expansion{} z2+ y2+ yz+
  136. @c end example pmat d2t_singular/inout_lib.doc:121
  137. @end smallexample
  138. @c ---end content pmat---
  139. @c ------------------- rMacaulay -------------
  140. @node rMacaulay, show, pmat, inout_lib
  141. @subsubsection rMacaulay
  142. @cindex rMacaulay
  143. @c ---content rMacaulay---
  144. Procedure from library @code{inout.lib} (@pxref{inout_lib}).
  145. @table @asis
  146. @item @strong{Usage:}
  147. rMacaulay(s[,n]); s string, n integer
  148. @item @strong{Return:}
  149. A string which should be readable by Singular if s is a string which
  150. was produced by Macaulay. If a second argument is present the first
  151. n lines of the file are deleted (which is useful if the file was
  152. produced e.g. by the putstd command of Macaulay).
  153. @item @strong{Note:}
  154. This does not always work with 'cut and paste' since the character
  155. \ is treated differently
  156. @end table
  157. @strong{Example:}
  158. @smallexample
  159. @c computed example rMacaulay d2t_singular/inout_lib.doc:156
  160. LIB "inout.lib";
  161. // Assume there exists a file 'Macid' with the following ideal in
  162. // Macaulay format:"
  163. // x[0]3-101/74x[0]2x[1]+7371x[0]x[1]2-13/83x[1]3-x[0]2x[2] \
  164. // -4/71x[0]x[1]x[2]
  165. // Read this file into Singular and assign it to the string s1 by:
  166. // string s1 = read("Macid");
  167. // This is equivalent to";
  168. string s1 =
  169. "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]";
  170. rMacaulay(s1);
  171. @expansion{} x(0)^3-101/74*x(0)^2*x(1)+7371*x(0)*x(1)^2-13/83*x(1)^3-x(0)^2*x(2)-4/71*\
  172. x(0)*x(1)*x(2)
  173. // You may wish to assign s1 to a Singular ideal id:
  174. string sid = "ideal id =",rMacaulay(s1),";";
  175. ring r = 0,x(0..3),dp;
  176. execute(sid);
  177. id; "";
  178. @expansion{} id[1]=x(0)^3-101/74*x(0)^2*x(1)+7371*x(0)*x(1)^2-13/83*x(1)^3-x(0)^2*x(2)\
  179. -4/71*x(0)*x(1)*x(2)
  180. @expansion{}
  181. // Now treat a matrix in Macaulay format. Using the execute
  182. // command, this could be assinged to a Singular matrix as above.
  183. string s2 = "
  184. 0 0 0 0 0
  185. a3 0 0 0 0
  186. 0 b3 0 0 0
  187. 0 0 c3 0 0
  188. 0 0 0 d3 0
  189. 0 0 0 0 e3 ";
  190. rMacaulay(s2);
  191. @expansion{} 0, 0, 0, 0, 0,
  192. @expansion{} a3,0, 0, 0, 0,
  193. @expansion{} 0, b3,0, 0, 0,
  194. @expansion{} 0, 0, c3,0, 0,
  195. @expansion{} 0, 0, 0, d3,0,
  196. @expansion{} 0, 0, 0, 0, e3
  197. @c end example rMacaulay d2t_singular/inout_lib.doc:156
  198. @end smallexample
  199. @c ---end content rMacaulay---
  200. @c ------------------- show -------------
  201. @node show, showrecursive, rMacaulay, inout_lib
  202. @subsubsection show
  203. @cindex show
  204. @c ---content show---
  205. Procedure from library @code{inout.lib} (@pxref{inout_lib}).
  206. @table @asis
  207. @item @strong{Usage:}
  208. show(id); id any object of basering or of type ring/qring
  209. @* show(R,s); R=ring, s=string (s = name of an object belonging to R)
  210. @item @strong{Display:}
  211. display id/s in a compact format together with some information
  212. @item @strong{Return:}
  213. no return value
  214. @item @strong{Note:}
  215. objects of type string, int, intvec, intmat belong to any ring.
  216. id may be a ring or a qring. In this case the minimal polynomial is
  217. displayed, and, for a qring, also the defining ideal.
  218. @*id may be of type list but the list must not contain a ring.
  219. @* show(R,s) does not work inside a procedure!
  220. @end table
  221. @strong{Example:}
  222. @smallexample
  223. @c computed example show d2t_singular/inout_lib.doc:215
  224. LIB "inout.lib";
  225. ring r;
  226. show(r);
  227. @expansion{} // ring: (32003),(x,y,z),(dp(3),C);
  228. @expansion{} // minpoly = 0
  229. @expansion{} // objects belonging to this ring:
  230. ideal i=x^3+y^5-6*z^3,xy,x3-y2;
  231. show(i,3); // introduce 3 space tabs before information
  232. @expansion{} // ideal, 3 generator(s)
  233. @expansion{} y5+x3-6z3,
  234. @expansion{} xy,
  235. @expansion{} x3-y2
  236. vector v=x*gen(1)+y*gen(3);
  237. module m=v,2*v+gen(4);
  238. list L = i,v,m;
  239. show(L);
  240. @expansion{} // list, 3 element(s):
  241. @expansion{} [1]:
  242. @expansion{} // ideal, 3 generator(s)
  243. @expansion{} y5+x3-6z3,
  244. @expansion{} xy,
  245. @expansion{} x3-y2
  246. @expansion{} [2]:
  247. @expansion{} // vector
  248. @expansion{} [x,0,y]
  249. @expansion{} [3]:
  250. @expansion{} // module, 2 generator(s)
  251. @expansion{} [x,0,y]
  252. @expansion{} [2x,0,2y,1]
  253. ring S=(0,T),(a,b,c,d),ws(1,2,3,4);
  254. minpoly = T^2+1;
  255. ideal i=a2+b,c2+T^2*d2; i=std(i);
  256. qring Q=i;
  257. show(Q);
  258. @expansion{} // qring: (0,T),(a,b,c,d),(ws(1,2,3,4),C);
  259. @expansion{} // minpoly = (T2+1)
  260. @expansion{} // quotient ring from ideal:
  261. @expansion{} _[1]=a2+b
  262. @expansion{} _[2]=c2-d2
  263. map F=r,a2,b^2,3*c3;
  264. show(F);
  265. @expansion{} // i-th variable of preimage ring is mapped to @@map[i]
  266. @expansion{} // @@map [1] map from r
  267. @expansion{} @@map[1]=a2
  268. @expansion{} @@map[2]=b2
  269. @expansion{} @@map[3]=3*c3
  270. // Apply 'show' to i (which does not belong to the basering) by typing
  271. // ring r; ideal i=xy,x3-y2; ring Q; show(r,"i");
  272. @c end example show d2t_singular/inout_lib.doc:215
  273. @end smallexample
  274. @c ---end content show---
  275. @c ------------------- showrecursive -------------
  276. @node showrecursive, split, show, inout_lib
  277. @subsubsection showrecursive
  278. @cindex showrecursive
  279. @c ---content showrecursive---
  280. Procedure from library @code{inout.lib} (@pxref{inout_lib}).
  281. @table @asis
  282. @item @strong{Usage:}
  283. showrecursive(id,p[ord]); id= any object of basering, p= product of
  284. variables and ord=string (any allowed ordstr)
  285. @item @strong{Display:}
  286. display 'id' in a recursive format as a polynomial in the variables
  287. occurring in p with coefficients in the remaining variables. This is
  288. done by mapping to a ring with parameters [and ordering 'ord',
  289. if a 3rd argument is present (default: ord="dp")] and applying
  290. procedure 'show'
  291. @item @strong{Return:}
  292. no return value
  293. @end table
  294. @strong{Example:}
  295. @smallexample
  296. @c computed example showrecursive d2t_singular/inout_lib.doc:263
  297. LIB "inout.lib";
  298. ring r=2,(a,b,c,d,x,y),ds;
  299. poly f=y+ax2+bx3+cx2y2+dxy3;
  300. showrecursive(f,x);
  301. @expansion{} // poly, 4 monomial(s)
  302. @expansion{} (b)*x3+(a+cy2)*x2+(dy3)*x+(y)
  303. showrecursive(f,xy,"lp");
  304. @expansion{} // poly, 5 monomial(s)
  305. @expansion{} (b)*x3+(c)*x2y2+(a)*x2+(d)*xy3+y
  306. @c end example showrecursive d2t_singular/inout_lib.doc:263
  307. @end smallexample
  308. @c ---end content showrecursive---
  309. @c ------------------- split -------------
  310. @node split, tab, showrecursive, inout_lib
  311. @subsubsection split
  312. @cindex split
  313. @c ---content split---
  314. Procedure from library @code{inout.lib} (@pxref{inout_lib}).
  315. @table @asis
  316. @item @strong{Usage:}
  317. split(s[,n]); s string, n integer
  318. @item @strong{Return:}
  319. same string, split into lines of length n separated by \
  320. (default: n=pagewidth)
  321. @item @strong{Note:}
  322. may be used in connection with lprint
  323. @end table
  324. @strong{Example:}
  325. @smallexample
  326. @c computed example split d2t_singular/inout_lib.doc:294
  327. LIB "inout.lib";
  328. ring r= 0,(x,y,z),ds;
  329. poly f = (x+y+z)^4;
  330. split(string(f),50);
  331. @expansion{} x4+4x3y+6x2y2+4xy3+y4+4x3z+12x2yz+12xy2z+4y3z+6x\
  332. @expansion{} 2z2+12xyz2+6y2z2+4xz3+4yz3+z4
  333. split(lprint(f));
  334. @expansion{} x4+4x3y+6x2y2+4xy3+y4+4x3z+12x2yz+12xy2z+4y3z+6x2z2+12xyz2+6y2z2+4xz3+4\
  335. yz3\
  336. @expansion{} +z4
  337. @c end example split d2t_singular/inout_lib.doc:294
  338. @end smallexample
  339. @c ---end content split---
  340. @c ------------------- tab -------------
  341. @node tab, writelist, split, inout_lib
  342. @subsubsection tab
  343. @cindex tab
  344. @c ---content tab---
  345. Procedure from library @code{inout.lib} (@pxref{inout_lib}).
  346. @table @asis
  347. @item @strong{Usage:}
  348. tab(n); n integer
  349. @item @strong{Return:}
  350. string of n space tabs
  351. @end table
  352. @strong{Example:}
  353. @smallexample
  354. @c computed example tab d2t_singular/inout_lib.doc:321
  355. LIB "inout.lib";
  356. for(int n=0; n<=5; n=n+1)
  357. @{ tab(5-n)+"*"+tab(n)+"+"+tab(n)+"*"; @}
  358. @expansion{} *+*
  359. @expansion{} * + *
  360. @expansion{} * + *
  361. @expansion{} * + *
  362. @expansion{} * + *
  363. @expansion{} * + *
  364. @c end example tab d2t_singular/inout_lib.doc:321
  365. @end smallexample
  366. @c ---end content tab---
  367. @c ------------------- writelist -------------
  368. @node writelist, pause, tab, inout_lib
  369. @subsubsection writelist
  370. @cindex writelist
  371. @c ---content writelist---
  372. Procedure from library @code{inout.lib} (@pxref{inout_lib}).
  373. @table @asis
  374. @item @strong{Usage:}
  375. writelist(file,name,L); file,name strings (file-name, list-name),
  376. L a list.
  377. @item @strong{Create:}
  378. a file with name `file`, write the content of the list L into it and
  379. call the list `name`, keeping the list structure
  380. @item @strong{Return:}
  381. no return value
  382. @item @strong{Note:}
  383. The syntax of writelist uses and is similar to the syntax of the
  384. write command of Singular which does not manage lists properly.
  385. If (file,name) = ("listfile","L1"), writelist creates (resp.
  386. appends if listfile exists) a file with name listfile and stores
  387. there the list L under the name L1. The Singular command
  388. execute(read("listfile")); assigns the content of L (stored in
  389. listfile) to a list L1.
  390. @* On a UNIX system, write(">file",...) overwrites an existing file
  391. `file` while write("file",...) and write(">>file",...) append.
  392. @end table
  393. @strong{Example:}
  394. @smallexample
  395. @c computed example writelist d2t_singular/inout_lib.doc:362
  396. LIB "inout.lib";
  397. ring r;
  398. ideal i=x,y,z;
  399. list k="Hi",nameof(basering),i,37;
  400. writelist("zumSpass","lustig",k);
  401. read("zumSpass");
  402. @expansion{} list lustig;
  403. @expansion{} lustig[1]=
  404. @expansion{} Hi;
  405. @expansion{} lustig[2]=
  406. @expansion{} r;
  407. @expansion{} lustig[3]=
  408. @expansion{} x,y,z;
  409. @expansion{} lustig[4]=
  410. @expansion{} 37;
  411. @expansion{}
  412. list L=res(i,0); //resolution of the ideal i
  413. writelist("res_list","res-name",L); "";
  414. @expansion{}
  415. read("res_list");
  416. @expansion{} list res-name;
  417. @expansion{} res-name[1]=
  418. @expansion{} z,y,x;
  419. @expansion{} res-name[2]=
  420. @expansion{} -y*gen(1)+z*gen(2),-x*gen(1)+z*gen(3),-x*gen(2)+y*gen(3);
  421. @expansion{} res-name[3]=
  422. @expansion{} x*gen(1)-y*gen(2)+z*gen(3);
  423. @expansion{}
  424. // execute(read("res_list")); would create a list with name res-name,
  425. // which is the resolution of i (the same content as L)
  426. system("sh","/bin/rm res_list zumSpass");
  427. @expansion{} 0
  428. // Under UNIX, this removes the files 'res_list' and 'zumSpass'
  429. // Type help system; to get more information about the shell escape
  430. // If your operating system does not accept the shell escape, you
  431. // must remove the just created files 'zumSpass' and 'res_list' directly
  432. @c end example writelist d2t_singular/inout_lib.doc:362
  433. @end smallexample
  434. @c ---end content writelist---
  435. @c ------------------- pause -------------
  436. @node pause,, writelist, inout_lib
  437. @subsubsection pause
  438. @cindex pause
  439. @c ---content pause---
  440. Procedure from library @code{inout.lib} (@pxref{inout_lib}).
  441. @table @asis
  442. @item @strong{Usage:}
  443. pause([ prompt ]) prompt string
  444. @item @strong{Return:}
  445. none
  446. @item @strong{Purpose:}
  447. interrupt the execution of commands until user input
  448. @item @strong{Note:}
  449. pause is useful in procedures in connection with printlevel to
  450. interrupt the computation and to display intermediate results.
  451. @end table
  452. @strong{Example:}
  453. @smallexample
  454. @c computed example pause d2t_singular/inout_lib.doc:407
  455. LIB "inout.lib";
  456. // can only be shown interactively, try the following commands:
  457. // pause("press <return> to continue");
  458. // pause();
  459. // In the following pocedure TTT, xxx is printed and the execution of
  460. // TTT is stopped until the return-key is pressed, if printlevel>0.
  461. // xxx may be any result of a previous computation or a comment, etc:
  462. //
  463. // proc TTT
  464. // @{ int pp = printlevel-voice+2; //pp=0 if printlevel=0 and if TTT is
  465. // .... //not called from another procedure
  466. // if( pp>0 )
  467. // @{
  468. // print( xxx );
  469. // pause("press <return> to continue");
  470. // @}
  471. // ....
  472. // @}
  473. @c end example pause d2t_singular/inout_lib.doc:407
  474. @end smallexample
  475. @c inserted refs from d2t_singular/inout_lib.doc:428
  476. @ifinfo
  477. @menu
  478. See also:
  479. * printlevel::
  480. * read::
  481. @end menu
  482. @end ifinfo
  483. @iftex
  484. @strong{See also:}
  485. @ref{printlevel};
  486. @ref{read}.
  487. @end iftex
  488. @c end inserted refs from d2t_singular/inout_lib.doc:428
  489. @c ---end content pause---