Mercurial > hg > octave-nkf
changeset 1866:b6c48195b552
[project @ 1996-02-04 11:07:17 by jwe]
author | jwe |
---|---|
date | Sun, 04 Feb 1996 11:09:09 +0000 |
parents | 0e095fed283c |
children | 52e7bca8ce33 |
files | liboctave/LinConst.cc liboctave/LinConst.h liboctave/NPSOL.h liboctave/QP.h |
diffstat | 4 files changed, 17 insertions(+), 150 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/LinConst.cc +++ b/liboctave/LinConst.cc @@ -42,126 +42,6 @@ (*current_liboctave_error_handler) ("fatal LinConst error: %s", msg); } -LinConst::LinConst (const Matrix& a_eq, const ColumnVector& b_eq, - const Matrix& a_ineq, const ColumnVector& b_ineq) -{ - // Need some checks here. - - int nc_eq = b_eq.capacity (); - int nc_ineq = b_ineq.capacity (); - nb = nc_eq + nc_ineq; - - lb.resize (nb); - ub.resize (nb); - - lb.insert (b_eq, 0); - lb.insert (-b_ineq, nc_eq); - - ub.insert (b_eq, 0); - ub.fill (DBL_MAX, nc_eq, nb-1); - - int nx = a_eq.columns (); - - A.resize (nb, nx); - - A.insert (a_eq, 0, 0); - A.insert (a_ineq, nc_eq, 0); -} - -LinConst& -LinConst::resize (int nc, int n) -{ - nb = nc; - lb.resize (nb); - A.resize (nb, n); - ub.resize (nb); - - return *this; -} - -Matrix -LinConst::eq_constraint_matrix (void) const -{ - int anr = A.rows (); - int anc = A.columns (); - Matrix retval (anr, anc); - int count = 0; - for (int i = 0; i < anr; i++) - { - if (lb.elem (i) == ub.elem (i)) - { - retval.insert (A.extract (i, 0, i, anc-1), count, 0); - count++; - } - } - retval.resize (count, anc); - return retval; -} - -Matrix -LinConst::ineq_constraint_matrix (void) const -{ - int anr = A.rows (); - int anc = A.columns (); - Matrix retval (2*anr, anc); - int count = 0; - for (int i = 0; i < anr; i++) - { - if (lb.elem (i) != ub.elem (i)) - { - Matrix tmp = A.extract (i, 0, i, anc-1); - retval.insert (tmp, count, 0); - count++; - if (ub.elem (i) < DBL_MAX) - { - retval.insert (-tmp, count, 0); - count++; - } - } - } - retval.resize (count, anc); - return retval; -} - -ColumnVector -LinConst::eq_constraint_vector (void) const -{ - ColumnVector retval (nb); - int count = 0; - for (int i = 0; i < nb; i++) - { - if (lb.elem (i) == ub.elem (i)) - { - retval.elem (count) = lb.elem (i); - count++; - } - } - retval.resize (count); - return retval; -} - -ColumnVector -LinConst::ineq_constraint_vector (void) const -{ - ColumnVector retval (2*nb); - int count = 0; - for (int i = 0; i < nb; i++) - { - if (lb.elem (i) != ub.elem (i)) - { - retval.elem (count) = -lb.elem (i); - count++; - if (ub.elem (i) < DBL_MAX) - { - retval.elem (count) = ub.elem (i); - count++; - } - } - } - retval.resize (count); - return retval; -} - ostream& operator << (ostream& os, const LinConst& c) {
--- a/liboctave/LinConst.h +++ b/liboctave/LinConst.h @@ -1,7 +1,7 @@ // LinConst.h -*- C++ -*- /* -Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton +Copyright (C) 1996 John W. Eaton This file is part of Octave. @@ -37,40 +37,36 @@ #include "dMatrix.h" #include "Bounds.h" -class LinConst : public Bounds +class +LinConst : public Bounds { public: - LinConst (void) : Bounds () { } - LinConst (int nc, int n) : Bounds (nc), A (nb, n) {} - - LinConst (int eq, int ineq, int n) - : Bounds (eq+ineq), A (nb, n) {} + LinConst (void) + : Bounds (), A () { } 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"); + if (Bounds::size () != amat.rows ()) + error ("nonconformant constraint matrix and bounds vectors"); } - 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 ()) {} + : Bounds (a.lb, a.ub), A (a.A) { } LinConst& operator = (const LinConst& a) { - nb = a.nb; - lb = a.lb; - A = a.A; - ub = a.ub; + if (this != &a) + { + Bounds::operator = (a); + A = a.A; + } return *this; } - LinConst& resize (int nclin, int n); + ~LinConst (void) { } Matrix constraint_matrix (void) const { return A; } @@ -84,12 +80,6 @@ return *this; } - Matrix eq_constraint_matrix (void) const; - Matrix ineq_constraint_matrix (void) const; - - ColumnVector eq_constraint_vector (void) const; - ColumnVector ineq_constraint_vector (void) const; - friend ostream& operator << (ostream& os, const LinConst& b); protected: @@ -99,7 +89,6 @@ private: void error (const char *msg); - }; #endif
--- a/liboctave/NPSOL.h +++ b/liboctave/NPSOL.h @@ -44,7 +44,7 @@ NPSOL_options (const NPSOL_options& opt) { copy (opt); } - NPSOL_options& operator = (const NPSOL_options& opt); + NPSOL_options& operator = (const NPSOL_options& opt) { if (this != &opt) copy (opt);
--- a/liboctave/QP.h +++ b/liboctave/QP.h @@ -51,7 +51,7 @@ { make_h_symmetric (); } QP (const ColumnVector& x, const Matrix& H_arg, const LinConst& l) - : base_minimizer (x), H (H_arg), lc (l), bnds (), lc () + : base_minimizer (x), H (H_arg), c (), bnds (), lc (l) { make_h_symmetric (); } QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg, @@ -91,7 +91,7 @@ return *this; } - ~QP (void) { } + virtual ~QP (void) { } Matrix hessian (void) const { return H; } @@ -101,8 +101,6 @@ LinConst linear_constraints (void) const { return lc; } - virtual ~QP (void) { } - protected: Matrix H;