00001
00002
00003
00004 #if !defined (octave_LSODE_options_h)
00005 #define octave_LSODE_options_h 1
00006
00007 #include <cfloat>
00008 #include <cmath>
00009
00010 #include <ODE.h>
00011
00012
00013 class
00014 LSODE_options
00015 {
00016 public:
00017
00018 LSODE_options (void) { init (); }
00019
00020 LSODE_options (const LSODE_options& opt) { copy (opt); }
00021
00022 LSODE_options& operator = (const LSODE_options& opt)
00023 {
00024 if (this != &opt)
00025 copy (opt);
00026
00027 return *this;
00028 }
00029
00030 ~LSODE_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 = ::sqrt (DBL_EPSILON);
00037 x_integration_method = "stiff";
00038 x_initial_step_size = -1.0;
00039 x_maximum_order = -1;
00040 x_maximum_step_size = -1.0;
00041 x_minimum_step_size = 0.0;
00042 x_step_limit = 100000;
00043 reset = true;
00044 }
00045
00046 void copy (const LSODE_options& opt)
00047 {
00048 x_absolute_tolerance = opt.x_absolute_tolerance;
00049 x_relative_tolerance = opt.x_relative_tolerance;
00050 x_integration_method = opt.x_integration_method;
00051 x_initial_step_size = opt.x_initial_step_size;
00052 x_maximum_order = opt.x_maximum_order;
00053 x_maximum_step_size = opt.x_maximum_step_size;
00054 x_minimum_step_size = opt.x_minimum_step_size;
00055 x_step_limit = opt.x_step_limit;
00056 reset = opt.reset;
00057 }
00058
00059 void set_options (const LSODE_options& opt) { copy (opt); }
00060
00061 void set_default_options (void) { init (); }
00062
00063 void set_absolute_tolerance (double val)
00064 {
00065 x_absolute_tolerance.resize (1);
00066 x_absolute_tolerance(0) = (val > 0.0) ? val : ::sqrt (DBL_EPSILON);
00067 reset = true;
00068 }
00069
00070 void set_absolute_tolerance (const Array<double>& val)
00071 { x_absolute_tolerance = val; reset = true; }
00072
00073 void set_relative_tolerance (double val)
00074 { x_relative_tolerance = (val > 0.0) ? val : ::sqrt (DBL_EPSILON); reset = true; }
00075
00076 void set_integration_method (const std::string& val)
00077 {
00078 if (val == "stiff" || val == "bdf")
00079 x_integration_method = "stiff";
00080 else if (val == "non-stiff" || val == "adams")
00081 x_integration_method = "non-stiff";
00082 else
00083 (*current_liboctave_error_handler)
00084 ("lsode_options: method must be \"stiff\", \"bdf\", \"non-stiff\", or \"adams\"");
00085 reset = true;
00086 }
00087
00088 void set_initial_step_size (double val)
00089 { x_initial_step_size = (val >= 0.0) ? val : -1.0; reset = true; }
00090
00091 void set_maximum_order (octave_idx_type val)
00092 { x_maximum_order = val; reset = true; }
00093
00094 void set_maximum_step_size (double val)
00095 { x_maximum_step_size = (val >= 0.0) ? val : -1.0; reset = true; }
00096
00097 void set_minimum_step_size (double val)
00098 { x_minimum_step_size = (val >= 0.0) ? val : 0.0; reset = true; }
00099
00100 void set_step_limit (octave_idx_type val)
00101 { x_step_limit = val; reset = true; }
00102 Array<double> absolute_tolerance (void) const
00103 { return x_absolute_tolerance; }
00104
00105 double relative_tolerance (void) const
00106 { return x_relative_tolerance; }
00107
00108 std::string integration_method (void) const
00109 { return x_integration_method; }
00110
00111 double initial_step_size (void) const
00112 { return x_initial_step_size; }
00113
00114 octave_idx_type maximum_order (void) const
00115 { return x_maximum_order; }
00116
00117 double maximum_step_size (void) const
00118 { return x_maximum_step_size; }
00119
00120 double minimum_step_size (void) const
00121 { return x_minimum_step_size; }
00122
00123 octave_idx_type step_limit (void) const
00124 { return x_step_limit; }
00125
00126 private:
00127
00128 Array<double> x_absolute_tolerance;
00129 double x_relative_tolerance;
00130 std::string x_integration_method;
00131 double x_initial_step_size;
00132 octave_idx_type x_maximum_order;
00133 double x_maximum_step_size;
00134 double x_minimum_step_size;
00135 octave_idx_type x_step_limit;
00136
00137 protected:
00138
00139 bool reset;
00140 };
00141
00142 #endif