# HG changeset patch # User jwe # Date 824272126 0 # Node ID 4689b52b4c6fb043cac1563b7b1b8b396b603eb1 # Parent d7dec93d4b87c83d3a45dc7592ab1e7633086f12 [project @ 1996-02-14 04:27:57 by jwe] diff --git a/src/npsol.cc b/src/npsol.cc --- 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) diff --git a/src/qpsol.cc b/src/qpsol.cc --- 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;