Mercurial > octave
annotate libinterp/corefcn/spparms.cc @ 22737:7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Space between '!' and expression that follows.
Eliminate whitespace at end of line.
Use '#' rather than '%' for comment character.
* ButtonGroup.cc, ListBoxControl.cc, file-editor-tab.cc, file-editor.cc,
bsxfun.cc, cellfun.cc, conv2.cc, data.cc, dot.cc, fft2.cc, file-io.cc,
filter.cc, graphics.cc, kron.cc, oct-stream.cc, quadcc.cc, spparms.cc,
sylvester.cc, convhulln.cc, qr.cc, ov-class.cc, ov-cx-mat.cc, ov-usr-fcn.cc,
pt.h, Array.cc, gsvd.h, inputdlg.m, krylov.m, shrinkfaces.m, padecoef.m,
polyout.m, durbinlevinson.m:
maint: Clean up code base to follow Octave coding conventions.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 08 Nov 2016 10:01:17 -0800 |
parents | 34ce5be04942 |
children | 3a2b891d0b33 |
rev | line source |
---|---|
5164 | 1 /* |
2 | |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
3 Copyright (C) 2004-2016 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 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
24 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
25 # include "config.h" |
5164 | 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" | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21055
diff
changeset
|
32 #include "errwarn.h" |
5164 | 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, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
37 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
38 @deftypefn {} { } spparms () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
39 @deftypefnx {} {@var{vals} =} spparms () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
40 @deftypefnx {} {[@var{keys}, @var{vals}] =} spparms () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
41 @deftypefnx {} {@var{val} =} spparms (@var{key}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
42 @deftypefnx {} { } spparms (@var{vals}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
43 @deftypefnx {} { } spparms ("default") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
44 @deftypefnx {} { } spparms ("tight") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
45 @deftypefnx {} { } spparms (@var{key}, @var{val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
46 Query or set the parameters used by the sparse solvers and factorization |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
47 functions. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
48 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
49 The first four calls above get information about the current settings, while |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
50 the others change the current settings. The parameters are stored as pairs |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
51 of keys and values, where the values are all floats and the keys are one of |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
52 the following strings: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
53 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
54 @table @samp |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
55 @item spumoni |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
56 Printing level of debugging information of the solvers (default 0) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
57 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
58 @item ths_rel |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
59 Included for compatibility. Not used. (default 1) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
60 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
61 @item ths_abs |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
62 Included for compatibility. Not used. (default 1) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
63 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
64 @item exact_d |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
65 Included for compatibility. Not used. (default 0) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
66 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
67 @item supernd |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
68 Included for compatibility. Not used. (default 3) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
69 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
70 @item rreduce |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
71 Included for compatibility. Not used. (default 3) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
72 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
73 @item wh_frac |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
74 Included for compatibility. Not used. (default 0.5) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
75 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
76 @item autommd |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
77 Flag whether the LU/QR and the '\' and '/' operators will automatically |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
78 use the sparsity preserving mmd functions (default 1) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
79 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
80 @item autoamd |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
81 Flag whether the LU and the '\' and '/' operators will automatically |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
82 use the sparsity preserving amd functions (default 1) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
83 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
84 @item piv_tol |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
85 The pivot tolerance of the @sc{umfpack} solvers (default 0.1) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
86 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
87 @item sym_tol |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
88 The pivot tolerance of the @sc{umfpack} symmetric solvers (default 0.001) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
89 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
90 @item bandden |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
91 The density of nonzero elements in a banded matrix before it is treated |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
92 by the @sc{lapack} banded solvers (default 0.5) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
93 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
94 @item umfpack |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
95 Flag whether the @sc{umfpack} or mmd solvers are used for the LU, '\' and |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
96 '/' operations (default 1) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
97 @end table |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
98 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
99 The value of individual keys can be set with |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
100 @code{spparms (@var{key}, @var{val})}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
101 The default values can be restored with the special keyword |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
102 @qcode{"default"}. The special keyword @qcode{"tight"} can be used to |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
103 set the mmd solvers to attempt a sparser solution at the potential cost of |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
104 longer running time. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
105 @seealso{chol, colamd, lu, qr, symamd} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
106 @end deftypefn */) |
5164 | 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) |
20892 | 116 retval = ovl (octave_sparse_params::get_vals ()); |
5164 | 117 else if (nargout == 2) |
20892 | 118 retval = ovl (octave_sparse_params::get_keys (), |
119 octave_sparse_params::get_vals ()); | |
5164 | 120 else |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
121 error ("spparms: too many output arguments"); |
5164 | 122 } |
123 else if (nargin == 1) | |
124 { | |
125 if (args(0).is_string ()) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
126 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
127 std::string str = args(0).string_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
128 int len = str.length (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
129 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
|
130 str[i] = tolower (str[i]); |
5164 | 131 |
19332
eb20020f36b5
spparms.cc: accept "default" as argument instead of "defaults" (bug #43602)
Marco Vitetta <marcovitetta@gmail.com>
parents:
18812
diff
changeset
|
132 if (str == "defaults" || str == "default") |
19333
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19332
diff
changeset
|
133 { |
19645
ebd27d8c63fd
update default branch to release as 4.0
John W. Eaton <jwe@octave.org>
parents:
19333
diff
changeset
|
134 // FIXME: deprecated in 4.0, remove "defaults" for 4.4 release |
19333
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19332
diff
changeset
|
135 static bool warned = false; |
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19332
diff
changeset
|
136 if (! warned && str == "defaults") |
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19332
diff
changeset
|
137 { |
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19332
diff
changeset
|
138 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:
19332
diff
changeset
|
139 warned = true; |
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19332
diff
changeset
|
140 } |
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19332
diff
changeset
|
141 octave_sparse_params::defaults (); |
bcec6f9d1596
spparms.cc: deprecate option "defaults" in favour of "default" (bug #43602)
Carnë Draug <carandraug@octave.org>
parents:
19332
diff
changeset
|
142 } |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
143 else if (str == "tight") |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
144 octave_sparse_params::tight (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
145 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
146 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
147 double val = octave_sparse_params::get_key (str); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
148 if (octave::math::isnan (val)) |
13080
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
149 error ("spparms: KEY not recognized"); |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
150 |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
151 retval = ovl (val); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
152 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
153 } |
5164 | 154 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
155 { |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
156 NDArray vals = args(0).xarray_value ("spparms: input must be a string or a vector"); |
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
157 if (vals.numel () > OCTAVE_SPARSE_CONTROLS_SIZE) |
13080
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
158 error ("spparms: too many elements in vector VALS"); |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
159 |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
160 octave_sparse_params::set_vals (vals); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
161 } |
5164 | 162 } |
163 else if (nargin == 2) | |
164 { | |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
165 std::string str = args(0).xstring_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
|
166 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
167 double val = args(1).xdouble_value ("spparms: second argument must be a real scalar"); |
5164 | 168 |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
169 if (str == "umfpack") |
20582
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20172
diff
changeset
|
170 warning ("spparms: request to disable umfpack solvers ignored"); |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20892
diff
changeset
|
171 else if (! octave_sparse_params::set_key (str, val)) |
20582
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20172
diff
changeset
|
172 error ("spparms: KEY not found"); |
5164 | 173 } |
174 else | |
175 error ("spparms: too many input arguments"); | |
176 | |
177 return retval; | |
178 } | |
13080
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
179 |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
180 /* |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
181 %!test |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
182 %! old_vals = spparms (); # save state |
19332
eb20020f36b5
spparms.cc: accept "default" as argument instead of "defaults" (bug #43602)
Marco Vitetta <marcovitetta@gmail.com>
parents:
18812
diff
changeset
|
183 %! spparms ("default"); |
13080
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
184 %! vals = spparms (); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
185 %! 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
|
186 %! [keys, vals] = spparms (); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
187 %! assert (rows (keys), 13); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
188 %! assert (keys(2,:), "ths_rel"); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
189 %! 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
|
190 %! spparms ([3 2 1]); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
191 %! assert (spparms ()(1:3), [3, 2, 1]'); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
192 %! assert (spparms ("ths_rel"), 2); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
193 %! spparms ("exact_d", 5); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
194 %! assert (spparms ("exact_d"), 5); |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
195 %! spparms (old_vals); # restore state |
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
196 |
22737
7abc25e6206a
maint: Clean up code base to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
197 ## Test input validation |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14366
diff
changeset
|
198 %!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
|
199 %!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
|
200 %!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
|
201 %!#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
|
202 %!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
|
203 %!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
|
204 %!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
|
205 %!#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
|
206 %!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
|
207 %!error <KEY not found> spparms ("UNKNOWN_KEY", 1) |
13080
5f86bde27700
codesprint: Tests for spparms()
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
208 */ |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
209 |