changeset 1865:0e095fed283c

[project @ 1996-02-04 10:53:09 by jwe]
author jwe
date Sun, 04 Feb 1996 10:54:46 +0000
parents e1c4dd0d503d
children b6c48195b552
files liboctave/NLConst.h liboctave/NLEqn.h
diffstat 2 files changed, 46 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/NLConst.h
+++ b/liboctave/NLConst.h
@@ -1,7 +1,7 @@
 // NLConst.h                                              -*- C++ -*-
 /*
 
-Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton
+Copyright (C) 1996 John W. Eaton
 
 This file is part of Octave.
 
@@ -33,34 +33,38 @@
 #include "Bounds.h"
 #include "NLFunc.h"
 
-class NLConst : public Bounds, public NLFunc
+class
+NLConst : public Bounds, public NLFunc
 {
 public:
 
-  NLConst (void) : Bounds (), NLFunc () { }
+  NLConst (void)
+    : Bounds (), NLFunc () { }
 
-  NLConst (int n) : Bounds (n), NLFunc () { }
+  NLConst (int n)
+    : Bounds (n), NLFunc () { }
 
   NLConst (const ColumnVector& lb, const NLFunc f, const ColumnVector& ub)
     : Bounds (lb, ub), NLFunc (f) { }
 
-  NLConst (const NLConst& a) : Bounds (a.lb, a.ub), NLFunc (a.fun, a.jac) { }
+  NLConst (const NLConst& a)
+    : Bounds (a.lb, a.ub), NLFunc (a.fun, a.jac) { }
 
   NLConst& operator = (const NLConst& a)
     {
-      nb = a.nb;
-      lb = a.lb;
-      fun = a.fun;
-      jac = a.jac;
-      ub = a.ub;
-
+      if (this != &a)
+	{
+	  Bounds::operator = (a);
+	  NLFunc::operator = (a);
+	}
       return *this;
     }
 
+  ~NLConst (void) { }
+
 private:
 
   void error (const char *msg);
-
 };
 
 #endif
--- a/liboctave/NLEqn.h
+++ b/liboctave/NLEqn.h
@@ -1,7 +1,7 @@
 // NLEqn.h                                                -*- C++ -*-
 /*
 
-Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton
+Copyright (C) 1996 John W. Eaton
 
 This file is part of Octave.
 
@@ -34,85 +34,72 @@
 #include "dColVector.h"
 #include "NLFunc.h"
 
-class NLEqn_options
+class
+NLEqn_options
 {
- public:
+public:
 
-  NLEqn_options (void) { init (); }
+  NLEqn_options (void)
+    : x_tolerance (::sqrt (DBL_EPSILON)) { }
 
-  NLEqn_options (const NLEqn_options& opt) { copy (opt); }
+  NLEqn_options (const NLEqn_options& opt)
+    : x_tolerance (opt.x_tolerance) { }
 
   NLEqn_options& operator = (const NLEqn_options& opt)
     {
       if (this != &opt)
-	copy (opt);
+	x_tolerance = opt.x_tolerance;
 
       return *this;
     }
 
   ~NLEqn_options (void) { }
 
-  void init (void)
-    {
-      double sqrt_eps = sqrt (DBL_EPSILON);
-      x_tolerance = sqrt_eps;
-    }
-
-  void copy (const NLEqn_options& opt)
-    {
-      x_tolerance = opt.x_tolerance;
-    }
-
-  void set_default_options (void) { init (); }
+  void set_default_options (void) { x_tolerance = ::sqrt (DBL_EPSILON); }
 
   void set_tolerance (double val)
-    {
-      x_tolerance = (val > 0.0) ? val : sqrt (DBL_EPSILON);
-    }
+    { x_tolerance = (val > 0.0) ? val : ::sqrt (DBL_EPSILON); }
 
   double tolerance (void) { return x_tolerance; }
 
- private:
+private:
 
   double x_tolerance;
 };
 
-class NLEqn : public NLFunc, public NLEqn_options
+class
+NLEqn : public NLFunc, public NLEqn_options
 {
- public:
-
-// Constructors
+public:
 
-  NLEqn (void) : NLFunc (), n (0), x () { }
+  NLEqn (void)
+    : NLFunc (), NLEqn_options (), x () { }
 
-  NLEqn (const ColumnVector& xvec, const NLFunc f) 
-    : NLFunc (f), n (xvec.capacity ()), x (xvec) { }
+  NLEqn (const ColumnVector& xx, const NLFunc f) 
+    : NLFunc (f), NLEqn_options (), x (xx) { }
 
-  NLEqn (const NLEqn& a) : NLFunc (a.fun, a.jac), n (a.n), x (a.x) { }
+  NLEqn (const NLEqn& a)
+    : NLFunc (a.fun, a.jac), NLEqn_options (), x (a.x) { }
 
   NLEqn& operator = (const NLEqn& a)
     {
-      fun = a.fun;
-      jac = a.jac;
-      x = a.n;
+      if (this != &a)
+	{
+	  NLFunc::operator = (a);
+	  NLEqn_options::operator = (a);
 
+	  x = a.x;
+	}
       return *this;
     }
 
-  void resize (int nn)
-    {
-      if (n != nn)
-	{
-	  n = nn;
-	  x.resize (n);
-	}
-    }
+  ~NLEqn (void) { }
 
-  void set_states (const ColumnVector&);
+  void set_states (const ColumnVector& xx) { x = xx; }
 
   ColumnVector states (void) const { return x; }
 
-  int size (void) const { return n; }
+  int size (void) const { return x.capacity (); }
 
   ColumnVector solve (void)
     {
@@ -137,7 +124,6 @@
 
  private:
 
-  int n;
   ColumnVector x;
 
   void error (const char* msg);