Mercurial > octave
annotate liboctave/numeric/oct-spparms.cc @ 27923:bd51beb6205e
update formatting of copyright notices
* Use <https://octave.org/copyright/> instead of
<https://octave.org/COPYRIGHT.html/>.
* For consistency with other comments in the Octave sources, use
C++-style comments for copyright blocks in C and C++ files.
* Use delimiters above and below copyright blocks that are appropriate
for the language used in the file.
* Eliminate extra spacing inside copyright blocks.
* lex.ll (looks_like_copyright): Also allow newlines and carriage
returns before the word "Copyright".
* scripts/mk-doc.pl (gethelp): Also skip empty comment lines.
* bp-table.cc, type.m: Adjust tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 08 Jan 2020 11:59:41 -0500 |
parents | 1891570abac8 |
children | 0a5b15007766 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 // Copyright (C) 1998-2020 The Octave Project Developers |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
5164 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21723
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21202
diff
changeset
|
27 # include "config.h" |
5893 | 28 #endif |
29 | |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23457
diff
changeset
|
30 #include <ostream> |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23457
diff
changeset
|
31 |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23457
diff
changeset
|
32 #include "dNDArray.h" |
5893 | 33 #include "lo-error.h" |
5164 | 34 #include "lo-ieee.h" |
35 #include "oct-spparms.h" | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
36 #include "singleton-cleanup.h" |
5164 | 37 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
38 octave_sparse_params *octave_sparse_params::instance = nullptr; |
5893 | 39 |
40 bool | |
41 octave_sparse_params::instance_ok (void) | |
42 { | |
43 bool retval = true; | |
44 | |
45 if (! instance) | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
46 { |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
47 instance = new octave_sparse_params (); |
26369
0249ba4c9589
Fix static analyzer detected V668 issues (bug #55347).
Andreas Weber <octave@josoansi.de>
parents:
25054
diff
changeset
|
48 singleton_cleanup_list::add (cleanup_instance); |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
49 } |
5893 | 50 |
51 return retval; | |
52 } | |
53 | |
54 void | |
55 octave_sparse_params::defaults (void) | |
56 { | |
57 if (instance_ok ()) | |
58 instance->do_defaults (); | |
59 } | |
5164 | 60 |
61 void | |
5893 | 62 octave_sparse_params::tight (void) |
63 { | |
64 if (instance_ok ()) | |
65 instance->do_tight (); | |
66 } | |
67 | |
68 string_vector | |
69 octave_sparse_params::get_keys (void) | |
70 { | |
71 return instance_ok () ? instance->do_get_keys () : string_vector (); | |
72 } | |
73 | |
74 ColumnVector | |
75 octave_sparse_params::get_vals (void) | |
76 { | |
77 return instance_ok () ? instance->do_get_vals () : ColumnVector (); | |
78 } | |
79 | |
80 bool | |
81 octave_sparse_params::set_vals (const NDArray& vals) | |
5164 | 82 { |
5893 | 83 return instance_ok () ? instance->do_set_vals (vals) : false; |
84 } | |
85 | |
86 bool | |
87 octave_sparse_params::set_key (const std::string& key, const double& val) | |
88 { | |
89 return instance_ok () ? instance->do_set_key (key, val) : false; | |
90 } | |
91 | |
92 double | |
93 octave_sparse_params::get_key (const std::string& key) | |
94 { | |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
95 return instance_ok () ? instance->do_get_key (key) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
96 : octave::numeric_limits<double>::NaN (); |
5893 | 97 } |
98 | |
6460 | 99 double |
100 octave_sparse_params::get_bandden (void) | |
101 { | |
102 return instance_ok () ? instance->do_get_bandden () : 0.0; | |
103 } | |
104 | |
5893 | 105 void |
106 octave_sparse_params::print_info (std::ostream& os, const std::string& prefix) | |
107 { | |
108 if (instance_ok ()) | |
109 instance->do_print_info (os, prefix); | |
5164 | 110 } |
111 | |
112 void | |
5893 | 113 octave_sparse_params::do_defaults (void) |
5164 | 114 { |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
115 params(0) = 0; // spumoni |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
116 params(1) = 1; // ths_rel |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
117 params(2) = 1; // ths_abs |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
118 params(3) = 0; // exact_d |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
119 params(4) = 3; // supernd |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
120 params(5) = 3; // rreduce |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
121 params(6) = 0.5; // wh_frac |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
122 params(7) = 1; // autommd |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
123 params(8) = 1; // autoamd |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
124 params(9) = 0.1; // piv_tol |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
125 params(10) = 0.5; // bandden |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
126 params(11) = 1; // umfpack |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
127 params(12) = 0.001; // sym_tol |
5893 | 128 } |
129 | |
130 void | |
131 octave_sparse_params::do_tight (void) | |
132 { | |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
133 params(0) = 0; // spumoni |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
134 params(1) = 1; // ths_rel |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
135 params(2) = 0; // ths_abs |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
136 params(3) = 1; // exact_d |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
137 params(4) = 1; // supernd |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
138 params(5) = 1; // rreduce |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
139 params(6) = 0.5; // wh_frac |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
140 params(7) = 1; // autommd |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
141 params(8) = 1; // autoamd |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
142 params(9) = 0.1; // piv_tol |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
143 params(10) = 0.5; // bandden |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
144 params(11) = 1; // umfpack |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
145 params(12) = 0.001; // sym_tol |
5164 | 146 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
147 |
5164 | 148 void |
5893 | 149 octave_sparse_params::init_keys (void) |
5164 | 150 { |
5893 | 151 keys(0) = "spumoni"; |
152 keys(1) = "ths_rel"; | |
153 keys(2) = "ths_abs"; | |
154 keys(3) = "exact_d"; | |
155 keys(4) = "supernd"; | |
156 keys(5) = "rreduce"; | |
157 keys(6) = "wh_frac"; | |
158 keys(7) = "autommd"; | |
159 keys(8) = "autoamd"; | |
160 keys(9) = "piv_tol"; | |
161 keys(10) = "bandden"; | |
162 keys(11) = "umfpack"; | |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
163 keys(12) = "sym_tol"; |
5164 | 164 } |
165 | |
6460 | 166 double |
167 octave_sparse_params::do_get_bandden (void) | |
168 { | |
169 return params(10); | |
170 } | |
171 | |
5164 | 172 bool |
5893 | 173 octave_sparse_params::do_set_vals (const NDArray& vals) |
174 { | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
175 octave_idx_type len = vals.numel (); |
5893 | 176 |
177 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
|
178 (*current_liboctave_error_handler) |
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
179 ("octave_sparse_params::do_set_vals: too many values"); |
5893 | 180 |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
181 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
|
182 params(i) = vals(i); |
5893 | 183 |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
184 return true; |
5893 | 185 } |
186 | |
187 bool | |
188 octave_sparse_params::do_set_key (const std::string& key, const double& val) | |
5164 | 189 { |
190 for (int i = 0; i < OCTAVE_SPARSE_CONTROLS_SIZE; i++) | |
5893 | 191 { |
192 if (keys (i) == key) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
193 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
194 params(i) = val; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
195 return true; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
196 } |
5893 | 197 } |
198 | |
5164 | 199 return false; |
200 } | |
201 | |
202 double | |
5893 | 203 octave_sparse_params::do_get_key (const std::string& key) |
5164 | 204 { |
205 for (int i = 0; i < OCTAVE_SPARSE_CONTROLS_SIZE; i++) | |
5893 | 206 { |
207 if (keys (i) == key) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
208 return params(i); |
5893 | 209 } |
5164 | 210 |
21723
bae585228161
use namespace for numeric_limits
John W. Eaton <jwe@octave.org>
parents:
21721
diff
changeset
|
211 return octave::numeric_limits<double>::NaN (); |
5164 | 212 } |
213 | |
214 void | |
5893 | 215 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
|
216 const std::string& prefix) const |
5164 | 217 { |
218 for (int i = 0; i < OCTAVE_SPARSE_CONTROLS_SIZE; i++) | |
219 os << prefix << keys(i) << ": " << params(i) << "\n"; | |
220 } |