12#include "DASRT-opts.h"
25struct DASRT_options_struct
30 int min_toks_to_match;
35static DASRT_options_struct DASRT_options_table [] =
37 {
"absolute tolerance",
38 {
"absolute",
"tolerance",
nullptr,
nullptr, },
39 { 1, 0, 0, 0, }, 1, },
41 {
"relative tolerance",
42 {
"relative",
"tolerance",
nullptr,
nullptr, },
43 { 1, 0, 0, 0, }, 1, },
45 {
"initial step size",
46 {
"initial",
"step",
"size",
nullptr, },
47 { 1, 0, 0, 0, }, 1, },
50 {
"maximum",
"order",
nullptr,
nullptr, },
51 { 1, 1, 0, 0, }, 2, },
53 {
"maximum step size",
54 {
"maximum",
"step",
"size",
nullptr, },
55 { 1, 1, 0, 0, }, 2, },
58 {
"step",
"limit",
nullptr,
nullptr, },
59 { 1, 0, 0, 0, }, 1, },
63print_DASRT_options (std::ostream& os)
65 std::ostringstream buf;
68 <<
"Options for DASRT include:\n\n"
70 <<
" ------- -----\n";
72 DASRT_options_struct *list = DASRT_options_table;
76 << std::setiosflags (std::ios::left) << std::setw (50)
78 << std::resetiosflags (std::ios::left)
83 if (val.
numel () == 1)
98 << std::setiosflags (std::ios::left) << std::setw (50)
100 << std::resetiosflags (std::ios::left)
105 if (val.
numel () == 1)
107 os << val(0) <<
"\n";
120 << std::setiosflags (std::ios::left) << std::setw (50)
122 << std::resetiosflags (std::ios::left)
125 double val = dasrt_opts.initial_step_size ();
132 << std::setiosflags (std::ios::left) << std::setw (50)
134 << std::resetiosflags (std::ios::left)
137 int val = dasrt_opts.maximum_order ();
144 << std::setiosflags (std::ios::left) << std::setw (50)
146 << std::resetiosflags (std::ios::left)
149 double val = dasrt_opts.maximum_step_size ();
156 << std::setiosflags (std::ios::left) << std::setw (50)
158 << std::resetiosflags (std::ios::left)
161 int val = dasrt_opts.step_limit ();
170set_DASRT_options (
const std::string& keyword,
const octave_value& val)
172 DASRT_options_struct *list = DASRT_options_table;
174 if (octave::keyword_almost_match (list[0].kw_tok, list[0].min_len,
175 keyword, list[0].min_toks_to_match,
MAX_TOKENS))
179 dasrt_opts.set_absolute_tolerance (tmp);
181 else if (octave::keyword_almost_match (list[1].kw_tok, list[1].min_len,
182 keyword, list[1].min_toks_to_match,
MAX_TOKENS))
186 dasrt_opts.set_relative_tolerance (tmp);
188 else if (octave::keyword_almost_match (list[2].kw_tok, list[2].min_len,
189 keyword, list[2].min_toks_to_match,
MAX_TOKENS))
193 dasrt_opts.set_initial_step_size (tmp);
195 else if (octave::keyword_almost_match (list[3].kw_tok, list[3].min_len,
196 keyword, list[3].min_toks_to_match,
MAX_TOKENS))
200 dasrt_opts.set_maximum_order (tmp);
202 else if (octave::keyword_almost_match (list[4].kw_tok, list[4].min_len,
203 keyword, list[4].min_toks_to_match,
MAX_TOKENS))
207 dasrt_opts.set_maximum_step_size (tmp);
209 else if (octave::keyword_almost_match (list[5].kw_tok, list[5].min_len,
210 keyword, list[5].min_toks_to_match,
MAX_TOKENS))
214 dasrt_opts.set_step_limit (tmp);
218 warning (
"dasrt_options: no match for `%s'", keyword.c_str ());
223show_DASRT_options (
const std::string& keyword)
227 DASRT_options_struct *list = DASRT_options_table;
229 if (octave::keyword_almost_match (list[0].kw_tok, list[0].min_len,
230 keyword, list[0].min_toks_to_match,
MAX_TOKENS))
234 if (val.
numel () == 1)
243 else if (octave::keyword_almost_match (list[1].kw_tok, list[1].min_len,
244 keyword, list[1].min_toks_to_match,
MAX_TOKENS))
248 if (val.
numel () == 1)
257 else if (octave::keyword_almost_match (list[2].kw_tok, list[2].min_len,
258 keyword, list[2].min_toks_to_match,
MAX_TOKENS))
260 double val = dasrt_opts.initial_step_size ();
264 else if (octave::keyword_almost_match (list[3].kw_tok, list[3].min_len,
265 keyword, list[3].min_toks_to_match,
MAX_TOKENS))
267 int val = dasrt_opts.maximum_order ();
269 retval =
static_cast<double> (val);
271 else if (octave::keyword_almost_match (list[4].kw_tok, list[4].min_len,
272 keyword, list[4].min_toks_to_match,
MAX_TOKENS))
274 double val = dasrt_opts.maximum_step_size ();
278 else if (octave::keyword_almost_match (list[5].kw_tok, list[5].min_len,
279 keyword, list[5].min_toks_to_match,
MAX_TOKENS))
281 int val = dasrt_opts.step_limit ();
283 retval =
static_cast<double> (val);
287 warning (
"dasrt_options: no match for `%s'", keyword.c_str ());
295DEFUN (dasrt_options, args, ,
354 int nargin = args.
length ();
365 std::string keyword = args(0).xstring_value (
"dasrt_options: expecting keyword as first argument");
368 retval = show_DASRT_options (keyword);
370 set_DASRT_options (keyword, args(1));
376OCTAVE_END_NAMESPACE(octave)
N Dimensional Array with copy-on-write semantics.
octave_idx_type numel() const
Number of elements in the array.
int int_value(bool req_int=false, bool frc_str_conv=false) const
Array< double > vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
octave_idx_type length() const
double double_value(bool frc_str_conv=false) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void warning(const char *fmt,...)
void octave_print_internal(std::ostream &os, const float_display_format &fmt, bool d, bool pr_as_read_syntax)