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