GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
oct-spparms.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2004-2017 David Bateman
4 Copyright (C) 1998-2004 Andy Adler
5 
6 This file is part of Octave.
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
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
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
19 along with Octave; see the file COPYING. If not, see
20 <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if defined (HAVE_CONFIG_H)
25 # include "config.h"
26 #endif
27 
28 #include "lo-error.h"
29 #include "lo-ieee.h"
30 
31 #include "oct-spparms.h"
32 #include "singleton-cleanup.h"
33 
35 
36 bool
38 {
39  bool retval = true;
40 
41  if (! instance)
42  {
44 
45  if (instance)
47  }
48 
49  if (! instance)
50  (*current_liboctave_error_handler)
51  ("unable to create octave_sparse_params object!");
52 
53  return retval;
54 }
55 
56 void
58 {
59  if (instance_ok ())
61 }
62 
63 void
65 {
66  if (instance_ok ())
67  instance->do_tight ();
68 }
69 
72 {
73  return instance_ok () ? instance->do_get_keys () : string_vector ();
74 }
75 
78 {
79  return instance_ok () ? instance->do_get_vals () : ColumnVector ();
80 }
81 
82 bool
84 {
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
96 {
97  return instance_ok () ? instance->do_get_key (key)
99 }
100 
101 double
103 {
104  return instance_ok () ? instance->do_get_bandden () : 0.0;
105 }
106 
107 void
108 octave_sparse_params::print_info (std::ostream& os, const std::string& prefix)
109 {
110  if (instance_ok ())
111  instance->do_print_info (os, prefix);
112 }
113 
114 void
116 {
117  params(0) = 0; // spumoni
118  params(1) = 1; // ths_rel
119  params(2) = 1; // ths_abs
120  params(3) = 0; // exact_d
121  params(4) = 3; // supernd
122  params(5) = 3; // rreduce
123  params(6) = 0.5; // wh_frac
124  params(7) = 1; // autommd
125  params(8) = 1; // autoamd
126  params(9) = 0.1; // piv_tol
127  params(10) = 0.5; // bandden
128  params(11) = 1; // umfpack
129  params(12) = 0.001; // sym_tol
130 }
131 
132 void
134 {
135  params(0) = 0; // spumoni
136  params(1) = 1; // ths_rel
137  params(2) = 0; // ths_abs
138  params(3) = 1; // exact_d
139  params(4) = 1; // supernd
140  params(5) = 1; // rreduce
141  params(6) = 0.5; // wh_frac
142  params(7) = 1; // autommd
143  params(8) = 1; // autoamd
144  params(9) = 0.1; // piv_tol
145  params(10) = 0.5; // bandden
146  params(11) = 1; // umfpack
147  params(12) = 0.001; // sym_tol
148 }
149 
150 void
152 {
153  keys(0) = "spumoni";
154  keys(1) = "ths_rel";
155  keys(2) = "ths_abs";
156  keys(3) = "exact_d";
157  keys(4) = "supernd";
158  keys(5) = "rreduce";
159  keys(6) = "wh_frac";
160  keys(7) = "autommd";
161  keys(8) = "autoamd";
162  keys(9) = "piv_tol";
163  keys(10) = "bandden";
164  keys(11) = "umfpack";
165  keys(12) = "sym_tol";
166 }
167 
168 double
170 {
171  return params(10);
172 }
173 
174 bool
176 {
177  octave_idx_type len = vals.numel ();
178 
179  if (len > OCTAVE_SPARSE_CONTROLS_SIZE)
180  (*current_liboctave_error_handler)
181  ("octave_sparse_params::do_set_vals: too many values");
182 
183  for (int i = 0; i < len; i++)
184  params(i) = vals(i);
185 
186  return true;
187 }
188 
189 bool
191 {
192  for (int i = 0; i < OCTAVE_SPARSE_CONTROLS_SIZE; i++)
193  {
194  if (keys (i) == key)
195  {
196  params(i) = val;
197  return true;
198  }
199  }
200 
201  return false;
202 }
203 
204 double
206 {
207  for (int i = 0; i < OCTAVE_SPARSE_CONTROLS_SIZE; i++)
208  {
209  if (keys (i) == key)
210  return params(i);
211  }
212 
214 }
215 
216 void
218  const std::string& prefix) const
219 {
220  for (int i = 0; i < OCTAVE_SPARSE_CONTROLS_SIZE; i++)
221  os << prefix << keys(i) << ": " << params(i) << "\n";
222 }
void do_print_info(std::ostream &os, const std::string &prefix) const
Definition: oct-spparms.cc:217
static string_vector get_keys(void)
Definition: oct-spparms.cc:71
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:363
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:5068
#define OCTAVE_SPARSE_CONTROLS_SIZE
Definition: oct-spparms.h:38
double do_get_key(const std::string &key)
Definition: oct-spparms.cc:205
static octave_sparse_params * instance
Definition: oct-spparms.h:98
static void print_info(std::ostream &os, const std::string &prefix)
Definition: oct-spparms.cc:108
ColumnVector do_get_vals(void) const
Definition: oct-spparms.h:108
static double get_key(const std::string &key)
Definition: oct-spparms.cc:95
static ColumnVector get_vals(void)
Definition: oct-spparms.cc:77
static void add(fptr f)
void do_defaults(void)
Definition: oct-spparms.cc:115
octave_value retval
Definition: data.cc:6294
ColumnVector params
Definition: oct-spparms.h:94
static void defaults(void)
Definition: oct-spparms.cc:57
string_vector keys
Definition: oct-spparms.h:96
double do_get_bandden(void)
Definition: oct-spparms.cc:169
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol NaN(Not a Number).NaN is the result of operations which do not produce a well defined 0 result.Common operations which produce a NaN are arithmetic with infinity ex($\infty-\infty $)
bool do_set_vals(const NDArray &vals)
Definition: oct-spparms.cc:175
static bool set_key(const std::string &key, const double &val)
Definition: oct-spparms.cc:89
bool do_set_key(const std::string &key, const double &val)
Definition: oct-spparms.cc:190
static bool set_vals(const NDArray &vals)
Definition: oct-spparms.cc:83
static void cleanup_instance(void)
Definition: oct-spparms.h:100
static void tight(void)
Definition: oct-spparms.cc:64
string_vector do_get_keys(void) const
Definition: oct-spparms.h:106
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:854
static bool instance_ok(void)
Definition: oct-spparms.cc:37
static double get_bandden(void)
Definition: oct-spparms.cc:102