changeset 1868:6822f1ccec47

[project @ 1996-02-04 11:31:58 by jwe]
author jwe
date Sun, 04 Feb 1996 11:35:56 +0000
parents 52e7bca8ce33
children 51fd6b03c3bb
files liboctave/DAE.h liboctave/DAEFunc.h liboctave/DASSL.h
diffstat 3 files changed, 78 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/DAE.h	Sun Feb 04 11:28:40 1996 +0000
+++ b/liboctave/DAE.h	Sun Feb 04 11:35:56 1996 +0000
@@ -31,7 +31,8 @@
 #include "DAEFunc.h"
 #include "base-de.h"
 
-class DAE : public base_diff_eqn, public DAEFunc
+class
+DAE : public base_diff_eqn, public DAEFunc
 {
 public:
 
--- a/liboctave/DAEFunc.h	Sun Feb 04 11:28:40 1996 +0000
+++ b/liboctave/DAEFunc.h	Sun Feb 04 11:35:56 1996 +0000
@@ -1,7 +1,7 @@
 // DAEFunc.h                                             -*- C++ -*-
 /*
 
-Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton
+Copyright (C) 1996 John W. Eaton
 
 This file is part of Octave.
 
@@ -36,7 +36,8 @@
 
 #endif
 
-class DAEFunc
+class
+DAEFunc
 {
 public:
 
@@ -53,37 +54,29 @@
 				const ColumnVector& xdot, double);
 
   DAEFunc (void)
-    {
-      fun = 0;
-      jac = 0;
-    }
+    : fun (0), jac (0) { }
 
   DAEFunc (DAERHSFunc f)
-    {
-      fun = f;
-      jac = 0;
-    }
+    : fun (f), jac (0) { }
 
   DAEFunc (DAERHSFunc f, DAEJacFunc j)
-    {
-      fun = f;
-      jac = j;
-    }
+    : fun (f), jac (j) { }
 
   DAEFunc (const DAEFunc& a)
-    {
-      fun = a.fun;
-      jac = a.jac;
-    }
+    : fun (a.fun), jac (a.jac) { }
 
   DAEFunc& operator = (const DAEFunc& a)
     {
-      fun = a.fun;
-      jac = a.jac;
-
+      if (this != &a)
+	{
+	  fun = a.fun;
+	  jac = a.jac;
+	}
       return *this;
     }
 
+  ~DAEFunc (void) { }
+
   DAERHSFunc function (void) const { return fun; }
 
   DAEFunc& set_function (DAERHSFunc f)
--- a/liboctave/DASSL.h	Sun Feb 04 11:28:40 1996 +0000
+++ b/liboctave/DASSL.h	Sun Feb 04 11:35:56 1996 +0000
@@ -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: