Mercurial > octave
annotate liboctave/numeric/oct-spparms.cc @ 21723:bae585228161
use namespace for numeric_limits
* lo-ieee.h (octave_numeric_limits): Rename to numeric_limits and
define inside octave namespace.
* Canvas.cc, data.cc, graphics.cc, graphics.in.h, oct-handle.h,
oct-stream.cc, quadcc.cc, sparse-xdiv.cc, str2double.cc, variables.h,
__glpk__.cc, __init_fltk__.cc, __voronoi__.cc, octave.cc, CMatrix.cc,
CNDArray.cc, CSparse.cc, Sparse-C.cc, dDiagMatrix.cc, dMatrix.cc,
dSparse.cc, fCMatrix.cc, fCNDArray.cc, fDiagMatrix.cc, fMatrix.cc,
Faddeeva.cc, eigs-base.cc, lo-mappers.cc, lo-mappers.h, lo-specfun.cc,
oct-norm.cc, oct-rand.cc, oct-rand.h, oct-spparms.cc, randgamma.cc,
randpoisson.cc, lo-utils.cc: Change all uses of octave_numeric_limits
to octave::numeric_limits.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 17 May 2016 11:32:53 -0400 |
parents | bcc30b45a225 |
children | aba2e6293dd8 |
rev | line source |
---|---|
5164 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
3 Copyright (C) 2004-2015 David Bateman |
11523 | 4 Copyright (C) 1998-2004 Andy Adler |
7016 | 5 |
6 This file is part of Octave. | |
5164 | 7 |
8 Octave is free software; you can redistribute it and/or modify it | |
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 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
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 | |
5893 | 24 #ifdef HAVE_CONFIG_H |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21202
diff
changeset
|
25 # include "config.h" |
5893 | 26 #endif |
27 | |
28 #include "lo-error.h" | |
5164 | 29 #include "lo-ieee.h" |
30 | |
31 #include "oct-spparms.h" | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
32 #include "singleton-cleanup.h" |
5164 | 33 |
5893 | 34 octave_sparse_params *octave_sparse_params::instance = 0; |
35 | |
36 bool | |
37 octave_sparse_params::instance_ok (void) | |
38 { | |
39 bool retval = true; | |
40 | |
41 if (! instance) | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
42 { |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
43 instance = new octave_sparse_params (); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
44 |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
45 if (instance) |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
46 singleton_cleanup_list::add (cleanup_instance); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
47 } |
5893 | 48 |
49 if (! instance) | |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
50 (*current_liboctave_error_handler) |
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
51 ("unable to create octave_sparse_params object!"); |
5893 | 52 |
53 return retval; | |
54 } | |
55 | |
56 void | |
57 octave_sparse_params::defaults (void) | |
58 { | |
59 if (instance_ok ()) | |
60 instance->do_defaults (); | |
61 } | |
5164 | 62 |
63 void | |
5893 | 64 octave_sparse_params::tight (void) |
65 { | |
66 if (instance_ok ()) | |
67 instance->do_tight (); | |
68 } | |
69 | |
70 string_vector | |
71 octave_sparse_params::get_keys (void) | |
72 { | |
73 return instance_ok () ? instance->do_get_keys () : string_vector (); | |
74 } | |
75 | |
76 ColumnVector | |
77 octave_sparse_params::get_vals (void) | |
78 { | |
79 return instance_ok () ? instance->do_get_vals () : ColumnVector (); | |
80 } | |
81 | |
82 bool | |
83 octave_sparse_params::set_vals (const NDArray& vals) | |
5164 | 84 { |
5893 | 85 return instance_ok () ? instance->do_set_vals (vals) : false; |
86 } | |
87 | |
88 bool | |
89 octave_sparse_params::set_key (const std::string& key, const double& val) | |
90 { | |
91 return instance_ok () ? instance->do_set_key (key, val) : false; | |
92 } | |
93 | |
94 double | |
95 octave_sparse_params::get_key (const std::string& key) | |
96 { | |
21723
bae585228161
use namespace for numeric_limits
John W. Eaton <jwe@octave.org>
parents:
21721
diff
changeset
|
97 return instance_ok () ? instance->do_get_key (key) : octave::numeric_limits<double>::NaN (); |
5893 | 98 } |
99 | |
6460 | 100 double |
101 octave_sparse_params::get_bandden (void) | |
102 { | |
103 return instance_ok () ? instance->do_get_bandden () : 0.0; | |
104 } | |
105 | |
5893 | 106 void |
107 octave_sparse_params::print_info (std::ostream& os, const std::string& prefix) | |
108 { | |
109 if (instance_ok ()) | |
110 instance->do_print_info (os, prefix); | |
5164 | 111 } |
112 | |
113 void | |
5893 | 114 octave_sparse_params::do_defaults (void) |
5164 | 115 { |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
116 params(0) = 0; // spumoni |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
117 params(1) = 1; // ths_rel |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
118 params(2) = 1; // ths_abs |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
119 params(3) = 0; // exact_d |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
120 params(4) = 3; // supernd |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
121 params(5) = 3; // rreduce |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
122 params(6) = 0.5; // wh_frac |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
123 params(7) = 1; // autommd |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
124 params(8) = 1; // autoamd |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
125 params(9) = 0.1; // piv_tol |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
126 params(10) = 0.5; // bandden |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
127 params(11) = 1; // umfpack |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
128 params(12) = 0.001; // sym_tol |
5893 | 129 } |
130 | |
131 void | |
132 octave_sparse_params::do_tight (void) | |
133 { | |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
134 params(0) = 0; // spumoni |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
135 params(1) = 1; // ths_rel |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
136 params(2) = 0; // ths_abs |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
137 params(3) = 1; // exact_d |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
138 params(4) = 1; // supernd |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
139 params(5) = 1; // rreduce |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
140 params(6) = 0.5; // wh_frac |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
141 params(7) = 1; // autommd |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
142 params(8) = 1; // autoamd |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
143 params(9) = 0.1; // piv_tol |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
144 params(10) = 0.5; // bandden |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
145 params(11) = 1; // umfpack |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
146 params(12) = 0.001; // sym_tol |
5164 | 147 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
148 |
5164 | 149 void |
5893 | 150 octave_sparse_params::init_keys (void) |
5164 | 151 { |
5893 | 152 keys(0) = "spumoni"; |
153 keys(1) = "ths_rel"; | |
154 keys(2) = "ths_abs"; | |
155 keys(3) = "exact_d"; | |
156 keys(4) = "supernd"; | |
157 keys(5) = "rreduce"; | |
158 keys(6) = "wh_frac"; | |
159 keys(7) = "autommd"; | |
160 keys(8) = "autoamd"; | |
161 keys(9) = "piv_tol"; | |
162 keys(10) = "bandden"; | |
163 keys(11) = "umfpack"; | |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
164 keys(12) = "sym_tol"; |
5164 | 165 } |
166 | |
6460 | 167 double |
168 octave_sparse_params::do_get_bandden (void) | |
169 { | |
170 return params(10); | |
171 } | |
172 | |
5164 | 173 bool |
5893 | 174 octave_sparse_params::do_set_vals (const NDArray& vals) |
175 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
176 octave_idx_type len = vals.numel (); |
5893 | 177 |
178 if (len > OCTAVE_SPARSE_CONTROLS_SIZE) | |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
179 (*current_liboctave_error_handler) |
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
180 ("octave_sparse_params::do_set_vals: too many values"); |
5893 | 181 |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
182 for (int i = 0; i < len; i++) |
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
183 params(i) = vals(i); |
5893 | 184 |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
185 return true; |
5893 | 186 } |
187 | |
188 bool | |
189 octave_sparse_params::do_set_key (const std::string& key, const double& val) | |
5164 | 190 { |
191 for (int i = 0; i < OCTAVE_SPARSE_CONTROLS_SIZE; i++) | |
5893 | 192 { |
193 if (keys (i) == key) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
194 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
195 params(i) = val; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
196 return true; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
197 } |
5893 | 198 } |
199 | |
5164 | 200 return false; |
201 } | |
202 | |
203 double | |
5893 | 204 octave_sparse_params::do_get_key (const std::string& key) |
5164 | 205 { |
206 for (int i = 0; i < OCTAVE_SPARSE_CONTROLS_SIZE; i++) | |
5893 | 207 { |
208 if (keys (i) == key) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
209 return params(i); |
5893 | 210 } |
5164 | 211 |
21723
bae585228161
use namespace for numeric_limits
John W. Eaton <jwe@octave.org>
parents:
21721
diff
changeset
|
212 return octave::numeric_limits<double>::NaN (); |
5164 | 213 } |
214 | |
215 void | |
5893 | 216 octave_sparse_params::do_print_info (std::ostream& os, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
217 const std::string& prefix) const |
5164 | 218 { |
219 for (int i = 0; i < OCTAVE_SPARSE_CONTROLS_SIZE; i++) | |
220 os << prefix << keys(i) << ": " << params(i) << "\n"; | |
221 } |