Go to the documentation of this file.00001
00002
00003
00004 #if !defined (octave_DASSL_options_h)
00005 #define octave_DASSL_options_h 1
00006
00007 #include <cfloat>
00008 #include <cmath>
00009
00010 #include <DAE.h>
00011
00012
00013 class
00014 DASSL_options
00015 {
00016 public:
00017
00018 DASSL_options (void)
00019 : x_absolute_tolerance (),
00020 x_relative_tolerance (),
00021 x_compute_consistent_initial_condition (),
00022 x_enforce_nonnegativity_constraints (),
00023 x_initial_step_size (),
00024 x_maximum_order (),
00025 x_maximum_step_size (),
00026 x_step_limit (),
00027 reset ()
00028 {
00029 init ();
00030 }
00031
00032 DASSL_options (const DASSL_options& opt)
00033 : x_absolute_tolerance (opt.x_absolute_tolerance),
00034 x_relative_tolerance (opt.x_relative_tolerance),
00035 x_compute_consistent_initial_condition (opt.x_compute_consistent_initial_condition),
00036 x_enforce_nonnegativity_constraints (opt.x_enforce_nonnegativity_constraints),
00037 x_initial_step_size (opt.x_initial_step_size),
00038 x_maximum_order (opt.x_maximum_order),
00039 x_maximum_step_size (opt.x_maximum_step_size),
00040 x_step_limit (opt.x_step_limit),
00041 reset (opt.reset)
00042 { }
00043
00044 DASSL_options& operator = (const DASSL_options& opt)
00045 {
00046 if (this != &opt)
00047 {
00048 x_absolute_tolerance = opt.x_absolute_tolerance;
00049 x_relative_tolerance = opt.x_relative_tolerance;
00050 x_compute_consistent_initial_condition = opt.x_compute_consistent_initial_condition;
00051 x_enforce_nonnegativity_constraints = opt.x_enforce_nonnegativity_constraints;
00052 x_initial_step_size = opt.x_initial_step_size;
00053 x_maximum_order = opt.x_maximum_order;
00054 x_maximum_step_size = opt.x_maximum_step_size;
00055 x_step_limit = opt.x_step_limit;
00056 reset = opt.reset;
00057 }
00058
00059 return *this;
00060 }
00061
00062 ~DASSL_options (void) { }
00063
00064 void init (void)
00065 {
00066 x_absolute_tolerance.resize (dim_vector (1, 1));
00067 x_absolute_tolerance(0) = ::sqrt (DBL_EPSILON);
00068 x_relative_tolerance.resize (dim_vector (1, 1));
00069 x_relative_tolerance(0) = ::sqrt (DBL_EPSILON);
00070 x_initial_step_size = -1.0;
00071 x_maximum_order = -1;
00072 x_maximum_step_size = -1.0;
00073 x_step_limit = -1;
00074 reset = true;
00075 }
00076
00077 void set_options (const DASSL_options& opt)
00078 {
00079 x_absolute_tolerance = opt.x_absolute_tolerance;
00080 x_relative_tolerance = opt.x_relative_tolerance;
00081 x_compute_consistent_initial_condition = opt.x_compute_consistent_initial_condition;
00082 x_enforce_nonnegativity_constraints = opt.x_enforce_nonnegativity_constraints;
00083 x_initial_step_size = opt.x_initial_step_size;
00084 x_maximum_order = opt.x_maximum_order;
00085 x_maximum_step_size = opt.x_maximum_step_size;
00086 x_step_limit = opt.x_step_limit;
00087 reset = opt.reset;
00088 }
00089
00090 void set_default_options (void) { init (); }
00091
00092 void set_absolute_tolerance (double val)
00093 {
00094 x_absolute_tolerance.resize (dim_vector (1, 1));
00095 x_absolute_tolerance(0) = (val > 0.0) ? val : ::sqrt (DBL_EPSILON);
00096 reset = true;
00097 }
00098
00099 void set_absolute_tolerance (const Array<double>& val)
00100 { x_absolute_tolerance = val; reset = true; }
00101
00102 void set_relative_tolerance (double val)
00103 {
00104 x_relative_tolerance.resize (dim_vector (1, 1));
00105 x_relative_tolerance(0) = (val > 0.0) ? val : ::sqrt (DBL_EPSILON);
00106 reset = true;
00107 }
00108
00109 void set_relative_tolerance (const Array<double>& val)
00110 { x_relative_tolerance = val; reset = true; }
00111
00112 void set_compute_consistent_initial_condition (octave_idx_type val)
00113 { x_compute_consistent_initial_condition = val; reset = true; }
00114
00115 void set_enforce_nonnegativity_constraints (octave_idx_type val)
00116 { x_enforce_nonnegativity_constraints = val; reset = true; }
00117
00118 void set_initial_step_size (double val)
00119 { x_initial_step_size = (val >= 0.0) ? val : -1.0; reset = true; }
00120
00121 void set_maximum_order (octave_idx_type val)
00122 { x_maximum_order = val; reset = true; }
00123
00124 void set_maximum_step_size (double val)
00125 { x_maximum_step_size = (val >= 0.0) ? val : -1.0; reset = true; }
00126
00127 void set_step_limit (octave_idx_type val)
00128 { x_step_limit = (val >= 0) ? val : -1; reset = true; }
00129 Array<double> absolute_tolerance (void) const
00130 { return x_absolute_tolerance; }
00131
00132 Array<double> relative_tolerance (void) const
00133 { return x_relative_tolerance; }
00134
00135 octave_idx_type compute_consistent_initial_condition (void) const
00136 { return x_compute_consistent_initial_condition; }
00137
00138 octave_idx_type enforce_nonnegativity_constraints (void) const
00139 { return x_enforce_nonnegativity_constraints; }
00140
00141 double initial_step_size (void) const
00142 { return x_initial_step_size; }
00143
00144 octave_idx_type maximum_order (void) const
00145 { return x_maximum_order; }
00146
00147 double maximum_step_size (void) const
00148 { return x_maximum_step_size; }
00149
00150 octave_idx_type step_limit (void) const
00151 { return x_step_limit; }
00152
00153 private:
00154
00155 Array<double> x_absolute_tolerance;
00156 Array<double> x_relative_tolerance;
00157 octave_idx_type x_compute_consistent_initial_condition;
00158 octave_idx_type x_enforce_nonnegativity_constraints;
00159 double x_initial_step_size;
00160 octave_idx_type x_maximum_order;
00161 double x_maximum_step_size;
00162 octave_idx_type x_step_limit;
00163
00164 protected:
00165
00166 bool reset;
00167 };
00168
00169 #endif