diff liboctave/DASSL.h @ 1868:6822f1ccec47

[project @ 1996-02-04 11:31:58 by jwe]
author jwe
date Sun, 04 Feb 1996 11:35:56 +0000
parents fc5667a20dd2
children bed9f3e11011
line wrap: on
line diff
--- a/liboctave/DASSL.h
+++ b/liboctave/DASSL.h
@@ -28,37 +28,76 @@
 #pragma interface
 #endif
 
+#include <cmath>
+
 #include "DAE.h"
 
-class DASSL_options
+class
+DASSL_options
 {
- public:
+public:
+
+  DASSL_options (void) { init (); }
 
-  DASSL_options (void);
-  DASSL_options (const DASSL_options& opt);
+  DASSL_options (const DASSL_options& opt) { copy (opt); }
+
+  DASSL_options& operator = (const DASSL_options& opt)
+    {
+      if (this != &opt)
+	copy (opt);
 
-  DASSL_options& operator = (const DASSL_options& opt);
+      return *this;
+    }
+
+  ~DASSL_options (void) { }
 
-  ~DASSL_options (void);
-
-  void init (void);
-  void copy (const DASSL_options& opt);
+  void init (void)
+    {
+      double sqrt_eps = sqrt (DBL_EPSILON);
+      x_absolute_tolerance = sqrt_eps;
+      x_initial_step_size = -1.0;
+      x_maximum_step_size = -1.0;
+      x_minimum_step_size = 0.0;
+      x_relative_tolerance = sqrt_eps;
+    }
 
-  void set_default_options (void);
+  void copy (const DASSL_options& opt)
+    {
+      x_absolute_tolerance = opt.x_absolute_tolerance;
+      x_initial_step_size = opt.x_initial_step_size;
+      x_maximum_step_size = opt.x_maximum_step_size;
+      x_minimum_step_size = opt.x_minimum_step_size;
+      x_relative_tolerance = opt.x_relative_tolerance;
+    }
 
-  void set_absolute_tolerance (double);
-  void set_initial_step_size (double);
-  void set_maximum_step_size (double);
-  void set_minimum_step_size (double);
-  void set_relative_tolerance (double);
+  void set_default_options (void) { init (); }
+
+  void set_absolute_tolerance (double val)
+    { x_absolute_tolerance = (val > 0.0) ? val : ::sqrt (DBL_EPSILON); }
+
+  void set_initial_step_size (double val)
+    { x_initial_step_size = (val >= 0.0) ? val : -1.0; }
 
-  double absolute_tolerance (void);
-  double initial_step_size (void);
-  double maximum_step_size (void);
-  double minimum_step_size (void);
-  double relative_tolerance (void);
+  void set_maximum_step_size (double val)
+    { x_maximum_step_size = (val >= 0.0) ? val : -1.0; }
+
+  void set_minimum_step_size (double val)
+    { x_minimum_step_size = (val >= 0.0) ? val : 0.0; }
+
+  void set_relative_tolerance (double val)
+    { x_relative_tolerance = (val > 0.0) ? val : ::sqrt (DBL_EPSILON); }
 
- private:
+  double absolute_tolerance (void) { return x_absolute_tolerance; }
+
+  double initial_step_size (void) { return x_initial_step_size; }
+
+  double maximum_step_size (void) { return x_maximum_step_size; }
+
+  double minimum_step_size (void) { return x_minimum_step_size; }
+
+  double relative_tolerance (void) { return x_relative_tolerance; }
+
+private:
 
   double x_absolute_tolerance;
   double x_initial_step_size;
@@ -67,7 +106,8 @@
   double x_relative_tolerance;
 };
 
-class DASSL : public DAE, public DASSL_options
+class
+DASSL : public DAE, public DASSL_options
 {
 public: