5164
|
1 /* |
|
2 |
|
3 Copyright (C) 2004 David Bateman |
|
4 Copyright (C) 1998-2004 Andy Adler |
|
5 |
|
6 This program is free software; you can redistribute it and/or modify it |
|
7 under the terms of the GNU General Public License as published by the |
|
8 Free Software Foundation; either version 2, or (at your option) any |
|
9 later version. |
|
10 |
|
11 This program is distributed in the hope that it will be useful, but WITHOUT |
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 for more details. |
|
15 |
|
16 You should have received a copy of the GNU General Public License |
5307
|
17 along with this program; see the file COPYING. If not, write to the |
|
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
19 Boston, MA 02110-1301, USA. |
5164
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
|
27 #include "defun-dld.h" |
|
28 #include "ov.h" |
|
29 #include "pager.h" |
|
30 #include "error.h" |
|
31 #include "gripes.h" |
|
32 |
|
33 #include "oct-spparms.h" |
|
34 |
|
35 DEFUN_DLD (spparms, args, nargout, |
|
36 "-*- texinfo -*-\n\ |
|
37 @deftypefn {Loadable Function} { } spparms ()\n\ |
|
38 @deftypefnx {Loadable Function} {@var{vals} =} spparms ()\n\ |
|
39 @deftypefnx {Loadable Function} {[@var{keys}, @var{vals}] =} spparms ()\n\ |
|
40 @deftypefnx {Loadable Function} {@var{val} =} spparms (@var{key})\n\ |
|
41 @deftypefnx {Loadable Function} { } spparms (@var{vals})\n\ |
|
42 @deftypefnx {Loadable Function} { } spparms ('defaults')\n\ |
|
43 @deftypefnx {Loadable Function} { } spparms ('tight')\n\ |
|
44 @deftypefnx {Loadable Function} { } spparms (@var{key}, @var{val})\n\ |
|
45 Sets or displays the parameters used by the sparse solvers and factorization\n\ |
|
46 functions. The first four calls above get information about the current\n\ |
|
47 settings, while the others change the current settings. The parameters are\n\ |
|
48 stored as pairs of keys and values, where the values are all floats and the\n\ |
|
49 keys are one of the strings\n\ |
|
50 \n\ |
|
51 @itemize\n\ |
|
52 @item spumoni\n\ |
|
53 Printing level of debugging information of the solvers (default 0)\n\ |
|
54 @item ths_rel\n\ |
5380
|
55 Included for compatiability. Bot used. (default 1)\n\ |
5164
|
56 @item ths_abs\n\ |
5380
|
57 Included for compatiability. Bot used. (default 1)\n\ |
5164
|
58 @item exact_d\n\ |
5380
|
59 Included for compatiability. Bot used. (default 0)\n\ |
5164
|
60 @item supernd\n\ |
5380
|
61 Included for compatiability. Not used. (default 3)\n\ |
5164
|
62 @item rreduce\n\ |
5380
|
63 Included for compatiability. Not used. (default 3)\n\ |
5164
|
64 @item wh_frac\n\ |
5380
|
65 Inluded for compatiability. Not used. (default 0.5)\n\ |
5164
|
66 @item autommd\n\ |
|
67 Flag whether the LU/QR and the '\\' and '/' operators will automatically\n\ |
|
68 use the sparsity preserving mmd functions (default 1)\n\ |
|
69 @item autoamd\n\ |
|
70 Flag whether the LU and the '\\' and '/' operators will automatically\n\ |
|
71 use the sparsity preserving amd functions (default 1)\n\ |
|
72 @item piv_tol\n\ |
|
73 The pivot tolerance of the UMFPACK solvers (default 0.1)\n\ |
|
74 @item bandden\n\ |
|
75 ?? (default 0.5)\n\ |
|
76 @item umfpack\n\ |
|
77 Flag whether the UMFPACK or mmd solvers are used for the LU, '\\' and\n\ |
|
78 '/' operations (default 1)\n\ |
|
79 @end itemize\n\ |
|
80 \n\ |
|
81 The value of individual keys can be set with @code{spparms (@var{key},\n\ |
|
82 @var{val})}. The default values can be restored with the special keyword\n\ |
|
83 'defaults'. The special keyword 'tight' can be used to set the mmd solvers\n\ |
|
84 to attempt for a sparser solution at the potetial cost of longer running\n\ |
|
85 time.\n\ |
|
86 @end deftypefn") |
|
87 { |
|
88 octave_value_list retval; |
|
89 int nargin = args.length (); |
|
90 |
|
91 if (nargin == 0) |
|
92 { |
|
93 if (nargout == 0) |
|
94 Voctave_sparse_controls.print_info (octave_stdout, ""); |
|
95 else if (nargout == 1) |
|
96 retval(0) = Voctave_sparse_controls.get_vals (); |
|
97 else if (nargout == 2) |
|
98 { |
|
99 retval (0) = Voctave_sparse_controls.get_keys (); |
|
100 retval (1) = Voctave_sparse_controls.get_vals (); |
|
101 } |
|
102 else |
5380
|
103 error ("spparms: too many output arguments"); |
5164
|
104 } |
|
105 else if (nargin == 1) |
|
106 { |
|
107 if (args(0).is_string ()) |
|
108 { |
|
109 std::string str = args(0).string_value (); |
|
110 int len = str.length (); |
|
111 for (int i = 0; i < len; i++) |
|
112 str [i] = tolower (str [i]); |
|
113 |
|
114 if (str == "defaults") |
|
115 Voctave_sparse_controls.defaults (); |
|
116 else if (str == "tight") |
|
117 Voctave_sparse_controls.tight (); |
|
118 else |
|
119 { |
|
120 double val = Voctave_sparse_controls.get_key (str); |
|
121 if (xisnan (val)) |
|
122 error ("spparams: unrecognized key"); |
|
123 else |
|
124 retval (0) = val; |
|
125 } |
|
126 } |
|
127 else |
|
128 { |
|
129 NDArray vals = args(0).array_value (); |
|
130 |
|
131 if (error_state) |
|
132 error ("spparms: input must be a string or a vector"); |
|
133 else if (vals.numel () > OCTAVE_SPARSE_CONTROLS_SIZE) |
|
134 error ("spparams: too many elements in values vector"); |
|
135 else |
|
136 for (int i = 0; i < vals.length (); i++) |
|
137 Voctave_sparse_controls (i) = vals (i); |
|
138 } |
|
139 } |
|
140 else if (nargin == 2) |
|
141 { |
|
142 if (args(0).is_string ()) |
|
143 { |
|
144 std::string str = args(0).string_value (); |
|
145 |
|
146 double val = args(1).double_value (); |
|
147 |
|
148 if (error_state) |
|
149 error ("spparms: second argument must be a real scalar"); |
|
150 else if (str == "umfpack") |
|
151 warning ("spparms: request to disable umfpack solvers ignored"); |
|
152 else if (!Voctave_sparse_controls.set_key (str, val)) |
|
153 error ("spparms: key not found"); |
|
154 } |
|
155 else |
|
156 error ("spparms: first argument must be a string"); |
|
157 } |
|
158 else |
|
159 error ("spparms: too many input arguments"); |
|
160 |
|
161 return retval; |
|
162 } |
|
163 |
|
164 /* |
|
165 ;;; Local Variables: *** |
|
166 ;;; mode: C++ *** |
|
167 ;;; End: *** |
|
168 */ |