# HG changeset patch # User jwe # Date 812870539 0 # Node ID db1a54941d529ddb69e090a5504552a16f86e33a # Parent 479ee97c85c651a850a8d03e772c86b4baeb7968 [project @ 1995-10-05 05:22:01 by jwe] diff --git a/liboctave/NLEqn.h b/liboctave/NLEqn.h --- a/liboctave/NLEqn.h +++ b/liboctave/NLEqn.h @@ -28,32 +28,49 @@ #pragma interface #endif +#include +#include + #include "dColVector.h" #include "NLFunc.h" -#ifndef Vector -#define Vector ColumnVector -#endif - class NLEqn_options { public: - NLEqn_options (void); - NLEqn_options (const NLEqn_options& opt); + NLEqn_options (void) { init (); } + + NLEqn_options (const NLEqn_options& opt) { copy (opt); } - NLEqn_options& operator = (const NLEqn_options& opt); + NLEqn_options& operator = (const NLEqn_options& opt) + { + if (this != &opt) + copy (opt); - ~NLEqn_options (void); + return *this; + } + + ~NLEqn_options (void) { } - void init (void); - void copy (const NLEqn_options& opt); + void init (void) + { + double sqrt_eps = sqrt (DBL_EPSILON); + x_tolerance = sqrt_eps; + } - void set_default_options (void); + void copy (const NLEqn_options& opt) + { + x_tolerance = opt.x_tolerance; + } + + void set_default_options (void) { init (); } - void set_tolerance (double); + void set_tolerance (double val) + { + x_tolerance = (val > 0.0) ? val : sqrt (DBL_EPSILON); + } - double tolerance (void); + double tolerance (void) { return x_tolerance; } private: @@ -64,31 +81,64 @@ { public: - NLEqn (void); - NLEqn (const Vector&, const NLFunc); +// Constructors + + NLEqn (void) : NLFunc (), n (0), x () { } + + NLEqn (const ColumnVector& xvec, const NLFunc f) + : NLFunc (f), n (xvec.capacity ()), x (xvec) { } + + NLEqn (const NLEqn& a) : NLFunc (a.fun, a.jac), n (a.n), x (a.x) { } - NLEqn (const NLEqn &); + NLEqn& operator = (const NLEqn& a) + { + fun = a.fun; + jac = a.jac; + x = a.n; + + return *this; + } - NLEqn& operator = (const NLEqn& a); - - void resize (int); + void resize (int nn) + { + if (n != nn) + { + n = nn; + x.resize (n); + } + } - void set_states (const Vector&); + void set_states (const ColumnVector&); + + ColumnVector states (void) const { return x; } + + int size (void) const { return n; } - Vector states (void) const; - - int size (void) const; + ColumnVector solve (void) + { + int info; + return solve (info); + } - Vector solve (void); - Vector solve (const Vector&); + ColumnVector solve (const ColumnVector& xvec) + { + set_states (xvec); + int info; + return solve (info); + } - Vector solve (int& info); - Vector solve (const Vector&, int& info); + ColumnVector solve (const ColumnVector& xvec, int& info) + { + set_states (xvec); + return solve (info); + } + + ColumnVector solve (int& info); private: int n; - Vector x; + ColumnVector x; void error (const char* msg); }; diff --git a/liboctave/QLD.cc b/liboctave/QLD.cc --- a/liboctave/QLD.cc +++ b/liboctave/QLD.cc @@ -47,16 +47,16 @@ int&, int*, int&); } -Vector +ColumnVector QLD::minimize (double& objf, int& inform) { int n = x.capacity (); Matrix A1 = lc.eq_constraint_matrix (); - Vector b1 = lc.eq_constraint_vector (); + ColumnVector b1 = lc.eq_constraint_vector (); Matrix A2 = lc.ineq_constraint_matrix (); - Vector b2 = lc.ineq_constraint_vector (); + ColumnVector b2 = lc.ineq_constraint_vector (); int me = A1.rows (); int m = me + A2.rows (); @@ -99,8 +99,8 @@ if (b1.capacity () > 0) pb = b1.fortran_vec (); - Vector xlb = bnds.lower_bounds (); - Vector xub = bnds.upper_bounds (); + ColumnVector xlb = bnds.lower_bounds (); + ColumnVector xub = bnds.upper_bounds (); if (xlb.capacity () <= 0) { xlb.resize (n, -1.0e30); diff --git a/src/quad.cc b/src/quad.cc --- a/src/quad.cc +++ b/src/quad.cc @@ -161,8 +161,8 @@ double val = 0.0; double abstol = 1e-6; double reltol = 1e-6; - Vector tol (2); - Vector sing; + ColumnVector tol (2); + ColumnVector sing; int have_sing = 0; switch (nargin) {