changeset 1861:620a65533630

[project @ 1996-02-04 10:17:34 by jwe]
author jwe
date Sun, 04 Feb 1996 10:26:22 +0000
parents 821870c30840
children 58b42823284f
files liboctave/ODE.h liboctave/ODEFunc.h liboctave/Objective.h liboctave/QLD.cc liboctave/QLD.h liboctave/QP.h
diffstat 6 files changed, 94 insertions(+), 72 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ODE.h	Sun Feb 04 10:06:30 1996 +0000
+++ b/liboctave/ODE.h	Sun Feb 04 10:26:22 1996 +0000
@@ -27,7 +27,8 @@
 #include "ODEFunc.h"
 #include "base-de.h"
 
-class ODE : public base_diff_eqn, public ODEFunc
+class
+ODE : public base_diff_eqn, public ODEFunc
 {
 public:
 
--- a/liboctave/ODEFunc.h	Sun Feb 04 10:06:30 1996 +0000
+++ b/liboctave/ODEFunc.h	Sun Feb 04 10:26:22 1996 +0000
@@ -27,7 +27,8 @@
 class Matrix;
 class ColumnVector;
 
-class ODEFunc
+class
+ODEFunc
 {
 public:
 
@@ -56,6 +57,8 @@
       return *this;
     }
 
+  ~ODEFunc (void) { }
+
   ODERHSFunc function (void) const { return fun; }
 
   ODEFunc& set_function (ODERHSFunc f)
@@ -75,7 +78,6 @@
 protected:
 
   ODERHSFunc fun;
-
   ODEJacFunc jac;
 };
 
