comparison src/DLD-FUNCTIONS/spparms.cc @ 5164:57077d0ddc8e

[project @ 2005-02-25 19:55:24 by jwe]
author jwe
date Fri, 25 Feb 2005 19:55:28 +0000
parents
children 4c8a2e4e0717
comparison
equal deleted inserted replaced
5163:9f3299378193 5164:57077d0ddc8e
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
17 along with this program; see the file COPYING. If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 */
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include "defun-dld.h"
27 #include "ov.h"
28 #include "pager.h"
29 #include "error.h"
30 #include "gripes.h"
31
32 #include "oct-spparms.h"
33
34 DEFUN_DLD (spparms, args, nargout,
35 "-*- texinfo -*-\n\
36 @deftypefn {Loadable Function} { } spparms ()\n\
37 @deftypefnx {Loadable Function} {@var{vals} =} spparms ()\n\
38 @deftypefnx {Loadable Function} {[@var{keys}, @var{vals}] =} spparms ()\n\
39 @deftypefnx {Loadable Function} {@var{val} =} spparms (@var{key})\n\
40 @deftypefnx {Loadable Function} { } spparms (@var{vals})\n\
41 @deftypefnx {Loadable Function} { } spparms ('defaults')\n\
42 @deftypefnx {Loadable Function} { } spparms ('tight')\n\
43 @deftypefnx {Loadable Function} { } spparms (@var{key}, @var{val})\n\
44 Sets or displays the parameters used by the sparse solvers and factorization\n\
45 functions. The first four calls above get information about the current\n\
46 settings, while the others change the current settings. The parameters are\n\
47 stored as pairs of keys and values, where the values are all floats and the\n\
48 keys are one of the strings\n\
49 \n\
50 @itemize\n\
51 @item spumoni\n\
52 Printing level of debugging information of the solvers (default 0)\n\
53 @item ths_rel\n\
54 ?? (default 1)\n\
55 @item ths_abs\n\
56 ?? (default 1)\n\
57 @item exact_d\n\
58 ?? (default 0)\n\
59 @item supernd\n\
60 ?? (default 3)\n\
61 @item rreduce\n\
62 ?? (default 3)\n\
63 @item wh_frac\n\
64 ?? (default 0.5)\n\
65 @item autommd\n\
66 Flag whether the LU/QR and the '\\' and '/' operators will automatically\n\
67 use the sparsity preserving mmd functions (default 1)\n\
68 @item autoamd\n\
69 Flag whether the LU and the '\\' and '/' operators will automatically\n\
70 use the sparsity preserving amd functions (default 1)\n\
71 @item piv_tol\n\
72 The pivot tolerance of the UMFPACK solvers (default 0.1)\n\
73 @item bandden\n\
74 ?? (default 0.5)\n\
75 @item umfpack\n\
76 Flag whether the UMFPACK or mmd solvers are used for the LU, '\\' and\n\
77 '/' operations (default 1)\n\
78 @end itemize\n\
79 \n\
80 The value of individual keys can be set with @code{spparms (@var{key},\n\
81 @var{val})}. The default values can be restored with the special keyword\n\
82 'defaults'. The special keyword 'tight' can be used to set the mmd solvers\n\
83 to attempt for a sparser solution at the potetial cost of longer running\n\
84 time.\n\
85 @end deftypefn")
86 {
87 octave_value_list retval;
88 int nargin = args.length ();
89
90 if (nargin == 0)
91 {
92 if (nargout == 0)
93 Voctave_sparse_controls.print_info (octave_stdout, "");
94 else if (nargout == 1)
95 retval(0) = Voctave_sparse_controls.get_vals ();
96 else if (nargout == 2)
97 {
98 retval (0) = Voctave_sparse_controls.get_keys ();
99 retval (1) = Voctave_sparse_controls.get_vals ();
100 }
101 else
102 error ("spparms: too many outpu arguments");
103 }
104 else if (nargin == 1)
105 {
106 if (args(0).is_string ())
107 {
108 std::string str = args(0).string_value ();
109 int len = str.length ();
110 for (int i = 0; i < len; i++)
111 str [i] = tolower (str [i]);
112
113 if (str == "defaults")
114 Voctave_sparse_controls.defaults ();
115 else if (str == "tight")
116 Voctave_sparse_controls.tight ();
117 else
118 {
119 double val = Voctave_sparse_controls.get_key (str);
120 if (xisnan (val))
121 error ("spparams: unrecognized key");
122 else
123 retval (0) = val;
124 }
125 }
126 else
127 {
128 NDArray vals = args(0).array_value ();
129
130 if (error_state)
131 error ("spparms: input must be a string or a vector");
132 else if (vals.numel () > OCTAVE_SPARSE_CONTROLS_SIZE)
133 error ("spparams: too many elements in values vector");
134 else
135 for (int i = 0; i < vals.length (); i++)
136 Voctave_sparse_controls (i) = vals (i);
137 }
138 }
139 else if (nargin == 2)
140 {
141 if (args(0).is_string ())
142 {
143 std::string str = args(0).string_value ();
144
145 double val = args(1).double_value ();
146
147 if (error_state)
148 error ("spparms: second argument must be a real scalar");
149 else if (str == "umfpack")
150 warning ("spparms: request to disable umfpack solvers ignored");
151 else if (!Voctave_sparse_controls.set_key (str, val))
152 error ("spparms: key not found");
153 }
154 else
155 error ("spparms: first argument must be a string");
156 }
157 else
158 error ("spparms: too many input arguments");
159
160 return retval;
161 }
162
163 /*
164 ;;; Local Variables: ***
165 ;;; mode: C++ ***
166 ;;; End: ***
167 */