25struct Quad_options_struct
30 int min_toks_to_match;
35static Quad_options_struct Quad_options_table [] =
37 {
"absolute tolerance",
38 {
"absolute",
"tolerance",
nullptr,
nullptr,
nullptr, },
39 { 1, 0, 0, 0, 0, }, 1, },
41 {
"relative tolerance",
42 {
"relative",
"tolerance",
nullptr,
nullptr,
nullptr, },
43 { 1, 0, 0, 0, 0, }, 1, },
45 {
"single precision absolute tolerance",
46 {
"single",
"precision",
"absolute",
"tolerance",
nullptr, },
47 { 1, 1, 1, 0, 0, }, 3, },
49 {
"single precision relative tolerance",
50 {
"single",
"precision",
"relative",
"tolerance",
nullptr, },
51 { 1, 1, 1, 0, 0, }, 3, },
55print_Quad_options (std::ostream& os)
57 std::ostringstream buf;
60 <<
"Options for Quad include:\n\n"
62 <<
" ------- -----\n";
64 Quad_options_struct *list = Quad_options_table;
68 << std::setiosflags (std::ios::left) << std::setw (50)
70 << std::resetiosflags (std::ios::left)
73 double val = quad_opts.absolute_tolerance ();
80 << std::setiosflags (std::ios::left) << std::setw (50)
82 << std::resetiosflags (std::ios::left)
85 double val = quad_opts.relative_tolerance ();
92 << std::setiosflags (std::ios::left) << std::setw (50)
94 << std::resetiosflags (std::ios::left)
97 float val = quad_opts.single_precision_absolute_tolerance ();
104 << std::setiosflags (std::ios::left) << std::setw (50)
106 << std::resetiosflags (std::ios::left)
109 float val = quad_opts.single_precision_relative_tolerance ();
118set_Quad_options (
const std::string& keyword,
const octave_value& val)
120 Quad_options_struct *list = Quad_options_table;
122 if (octave::keyword_almost_match (list[0].kw_tok, list[0].min_len,
123 keyword, list[0].min_toks_to_match,
MAX_TOKENS))
127 quad_opts.set_absolute_tolerance (tmp);
129 else if (octave::keyword_almost_match (list[1].kw_tok, list[1].min_len,
130 keyword, list[1].min_toks_to_match,
MAX_TOKENS))
134 quad_opts.set_relative_tolerance (tmp);
136 else if (octave::keyword_almost_match (list[2].kw_tok, list[2].min_len,
137 keyword, list[2].min_toks_to_match,
MAX_TOKENS))
141 quad_opts.set_single_precision_absolute_tolerance (tmp);
143 else if (octave::keyword_almost_match (list[3].kw_tok, list[3].min_len,
144 keyword, list[3].min_toks_to_match,
MAX_TOKENS))
148 quad_opts.set_single_precision_relative_tolerance (tmp);
152 warning (
"quad_options: no match for `%s'", keyword.c_str ());
157show_Quad_options (
const std::string& keyword)
161 Quad_options_struct *list = Quad_options_table;
163 if (octave::keyword_almost_match (list[0].kw_tok, list[0].min_len,
164 keyword, list[0].min_toks_to_match,
MAX_TOKENS))
166 double val = quad_opts.absolute_tolerance ();
170 else if (octave::keyword_almost_match (list[1].kw_tok, list[1].min_len,
171 keyword, list[1].min_toks_to_match,
MAX_TOKENS))
173 double val = quad_opts.relative_tolerance ();
177 else if (octave::keyword_almost_match (list[2].kw_tok, list[2].min_len,
178 keyword, list[2].min_toks_to_match,
MAX_TOKENS))
180 float val = quad_opts.single_precision_absolute_tolerance ();
184 else if (octave::keyword_almost_match (list[3].kw_tok, list[3].min_len,
185 keyword, list[3].min_toks_to_match,
MAX_TOKENS))
187 float val = quad_opts.single_precision_relative_tolerance ();
193 warning (
"quad_options: no match for `%s'", keyword.c_str ());
201DEFUN (quad_options, args, ,
240 int nargin = args.
length ();
251 std::string keyword = args(0).xstring_value (
"quad_options: expecting keyword as first argument");
254 retval = show_Quad_options (keyword);
256 set_Quad_options (keyword, args(1));
262OCTAVE_END_NAMESPACE(octave)
float float_value(bool frc_str_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,...)