--- a/liboctave/Objective.h	Sun Feb 04 10:06:30 1996 +0000
+++ b/liboctave/Objective.h	Sun Feb 04 10:26:22 1996 +0000
@@ -1,7 +1,7 @@
 // Objective.h                                          -*- C++ -*-
 /*
 
-Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton
+Copyright (C) 1996 John W. Eaton
 
 This file is part of Octave.
 
@@ -26,45 +26,38 @@
 
 #include "dColVector.h"
 
-class Objective
+class
+Objective
 {
- public:
+public:
 
   typedef double (*objective_fcn) (const ColumnVector&);
   typedef ColumnVector (*gradient_fcn) (const ColumnVector&);
 
   Objective (void)
-    {
-      phi = 0;
-      grad = 0;
-    }
+    : phi (0), grad (0) { }
 
   Objective (const objective_fcn obj)
-    {
-      phi = obj;
-      grad = 0;
-    }
+    : phi (obj), grad (0) { }
 
   Objective (const objective_fcn obj, const gradient_fcn g)
-    {
-      phi = obj;
-      grad = g;
-    }
+    : phi (obj), grad (g) { }
 
   Objective (const Objective& a)
-    {
-      phi = a.phi;
-      grad = a.grad;
-    }
+    : phi (a.phi), grad (a.grad) { }
 
   Objective& operator = (const Objective& a)
     {
-      phi = a.phi;
-      grad = a.grad;
-
+      if (this != &a)
+	{
+	  phi = a.phi;
+	  grad = a.grad;
+	}
       return *this;
     }
 
+  ~Objective (void) { }
+
   objective_fcn objective_function (void) const { return phi; }
 
   Objective& set_objective_function (const objective_fcn obj)
@@ -81,7 +74,7 @@
       return *this;
     }
 
- private:
+private:
 
   objective_fcn phi;
   gradient_fcn grad;
--- a/liboctave/QLD.cc	Sun Feb 04 10:06:30 1996 +0000
+++ b/liboctave/QLD.cc	Sun Feb 04 10:26:22 1996 +0000
@@ -127,12 +127,6 @@
   return x;
 }
 
-void
-QLD::set_default_options (void)
-{
-  iprint = 0;
-}
-
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***
--- a/liboctave/QLD.h	Sun Feb 04 10:06:30 1996 +0000
+++ b/liboctave/QLD.h	Sun Feb 04 10:26:22 1996 +0000
@@ -1,7 +1,7 @@
 // QLD.h                                                -*- C++ -*-
 /*
 
-Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton
+Copyright (C) 1996 John W. Eaton
 
 This file is part of Octave.
 
@@ -33,58 +33,62 @@
 
 #include "QP.h"
 
-class QLD : public QP
+class
+QLD : public QP
 {
- public:
+public:
 
-  QLD (void) : QP ()
-    { set_default_options (); }
+  QLD (void)
+    : QP (), iprint (0) { }
 
-  QLD (const ColumnVector& x, const Matrix& H) : QP (x, H)
-    { set_default_options (); }
+  QLD (const ColumnVector& x, const Matrix& H)
+    : QP (x, H), iprint (0) { }
 
   QLD (const ColumnVector& x, const Matrix& H, const ColumnVector& c)
-    : QP (x, H, c) { set_default_options (); }
+    : QP (x, H, c), iprint (0) { }
 
-  QLD (const ColumnVector& x, const Matrix& H, const Bounds& b) : QP (x, H, b)
-    { set_default_options (); }
+  QLD (const ColumnVector& x, const Matrix& H, const Bounds& b)
+    : QP (x, H, b), iprint (0) { }
 
   QLD (const ColumnVector& x, const Matrix& H, const LinConst& lc)
-    : QP (x, H, lc)
-      { set_default_options (); }
+    : QP (x, H, lc), iprint (0) { }
 
   QLD (const ColumnVector& x, const Matrix& H, const ColumnVector& c,
-       const Bounds& b) : QP (x, H, c, b) { set_default_options (); }
+       const Bounds& b)
+    : QP (x, H, c, b), iprint (0) { }
 
   QLD (const ColumnVector& x, const Matrix& H, const ColumnVector& c,
-       const LinConst& lc) : QP (x, H, c, lc) { set_default_options (); }
+       const LinConst& lc)
+    : QP (x, H, c, lc), iprint (0) { }
 
   QLD (const ColumnVector& x, const Matrix& H, const Bounds& b,
-       const LinConst& lc) : QP (x, H, b, lc) { set_default_options (); }
+       const LinConst& lc)
+    : QP (x, H, b, lc), iprint (0) { }
 
   QLD (const ColumnVector& x, const Matrix& H, const ColumnVector& c,
-       const Bounds& b, const LinConst& lc) : QP (x, H, c, b, lc)
-   { set_default_options (); }
+       const Bounds& b, const LinConst& lc)
+    : QP (x, H, c, b, lc), iprint (0) { }
 
-  QLD (const QLD& a) : QP (a.x, a.H, a.c, a.bnds, a.lc)
-    { set_default_options (); }
+  QLD (const QLD& a)
+    : QP (a.x, a.H, a.c, a.bnds, a.lc), iprint (0) { }
 
   QLD& operator = (const QLD& a)
     {
-      x = a.x;
-      H = a.H;
-      c = a.c;
-      bnds = a.bnds;
-      lc = a.lc;
-      iprint = a.iprint;
+      if (this != &a)
+	{
+	  QP::operator = (a);
 
+	  iprint = a.iprint;
+	}
       return *this;
     }
 
+  ~QLD (void) { }
+
   ColumnVector minimize (double& objf, int& inform);
 
 private:
-  void set_default_options (void);
+
   int iprint;
 };
 
--- a/liboctave/QP.h	Sun Feb 04 10:06:30 1996 +0000
+++ b/liboctave/QP.h	Sun Feb 04 10:26:22 1996 +0000
@@ -1,7 +1,7 @@
 // QP.h                                                -*- C++ -*-
 /*
 
-Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton
+Copyright (C) 1996 John W. Eaton
 
 This file is part of Octave.
 
@@ -30,41 +30,43 @@
 #include "LinConst.h"
 #include "base-min.h"
 
-class QP : public base_minimizer
+class
+QP : public base_minimizer
 {
- public:
+public:
 
-  QP (void) : base_minimizer () { }
+  QP (void)
+    : base_minimizer (), H (), c (), bnds (), lc () { }
 
   QP (const ColumnVector& x, const Matrix& H_arg)
-    : base_minimizer (x), H (H_arg)
+    : base_minimizer (x), H (H_arg), c (), bnds (), lc ()
       { make_h_symmetric (); }
 
   QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg)
-    : base_minimizer (x), H (H_arg), c (c_arg)
+    : base_minimizer (x), H (H_arg), c (c_arg), bnds (), lc ()
       { make_h_symmetric (); }
 
   QP (const ColumnVector& x, const Matrix& H_arg, const Bounds& b)
-    : base_minimizer (x), H (H_arg), bnds (b)
+    : base_minimizer (x), H (H_arg), c (), bnds (b), lc ()
       { make_h_symmetric (); }
 
   QP (const ColumnVector& x, const Matrix& H_arg, const LinConst& l)
-    : base_minimizer (x), H (H_arg), lc (l)
+    : base_minimizer (x), H (H_arg), lc (l), bnds (), lc ()
       { make_h_symmetric (); }
 
   QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg,
       const Bounds& b)
-    : base_minimizer (x), H (H_arg), c (c_arg), bnds (b)
+    : base_minimizer (x), H (H_arg), c (c_arg), bnds (b), lc ()
       { make_h_symmetric (); }
 
   QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg,
       const LinConst& l)
-    : base_minimizer (x), H (H_arg), c (c_arg), lc (l)
+    : base_minimizer (x), H (H_arg), c (c_arg), bnds (), lc (l)
       { make_h_symmetric (); }
 
   QP (const ColumnVector& x, const Matrix& H_arg, const Bounds& b,
       const LinConst& l)
-    : base_minimizer (x), H (H_arg), bnds (b), lc (l)
+    : base_minimizer (x), H (H_arg), c (), bnds (b), lc (l)
       { make_h_symmetric (); }
 
   QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg,
@@ -72,17 +74,43 @@
     : base_minimizer (x), H (H_arg), c (c_arg), bnds (b), lc (l)
       { make_h_symmetric (); }
 
+  QP (const QP& qp)
+    : base_minimizer (qp), H (qp.H), c (qp.c), bnds (qp.bnds), lc (qp.lc) { }
+
+  QP& operator = (const QP& qp)
+    {
+      if (this != &qp)
+	{
+	  base_minimizer::operator = (qp);
+
+	  H = qp.H;
+	  c = qp.c;
+	  bnds = qp.bnds;
+	  lc = qp.lc;
+	}
+      return *this;
+    }
+
+  ~QP (void) { }
+
+  Matrix hessian (void) const { return H; }
+
+  ColumnVector linear_obj_coeff (void) const { return c; }
+
+  Bounds bounds (void) const { return bnds; }
+
+  LinConst linear_constraints (void) const { return lc; }
+
   virtual ~QP (void) { }
 
- protected:
+protected:
 
-  ColumnVector x;
   Matrix H;  
   ColumnVector c;
   Bounds bnds;
   LinConst lc;
 
- private:
+private:
 
   Matrix make_h_symmetric (void) { return 0.5 * (H + H.transpose ()); }
 };