Mercurial > hg > octave-lyh
annotate src/DLD-FUNCTIONS/spparms.cc @ 10840:89f4d7e294cc
Grammarcheck .cc files
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sat, 31 Jul 2010 11:18:11 -0700 |
parents | fbd7843974fa |
children | fd0a3ac60b0e |
rev | line source |
---|---|
5164 | 1 /* |
2 | |
8920 | 3 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 David Bateman |
7016 | 4 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 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 | |
28 #include "defun-dld.h" | |
29 #include "ov.h" | |
30 #include "pager.h" | |
31 #include "error.h" | |
32 #include "gripes.h" | |
33 | |
34 #include "oct-spparms.h" | |
35 | |
36 DEFUN_DLD (spparms, args, nargout, | |
37 "-*- texinfo -*-\n\ | |
10840 | 38 @deftypefn {Loadable Function} { } spparms ()\n\ |
5164 | 39 @deftypefnx {Loadable Function} {@var{vals} =} spparms ()\n\ |
40 @deftypefnx {Loadable Function} {[@var{keys}, @var{vals}] =} spparms ()\n\ | |
41 @deftypefnx {Loadable Function} {@var{val} =} spparms (@var{key})\n\ | |
42 @deftypefnx {Loadable Function} { } spparms (@var{vals})\n\ | |
43 @deftypefnx {Loadable Function} { } spparms ('defaults')\n\ | |
44 @deftypefnx {Loadable Function} { } spparms ('tight')\n\ | |
45 @deftypefnx {Loadable Function} { } spparms (@var{key}, @var{val})\n\ | |
46 Sets or displays the parameters used by the sparse solvers and factorization\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
47 functions. The first four calls above get information about the current\n\ |
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
48 settings, while the others change the current settings. The parameters are\n\ |
5164 | 49 stored as pairs of keys and values, where the values are all floats and the\n\ |
8828 | 50 keys are one of the following strings:\n\ |
5164 | 51 \n\ |
8828 | 52 @table @code\n\ |
5164 | 53 @item spumoni\n\ |
54 Printing level of debugging information of the solvers (default 0)\n\ | |
10840 | 55 \n\ |
5164 | 56 @item ths_rel\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
57 Included for compatibility. Not used. (default 1)\n\ |
10840 | 58 \n\ |
5164 | 59 @item ths_abs\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
60 Included for compatibility. Not used. (default 1)\n\ |
10840 | 61 \n\ |
5164 | 62 @item exact_d\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
63 Included for compatibility. Not used. (default 0)\n\ |
10840 | 64 \n\ |
5164 | 65 @item supernd\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
66 Included for compatibility. Not used. (default 3)\n\ |
10840 | 67 \n\ |
5164 | 68 @item rreduce\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
69 Included for compatibility. Not used. (default 3)\n\ |
10840 | 70 \n\ |
5164 | 71 @item wh_frac\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
72 Included for compatibility. Not used. (default 0.5)\n\ |
10840 | 73 \n\ |
5164 | 74 @item autommd\n\ |
75 Flag whether the LU/QR and the '\\' and '/' operators will automatically\n\ | |
76 use the sparsity preserving mmd functions (default 1)\n\ | |
10840 | 77 \n\ |
5164 | 78 @item autoamd\n\ |
79 Flag whether the LU and the '\\' and '/' operators will automatically\n\ | |
80 use the sparsity preserving amd functions (default 1)\n\ | |
10840 | 81 \n\ |
5164 | 82 @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
|
83 The pivot tolerance of the @sc{umfpack} solvers (default 0.1)\n\ |
10840 | 84 \n\ |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
85 @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
|
86 The pivot tolerance of the @sc{umfpack} symmetric solvers (default 0.001)\n\ |
10840 | 87 \n\ |
5164 | 88 @item bandden\n\ |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
89 The density of non-zero 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
|
90 by the @sc{lapack} banded solvers (default 0.5)\n\ |
10840 | 91 \n\ |
5164 | 92 @item umfpack\n\ |
10711
fbd7843974fa
Periodic grammar check of documentation files to ensure common format.
Rik <octave@nomad.inbox5.com>
parents:
10155
diff
changeset
|
93 Flag whether the @sc{umfpack} or mmd solvers are used for the LU, '\\' and\n\ |
5164 | 94 '/' operations (default 1)\n\ |
8828 | 95 @end table\n\ |
5164 | 96 \n\ |
97 The value of individual keys can be set with @code{spparms (@var{key},\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
98 @var{val})}. The default values can be restored with the special keyword\n\ |
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
99 'defaults'. The special keyword 'tight' can be used to set the mmd solvers\n\ |
7001 | 100 to attempt for a sparser solution at the potential cost of longer running\n\ |
5164 | 101 time.\n\ |
102 @end deftypefn") | |
103 { | |
104 octave_value_list retval; | |
105 int nargin = args.length (); | |
106 | |
107 if (nargin == 0) | |
108 { | |
109 if (nargout == 0) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
110 octave_sparse_params::print_info (octave_stdout, ""); |
5164 | 111 else if (nargout == 1) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
112 retval(0) = octave_sparse_params::get_vals (); |
5164 | 113 else if (nargout == 2) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
114 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
115 retval (0) = octave_sparse_params::get_keys (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
116 retval (1) = octave_sparse_params::get_vals (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
117 } |
5164 | 118 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
119 error ("spparms: too many output arguments"); |
5164 | 120 } |
121 else if (nargin == 1) | |
122 { | |
123 if (args(0).is_string ()) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
124 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
125 std::string str = args(0).string_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
126 int len = str.length (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
127 for (int i = 0; i < len; i++) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
128 str [i] = tolower (str [i]); |
5164 | 129 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
130 if (str == "defaults") |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
131 octave_sparse_params::defaults (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
132 else if (str == "tight") |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
133 octave_sparse_params::tight (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
134 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
135 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
136 double val = octave_sparse_params::get_key (str); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
137 if (xisnan (val)) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
138 error ("spparams: unrecognized key"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
139 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
140 retval (0) = val; |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
141 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
142 } |
5164 | 143 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
144 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
145 NDArray vals = args(0).array_value (); |
5164 | 146 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
147 if (error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
148 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
|
149 else if (vals.numel () > OCTAVE_SPARSE_CONTROLS_SIZE) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
150 error ("spparams: too many elements in values vector"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
151 else |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
152 octave_sparse_params::set_vals (vals); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
153 } |
5164 | 154 } |
155 else if (nargin == 2) | |
156 { | |
157 if (args(0).is_string ()) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
158 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
159 std::string str = args(0).string_value (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
160 |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
161 double val = args(1).double_value (); |
5164 | 162 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
163 if (error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
164 error ("spparms: second argument must be a real scalar"); |
5164 | 165 else if (str == "umfpack") |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
166 warning ("spparms: request to disable umfpack solvers ignored"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
167 else if (!octave_sparse_params::set_key (str, val)) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
168 error ("spparms: key not found"); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
169 } |
5164 | 170 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
171 error ("spparms: first argument must be a string"); |
5164 | 172 } |
173 else | |
174 error ("spparms: too many input arguments"); | |
175 | |
176 return retval; | |
177 } |