Mercurial > octave-nkf
annotate libinterp/corefcn/spparms.cc @ 20626:5fc798a9b32c
maint: Periodic merge of stable to default.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 09 Oct 2015 19:28:05 -0700 |
parents | ba2b07c13913 |
children |
rev | line source |
---|---|
5164 | 1 /* |
2 | |
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19679
diff
changeset
|
3 Copyright (C) 2004-2015 David Bateman |
11523 | 4 Copyright (C) 1998-2004 Andy Adler |
5164 | 5 |
7016 | 6 This file is part of Octave. |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
5164 | 9 under the terms of the GNU General Public License as published by the |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
5164 | 12 |
7016 | 13 Octave is distributed in the hope that it will be useful, but WITHOUT |
5164 | 14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
5164 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
15020
diff
changeset
|
28 #include "defun.h" |
5164 | 29 #include "ov.h" |
30 #include "pager.h" | |
31 #include "error.h" | |
32 #include "gripes.h" | |
33 | |
34 #include "oct-spparms.h" | |
35 | |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
15020
diff
changeset
|
36 DEFUN (spparms, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
37 "-*- texinfo -*-\n\ |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
15020
diff
changeset
|
38 @deftypefn {Built-in Function} { } spparms ()\n\ |
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
15020
diff
changeset
|
39 @deftypefnx {Built-in Function} {@var{vals} =} spparms ()\n\ |
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
15020
diff
changeset
|
40 @deftypefnx {Built-in Function} {[@var{keys}, @var{vals}] =} spparms ()\n\ |
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
15020
diff
changeset
|
41 @deftypefnx {Built-in Function} {@var{val} =} spparms (@var{key})\n\ |
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
15020
diff
changeset
|
42 @deftypefnx {Built-in Function} { } spparms (@var{vals})\n\ |
19364
eb20020f36b5
spparms.cc: accept "default" as argument instead of "defaults" (bug #43602)
Marco Vitetta <marcovitetta@gmail.com>
parents:
18851
diff
changeset
|
43 @deftypefnx {Built-in Function} { } spparms (\"default\")\n\ |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
15020
diff
changeset
|
44 @deftypefnx {Built-in Function} { } spparms (\"tight\")\n\ |
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
15020
diff
changeset
|
45 @deftypefnx {Built-in Function} { } spparms (@var{key}, @var{val})\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
46 Query or set the parameters used by the sparse solvers and factorization\n\ |
20207
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
47 functions.\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
48 \n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
49 The first four calls above get information about the current settings, while\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
50 the others change the current settings. The parameters are stored as pairs\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
51 of keys and values, where the values are all floats and the keys are one of\n\ |
4f45eaf83908
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
52 the following strings:\n\ |
5164 | 53 \n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
54 @table @samp\n\ |
5164 | 55 @item spumoni\n\ |
56 Printing level of debugging information of the solvers (default 0)\n\ | |
10840 | 57 \n\ |
5164 | 58 @item ths_rel\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
59 Included for compatibility. Not used. (default 1)\n\ |
10840 | 60 \n\ |
5164 | 61 @item ths_abs\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
62 Included for compatibility. Not used. (default 1)\n\ |
10840 | 63 \n\ |
5164 | 64 @item exact_d\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
65 Included for compatibility. Not used. (default 0)\n\ |
10840 | 66 \n\ |
5164 | 67 @item supernd\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
68 Included for compatibility. Not used. (default 3)\n\ |
10840 | 69 \n\ |
5164 | 70 @item rreduce\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
71 Included for compatibility. Not used. (default 3)\n\ |
10840 | 72 \n\ |
5164 | 73 @item wh_frac\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
74 Included for compatibility. Not used. (default 0.5)\n\ |
10840 | 75 \n\ |
5164 | 76 @item autommd\n\ |
77 Flag whether the LU/QR and the '\\' and '/' operators will automatically\n\ | |
78 use the sparsity preserving mmd functions (default 1)\n\ | |
10840 | 79 \n\ |
5164 | 80 @item autoamd\n\ |
81 Flag whether the LU and the '\\' and '/' operators will automatically\n\ | |
82 use the sparsity preserving amd functions (default 1)\n\ | |
10840 | 83 \n\ |
5164 | 84 @item piv_tol\n\ |
10711
fbd7843974fa
Periodic grammar check of documentation files to ensure common format.
Rik <octave@nomad.inbox5.com>
parents:
10155
diff
changeset
|
85 The pivot tolerance of the @sc{umfpack} solvers (default 0.1)\n\ |
10840 | 86 \n\ |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
87 @item sym_tol\n\ |
10711
fbd7843974fa
Periodic grammar check of documentation files to ensure common format.
Rik <octave@nomad.inbox5.com>
parents:
10155
diff
changeset
|
88 The pivot tolerance of the @sc{umfpack} symmetric solvers (default 0.001)\n\ |
10840 | 89 \n\ |
5164 | 90 @item bandden\n\ |
18851
9ac2357f19bc
doc: Replace "non-zero" with "nonzero" to match existing usage.
Rik <rik@octave.org>
parents:
18848
diff
changeset
|
91 The density of nonzero elements in a banded matrix before it is treated\n\ |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
92 by the @sc{lapack} banded solvers (default 0.5)\n\ |
10840 | 93 \n\ |
5164 | 94 @item umfpack\n\ |
10711
fbd7843974fa
Periodic grammar check of documentation files to ensure common format.
Rik <octave@nomad.inbox5.com>
parents:
10155
diff
changeset
|
95 Flag whether the @sc{umfpack} or mmd solvers are used for the LU, '\\' and\n\ |
5164 | 96 '/' operations (default 1)\n\ |
8828 | 97 @end table\n\ |
5164 | 98 \n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
99 The value of individual keys can be set with\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
100 @code{spparms (@var{key}, @var{val})}.\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
101 The default values can be restored with the special keyword\n\ |
19364
eb20020f36b5
spparms.cc: accept "default" as argument instead of "defaults" (bug #43602)
Marco Vitetta <marcovitetta@gmail.com>
parents:
18851
diff
changeset
|
102 @qcode{\"default\"}. The special keyword @qcode{\"tight\"} can be used to\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
103 set the mmd solvers to attempt a sparser solution at the potential cost of\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
15195
diff
changeset
|
104 longer running time.\n\ |
18848
53af80da6781
doc: Update documentation of sparse functions including seealso links.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
105 @seealso{chol, colamd, lu, qr, symamd}\n\ |
5164 | 106 @end deftypefn") |
107 { | |
108 octave_value_list retval; | |
109 int nargin = args.length (); | |
110 | |
111 if (nargin == 0) | |
112 { | |
113 if (nargout == 0) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
114 octave_sparse_params::print_info (octave_stdout, ""); |
5164 | 115 else if (nargout == 1) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
116 retval(0) = octave_sparse_params::get_vals (); |
5164 | 117 else if (nargout == 2) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
118 { |
14844
5bc9b9cb4362
maint: Use Octave coding conventions for cuddled parenthesis in retval assignments.
Rik <octave@nomad.inbox5.com>
parents:
14501
diff
changeset
|
119 retval(1) = octave_sparse_params::get_vals (); |
5bc9b9cb4362
maint: Use Octave coding conventions for cuddled parenthesis in retval assignments.
Rik <octave@nomad.inbox5.com>
parents:
14501
diff
changeset
|
120 retval(0) = octave_sparse_params::get_keys (); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
121 } |
5164 | 122 else |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
123 error ("spparms: too many output arguments"); |
5164 | 124 } |
125 else if (nargin == 1) | |
126 { | |
127 if (args(0).is_string ()) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
128 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
129 std::string str = args(0).string_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
130 int len = str.length (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
131 for (int i = 0; i < len; i++) |
15020
560317fd5977
maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents:
14844
diff
changeset
|
132 str[i] = tolower (str[i]); |
5164 | 133 |
19364
eb20020f36b5
spparms.cc: accept "default" as argument instead of "defaults" (bug #43602)
Marco Vitetta <marcovitetta@gmail.com>
parents:
18851
diff
changeset
|
134 if (str == "defaults" || str == "default") |
19365
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19364
diff
changeset
|
135 { |
19679
ebd27d8c63fd
update default branch to release as 4.0
John W. Eaton <jwe@octave.org>
parents:
19365
diff
changeset
|
136 // FIXME: deprecated in 4.0, remove "defaults" for 4.4 release |
19365
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19364
diff
changeset
|
137 static bool warned = false; |
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19364
diff
changeset
|
138 if (! warned && str == "defaults") |
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19364
diff
changeset
|
139 { |
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19364
diff
changeset
|
140 warning ("spparms: use \"default\" instead of \"defaults\""); |
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19364
diff
changeset
|
141 warned = true; |
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19364
diff
changeset
|
142 } |
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19364
diff
changeset
|
143 octave_sparse_params::defaults (); |
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19364
diff
changeset
|
144 } |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
145 else if (str == "tight") |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
146 octave_sparse_params::tight (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
147 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
148 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
149 double val = octave_sparse_params::get_key (str); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
150 if (xisnan (val)) |
13080
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
151 error ("spparms: KEY not recognized"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
152 else |
14844
5bc9b9cb4362
maint: Use Octave coding conventions for cuddled parenthesis in retval assignments.
Rik <octave@nomad.inbox5.com>
parents:
14501
diff
changeset
|
153 retval(0) = val; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
154 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
155 } |
5164 | 156 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
157 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
158 NDArray vals = args(0).array_value (); |
5164 | 159 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
160 if (error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
161 error ("spparms: input must be a string or a vector"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
162 else if (vals.numel () > OCTAVE_SPARSE_CONTROLS_SIZE) |
13080
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
163 error ("spparms: too many elements in vector VALS"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
164 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
165 octave_sparse_params::set_vals (vals); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
166 } |
5164 | 167 } |
168 else if (nargin == 2) | |
169 { | |
20617
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20207
diff
changeset
|
170 std::string str = args(0).string_value ("spparms: first argument must be a string"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
171 |
20617
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20207
diff
changeset
|
172 double val = args(1).double_value (); |
5164 | 173 |
20617
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20207
diff
changeset
|
174 if (error_state) |
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20207
diff
changeset
|
175 error ("spparms: second argument must be a real scalar"); |
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20207
diff
changeset
|
176 else if (str == "umfpack") |
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20207
diff
changeset
|
177 warning ("spparms: request to disable umfpack solvers ignored"); |
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20207
diff
changeset
|
178 else if (!octave_sparse_params::set_key (str, val)) |
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20207
diff
changeset
|
179 error ("spparms: KEY not found"); |
5164 | 180 } |
181 else | |
182 error ("spparms: too many input arguments"); | |
183 | |
184 return retval; | |
185 } | |
13080
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
186 |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
187 /* |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
188 %!test |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
189 %! old_vals = spparms (); # save state |
19364
eb20020f36b5
spparms.cc: accept "default" as argument instead of "defaults" (bug #43602)
Marco Vitetta <marcovitetta@gmail.com>
parents:
18851
diff
changeset
|
190 %! spparms ("default"); |
13080
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
191 %! vals = spparms (); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
192 %! assert (vals, [0 1 1 0 3 3 0.5 1.0 1.0 0.1 0.5 1.0 0.001]'); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
193 %! [keys, vals] = spparms (); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
194 %! assert (rows (keys), 13); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
195 %! assert (keys(2,:), "ths_rel"); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
196 %! assert (vals, [0 1 1 0 3 3 0.5 1.0 1.0 0.1 0.5 1.0 0.001]'); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
197 %! spparms ([3 2 1]); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
198 %! assert (spparms ()(1:3), [3, 2, 1]'); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
199 %! assert (spparms ("ths_rel"), 2); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
200 %! spparms ("exact_d", 5); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
201 %! assert (spparms ("exact_d"), 5); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
202 %! spparms (old_vals); # restore state |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
203 |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
204 %% Test input validation |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14366
diff
changeset
|
205 %!error <too many input arguments> spparms (1, 2, 3) |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14366
diff
changeset
|
206 %!error <too many output arguments> [x, y, z] = spparms () |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14366
diff
changeset
|
207 %!error <KEY not recognized> spparms ("UNKNOWN_KEY") |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14366
diff
changeset
|
208 %!#error <input must be a string> spparms ({1, 2, 3}) |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14366
diff
changeset
|
209 %!error spparms ({1, 2, 3}) |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14366
diff
changeset
|
210 %!error <too many elements in vector VALS> spparms (ones (14, 1)) |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14366
diff
changeset
|
211 %!error <first argument must be a string> spparms (1, 1) |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14366
diff
changeset
|
212 %!#error <second argument must be a real scalar> spparms ("ths_rel", "hello") |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14366
diff
changeset
|
213 %!error spparms ("ths_rel", "hello") |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14366
diff
changeset
|
214 %!error <KEY not found> spparms ("UNKNOWN_KEY", 1) |
13080
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
215 */ |