annotate doc/interpreter/sparseimages.m @ 16994:333243133364

Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance. matrix concatenation is ~80% faster than cstrcat(). * doc/interpreter/strings.txi: Document preference for matrix concatenation as opposed to alternatives. * doc/interpreter/geometryimages.m, doc/interpreter/interpimages.m, doc/interpreter/plotimages.m, doc/interpreter/sparseimages.m, doc/interpreter/splineimages.m, scripts/general/genvarname.m, scripts/general/int2str.m, scripts/general/num2str.m, scripts/help/__makeinfo__.m, scripts/help/help.m, scripts/miscellaneous/copyfile.m, scripts/miscellaneous/dir.m, scripts/miscellaneous/edit.m, scripts/miscellaneous/fact.m, scripts/miscellaneous/fullfile.m, scripts/miscellaneous/mkoctfile.m, scripts/miscellaneous/movefile.m, scripts/miscellaneous/perl.m, scripts/miscellaneous/python.m, scripts/miscellaneous/run.m, scripts/miscellaneous/tempdir.m, scripts/miscellaneous/unpack.m, scripts/pkg/private/configure_make.m, scripts/pkg/private/create_pkgadddel.m, scripts/pkg/private/extract_pkg.m, scripts/pkg/private/get_description.m, scripts/pkg/private/get_forge_pkg.m, scripts/pkg/private/getarch.m, scripts/pkg/private/getarchprefix.m, scripts/pkg/private/install.m, scripts/pkg/private/installed_packages.m, scripts/pkg/private/load_packages_and_dependencies.m, scripts/pkg/private/rebuild.m, scripts/pkg/private/repackage.m, scripts/pkg/private/shell.m, scripts/pkg/private/uninstall.m, scripts/plot/private/__go_draw_axes__.m, scripts/signal/spectral_adf.m, scripts/signal/spectral_xdf.m, scripts/statistics/tests/z_test.m, scripts/statistics/tests/z_test_2.m, scripts/strings/mat2str.m, scripts/strings/strtok.m, scripts/testfun/__run_test_suite__.m, scripts/testfun/assert.m, scripts/testfun/demo.m, scripts/testfun/speed.m, scripts/testfun/test.m, test/eval-catch.tst, test/io.tst, test/try.tst: Replace cstrcat() with matrix concatenation where possible.
author Rik <rik@octave.org>
date Wed, 17 Jul 2013 14:02:32 -0700
parents 2a4f83826024
children 8b692d9ea54e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 12702
diff changeset
1 ## Copyright (C) 2006-2012 David Bateman
7018
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
2 ##
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
3 ## This file is part of Octave.
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
4 ##
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
6 ## under the terms of the GNU General Public License as published by
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
8 ## your option) any later version.
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
9 ##
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
13 ## General Public License for more details.
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
14 ##
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
15 ## You should have received a copy of the GNU General Public License
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
17 ## <http://www.gnu.org/licenses/>.
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 6257
diff changeset
18
6126
c0011bf8f815 [project @ 2006-10-31 20:08:30 by jwe]
jwe
parents: 6040
diff changeset
19 function sparseimages (nm, typ)
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
20 graphics_toolkit ("gnuplot");
9912
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
21 set_print_size ();
7257
e8a3e3e33490 [project @ 2007-12-05 01:18:41 by jwe]
jwe
parents: 7256
diff changeset
22 if (strcmp (typ, "png"))
e8a3e3e33490 [project @ 2007-12-05 01:18:41 by jwe]
jwe
parents: 7256
diff changeset
23 set (0, "defaulttextfontname", "*");
e8a3e3e33490 [project @ 2007-12-05 01:18:41 by jwe]
jwe
parents: 7256
diff changeset
24 endif
9914
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
25
16170
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
26 if (__have_feature__ ("COLAMD")
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
27 && __have_feature__ ("CHOLMOD")
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
28 && __have_feature__ ("UMFPACK"))
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
29 if (strcmp (typ,"txt"))
6126
c0011bf8f815 [project @ 2006-10-31 20:08:30 by jwe]
jwe
parents: 6040
diff changeset
30 txtimages (nm, 15, typ);
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
31 else
6126
c0011bf8f815 [project @ 2006-10-31 20:08:30 by jwe]
jwe
parents: 6040
diff changeset
32 if (strcmp (nm, "gplot"))
11033
d9c8916bb9dd Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents: 9914
diff changeset
33 gplotimages ("gplot", typ);
6126
c0011bf8f815 [project @ 2006-10-31 20:08:30 by jwe]
jwe
parents: 6040
diff changeset
34 elseif (strcmp (nm, "grid"))
11033
d9c8916bb9dd Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents: 9914
diff changeset
35 femimages ("grid", typ);
6126
c0011bf8f815 [project @ 2006-10-31 20:08:30 by jwe]
jwe
parents: 6040
diff changeset
36 else
11033
d9c8916bb9dd Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents: 9914
diff changeset
37 otherimages (nm, 200, typ);
6126
c0011bf8f815 [project @ 2006-10-31 20:08:30 by jwe]
jwe
parents: 6040
diff changeset
38 endif
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
39 endif
6040
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
40 else ## There is no sparse matrix implementation available because
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
41 ## of missing libraries, plot sombreros instead
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
42 sombreroimage (nm, typ);
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
43 endif
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
44 endfunction
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
45
9912
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
46 function set_print_size ()
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
47 image_size = [5.0, 3.5]; # in inches, 16:9 format
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
48 border = 0; # For postscript use 50/72
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
49 set (0, "defaultfigurepapertype", "<custom>");
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
50 set (0, "defaultfigurepaperorientation", "landscape");
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
51 set (0, "defaultfigurepapersize", image_size + 2*border);
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
52 set (0, "defaultfigurepaperposition", [border, border, image_size]);
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
53 endfunction
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
54
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
55 function hide_output ()
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6180
diff changeset
56 f = figure (1);
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6180
diff changeset
57 set (f, "visible", "off");
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
58 endfunction
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
59
6040
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
60 function gplotimages (nm, typ)
9912
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
61 hide_output ();
9914
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
62 if (strcmp (typ, "eps"))
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
63 d_typ = "-depsc2";
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
64 else
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
65 d_typ = ["-d" typ];
9914
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
66 endif
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
67
6040
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
68 A = sparse ([2,6,1,3,2,4,3,5,4,6,1,5],
11033
d9c8916bb9dd Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents: 9914
diff changeset
69 [1,1,2,2,3,3,4,4,5,5,6,6], 1, 6, 6);
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
70 xy = [0,4,8,6,4,2;5,0,5,7,5,7]';
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
71 gplot (A, xy);
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
72 print ([nm "." typ], d_typ);
9912
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
73 hide_output ();
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
74 endfunction
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
75
11039
4cbb08163a1f Use Octave to create pdf versions of plots for documentation.
Rik <octave@nomad.inbox5.com>
parents: 11033
diff changeset
76 function txtimages(nm, n, typ)
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
77 a = 10*speye(n) + sparse(1:n,ceil([1:n]/2),1,n,n) + ...
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
78 sparse(ceil([1:n]/2),1:n,1,n,n);
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
79 if (strcmp (nm, "gplot") || strcmp (nm, "grid"))
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
80 fid = fopen (sprintf ("%s.txt", nm), "wt");
7256
be3280acbdb8 [project @ 2007-12-05 01:08:17 by jwe]
jwe
parents: 7018
diff changeset
81 fputs (fid, "\n");
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
82 fputs (fid, "+---------------------------------+\n");
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
83 fputs (fid, "| Image unavailable in text mode. |\n");
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
84 fputs (fid, "+---------------------------------+\n");
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
85 fclose (fid);
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
86 elseif (strcmp (nm, "spmatrix"))
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
87 printsparse (a, ["spmatrix." typ]);
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
88 else
16170
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
89 if (__have_feature__ ("COLAMD")
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
90 && __have_feature__ ("CHOLMOD"))
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
91 if (strcmp (nm, "spchol"))
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
92 r1 = chol (a);
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
93 printsparse (r1, ["spchol." typ]);
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
94 elseif (strcmp (nm, "spcholperm"))
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
95 [r2,p2,q2] = chol (a);
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
96 printsparse(r2, ["spcholperm." typ]);
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
97 endif
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
98 ## printf("Text NNZ: Matrix %d, Chol %d, PermChol %d\n",nnz(a),nnz(r1),nnz(r2));
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
99 endif
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
100 endif
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
101 endfunction
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
102
11039
4cbb08163a1f Use Octave to create pdf versions of plots for documentation.
Rik <octave@nomad.inbox5.com>
parents: 11033
diff changeset
103 function otherimages(nm, n, typ)
9912
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
104 hide_output ();
9914
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
105 if (strcmp (typ, "eps"))
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
106 d_typ = "-depsc2";
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
107 else
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
108 d_typ = ["-d" typ];
9914
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
109 endif
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
110
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
111 a = 10*speye(n) + sparse(1:n,ceil([1:n]/2),1,n,n) + ...
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
112 sparse(ceil([1:n]/2),1:n,1,n,n);
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
113 if (strcmp (nm, "spmatrix"))
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
114 spy (a);
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
115 axis ("ij");
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
116 print (["spmatrix." typ], d_typ);
9912
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
117 hide_output ();
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
118 else
16170
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
119 if (__have_feature__ ("COLAMD")
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
120 && __have_feature__ ("CHOLMOD"))
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
121 if (strcmp (nm, "spchol"))
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
122 r1 = chol (a);
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
123 spy (r1);
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
124 axis ("ij");
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
125 print (["spchol." typ], d_typ);
11033
d9c8916bb9dd Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents: 9914
diff changeset
126 hide_output ();
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
127 elseif (strcmp (nm, "spcholperm"))
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
128 [r2,p2,q2] = chol (a);
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
129 spy (r2);
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
130 axis ("ij");
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
131 print (["spcholperm." typ], d_typ);
11033
d9c8916bb9dd Untabify a few remaining .m scripts.
Rik <octave@nomad.inbox5.com>
parents: 9914
diff changeset
132 hide_output ();
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
133 endif
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
134 ## printf("Image NNZ: Matrix %d, Chol %d, PermChol %d\n",nnz(a),nnz(r1),nnz(r2));
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
135 endif
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
136 endif
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
137 endfunction
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
138
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
139 function printsparse (a, nm)
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
140 fid = fopen (nm,"wt");
7256
be3280acbdb8 [project @ 2007-12-05 01:08:17 by jwe]
jwe
parents: 7018
diff changeset
141 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
142 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
143 if (rem (i,5) == 0)
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
144 fprintf (fid," %2d - ", i);
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
145 else
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
146 fprintf (fid," | ");
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
147 endif
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
148 for j = 1:columns (a)
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
149 if (a(i,j) == 0)
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
150 fprintf (fid," ");
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
151 else
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
152 fprintf (fid," *");
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
153 endif
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
154 endfor
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
155 fprintf (fid,"\n");
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
156 endfor
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
157 fprintf (fid," |-");
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
158 for j=1:columns (a)
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
159 if (rem (j,5) == 0)
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
160 fprintf (fid,"-|");
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
161 else
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
162 fprintf (fid,"--");
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
163 endif
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
164 endfor
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
165 fprintf (fid,"\n");
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
166 fprintf (fid," ");
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
167 for j=1:columns (a)
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
168 if (rem (j,5) == 0)
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
169 fprintf (fid,"%2d",j);
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
170 else
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
171 fprintf (fid," ");
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
172 endif
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
173 endfor
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
174 fclose (fid);
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
175 endfunction
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
176
11039
4cbb08163a1f Use Octave to create pdf versions of plots for documentation.
Rik <octave@nomad.inbox5.com>
parents: 11033
diff changeset
177 function femimages (nm, typ)
9912
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
178 hide_output ();
9914
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
179 if (strcmp (typ, "eps"))
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
180 d_typ = "-depsc2";
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
181 else
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
182 d_typ = ["-d" typ];
9914
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
183 endif
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
184
16170
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
185 if (__have_feature__ ("COLAMD")
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
186 && __have_feature__ ("CHOLMOD")
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
187 && __have_feature__ ("UMFPACK"))
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
188 ## build a rectangle
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
189 node_y = [1;1.2;1.5;1.8;2]*ones(1,11);
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
190 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];
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
191 nodes = [node_x(:), node_y(:)];
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
192
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
193 [h,w] = size (node_x);
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
194 elems = [];
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
195 for idx = 1:w-1
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
196 widx = (idx-1)*h;
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
197 elems = [elems; widx+[(1:h-1);(2:h);h+(1:h-1)]'];
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
198 elems = [elems; widx+[(2:h);h+(2:h);h+(1:h-1)]'];
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
199 endfor
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
200
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
201 E = size (elems,1); #No. of elements
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
202 N = size (nodes,1); #No. of elements
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
203 D = size (elems,2); #dimensions+1
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
204
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
205 ## Plot FEM Geometry
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
206 elemx = elems(:,[1,2,3,1])';
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
207 xelems = reshape (nodes(elemx, 1), 4, E);
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
208 yelems = reshape (nodes(elemx, 2), 4, E);
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
209
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
210 ## Set element conductivity
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
211 conductivity = [1*ones(1,16),2*ones(1,48),1*ones(1,16)];
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
212
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
213 ## Dirichlet boundary conditions
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
214 D_nodes = [1:5, 51:55];
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
215 D_value = [10*ones(1,5), 20*ones(1,5)];
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
216
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
217 ## Neumann boundary conditions
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
218 ## Note that N_value must be normalized by the boundary
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
219 ## length and element conductivity
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
220 N_nodes = [];
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
221 N_value = [];
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
222
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
223 ## Calculate connectivity matrix
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
224 C = sparse ((1:D*E), reshape (elems',D*E,1),1, D*E, N);
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
225
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
226 ## Calculate stiffness matrix
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
227 Siidx = floor ([0:D*E-1]'/D)*D*ones(1,D) + ones(D*E,1)*(1:D) ;
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
228 Sjidx = [1:D*E]'*ones (1,D);
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
229 Sdata = zeros (D*E,D);
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
230 dfact = prod (2:(D-1));
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
231 for j = 1:E
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
232 a = inv ([ ones(D,1), nodes( elems(j,:), : ) ]);
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
233 const = conductivity(j)*2/dfact/abs(det(a));
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
234 Sdata(D*(j-1)+(1:D),:)= const * a(2:D,:)'*a(2:D,:);
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
235 endfor
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
236
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
237 ## Element-wise system matrix
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
238 SE = sparse (Siidx,Sjidx,Sdata);
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
239 ## Global system matrix
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
240 S = C'* SE *C;
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
241
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
242 ## Set Dirichlet boundary
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
243 V = zeros (N,1);
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
244 V(D_nodes) = D_value;
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
245 idx = 1:N;
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
246 idx(D_nodes) = [];
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
247
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
248 ## Set Neumann boundary
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
249 Q = zeros (N,1);
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
250 Q(N_nodes) = N_value; # FIXME
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
251
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
252 V(idx) = S(idx,idx)\( Q(idx) - S(idx,D_nodes)*V(D_nodes) );
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
253
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
254 velems = reshape ( V(elemx), 4, E);
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
255
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
256 sz = size (xelems,2);
6178
830235f4984f [project @ 2006-11-17 00:16:57 by jwe]
jwe
parents: 6126
diff changeset
257
830235f4984f [project @ 2006-11-17 00:16:57 by jwe]
jwe
parents: 6126
diff changeset
258 plot3 (xelems, yelems, velems);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6180
diff changeset
259 view (10, 10);
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
260 print ([nm "." typ], d_typ);
9912
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
261 hide_output ();
6003
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
262 endif
7f8e4f5e2eb7 [project @ 2006-09-26 21:09:31 by jwe]
jwe
parents:
diff changeset
263 endfunction
6040
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
264
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
265 ## There is no sparse matrix implementation available because of missing
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
266 ## libraries, plot sombreros instead. Also plot a nice title that we are
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
267 ## sorry about that.
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
268 function sombreroimage (nm, typ)
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
269 if (strcmp (typ, "txt"))
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
270 fid = fopen (sprintf ("%s.txt", nm), "wt");
7256
be3280acbdb8 [project @ 2007-12-05 01:08:17 by jwe]
jwe
parents: 7018
diff changeset
271 fputs (fid, "\n");
6040
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
272 fputs (fid, "+---------------------------------------+\n");
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
273 fputs (fid, "| Image unavailable because of a |\n");
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
274 fputs (fid, "| missing sparse matrix implementation. |\n");
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
275 fputs (fid, "+---------------------------------------+\n");
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
276 fclose (fid);
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
277 return;
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
278 else ## if (!strcmp (typ, "txt"))
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
279
9912
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
280 hide_output ();
9914
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
281 if (strcmp (typ, "eps"))
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
282 d_typ = "-depsc2";
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
283 else
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
284 d_typ = ["-d" typ];
9914
e76d8c767584 Switch to color output for PostScript documentation images
Rik <rdrider0-list@yahoo.com>
parents: 9912
diff changeset
285 endif
6040
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
286
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
287 x = y = linspace (-8, 8, 41)';
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
288 [xx, yy] = meshgrid (x, y);
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
289 r = sqrt (xx .^ 2 + yy .^ 2) + eps;
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
290 z = sin (r) ./ r;
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
291 unwind_protect
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6180
diff changeset
292 mesh (x, y, z);
11039
4cbb08163a1f Use Octave to create pdf versions of plots for documentation.
Rik <octave@nomad.inbox5.com>
parents: 11033
diff changeset
293 title ("Sorry, graphics are unavailable because Octave was\ncompiled without a sparse matrix implementation.");
6040
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
294 unwind_protect_cleanup
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16170
diff changeset
295 print ([nm "." typ], d_typ);
9912
e9fe12c1b0c0 Set default papersize to the desired imagesize
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
296 hide_output ();
6040
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
297 end_unwind_protect
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
298 endif
2bcb2fa24bbf [project @ 2006-10-09 15:13:29 by jwe]
jwe
parents: 6003
diff changeset
299 endfunction
7262
16e61aecddc1 [project @ 2007-12-05 20:50:47 by jwe]
jwe
parents: 7257
diff changeset
300
16e61aecddc1 [project @ 2007-12-05 20:50:47 by jwe]
jwe
parents: 7257
diff changeset
301 ## generate something for the texinfo @image command to process
16e61aecddc1 [project @ 2007-12-05 20:50:47 by jwe]
jwe
parents: 7257
diff changeset
302 function image_as_txt(nm)
16e61aecddc1 [project @ 2007-12-05 20:50:47 by jwe]
jwe
parents: 7257
diff changeset
303 fid = fopen (sprintf ("%s.txt", nm), "wt");
16e61aecddc1 [project @ 2007-12-05 20:50:47 by jwe]
jwe
parents: 7257
diff changeset
304 fputs (fid, "\n");
16e61aecddc1 [project @ 2007-12-05 20:50:47 by jwe]
jwe
parents: 7257
diff changeset
305 fputs (fid, "+---------------------------------+\n");
16e61aecddc1 [project @ 2007-12-05 20:50:47 by jwe]
jwe
parents: 7257
diff changeset
306 fputs (fid, "| Image unavailable in text mode. |\n");
16e61aecddc1 [project @ 2007-12-05 20:50:47 by jwe]
jwe
parents: 7257
diff changeset
307 fputs (fid, "+---------------------------------+\n");
16e61aecddc1 [project @ 2007-12-05 20:50:47 by jwe]
jwe
parents: 7257
diff changeset
308 fclose (fid);
16e61aecddc1 [project @ 2007-12-05 20:50:47 by jwe]
jwe
parents: 7257
diff changeset
309 endfunction