Mercurial > hg > octave-lyh
annotate src/DLD-FUNCTIONS/spparms.cc @ 8920:eb63fbe60fab
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 07 Mar 2009 10:41:27 -0500 |
parents | 8463d1a2e544 |
children | 7c02ec148a3c |
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\ | |
38 @deftypefn {Loadable Function} { } spparms ()\n\ | |
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\ | |
47 functions. The first four calls above get information about the current\n\ | |
48 settings, while the others change the current settings. The parameters are\n\ | |
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\ | |
55 @item ths_rel\n\ | |
7001 | 56 Included for compatibility. Not used. (default 1)\n\ |
5164 | 57 @item ths_abs\n\ |
7001 | 58 Included for compatibility. Not used. (default 1)\n\ |
5164 | 59 @item exact_d\n\ |
7001 | 60 Included for compatibility. Not used. (default 0)\n\ |
5164 | 61 @item supernd\n\ |
7001 | 62 Included for compatibility. Not used. (default 3)\n\ |
5164 | 63 @item rreduce\n\ |
7001 | 64 Included for compatibility. Not used. (default 3)\n\ |
5164 | 65 @item wh_frac\n\ |
7001 | 66 Included for compatibility. Not used. (default 0.5)\n\ |
5164 | 67 @item autommd\n\ |
68 Flag whether the LU/QR and the '\\' and '/' operators will automatically\n\ | |
69 use the sparsity preserving mmd functions (default 1)\n\ | |
70 @item autoamd\n\ | |
71 Flag whether the LU and the '\\' and '/' operators will automatically\n\ | |
72 use the sparsity preserving amd functions (default 1)\n\ | |
73 @item piv_tol\n\ | |
74 The pivot tolerance of the UMFPACK solvers (default 0.1)\n\ | |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
75 @item sym_tol\n\ |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
76 The pivot tolerance of the UMFPACK symmetric solvers (default 0.001)\n\ |
5164 | 77 @item bandden\n\ |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
78 The density of non-zero elements in a banded matrix before it is treated\n\ |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
79 by the LAPACK banded solvers (default 0.5)\n\ |
5164 | 80 @item umfpack\n\ |
81 Flag whether the UMFPACK or mmd solvers are used for the LU, '\\' and\n\ | |
82 '/' operations (default 1)\n\ | |
8828 | 83 @end table\n\ |
5164 | 84 \n\ |
85 The value of individual keys can be set with @code{spparms (@var{key},\n\ | |
86 @var{val})}. The default values can be restored with the special keyword\n\ | |
87 'defaults'. The special keyword 'tight' can be used to set the mmd solvers\n\ | |
7001 | 88 to attempt for a sparser solution at the potential cost of longer running\n\ |
5164 | 89 time.\n\ |
90 @end deftypefn") | |
91 { | |
92 octave_value_list retval; | |
93 int nargin = args.length (); | |
94 | |
95 if (nargin == 0) | |
96 { | |
97 if (nargout == 0) | |
5893 | 98 octave_sparse_params::print_info (octave_stdout, ""); |
5164 | 99 else if (nargout == 1) |
5893 | 100 retval(0) = octave_sparse_params::get_vals (); |
5164 | 101 else if (nargout == 2) |
102 { | |
5893 | 103 retval (0) = octave_sparse_params::get_keys (); |
104 retval (1) = octave_sparse_params::get_vals (); | |
5164 | 105 } |
106 else | |
5380 | 107 error ("spparms: too many output arguments"); |
5164 | 108 } |
109 else if (nargin == 1) | |
110 { | |
111 if (args(0).is_string ()) | |
112 { | |
113 std::string str = args(0).string_value (); | |
114 int len = str.length (); | |
115 for (int i = 0; i < len; i++) | |
116 str [i] = tolower (str [i]); | |
117 | |
118 if (str == "defaults") | |
5893 | 119 octave_sparse_params::defaults (); |
5164 | 120 else if (str == "tight") |
5893 | 121 octave_sparse_params::tight (); |
5164 | 122 else |
123 { | |
5893 | 124 double val = octave_sparse_params::get_key (str); |
5164 | 125 if (xisnan (val)) |
126 error ("spparams: unrecognized key"); | |
127 else | |
128 retval (0) = val; | |
129 } | |
130 } | |
131 else | |
132 { | |
133 NDArray vals = args(0).array_value (); | |
134 | |
135 if (error_state) | |
136 error ("spparms: input must be a string or a vector"); | |
137 else if (vals.numel () > OCTAVE_SPARSE_CONTROLS_SIZE) | |
138 error ("spparams: too many elements in values vector"); | |
139 else | |
5893 | 140 octave_sparse_params::set_vals (vals); |
5164 | 141 } |
142 } | |
143 else if (nargin == 2) | |
144 { | |
145 if (args(0).is_string ()) | |
146 { | |
147 std::string str = args(0).string_value (); | |
148 | |
149 double val = args(1).double_value (); | |
150 | |
151 if (error_state) | |
152 error ("spparms: second argument must be a real scalar"); | |
153 else if (str == "umfpack") | |
154 warning ("spparms: request to disable umfpack solvers ignored"); | |
5893 | 155 else if (!octave_sparse_params::set_key (str, val)) |
5164 | 156 error ("spparms: key not found"); |
157 } | |
158 else | |
159 error ("spparms: first argument must be a string"); | |
160 } | |
161 else | |
162 error ("spparms: too many input arguments"); | |
163 | |
164 return retval; | |
165 } | |
166 | |
167 /* | |
168 ;;; Local Variables: *** | |
169 ;;; mode: C++ *** | |
170 ;;; End: *** | |
171 */ |