changeset 1536:26411f9c7603

[project @ 1995-10-05 05:41:26 by jwe]
author jwe
date Thu, 05 Oct 1995 05:51:20 +0000
parents 5f3f07b6db89
children 3b6474ef546f
files liboctave/DAE.h liboctave/FSQP.h liboctave/LP.h liboctave/LinConst.h liboctave/Makefile.in liboctave/NLEqn.cc liboctave/NLFunc.h liboctave/NPSOL.cc liboctave/ODEFunc.h liboctave/Objective.h liboctave/QLD.h liboctave/QPSOL.h liboctave/Quad.h liboctave/base-min.h
diffstat 14 files changed, 133 insertions(+), 230 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/DAE.h	Thu Oct 05 05:38:26 1995 +0000
+++ b/liboctave/DAE.h	Thu Oct 05 05:51:20 1995 +0000
@@ -32,10 +32,6 @@
 #include "ODE.h"
 #include "DAEFunc.h"
 
-#ifndef Vector
-#define Vector ColumnVector
-#endif
-
 class DAE : public ODE, public DAEFunc
 {
 public:
@@ -44,29 +40,31 @@
 
   DAE (int);
 
-  DAE (const Vector& x, double time, DAEFunc& f);
+  DAE (const ColumnVector& x, double time, DAEFunc& f);
 
-  DAE (const Vector& x, const Vector& xdot, double time, DAEFunc& f);
+  DAE (const ColumnVector& x, const ColumnVector& xdot,
+       double time, DAEFunc& f);
 
  ~DAE (void);
 
-  Vector deriv (void);
+  ColumnVector deriv (void);
 
-  virtual void initialize (const Vector& x, double t);
-  virtual void initialize (const Vector& x, const Vector& xdot, double t);
+  virtual void initialize (const ColumnVector& x, double t);
+  virtual void initialize (const ColumnVector& x,
+			   const ColumnVector& xdot, double t);
 
-  Vector integrate (double t);
+  ColumnVector integrate (double t);
 
-  Matrix integrate (const Vector& tout, Matrix& xdot_out);
-  Matrix integrate (const Vector& tout, Matrix& xdot_out,
-		    const Vector& tcrit); 
+  Matrix integrate (const ColumnVector& tout, Matrix& xdot_out);
+  Matrix integrate (const ColumnVector& tout, Matrix& xdot_out,
+		    const ColumnVector& tcrit); 
 
 protected:
 
   // Some of this is probably too closely related to DASSL, but hey,
   // this is just a first attempt...
 
-  Vector xdot;
+  ColumnVector xdot;
 
 private:
 
--- a/liboctave/FSQP.h	Thu Oct 05 05:38:26 1995 +0000
+++ b/liboctave/FSQP.h	Thu Oct 05 05:51:20 1995 +0000
@@ -32,10 +32,6 @@
 
 #include "NLP.h"
 
-#ifndef Vector
-#define Vector ColumnVector
-#endif
-
 class FSQP : public NLP
 {
  public:
--- a/liboctave/LP.h	Thu Oct 05 05:38:26 1995 +0000
+++ b/liboctave/LP.h	Thu Oct 05 05:51:20 1995 +0000
@@ -24,10 +24,6 @@
 #if !defined (octave_LP_h)
 #define octave_LP_h 1
 
-#if defined (__GNUG__)
-#pragma interface
-#endif
-
 #include "dColVector.h"
 #include "Bounds.h"
 #include "LinConst.h"
--- a/liboctave/LinConst.h	Thu Oct 05 05:38:26 1995 +0000
+++ b/liboctave/LinConst.h	Thu Oct 05 05:51:20 1995 +0000
@@ -37,10 +37,6 @@
 #include "dMatrix.h"
 #include "Bounds.h"
 
-#ifndef Vector
-#define Vector ColumnVector
-#endif
-
 class LinConst : public Bounds
 {
 public:
@@ -51,15 +47,15 @@
   LinConst (int eq, int ineq, int n)
     : Bounds (eq+ineq), A (nb, n) {}
 
-  LinConst (const Vector& l, const Matrix& amat, const Vector& u)
+  LinConst (const ColumnVector& l, const Matrix& amat, const ColumnVector& u)
     : Bounds (l, u), A (amat)
       {
 	if (nb != amat.rows ())
 	  error ("inconsistent sizes for constraint matrix and bounds vectors");
       }
 
-  LinConst (const Matrix& A_eq, const Vector& b_eq,
-	    const Matrix& A_ineq, const Vector& b_ineq);
+  LinConst (const Matrix& A_eq, const ColumnVector& b_eq,
+	    const Matrix& A_ineq, const ColumnVector& b_ineq);
 
   LinConst (const LinConst& a)
     : Bounds (a.lb, a.ub), A (a.constraint_matrix ()) {}
@@ -91,8 +87,8 @@
   Matrix eq_constraint_matrix (void) const;
   Matrix ineq_constraint_matrix (void) const;
 
-  Vector eq_constraint_vector (void) const;
-  Vector ineq_constraint_vector (void) const;
+  ColumnVector eq_constraint_vector (void) const;
+  ColumnVector ineq_constraint_vector (void) const;
 
   friend ostream& operator << (ostream& os, const LinConst& b);
 
--- a/liboctave/Makefile.in	Thu Oct 05 05:38:26 1995 +0000
+++ b/liboctave/Makefile.in	Thu Oct 05 05:51:20 1995 +0000
@@ -44,8 +44,8 @@
 	dbleLU.cc dbleQR.cc dbleQRP.cc dbleSCHUR.cc dbleSVD.cc
 
 SOURCES = Bounds.cc CollocWt.cc DAE.cc FEGrid.cc FSQP.cc LinConst.cc \
-	LPsolve.cc NLEqn.cc NPSOL.cc Objective.cc ODE.cc QLD.cc \
-	QPSOL.cc Quad.cc Range.cc lo-error.cc sun-utils.cc \
+	LPsolve.cc NLEqn.cc NPSOL.cc ODE.cc QLD.cc QPSOL.cc Quad.cc \
+	Range.cc lo-error.cc sun-utils.cc \
 	$(TEMPLATE_SRC) \
 	$(TI_SRC) \
 	$(MATRIX_SRC)
--- a/liboctave/NLEqn.cc	Thu Oct 05 05:38:26 1995 +0000
+++ b/liboctave/NLEqn.cc	Thu Oct 05 05:51:20 1995 +0000
@@ -29,9 +29,6 @@
 #include <config.h>
 #endif
 
-#include <cfloat>
-#include <cmath>
-
 #include "NLEqn.h"
 #include "dMatrix.h"
 #include "f77-uscore.h"
@@ -51,8 +48,8 @@
 				double*, const int&);
 }
 
-static nonlinear_fcn user_fun;
-static jacobian_fcn user_jac;
+static NLFunc::nonlinear_fcn user_fun;
+static NLFunc::jacobian_fcn user_jac;
 
 // error handling
 
@@ -62,51 +59,8 @@
   (*current_liboctave_error_handler) ("fatal NLEqn error: %s", msg);
 }
 
