Mercurial > hg > octave-lyh
changeset 1949:4689b52b4c6f
[project @ 1996-02-14 04:27:57 by jwe]
author | jwe |
---|---|
date | Wed, 14 Feb 1996 04:28:46 +0000 |
parents | d7dec93d4b87 |
children | ab6abe89aaa1 |
files | src/npsol.cc src/qpsol.cc |
diffstat | 2 files changed, 34 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/npsol.cc +++ b/src/npsol.cc @@ -168,7 +168,7 @@ return retval; } -int +static int linear_constraints_ok (const ColumnVector& x, const ColumnVector& llb, const Matrix& c, const ColumnVector& lub, char *warn_for, int warn) @@ -199,7 +199,7 @@ return ok; } -int +static int nonlinear_constraints_ok (const ColumnVector& x, const ColumnVector& nllb, NLFunc::nonlinear_fcn g, const ColumnVector& nlub, char *warn_for, int warn)
--- a/src/qpsol.cc +++ b/src/qpsol.cc @@ -43,12 +43,38 @@ #ifndef QPSOL_MISSING -// This should probably be defined in some shared file and declared in -// a header file... -extern int linear_constraints_ok (const ColumnVector& x, - const ColumnVector& llb, const Matrix& c, - const ColumnVector& lub, char *warn_for, - int warn); +// XXX FIXME XXX -- this is duplicated in npsol.cc + +static int +linear_constraints_ok (const ColumnVector& x, const ColumnVector& llb, + const Matrix& c, const ColumnVector& lub, + char *warn_for, int warn) +{ + int x_len = x.capacity (); + int llb_len = llb.capacity (); + int lub_len = lub.capacity (); + int c_rows = c.rows (); + int c_cols = c.columns (); + + int ok = 1; + if (warn) + { + if (c_rows == 0 || c_cols == 0 || llb_len == 0 || lub_len == 0) + { + ok = 0; + error ("%s: linear constraints must have nonzero dimensions", + warn_for); + } + else if (x_len != c_cols || llb_len != lub_len || llb_len != c_rows) + { + ok = 0; + error ("%s: linear constraints have inconsistent dimensions", + warn_for); + } + } + + return ok; +} static QPSOL_options qpsol_opts;