00001
00002
00003
00004 #if !defined (octave_DASRT_options_h)
00005 #define octave_DASRT_options_h 1
00006
00007 #include <cfloat>
00008 #include <cmath>
00009
00010 #include <DAERT.h>
00011
00012
00013 class
00014 DASRT_options
00015 {
00016 public:
00017
00018 DASRT_options (void) { init (); }
00019
00020 DASRT_options (const DASRT_options& opt) { copy (opt); }
00021
00022 DASRT_options& operator = (const DASRT_options& opt)
00023 {
00024 if (this != &opt)
00025 copy (opt);
00026
00027 return *this;
00028 }
00029
00030 ~DASRT_options (void) { }
00031
00032 void init (void)
00033 {
00034 x_absolute_tolerance.resize (1);
00035 x_absolute_tolerance(0) = ::sqrt (DBL_EPSILON);
00036 x_relative_tolerance.resize (1);
00037 x_relative_tolerance(0) = ::sqrt (DBL_EPSILON);
00038 x_initial_step_size = -1.0;
00039 x_maximum_order = -1;
00040 x_maximum_step_size = -1.0;
00041 x_step_limit = -1;
00042 reset = true;
00043 }
00044
00045 void copy (const DASRT_options& opt)
00046 {
00047 x_absolute_tolerance = opt.x_absolute_tolerance;
00048 x_relative_tolerance = opt.x_relative_tolerance;
00049 x_initial_step_size = opt.x_initial_step_size;
00050 x_maximum_order = opt.x_maximum_order;
00051 x_maximum_step_size = opt.x_maximum_step_size;
00052 x_step_limit = opt.x_step_limit;
00053 reset = opt.reset;
00054 }
00055
00056 void set_options (const DASRT_options& opt) { copy (opt); }
00057
00058 void set_default_options (void) { init (); }
00059
00060 void set_absolute_tolerance (double val)
00061 {
00062 x_absolute_tolerance.resize (1);
00063 x_absolute_tolerance(0) = (val > 0.0) ? val : ::sqrt (DBL_EPSILON);
00064 reset = true;
00065 }
00066
00067 void set_absolute_tolerance (const Array<double>& val)
00068 { x_absolute_tolerance = val; reset = true; }
00069
00070 void set_relative_tolerance (double val)
00071 {
00072 x_relative_tolerance.resize (1);
00073 x_relative_tolerance(0) = (val > 0.0) ? val : ::sqrt (DBL_EPSILON);
00074 reset = true;
00075 }
00076
00077 void set_relative_tolerance (const Array<double>& val)
00078 { x_relative_tolerance = val; reset = true; }
00079
00080 void set_initial_step_size (double val)
00081 { x_initial_step_size = (val >= 0.0) ? val : -1.0; reset = true; }
00082
00083 void set_maximum_order (octave_idx_type val)
00084 { x_maximum_order = val; reset = true; }
00085
00086 void set_maximum_step_size (double val)
00087 { x_maximum_step_size = (val >= 0.0) ? val : -1.0; reset = true; }
00088
00089 void set_step_limit (octave_idx_type val)
00090 { x_step_limit = (val >= 0) ? val : -1; reset = true; }
00091 Array<double> absolute_tolerance (void) const
00092 { return x_absolute_tolerance; }
00093
00094 Array<double> relative_tolerance (void) const
00095 { return x_relative_tolerance; }
00096
00097 double initial_step_size (void) const
00098 { return x_initial_step_size; }
00099
00100 octave_idx_type maximum_order (void) const
00101 { return x_maximum_order; }
00102
00103 double maximum_step_size (void) const
00104 { return x_maximum_step_size; }
00105
00106 octave_idx_type step_limit (void) const
00107 { return x_step_limit; }
00108
00109 private:
00110
00111 Array<double> x_absolute_tolerance;
00112 Array<double> x_relative_tolerance;
00113 double x_initial_step_size;
00114 octave_idx_type x_maximum_order;
00115 double x_maximum_step_size;
00116 octave_idx_type x_step_limit;
00117
00118 protected:
00119
00120 bool reset;
00121 };
00122
00123 #endif