Mercurial > octave
annotate doc/interpreter/sparseimages.m @ 31706:597f3ee61a48 stable
update Octave Project Developers copyright for the new year
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 06 Jan 2023 13:11:27 -0500 |
parents | 796f54d4ddbf |
children | 3678187f4355 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
31706
597f3ee61a48
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3 ## Copyright (C) 2006-2023 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27847
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
7018 | 7 ## |
8 ## This file is part of Octave. | |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24462
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
7018 | 11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24462
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
7018 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
7018 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
21 ## along with Octave; see the file COPYING. If not, see | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24462
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
7018 | 25 |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19717
diff
changeset
|
26 function sparseimages (d, nm, typ) |
28620
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
27 |
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
28 if (strcmp (typ, "txt")) |
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
29 txtimages (d, nm, 15, typ); |
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
30 return; |
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
31 endif |
45a9dcee45db
doc: Short-circuit building txt images for manual (bug #57591).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
32 |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
33 set_graphics_toolkit (); |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
34 set_print_size (); |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
35 hide_output (); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
36 outfile = fullfile (d, [nm "." typ]); |
7257 | 37 if (strcmp (typ, "png")) |
24462
8ff3c13d14c1
groot.m: New function to return handle of graphics root object.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
38 set (groot, "defaulttextfontname", "*"); |
7257 | 39 endif |
9914
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
40 if (strcmp (typ, "eps")) |
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
41 d_typ = "-depsc2"; |
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
42 else |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16170
diff
changeset
|
43 d_typ = ["-d" typ]; |
9914
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
44 endif |
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
45 |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
46 if (! (__have_feature__ ("COLAMD") |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
47 && __have_feature__ ("CHOLMOD") |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
48 && __have_feature__ ("UMFPACK"))) |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
49 ## There is no sparse matrix implementation available because |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
50 ## of missing libraries, plot sombreros instead. |
22013
6267807eb70b
build: fix doc build error when building without SuiteSparse
Mike Miller <mtmiller@octave.org>
parents:
21226
diff
changeset
|
51 sombreroimage (outfile, typ, d_typ); |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
52 elseif (strcmp (nm, "gplot")) |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
53 A = sparse ([2,6,1,3,2,4,3,5,4,6,1,5], |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
54 [1,1,2,2,3,3,4,4,5,5,6,6], 1, 6, 6); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
55 xy = [0,4,8,6,4,2;5,0,5,7,5,7]'; |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
56 gplot (A, xy); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
57 print (outfile, d_typ); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
58 elseif (strcmp (nm, "grid")) |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
59 femimages (outfile, d_typ); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
60 elseif (strcmp (nm, "spmatrix")) |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
61 n = 200; |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
62 a = 10*speye (n) + sparse (1:n,ceil ([1:n]/2),1,n,n) + ... |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
63 sparse (ceil ([1:n]/2),1:n,1,n,n); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
64 spy (a); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
65 axis ("ij"); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
66 print (outfile, d_typ); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
67 elseif (strcmp (nm, "spchol")) |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
68 n = 200; |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
69 a = 10*speye (n) + sparse (1:n,ceil ([1:n]/2),1,n,n) + ... |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
70 sparse (ceil ([1:n]/2),1:n,1,n,n); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
71 r1 = chol (a); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
72 spy (r1); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
73 axis ("ij"); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
74 print (outfile, d_typ); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
75 elseif (strcmp (nm, "spcholperm")) |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
76 n = 200; |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
77 a = 10*speye (n) + sparse (1:n,ceil ([1:n]/2),1,n,n) + ... |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
78 sparse (ceil ([1:n]/2),1:n,1,n,n); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
79 [r2,p2,q2] = chol (a); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
80 spy (r2); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
81 axis ("ij"); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
82 print (outfile, d_typ); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
83 else |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
84 error ("unrecognized plot requested"); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
85 endif |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
86 hide_output (); |
6003 | 87 endfunction |
88 | |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19717
diff
changeset
|
89 function txtimages (d, nm, n, typ) |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
90 outfile = fullfile (d, [nm "." typ]); |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
91 a = 10*speye (n) + sparse (1:n,ceil([1:n]/2),1,n,n) + ... |
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
92 sparse (ceil ([1:n]/2),1:n,1,n,n); |
6003 | 93 if (strcmp (nm, "gplot") || strcmp (nm, "grid")) |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
94 fid = fopen (outfile, "wt"); |
7256 | 95 fputs (fid, "\n"); |
6003 | 96 fputs (fid, "+---------------------------------+\n"); |
97 fputs (fid, "| Image unavailable in text mode. |\n"); | |
98 fputs (fid, "+---------------------------------+\n"); | |
99 fclose (fid); | |
100 elseif (strcmp (nm, "spmatrix")) | |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19717
diff
changeset
|
101 printsparse (a, outfile); |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
102 elseif (strcmp (nm, "spchol")) |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
103 r1 = chol (a); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
104 printsparse (r1, outfile); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
105 elseif (strcmp (nm, "spcholperm")) |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
106 [r2,p2,q2] = chol (a); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
107 printsparse (r2, outfile); |
9914
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
108 else |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
109 error ("unrecognized plot requested"); |
6003 | 110 endif |
111 endfunction | |
112 | |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16170
diff
changeset
|
113 function printsparse (a, nm) |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
114 fid = fopen (nm, "wt"); |
7256 | 115 fputs (fid, "\n"); |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16170
diff
changeset
|
116 for i = 1:rows (a) |
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16170
diff
changeset
|
117 if (rem (i,5) == 0) |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
118 fprintf (fid, " %2d - ", i); |
6003 | 119 else |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
120 fprintf (fid, " | "); |
6003 | 121 endif |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16170
diff
changeset
|
122 for j = 1:columns (a) |
6003 | 123 if (a(i,j) == 0) |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
124 fprintf (fid, " "); |
6003 | 125 else |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
126 fprintf (fid, " *"); |
6003 | 127 endif |
128 endfor | |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
129 fprintf (fid, "\n"); |
6003 | 130 endfor |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
131 fprintf (fid, " |-"); |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
132 for j = 1:columns (a) |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16170
diff
changeset
|
133 if (rem (j,5) == 0) |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
134 fprintf (fid, "-|"); |
6003 | 135 else |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
136 fprintf (fid, "--"); |
6003 | 137 endif |
138 endfor | |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
139 fprintf (fid, "\n"); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
140 fprintf (fid, " "); |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
141 for j = 1:columns (a) |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16170
diff
changeset
|
142 if (rem (j,5) == 0) |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
143 fprintf (fid, "%2d", j); |
6003 | 144 else |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
145 fprintf (fid, " "); |
6003 | 146 endif |
147 endfor | |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16170
diff
changeset
|
148 fclose (fid); |
6003 | 149 endfunction |
150 | |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
151 function femimages (outfile, d_typ) |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
152 |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
153 ## build a rectangle |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
154 node_y = [1;1.2;1.5;1.8;2] * ones (1,11); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
155 node_x = ones (5,1) * [1,1.05,1.1,1.2,1.3,1.5,1.7,1.8,1.9,1.95,2]; |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
156 nodes = [node_x(:), node_y(:)]; |
9914
e76d8c767584
Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents:
9912
diff
changeset
|
157 |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
158 [h,w] = size (node_x); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
159 elems = []; |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
160 for idx = 1 : w-1 |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
161 widx = (idx-1)*h; |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
162 elems = [elems; widx+[(1:h-1);(2:h);h+(1:h-1)]']; |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
163 elems = [elems; widx+[(2:h);h+(2:h);h+(1:h-1)]']; |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
164 endfor |
6003 | 165 |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
166 E = size (elems,1); # No. of elements |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
167 N = size (nodes,1); # No. of elements |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
168 D = size (elems,2); # dimensions+1 |
6003 | 169 |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
170 ## Plot FEM Geometry |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
171 elemx = elems(:,[1,2,3,1])'; |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
172 xelems = reshape (nodes(elemx, 1), 4, E); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
173 yelems = reshape (nodes(elemx, 2), 4, E); |
6003 | 174 |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
175 ## Set element conductivity |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
176 conductivity = [1*ones(1,16), 2*ones(1,48), 1*ones(1,16)]; |
6003 | 177 |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
178 ## Dirichlet boundary conditions |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
179 D_nodes = [1:5, 51:55]; |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
180 D_value = [10*ones(1,5), 20*ones(1,5)]; |
6003 | 181 |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
182 ## Neumann boundary conditions |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
183 ## Note that N_value must be normalized by the boundary |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
184 ## length and element conductivity |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
185 N_nodes = []; |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
186 N_value = []; |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17887
diff
changeset
|
187 |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
188 ## Calculate connectivity matrix |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
189 C = sparse ((1:D*E), reshape (elems',D*E,1),1, D*E, N); |
6003 | 190 |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
191 ## Calculate stiffness matrix |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
192 Siidx = floor ([0:D*E-1]'/D)*D*ones(1,D) + ones(D*E,1)*(1:D); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
193 Sjidx = [1:D*E]'*ones (1,D); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
194 Sdata = zeros (D*E,D); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
195 dfact = prod (2:(D-1)); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
196 for j = 1:E |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
197 a = inv ([ ones(D,1), nodes( elems(j,:), : ) ]); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
198 const = conductivity(j)*2/dfact/abs (det (a)); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
199 Sdata(D*(j-1)+(1:D),:) = const * a(2:D,:)'*a(2:D,:); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
200 endfor |
6003 | 201 |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
202 ## Element-wise system matrix |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
203 SE = sparse (Siidx,Sjidx,Sdata); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
204 ## Global system matrix |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
205 S = C'* SE *C; |
6003 | 206 |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
207 ## Set Dirichlet boundary |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
208 V = zeros (N,1); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
209 V(D_nodes) = D_value; |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
210 idx = 1:N; |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
211 idx(D_nodes) = []; |
6003 | 212 |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
213 ## Set Neumann boundary |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
214 Q = zeros (N,1); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
215 Q(N_nodes) = N_value; # FIXME |
6003 | 216 |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
217 V(idx) = S(idx,idx) \ ( Q(idx) - S(idx,D_nodes)*V(D_nodes) ); |
6003 | 218 |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
219 velems = reshape (V(elemx), 4, E); |
6178 | 220 |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
221 plot3 (xelems, yelems, velems); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
222 view (80, 10); |
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
223 print (outfile, d_typ); |
6003 | 224 endfunction |
6040 | 225 |
226 ## There is no sparse matrix implementation available because of missing | |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
227 ## libraries, plot sombreros instead. Also plot a nice title that we are |
6040 | 228 ## sorry about that. |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
229 function sombreroimage (outfile, typ, d_typ) |
6040 | 230 if (strcmp (typ, "txt")) |
20779
b6af3f77d1bd
sparseimages.m: Rewrite to follow model of other doc-image-generating functions.
Rik <rik@octave.org>
parents:
20776
diff
changeset
|
231 fid = fopen (outfile, "wt"); |
22013
6267807eb70b
build: fix doc build error when building without SuiteSparse
Mike Miller <mtmiller@octave.org>
parents:
21226
diff
changeset
|
232 fputs (fid, "+--------------------------------+\n"); |
6267807eb70b
build: fix doc build error when building without SuiteSparse
Mike Miller <mtmiller@octave.org>
parents:
21226
diff
changeset
|
233 fputs (fid, "| Image unavailable because of a |\n"); |
6267807eb70b
build: fix doc build error when building without SuiteSparse
Mike Miller <mtmiller@octave.org>
parents:
21226
diff
changeset
|
234 fputs (fid, "| missing SuiteSparse library. |\n"); |
6267807eb70b
build: fix doc build error when building without SuiteSparse
Mike Miller <mtmiller@octave.org>
parents:
21226
diff
changeset
|
235 fputs (fid, "+--------------------------------+\n"); |
6040 | 236 fclose (fid); |
237 return; | |
20316
d8992a16643c
doc: Clean up m-files which generate images for Manual.
Rik <rik@octave.org>
parents:
20307
diff
changeset
|
238 else |
17504
8b692d9ea54e
Use Octave coding conventions for m-files which generate images for manual.
Rik <rik@octave.org>
parents:
16994
diff
changeset
|
239 [x, y, z] = sombrero (); |
6040 | 240 unwind_protect |
6257 | 241 mesh (x, y, z); |
22013
6267807eb70b
build: fix doc build error when building without SuiteSparse
Mike Miller <mtmiller@octave.org>
parents:
21226
diff
changeset
|
242 title ({"Sorry, graphics are unavailable because Octave was", |
6267807eb70b
build: fix doc build error when building without SuiteSparse
Mike Miller <mtmiller@octave.org>
parents:
21226
diff
changeset
|
243 "compiled without the SuiteSparse library."}); |
6040 | 244 unwind_protect_cleanup |
20307
c3c1fb44f9b5
eliminate recursive make invocations in doc directory tree
John W. Eaton <jwe@octave.org>
parents:
19717
diff
changeset
|
245 print (outfile, d_typ); |
9912
e9fe12c1b0c0
Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
246 hide_output (); |
6040 | 247 end_unwind_protect |
248 endif | |
249 endfunction | |
7262 | 250 |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
251 ## This function no longer sets the graphics toolkit; That is now done |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
252 ## automatically by C++ code which will ordinarily choose 'qt', but might |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
253 ## choose gnuplot on older systems. Only a complete lack of plotting is a |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
254 ## problem. |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
255 function set_graphics_toolkit () |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
256 if (isempty (available_graphics_toolkits ())) |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
257 error ("no graphics toolkit available for plotting"); |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
258 elseif (strcmp ("qt", graphics_toolkit ()) |
25428
2b3c3c8c8360
Properly test Qt offscreen printing during manual figures generation.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25054
diff
changeset
|
259 && __have_feature__ ("QT_OFFSCREEN")) |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
260 ## Use qt with QOffscreenSurface for plot |
27847
56d94f86a659
Don't test presence of OSMESA which will always fail (bug #57424)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26376
diff
changeset
|
261 elseif (! strcmp ("gnuplot", graphics_toolkit ())) |
20885
e5f78891ad9e
Allow doc's images to be generated using gnuplot when osmesa isn't available.
Ben Abbott <bpabbott@mac.com>
parents:
20779
diff
changeset
|
262 if (! any (strcmp ("gnuplot", available_graphics_toolkits ()))) |
e5f78891ad9e
Allow doc's images to be generated using gnuplot when osmesa isn't available.
Ben Abbott <bpabbott@mac.com>
parents:
20779
diff
changeset
|
263 error ("no graphics toolkit available for offscreen plotting"); |
e5f78891ad9e
Allow doc's images to be generated using gnuplot when osmesa isn't available.
Ben Abbott <bpabbott@mac.com>
parents:
20779
diff
changeset
|
264 else |
e5f78891ad9e
Allow doc's images to be generated using gnuplot when osmesa isn't available.
Ben Abbott <bpabbott@mac.com>
parents:
20779
diff
changeset
|
265 graphics_toolkit ("gnuplot"); |
e5f78891ad9e
Allow doc's images to be generated using gnuplot when osmesa isn't available.
Ben Abbott <bpabbott@mac.com>
parents:
20779
diff
changeset
|
266 endif |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
267 endif |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
268 endfunction |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
269 |
20316
d8992a16643c
doc: Clean up m-files which generate images for Manual.
Rik <rik@octave.org>
parents:
20307
diff
changeset
|
270 function set_print_size () |
d8992a16643c
doc: Clean up m-files which generate images for Manual.
Rik <rik@octave.org>
parents:
20307
diff
changeset
|
271 image_size = [5.0, 3.5]; # in inches, 16:9 format |
d8992a16643c
doc: Clean up m-files which generate images for Manual.
Rik <rik@octave.org>
parents:
20307
diff
changeset
|
272 border = 0; # For postscript use 50/72 |
24462
8ff3c13d14c1
groot.m: New function to return handle of graphics root object.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
273 set (groot, "defaultfigurepapertype", "<custom>"); |
8ff3c13d14c1
groot.m: New function to return handle of graphics root object.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
274 set (groot, "defaultfigurepaperorientation", "landscape"); |
8ff3c13d14c1
groot.m: New function to return handle of graphics root object.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
275 set (groot, "defaultfigurepapersize", image_size + 2*border); |
8ff3c13d14c1
groot.m: New function to return handle of graphics root object.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
276 set (groot, "defaultfigurepaperposition", [border, border, image_size]); |
20316
d8992a16643c
doc: Clean up m-files which generate images for Manual.
Rik <rik@octave.org>
parents:
20307
diff
changeset
|
277 endfunction |
d8992a16643c
doc: Clean up m-files which generate images for Manual.
Rik <rik@octave.org>
parents:
20307
diff
changeset
|
278 |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
279 ## Use this function before plotting commands and after every call to print |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
280 ## since print() resets output to stdout (unfortunately, gnuplot can't pop |
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
281 ## output as it can the terminal type). |
20316
d8992a16643c
doc: Clean up m-files which generate images for Manual.
Rik <rik@octave.org>
parents:
20307
diff
changeset
|
282 function hide_output () |
20335
b439ccc9a162
doc: Improve building of images for the Manual.
Rik <rik@octave.org>
parents:
20316
diff
changeset
|
283 hf = figure (1, "visible", "off"); |
20316
d8992a16643c
doc: Clean up m-files which generate images for Manual.
Rik <rik@octave.org>
parents:
20307
diff
changeset
|
284 endfunction |