Go to the documentation of this file.00001
00002
00003
00004 #if !defined (octave_Quad_options_h)
00005 #define octave_Quad_options_h 1
00006
00007 #include <cfloat>
00008 #include <cmath>
00009
00010
00011
00012 class
00013 Quad_options
00014 {
00015 public:
00016
00017 Quad_options (void)
00018 : x_absolute_tolerance (),
00019 x_relative_tolerance (),
00020 x_single_precision_absolute_tolerance (),
00021 x_single_precision_relative_tolerance (),
00022 reset ()
00023 {
00024 init ();
00025 }
00026
00027 Quad_options (const Quad_options& opt)
00028 : x_absolute_tolerance (opt.x_absolute_tolerance),
00029 x_relative_tolerance (opt.x_relative_tolerance),
00030 x_single_precision_absolute_tolerance (opt.x_single_precision_absolute_tolerance),
00031 x_single_precision_relative_tolerance (opt.x_single_precision_relative_tolerance),
00032 reset (opt.reset)
00033 { }
00034
00035 Quad_options& operator = (const Quad_options& opt)
00036 {
00037 if (this != &opt)
00038 {
00039 x_absolute_tolerance = opt.x_absolute_tolerance;
00040 x_relative_tolerance = opt.x_relative_tolerance;
00041 x_single_precision_absolute_tolerance = opt.x_single_precision_absolute_tolerance;
00042 x_single_precision_relative_tolerance = opt.x_single_precision_relative_tolerance;
00043 reset = opt.reset;
00044 }
00045
00046 return *this;
00047 }
00048
00049 ~Quad_options (void) { }
00050
00051 void init (void)
00052 {
00053 x_absolute_tolerance = ::sqrt (DBL_EPSILON);
00054 x_relative_tolerance = ::sqrt (DBL_EPSILON);
00055 x_single_precision_absolute_tolerance = ::sqrt (FLT_EPSILON);
00056 x_single_precision_relative_tolerance = ::sqrt (FLT_EPSILON);
00057 reset = true;
00058 }
00059
00060 void set_options (const Quad_options& opt)
00061 {
00062 x_absolute_tolerance = opt.x_absolute_tolerance;
00063 x_relative_tolerance = opt.x_relative_tolerance;
00064 x_single_precision_absolute_tolerance = opt.x_single_precision_absolute_tolerance;
00065 x_single_precision_relative_tolerance = opt.x_single_precision_relative_tolerance;
00066 reset = opt.reset;
00067 }
00068
00069 void set_default_options (void) { init (); }
00070
00071 void set_absolute_tolerance (double val)
00072 { x_absolute_tolerance = val; reset = true; }
00073
00074 void set_relative_tolerance (double val)
00075 { x_relative_tolerance = val; reset = true; }
00076
00077 void set_single_precision_absolute_tolerance (float val)
00078 { x_single_precision_absolute_tolerance = val; reset = true; }
00079
00080 void set_single_precision_relative_tolerance (float val)
00081 { x_single_precision_relative_tolerance = val; reset = true; }
00082 double absolute_tolerance (void) const
00083 { return x_absolute_tolerance; }
00084
00085 double relative_tolerance (void) const
00086 { return x_relative_tolerance; }
00087
00088 float single_precision_absolute_tolerance (void) const
00089 { return x_single_precision_absolute_tolerance; }
00090
00091 float single_precision_relative_tolerance (void) const
00092 { return x_single_precision_relative_tolerance; }
00093
00094 private:
00095
00096 double x_absolute_tolerance;
00097 double x_relative_tolerance;
00098 float x_single_precision_absolute_tolerance;
00099 float x_single_precision_relative_tolerance;
00100
00101 protected:
00102
00103 bool reset;
00104 };
00105
00106 #endif