1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
|
// DO NOT EDIT!
// Generated automatically from ../liboctave/numeric/Quad-opts.in.
// This file should not include config.h. It is only included in other
// C++ source files that should have included config.h before including
// this file.
#include <iomanip>
#include <ostream>
#include <sstream>
#include "Quad-opts.h"
#include "defun.h"
#include "pr-output.h"
#include "ovl.h"
#include "utils.h"
#include "pager.h"
static Quad_options quad_opts;
#define MAX_TOKENS 4
struct Quad_options_struct
{
const char *keyword;
const char *kw_tok[MAX_TOKENS + 1];
int min_len[MAX_TOKENS + 1];
int min_toks_to_match;
};
#define NUM_OPTIONS 4
static Quad_options_struct Quad_options_table [] =
{
{ "absolute tolerance",
{ "absolute", "tolerance", nullptr, nullptr, nullptr, },
{ 1, 0, 0, 0, 0, }, 1, },
{ "relative tolerance",
{ "relative", "tolerance", nullptr, nullptr, nullptr, },
{ 1, 0, 0, 0, 0, }, 1, },
{ "single precision absolute tolerance",
{ "single", "precision", "absolute", "tolerance", nullptr, },
{ 1, 1, 1, 0, 0, }, 3, },
{ "single precision relative tolerance",
{ "single", "precision", "relative", "tolerance", nullptr, },
{ 1, 1, 1, 0, 0, }, 3, },
};
static void
print_Quad_options (std::ostream& os)
{
std::ostringstream buf;
os << "\n"
<< "Options for Quad include:\n\n"
<< " keyword value\n"
<< " ------- -----\n";
Quad_options_struct *list = Quad_options_table;
{
os << " "
<< std::setiosflags (std::ios::left) << std::setw (50)
<< list[0].keyword
<< std::resetiosflags (std::ios::left)
<< " ";
double val = quad_opts.absolute_tolerance ();
os << val << "\n";
}
{
os << " "
<< std::setiosflags (std::ios::left) << std::setw (50)
<< list[1].keyword
<< std::resetiosflags (std::ios::left)
<< " ";
double val = quad_opts.relative_tolerance ();
os << val << "\n";
}
{
os << " "
<< std::setiosflags (std::ios::left) << std::setw (50)
<< list[2].keyword
<< std::resetiosflags (std::ios::left)
<< " ";
float val = quad_opts.single_precision_absolute_tolerance ();
os << val << "\n";
}
{
os << " "
<< std::setiosflags (std::ios::left) << std::setw (50)
<< list[3].keyword
<< std::resetiosflags (std::ios::left)
<< " ";
float val = quad_opts.single_precision_relative_tolerance ();
os << val << "\n";
}
os << "\n";
}
static void
set_Quad_options (const std::string& keyword, const octave_value& val)
{
Quad_options_struct *list = Quad_options_table;
if (octave::keyword_almost_match (list[0].kw_tok, list[0].min_len,
keyword, list[0].min_toks_to_match, MAX_TOKENS))
{
double tmp = val.double_value ();
quad_opts.set_absolute_tolerance (tmp);
}
else if (octave::keyword_almost_match (list[1].kw_tok, list[1].min_len,
keyword, list[1].min_toks_to_match, MAX_TOKENS))
{
double tmp = val.double_value ();
quad_opts.set_relative_tolerance (tmp);
}
else if (octave::keyword_almost_match (list[2].kw_tok, list[2].min_len,
keyword, list[2].min_toks_to_match, MAX_TOKENS))
{
float tmp = val.float_value ();
quad_opts.set_single_precision_absolute_tolerance (tmp);
}
else if (octave::keyword_almost_match (list[3].kw_tok, list[3].min_len,
keyword, list[3].min_toks_to_match, MAX_TOKENS))
{
float tmp = val.float_value ();
quad_opts.set_single_precision_relative_tolerance (tmp);
}
else
{
warning ("quad_options: no match for `%s'", keyword.c_str ());
}
}
static octave_value_list
show_Quad_options (const std::string& keyword)
{
octave_value retval;
Quad_options_struct *list = Quad_options_table;
if (octave::keyword_almost_match (list[0].kw_tok, list[0].min_len,
keyword, list[0].min_toks_to_match, MAX_TOKENS))
{
double val = quad_opts.absolute_tolerance ();
retval = val;
}
else if (octave::keyword_almost_match (list[1].kw_tok, list[1].min_len,
keyword, list[1].min_toks_to_match, MAX_TOKENS))
{
double val = quad_opts.relative_tolerance ();
retval = val;
}
else if (octave::keyword_almost_match (list[2].kw_tok, list[2].min_len,
keyword, list[2].min_toks_to_match, MAX_TOKENS))
{
float val = quad_opts.single_precision_absolute_tolerance ();
retval = val;
}
else if (octave::keyword_almost_match (list[3].kw_tok, list[3].min_len,
keyword, list[3].min_toks_to_match, MAX_TOKENS))
{
float val = quad_opts.single_precision_relative_tolerance ();
retval = val;
}
else
{
warning ("quad_options: no match for `%s'", keyword.c_str ());
}
return retval;
}
DEFUN (quad_options, args, ,
doc: /* -*- texinfo -*-
@deftypefn {} {} quad_options ()
@deftypefnx {} {val =} quad_options (@var{opt})
@deftypefnx {} {} quad_options (@var{opt}, @var{val})
Query or set options for the function @code{quad}.
When called with no arguments, the names of all available options and
their current values are displayed.
Given one argument, return the value of the option @var{opt}.
When called with two arguments, @code{quad_options} sets the option
@var{opt} to value @var{val}.
Options include
@table @asis
@item @qcode{"absolute tolerance"}
Absolute tolerance; may be zero for pure relative error test.
@item @qcode{"relative tolerance"}
Non-negative relative tolerance. If the absolute tolerance is zero,
the relative tolerance must be greater than or equal to
@w{@code{max (50*eps, 0.5e-28)}}.
@item @qcode{"single precision absolute tolerance"}
Absolute tolerance for single precision; may be zero for pure relative
error test.
@item @qcode{"single precision relative tolerance"}
Non-negative relative tolerance for single precision. If the absolute
tolerance is zero, the relative tolerance must be greater than or equal to
@w{@code{max (50*eps, 0.5e-28)}}.
@end table
@end deftypefn */)
{
octave_value_list retval;
int nargin = args.length ();
if (nargin > 2)
print_usage ();
if (nargin == 0)
{
print_Quad_options (octave_stdout);
}
else
{
std::string keyword = args(0).xstring_value ("quad_options: expecting keyword as first argument");
if (nargin == 1)
retval = show_Quad_options (keyword);
else
set_Quad_options (keyword, args(1));
}
return retval;
}
|