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
DASRT-opts.cc
Go to the documentation of this file.
1 // DO NOT EDIT!
2 // Generated automatically from ../liboctave/numeric/DASRT-opts.in.
3 
4 // This file should not include config.h. It is only included in other
5 // C++ source files that should have included config.h before including
6 // this file.
7 
8 #include <iomanip>
9 #include <iostream>
10 
11 #include "DASRT-opts.h"
12 
13 #include "defun.h"
14 #include "pr-output.h"
15 
16 #include "ovl.h"
17 #include "utils.h"
18 #include "pager.h"
19 
21 
22 #define MAX_TOKENS 3
23 
25 {
26  const char *keyword;
27  const char *kw_tok[MAX_TOKENS + 1];
28  int min_len[MAX_TOKENS + 1];
30 };
31 
32 #define NUM_OPTIONS 6
33 
35 {
36  { "absolute tolerance",
37  { "absolute", "tolerance", 0, 0, },
38  { 1, 0, 0, 0, }, 1, },
39 
40  { "relative tolerance",
41  { "relative", "tolerance", 0, 0, },
42  { 1, 0, 0, 0, }, 1, },
43 
44  { "initial step size",
45  { "initial", "step", "size", 0, },
46  { 1, 0, 0, 0, }, 1, },
47 
48  { "maximum order",
49  { "maximum", "order", 0, 0, },
50  { 1, 1, 0, 0, }, 2, },
51 
52  { "maximum step size",
53  { "maximum", "step", "size", 0, },
54  { 1, 1, 0, 0, }, 2, },
55 
56  { "step limit",
57  { "step", "limit", 0, 0, },
58  { 1, 0, 0, 0, }, 1, },
59 };
60 
61 static void
62 print_DASRT_options (std::ostream& os)
63 {
64  std::ostringstream buf;
65 
66  os << "\n"
67  << "Options for DASRT include:\n\n"
68  << " keyword value\n"
69  << " ------- -----\n";
70 
72 
73  {
74  os << " "
75  << std::setiosflags (std::ios::left) << std::setw (50)
76  << list[0].keyword
77  << std::resetiosflags (std::ios::left)
78  << " ";
79 
80  Array<double> val = dasrt_opts.absolute_tolerance ();
81 
82  if (val.numel () == 1)
83  {
84  os << val(0) << "\n";
85  }
86  else
87  {
88  os << "\n\n";
89  Matrix tmp = Matrix (ColumnVector (val));
90  octave_print_internal (os, tmp, false, 2);
91  os << "\n\n";
92  }
93  }
94 
95  {
96  os << " "
97  << std::setiosflags (std::ios::left) << std::setw (50)
98  << list[1].keyword
99  << std::resetiosflags (std::ios::left)
100  << " ";
101 
102  Array<double> val = dasrt_opts.relative_tolerance ();
103 
104  if (val.numel () == 1)
105  {
106  os << val(0) << "\n";
107  }
108  else
109  {
110  os << "\n\n";
111  Matrix tmp = Matrix (ColumnVector (val));
112  octave_print_internal (os, tmp, false, 2);
113  os << "\n\n";
114  }
115  }
116 
117  {
118  os << " "
119  << std::setiosflags (std::ios::left) << std::setw (50)
120  << list[2].keyword
121  << std::resetiosflags (std::ios::left)
122  << " ";
123 
124  double val = dasrt_opts.initial_step_size ();
125 
126  os << val << "\n";
127  }
128 
129  {
130  os << " "
131  << std::setiosflags (std::ios::left) << std::setw (50)
132  << list[3].keyword
133  << std::resetiosflags (std::ios::left)
134  << " ";
135 
136  int val = dasrt_opts.maximum_order ();
137 
138  os << val << "\n";
139  }
140 
141  {
142  os << " "
143  << std::setiosflags (std::ios::left) << std::setw (50)
144  << list[4].keyword
145  << std::resetiosflags (std::ios::left)
146  << " ";
147 
148  double val = dasrt_opts.maximum_step_size ();
149 
150  os << val << "\n";
151  }
152 
153  {
154  os << " "
155  << std::setiosflags (std::ios::left) << std::setw (50)
156  << list[5].keyword
157  << std::resetiosflags (std::ios::left)
158  << " ";
159 
160  int val = dasrt_opts.step_limit ();
161 
162  os << val << "\n";
163  }
164 
165  os << "\n";
166 }
167 
168 static void
170 {
172 
173  if (keyword_almost_match (list[0].kw_tok, list[0].min_len,
174  keyword, list[0].min_toks_to_match, MAX_TOKENS))
175  {
176  Array<double> tmp = val.vector_value ();
177 
178  dasrt_opts.set_absolute_tolerance (tmp);
179  }
180  else if (keyword_almost_match (list[1].kw_tok, list[1].min_len,
181  keyword, list[1].min_toks_to_match, MAX_TOKENS))
182  {
183  Array<double> tmp = val.vector_value ();
184 
185  dasrt_opts.set_relative_tolerance (tmp);
186  }
187  else if (keyword_almost_match (list[2].kw_tok, list[2].min_len,
188  keyword, list[2].min_toks_to_match, MAX_TOKENS))
189  {
190  double tmp = val.double_value ();
191 
192  dasrt_opts.set_initial_step_size (tmp);
193  }
194  else if (keyword_almost_match (list[3].kw_tok, list[3].min_len,
195  keyword, list[3].min_toks_to_match, MAX_TOKENS))
196  {
197  int tmp = val.int_value ();
198 
199  dasrt_opts.set_maximum_order (tmp);
200  }
201  else if (keyword_almost_match (list[4].kw_tok, list[4].min_len,
202  keyword, list[4].min_toks_to_match, MAX_TOKENS))
203  {
204  double tmp = val.double_value ();
205 
206  dasrt_opts.set_maximum_step_size (tmp);
207  }
208  else if (keyword_almost_match (list[5].kw_tok, list[5].min_len,
209  keyword, list[5].min_toks_to_match, MAX_TOKENS))
210  {
211  int tmp = val.int_value ();
212 
213  dasrt_opts.set_step_limit (tmp);
214  }
215  else
216  {
217  warning ("dasrt_options: no match for `%s'", keyword.c_str ());
218  }
219 }
220 
221 static octave_value_list
223 {
225 
227 
228  if (keyword_almost_match (list[0].kw_tok, list[0].min_len,
229  keyword, list[0].min_toks_to_match, MAX_TOKENS))
230  {
231  Array<double> val = dasrt_opts.absolute_tolerance ();
232 
233  if (val.numel () == 1)
234  {
235  retval = val(0);
236  }
237  else
238  {
239  retval = ColumnVector (val);
240  }
241  }
242  else if (keyword_almost_match (list[1].kw_tok, list[1].min_len,
243  keyword, list[1].min_toks_to_match, MAX_TOKENS))
244  {
245  Array<double> val = dasrt_opts.relative_tolerance ();
246 
247  if (val.numel () == 1)
248  {
249  retval = val(0);
250  }
251  else
252  {
253  retval = ColumnVector (val);
254  }
255  }
256  else if (keyword_almost_match (list[2].kw_tok, list[2].min_len,
257  keyword, list[2].min_toks_to_match, MAX_TOKENS))
258  {
259  double val = dasrt_opts.initial_step_size ();
260 
261  retval = val;
262  }
263  else if (keyword_almost_match (list[3].kw_tok, list[3].min_len,
264  keyword, list[3].min_toks_to_match, MAX_TOKENS))
265  {
266  int val = dasrt_opts.maximum_order ();
267 
268  retval = static_cast<double> (val);
269  }
270  else if (keyword_almost_match (list[4].kw_tok, list[4].min_len,
271  keyword, list[4].min_toks_to_match, MAX_TOKENS))
272  {
273  double val = dasrt_opts.maximum_step_size ();
274 
275  retval = val;
276  }
277  else if (keyword_almost_match (list[5].kw_tok, list[5].min_len,
278  keyword, list[5].min_toks_to_match, MAX_TOKENS))
279  {
280  int val = dasrt_opts.step_limit ();
281 
282  retval = static_cast<double> (val);
283  }
284  else
285  {
286  warning ("dasrt_options: no match for `%s'", keyword.c_str ());
287  }
288 
289  return retval;
290 }
291 
292 DEFUN (dasrt_options, args, ,
293  doc: /* -*- texinfo -*-
294 @deftypefn {} {} dasrt_options ()
295 @deftypefnx {} {val =} dasrt_options (@var{opt})
296 @deftypefnx {} {} dasrt_options (@var{opt}, @var{val})
297 Query or set options for the function @code{dasrt}.
298 
299 When called with no arguments, the names of all available options and
300 their current values are displayed.
301 
302 Given one argument, return the value of the option @var{opt}.
303 
304 When called with two arguments, @code{dasrt_options} sets the option
305 @var{opt} to value @var{val}.
306 
307 Options include
308 
309 @table @asis
310 @item @qcode{"absolute tolerance"}
311 Absolute tolerance. May be either vector or scalar. If a vector, it
312 must match the dimension of the state vector, and the relative
313 tolerance must also be a vector of the same length.
314 
315 @item @qcode{"relative tolerance"}
316 Relative tolerance. May be either vector or scalar. If a vector, it
317 must match the dimension of the state vector, and the absolute
318 tolerance must also be a vector of the same length.
319 
320 The local error test applied at each integration step is
321 
322 @example
323 @group
324  abs (local error in x(i)) <= ...
325  rtol(i) * abs (Y(i)) + atol(i)
326 @end group
327 @end example
328 
329 @item @qcode{"initial step size"}
330 Differential-algebraic problems may occasionally suffer from severe
331 scaling difficulties on the first step. If you know a great deal
332 about the scaling of your problem, you can help to alleviate this
333 problem by specifying an initial stepsize.
334 
335 @item @qcode{"maximum order"}
336 Restrict the maximum order of the solution method. This option must
337 be between 1 and 5, inclusive.
338 
339 @item @qcode{"maximum step size"}
340 Setting the maximum stepsize will avoid passing over very large
341 regions.
342 
343 @item @qcode{"step limit"}
344 Maximum number of integration steps to attempt on a single call to the
345 underlying Fortran code.
346 @end table
347 @end deftypefn */)
348 {
350 
351  int nargin = args.length ();
352 
353  if (nargin > 2)
354  print_usage ();
355 
356  if (nargin == 0)
357  {
359  }
360  else
361  {
362  std::string keyword = args(0).xstring_value ("dasrt_options: expecting keyword as first argument");
363 
364  if (nargin == 1)
365  retval = show_DASRT_options (keyword);
366  else
367  set_DASRT_options (keyword, args(1));
368  }
369 
370  return retval;
371 }
double maximum_step_size(void) const
Definition: DASRT-opts.h:127
static int left
Definition: randmtzig.cc:185
void set_relative_tolerance(double val)
Definition: DASRT-opts.h:94
The value of lines which begin with a space character are not saved in the history list A value of all commands are saved on the history list
Definition: oct-hist.cc:728
void set_step_limit(octave_idx_type val)
Definition: DASRT-opts.h:113
OCTINTERP_API void print_usage(void)
Definition: defun.cc:52
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
void set_absolute_tolerance(double val)
Definition: DASRT-opts.h:84
int int_value(bool req_int=false, bool frc_str_conv=false) const
Definition: ov.h:746
#define DEFUN(name, args_name, nargout_name, doc)
Definition: defun.h:46
#define MAX_TOKENS
Definition: DASRT-opts.cc:22
static DASRT_options dasrt_opts
Definition: DASRT-opts.cc:20
void set_maximum_order(octave_idx_type val)
Definition: DASRT-opts.h:107
void set_maximum_step_size(double val)
Definition: DASRT-opts.h:110
static octave_value_list show_DASRT_options(const std::string &keyword)
Definition: DASRT-opts.cc:222
JNIEnv void * args
Definition: ov-java.cc:67
static void print_DASRT_options(std::ostream &os)
Definition: DASRT-opts.cc:62
const char * keyword
Definition: DASRT-opts.cc:26
static void set_DASRT_options(const std::string &keyword, const octave_value &val)
Definition: DASRT-opts.cc:169
int nargin
Definition: graphics.cc:10115
double tmp
Definition: data.cc:6300
octave_value retval
Definition: data.cc:6294
Definition: dMatrix.h:37
int keyword_almost_match(const char *const *std, int *min_len, const std::string &s, int min_toks_to_match, int max_toks)
Definition: utils.cc:152
octave_idx_type step_limit(void) const
Definition: DASRT-opts.h:130
void warning(const char *fmt,...)
Definition: error.cc:788
Array< double > relative_tolerance(void) const
Definition: DASRT-opts.h:118
#define octave_stdout
Definition: pager.h:146
const char * kw_tok[3+1]
Definition: DASRT-opts.cc:27
Array< double > absolute_tolerance(void) const
Definition: DASRT-opts.h:115
void octave_print_internal(std::ostream &, char, bool)
Definition: pr-output.cc:1722
Array< double > vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1798
octave_idx_type maximum_order(void) const
Definition: DASRT-opts.h:124
void set_initial_step_size(double val)
Definition: DASRT-opts.h:104
double initial_step_size(void) const
Definition: DASRT-opts.h:121
double double_value(bool frc_str_conv=false) const
Definition: ov.h:775
static DASRT_options_struct DASRT_options_table[]
Definition: DASRT-opts.cc:34
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