Mercurial > octave-nkf
comparison doc/interpreter/sparseimages.m @ 20351:d8992a16643c
doc: Clean up m-files which generate images for Manual.
* geometryimages.m, interpimages.m, plotimages.m, sparseimages.m,
splineimages.m: Use the same style throughout the mi-files.
Obey Octave coding conventions.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 09 Jul 2015 21:38:57 -0700 |
parents | c3c1fb44f9b5 |
children | b439ccc9a162 |
comparison
equal
deleted
inserted
replaced
20350:b9d4ccf4291c | 20351:d8992a16643c |
---|---|
39 endif | 39 endif |
40 else ## There is no sparse matrix implementation available because | 40 else ## There is no sparse matrix implementation available because |
41 ## of missing libraries, plot sombreros instead | 41 ## of missing libraries, plot sombreros instead |
42 sombreroimage (d, nm, typ); | 42 sombreroimage (d, nm, typ); |
43 endif | 43 endif |
44 endfunction | |
45 | |
46 function set_print_size () | |
47 image_size = [5.0, 3.5]; # in inches, 16:9 format | |
48 border = 0; # For postscript use 50/72 | |
49 set (0, "defaultfigurepapertype", "<custom>"); | |
50 set (0, "defaultfigurepaperorientation", "landscape"); | |
51 set (0, "defaultfigurepapersize", image_size + 2*border); | |
52 set (0, "defaultfigurepaperposition", [border, border, image_size]); | |
53 endfunction | |
54 | |
55 function hide_output () | |
56 f = figure (1); | |
57 set (f, "visible", "off"); | |
58 endfunction | 44 endfunction |
59 | 45 |
60 function gplotimages (d, nm, typ) | 46 function gplotimages (d, nm, typ) |
61 hide_output (); | 47 hide_output (); |
62 outfile = fullfile (d, strcat (nm, ".", typ)); | 48 outfile = fullfile (d, strcat (nm, ".", typ)); |
92 if (strcmp (nm, "spchol")) | 78 if (strcmp (nm, "spchol")) |
93 r1 = chol (a); | 79 r1 = chol (a); |
94 printsparse (r1, outfile); | 80 printsparse (r1, outfile); |
95 elseif (strcmp (nm, "spcholperm")) | 81 elseif (strcmp (nm, "spcholperm")) |
96 [r2,p2,q2] = chol (a); | 82 [r2,p2,q2] = chol (a); |
97 printsparse(r2, outfile); | 83 printsparse (r2, outfile); |
98 endif | 84 endif |
99 ## printf("Text NNZ: Matrix %d, Chol %d, PermChol %d\n",nnz(a),nnz(r1),nnz(r2)); | 85 ## printf("Text NNZ: Matrix %d, Chol %d, PermChol %d\n",nnz(a),nnz(r1),nnz(r2)); |
100 endif | 86 endif |
101 endif | 87 endif |
102 endfunction | 88 endfunction |
108 d_typ = "-depsc2"; | 94 d_typ = "-depsc2"; |
109 else | 95 else |
110 d_typ = ["-d" typ]; | 96 d_typ = ["-d" typ]; |
111 endif | 97 endif |
112 | 98 |
113 a = 10*speye (n) + sparse (1:n,ceil([1:n]/2),1,n,n) + ... | 99 a = 10*speye (n) + sparse (1:n,ceil ([1:n]/2),1,n,n) + ... |
114 sparse (ceil ([1:n]/2),1:n,1,n,n); | 100 sparse (ceil ([1:n]/2),1:n,1,n,n); |
115 if (strcmp (nm, "spmatrix")) | 101 if (strcmp (nm, "spmatrix")) |
116 spy (a); | 102 spy (a); |
117 axis ("ij"); | 103 axis ("ij"); |
118 print (outfile, d_typ); | 104 print (outfile, d_typ); |
265 ## There is no sparse matrix implementation available because of missing | 251 ## There is no sparse matrix implementation available because of missing |
266 ## libraries, plot sombreros instead. Also plot a nice title that we are | 252 ## libraries, plot sombreros instead. Also plot a nice title that we are |
267 ## sorry about that. | 253 ## sorry about that. |
268 function sombreroimage (d, nm, typ) | 254 function sombreroimage (d, nm, typ) |
269 if (strcmp (typ, "txt")) | 255 if (strcmp (typ, "txt")) |
270 fid = fopen (fullfile (d, strcat (nm, ".txt")), "wt"); | 256 fid = fopen (fullfile (d, [nm ".txt"]), "wt"); |
271 fputs (fid, "\n"); | 257 fputs (fid, "\n"); |
272 fputs (fid, "+---------------------------------------+\n"); | 258 fputs (fid, "+---------------------------------------+\n"); |
273 fputs (fid, "| Image unavailable because of a |\n"); | 259 fputs (fid, "| Image unavailable because of a |\n"); |
274 fputs (fid, "| missing sparse matrix implementation. |\n"); | 260 fputs (fid, "| missing sparse matrix implementation. |\n"); |
275 fputs (fid, "+---------------------------------------+\n"); | 261 fputs (fid, "+---------------------------------------+\n"); |
276 fclose (fid); | 262 fclose (fid); |
277 return; | 263 return; |
278 else ## if (!strcmp (typ, "txt")) | 264 else |
279 | |
280 hide_output (); | 265 hide_output (); |
281 if (strcmp (typ, "eps")) | 266 if (strcmp (typ, "eps")) |
282 d_typ = "-depsc2"; | 267 d_typ = "-depsc2"; |
283 else | 268 else |
284 d_typ = ["-d" typ]; | 269 d_typ = ["-d" typ]; |
293 hide_output (); | 278 hide_output (); |
294 end_unwind_protect | 279 end_unwind_protect |
295 endif | 280 endif |
296 endfunction | 281 endfunction |
297 | 282 |
283 function set_print_size () | |
284 image_size = [5.0, 3.5]; # in inches, 16:9 format | |
285 border = 0; # For postscript use 50/72 | |
286 set (0, "defaultfigurepapertype", "<custom>"); | |
287 set (0, "defaultfigurepaperorientation", "landscape"); | |
288 set (0, "defaultfigurepapersize", image_size + 2*border); | |
289 set (0, "defaultfigurepaperposition", [border, border, image_size]); | |
290 endfunction | |
291 | |
292 ## Use this function before plotting commands and after every call to | |
293 ## print since print() resets output to stdout (unfortunately, gnpulot | |
294 ## can't pop output as it can the terminal type). | |
295 function hide_output () | |
296 hf = figure (1); | |
297 set (hf, "visible", "off"); | |
298 endfunction | |
299 |