-// Constructors
-
-NLEqn::NLEqn (void) : NLFunc (), n (0), x () { }
-
-NLEqn::NLEqn (const Vector& xvec, const NLFunc f) 
-  : NLFunc (f), n (xvec.capacity ()), x (xvec) { }
-
-NLEqn::NLEqn (const NLEqn& a) : NLFunc (a.fun, a.jac), n (a.n), x (a.x) { }
-
 void
-NLEqn::resize (int nn)
-{
-  if (n != nn)
-    {
-      n = nn;
-      x.resize (n);
-    }
-}
-
-int
-NLEqn::size (void) const
-{
-  return n;
-}
-
-// Assignment
-
-NLEqn&
-NLEqn::operator = (const NLEqn& a)
-{
-  fun = a.fun;
-  jac = a.jac;
-  x = a.n;
-
-  return *this;
-}
-
-Vector
-NLEqn::states (void) const
-{
-  return x;
-}
-
-void
-NLEqn::set_states (const Vector& xvec)
+NLEqn::set_states (const ColumnVector& xvec)
 {
   if (xvec.capacity () != n)
     {
@@ -119,34 +73,12 @@
 
 // Other operations
 
-Vector
-NLEqn::solve (const Vector& xvec)
-{
-  set_states (xvec);
-  int info;
-  return solve (info);
-}
-
-Vector
-NLEqn::solve (const Vector& xvec, int& info)
-{
-  set_states (xvec);
-  return solve (info);
-}
-
-Vector
-NLEqn::solve (void)
-{
-  int info;
-  return solve (info);
-}
-
 int
 hybrd1_fcn (int *n, double *x, double *fvec, int *iflag)
 {
   int nn = *n;
-  Vector tmp_f (nn);
-  Vector tmp_x (nn);
+  ColumnVector tmp_f (nn);
+  ColumnVector tmp_x (nn);
 
   for (int i = 0; i < nn; i++)
     tmp_x.elem (i) = x[i];
@@ -169,7 +101,7 @@
 	    int *ldfjac, int *iflag)
 {
   int nn = *n;
-  Vector tmp_x (nn);
+  ColumnVector tmp_x (nn);
 
   for (int i = 0; i < nn; i++)
     tmp_x.elem (i) = x[i];
@@ -177,7 +109,7 @@
   int flag = *iflag;
   if (flag == 1)
     {
-      Vector tmp_f (nn);
+      ColumnVector tmp_f (nn);
 
       tmp_f = (*user_fun) (tmp_x);
 
@@ -209,13 +141,15 @@
   return 0;
 }
 
-Vector
+ColumnVector
 NLEqn::solve (int& info)
 {
+  ColumnVector retval;
+
   if (n == 0)
     {
       error ("equation set not initialized");
-      return Vector ();
+      return retval;
     }
 
   double tol = tolerance ();
@@ -251,8 +185,6 @@
       delete [] wa;
     }
 
-  Vector retval;
-
   if (info >= 0)
     {
       retval.resize (n);
@@ -267,60 +199,6 @@
   return retval;
 }
 
-NLEqn_options::NLEqn_options (void)
-{
-  init ();
-}
-
-NLEqn_options::NLEqn_options (const NLEqn_options& opt)
-{
-  copy (opt);
-}
-
-NLEqn_options&
-NLEqn_options::operator = (const NLEqn_options& opt)
-{
-  if (this != &opt)
-    copy (opt);
-
-  return *this;
-}
-
-NLEqn_options::~NLEqn_options (void)
-{
-}
-
-void
-NLEqn_options::init (void)
-{
-  double sqrt_eps = sqrt (DBL_EPSILON);
-  x_tolerance = sqrt_eps;
-}
-
-void
-NLEqn_options::copy (const NLEqn_options& opt)
-{
-  x_tolerance = opt.x_tolerance;
-}
-
-void
-NLEqn_options::set_default_options (void)
-{
-  init ();
-}
-
-void
-NLEqn_options::set_tolerance (double val)
-{
-  x_tolerance = (val > 0.0) ? val : sqrt (DBL_EPSILON);
-}
-
-double
-NLEqn_options::tolerance (void)
-{
-  return x_tolerance;
-}
-
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***
--- a/liboctave/NLFunc.h	Thu Oct 05 05:38:26 1995 +0000
+++ b/liboctave/NLFunc.h	Thu Oct 05 05:51:20 1995 +0000
@@ -24,20 +24,16 @@
 #if !defined (octave_NLFunc_h)
 #define octave_NLFunc_h 1
 
-#if defined (__GNUG__)
-#pragma interface
-#endif
-
 class ColumnVector;
 class Matrix;
 
-typedef ColumnVector (*nonlinear_fcn) (const ColumnVector&);
-typedef Matrix (*jacobian_fcn) (const ColumnVector&);
-
 class NLFunc
 {
 public:
 
+  typedef ColumnVector (*nonlinear_fcn) (const ColumnVector&);
+  typedef Matrix (*jacobian_fcn) (const ColumnVector&);
+
   NLFunc (void)
     {
       fun = 0;
--- a/liboctave/NPSOL.cc	Thu Oct 05 05:38:26 1995 +0000
+++ b/liboctave/NPSOL.cc	Thu Oct 05 05:51:20 1995 +0000
@@ -64,10 +64,10 @@
 // function, and the user wants us to quit.
 int npsol_objective_error = 0;
 
-static objective_fcn user_phi;
-static gradient_fcn user_grad;
-static nonlinear_fcn user_g;
-static jacobian_fcn user_jac;
+static Objective::objective_fcn user_phi;
+static Objective::gradient_fcn user_grad;
+static NLFunc::nonlinear_fcn user_g;
+static NLFunc::jacobian_fcn user_jac;
 
 int
 npsol_objfun (int& mode, const int& n, double *xx, double *objf,
--- a/liboctave/ODEFunc.h	Thu Oct 05 05:38:26 1995 +0000
+++ b/liboctave/ODEFunc.h	Thu Oct 05 05:51:20 1995 +0000
@@ -24,39 +24,63 @@
 #if !defined (octave_ODEFunc_h)
 #define octave_ODEFunc_h 1
 
-#if defined (__GNUG__)
-#pragma interface
-#endif
-
 class Matrix;
 class ColumnVector;
 
-#ifndef Vector
-#define Vector ColumnVector
-#endif
-
 class ODEFunc
 {
 public:
 
-  typedef Vector (*ODERHSFunc) (const Vector&, double);
-  typedef Matrix (*ODEJacFunc) (const Vector&, double);
+  typedef ColumnVector (*ODERHSFunc) (const ColumnVector&, double);
+  typedef Matrix (*ODEJacFunc) (const ColumnVector&, double);
+
+  ODEFunc (void)
+    {
+      fun = 0;
+      jac = 0;
+    }
 
-  ODEFunc (void);
-  ODEFunc (ODERHSFunc f);
-  ODEFunc (ODERHSFunc f, ODEJacFunc j);
+  ODEFunc (ODERHSFunc f)
+    {
+      fun = f;
+      jac = 0;
+    }
 
-  ODEFunc (const ODEFunc& a);
+  ODEFunc (ODERHSFunc f, ODEJacFunc j)
+    {
+      fun = f;
+      jac = j;
+    }
 
-  ODEFunc& operator = (const ODEFunc& a);
+  ODEFunc (const ODEFunc& a)
+    {
+      fun = a.function ();
+      jac = a.jacobian_function ();
+    }
 
-  ODERHSFunc function (void) const;
+  ODEFunc& operator = (const ODEFunc& a)
+    {
+      fun = a.function ();
+      jac = a.jacobian_function ();
+
+      return *this;
+    }
 
-  ODEFunc& set_function (ODERHSFunc f);
+  ODERHSFunc function (void) const { return fun; }
+
+  ODEFunc& set_function (ODERHSFunc f)
+    {
+      fun = f;
+      return *this;
+    }
 
-  ODEJacFunc jacobian_function (void) const;
+  ODEJacFunc jacobian_function (void) const { return jac; }
 
-  ODEFunc& set_jacobian_function (ODEJacFunc j);
+  ODEFunc& set_jacobian_function (ODEJacFunc j)
+    {
+      jac = j;
+      return *this;
+    }
 
 protected:
 
--- a/liboctave/Objective.h	Thu Oct 05 05:38:26 1995 +0000
+++ b/liboctave/Objective.h	Thu Oct 05 05:51:20 1995 +0000
@@ -24,38 +24,62 @@
 #if !defined (octave_Objective_h)
 #define octave_Objective_h 1
 
-#if defined (__GNUG__)
-#pragma interface
-#endif
-
 #include "dColVector.h"
 
-#ifndef Vector
-#define Vector ColumnVector
-#endif
-
-typedef double (*objective_fcn) (const Vector&);
-typedef Vector (*gradient_fcn) (const Vector&);
-
 class Objective
 {
  public:
 
-  Objective (void);
-  Objective (const objective_fcn);
-  Objective (const objective_fcn, const gradient_fcn);
+  typedef double (*objective_fcn) (const ColumnVector&);
+  typedef ColumnVector (*gradient_fcn) (const ColumnVector&);
+
+  Objective (void)
+    {
+      phi = 0;
+      grad = 0;
+    }
 
-  Objective (const Objective& a);
+  Objective (const objective_fcn obj)
+    {
+      phi = obj;
+      grad = 0;
+    }
 
-  Objective& operator = (const Objective& a);
+  Objective (const objective_fcn obj, const gradient_fcn g)
+    {
+      phi = obj;
+      grad = g;
+    }
 
-  objective_fcn objective_function (void) const;
+  Objective (const Objective& a)
+    {
+      phi = a.phi;
+      grad = a.grad;
+    }
 
-  Objective& set_objective_function (const objective_fcn);
+  Objective& operator = (const Objective& a)
+    {
+      phi = a.phi;
+      grad = a.grad;
+
+      return *this;
+    }
 
-  gradient_fcn gradient_function (void) const;
+  objective_fcn objective_function (void) const { return phi; }
+
+  Objective& set_objective_function (const objective_fcn obj)
+    {
+      phi = obj;
+      return *this;
+    }
 
-  Objective& set_gradient_function (const gradient_fcn);
+  gradient_fcn gradient_function (void) const { return grad; }
+
+  Objective& set_gradient_function (const gradient_fcn g)
+    {
+      grad = g;
+      return *this;
+    }
 
  private:
 
--- a/liboctave/QLD.h	Thu Oct 05 05:38:26 1995 +0000
+++ b/liboctave/QLD.h	Thu Oct 05 05:51:20 1995 +0000
@@ -33,10 +33,6 @@
 
 #include "QP.h"
 
-#ifndef Vector
-#define Vector ColumnVector
-#endif
-
 class QLD : public QP
 {
  public:
--- a/liboctave/QPSOL.h	Thu Oct 05 05:38:26 1995 +0000
+++ b/liboctave/QPSOL.h	Thu Oct 05 05:51:20 1995 +0000
@@ -34,10 +34,6 @@
 #include "dColVector.h"
 #include "QP.h"
 
-#ifndef Vector
-#define Vector ColumnVector
-#endif
-
 class QPSOL_options
 {
  public:
--- a/liboctave/Quad.h	Thu Oct 05 05:38:26 1995 +0000
+++ b/liboctave/Quad.h	Thu Oct 05 05:51:20 1995 +0000
@@ -28,6 +28,9 @@
 #pragma interface
 #endif
 
+#include <cfloat>
+#include <cmath>
+
 #include "dColVector.h"
 
 #if !defined (octave_Quad_typedefs)
--- a/liboctave/base-min.h	Thu Oct 05 05:38:26 1995 +0000
+++ b/liboctave/base-min.h	Thu Oct 05 05:51:20 1995 +0000
@@ -58,20 +58,20 @@
     {
       double objf;
       int inform;
-      Vector lambda;
+      ColumnVector lambda;
       return do_minimize (objf, inform, lambda);
     }
 
   virtual ColumnVector minimize (double& objf)
     {
       int inform;
-      Vector lambda;
+      ColumnVector lambda;
       return do_minimize (objf, inform, lambda);
     }
 
   virtual ColumnVector minimize (double& objf, int& inform)
     {
-      Vector lambda;
+      ColumnVector lambda;
       return do_minimize (objf, inform, lambda);
     }
 
@@ -86,7 +86,7 @@
       x = x0;
       double objf;
       int inform;
-      Vector lambda;
+      ColumnVector lambda;
       return do_minimize (objf, inform, lambda);
     }
 
@@ -94,7 +94,7 @@
     {
       x = x0;
       int inform;
-      Vector lambda;
+      ColumnVector lambda;
       return do_minimize (objf, inform, lambda);
     }
 
@@ -102,7 +102,7 @@
 				 int& inform)
     {
       x = x0;
-      Vector lambda;
+      ColumnVector lambda;
       return do_minimize (objf, inform, lambda);
     }