Mercurial > hg > octave-terminal
changeset 1531:db1a54941d52
[project @ 1995-10-05 05:22:01 by jwe]
author | jwe |
---|---|
date | Thu, 05 Oct 1995 05:22:19 +0000 |
parents | 479ee97c85c6 |
children | 8600f4f34aa9 |
files | liboctave/NLEqn.h liboctave/QLD.cc src/quad.cc |
diffstat | 3 files changed, 85 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/NLEqn.h +++ b/liboctave/NLEqn.h @@ -28,32 +28,49 @@ #pragma interface #endif +#include <cfloat> +#include <cmath> + #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); };
--- 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);