home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / octave-1.1.1p1-bin.lha / include / octave / LinConst.h < prev    next >
C/C++ Source or Header  |  1996-10-12  |  3KB  |  140 lines

  1. // LinConst.h                                                -*- C++ -*-
  2. /*
  3.  
  4. Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton
  5.  
  6. This file is part of Octave.
  7.  
  8. Octave is free software; you can redistribute it and/or modify it
  9. under the terms of the GNU General Public License as published by the
  10. Free Software Foundation; either version 2, or (at your option) any
  11. later version.
  12.  
  13. Octave is distributed in the hope that it will be useful, but WITHOUT
  14. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  16. for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with Octave; see the file COPYING.  If not, write to the Free
  20. Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. */
  23.  
  24. #if !defined (octave_LinConst_h)
  25. #define octave_LinConst_h 1
  26.  
  27. class ostream;
  28.  
  29. class ColumnVector;
  30.  
  31. #include <float.h>
  32.  
  33. #include "dMatrix.h"
  34. #include "Bounds.h"
  35.  
  36. extern "C++" {
  37.  
  38. #ifndef Vector
  39. #define Vector ColumnVector
  40. #endif
  41.  
  42. class LinConst : public Bounds
  43. {
  44. public:
  45.  
  46.   LinConst (void);
  47.   LinConst (int nclin, int nx);
  48.  
  49.   LinConst (int nclin_eq, int nclin_ineq, int nx);
  50.  
  51.   LinConst (const Vector& lb, const Matrix& A, const Vector& ub);
  52.  
  53.   LinConst (const Matrix& A_eq, const Vector& b_eq,
  54.         const Matrix& A_ineq, const Vector& b_ineq);
  55.  
  56.   LinConst (const LinConst& a);
  57.  
  58.   LinConst& operator = (const LinConst& a);
  59.  
  60.   LinConst& resize (int nclin, int n);
  61.  
  62.   Matrix constraint_matrix (void) const;
  63.  
  64.   LinConst& set_constraint_matrix (const Matrix& A);
  65.  
  66.   Matrix eq_constraint_matrix (void) const;
  67.   Matrix ineq_constraint_matrix (void) const;
  68.  
  69.   Vector eq_constraint_vector (void) const;
  70.   Vector ineq_constraint_vector (void) const;
  71.  
  72.   friend ostream& operator << (ostream& os, const LinConst& b);
  73.  
  74. protected:
  75.  
  76.   Matrix A;
  77.  
  78. private:
  79.  
  80.   void error (const char *msg);
  81.  
  82. };
  83.  
  84. inline LinConst::LinConst (void) : Bounds () {}
  85.  
  86. inline LinConst::LinConst (int nc, int n) : Bounds (nc), A (nb, n) {}
  87.  
  88. inline LinConst::LinConst (int eq, int ineq, int n)
  89.   : Bounds (eq+ineq), A (nb, n) {}
  90.  
  91. inline LinConst::LinConst (const Vector& l, const Matrix& amat,
  92.                const Vector& u)
  93.   : Bounds (l, u), A (amat)
  94. {
  95.   if (nb != amat.rows ())
  96.     error ("inconsistent sizes for constraint matrix and bounds vectors");
  97. }
  98.  
  99. inline LinConst::LinConst (const LinConst& a)
  100.   : Bounds (a.lb, a.ub), A (a.constraint_matrix ()) {}
  101.  
  102. inline LinConst&
  103. LinConst::operator = (const LinConst& a)
  104. {
  105.   nb = a.nb;
  106.   lb = a.lb;
  107.   A  = a.A;
  108.   ub = a.ub;
  109.  
  110.   return *this;
  111. }
  112.  
  113. inline Matrix
  114. LinConst::constraint_matrix (void) const
  115. {
  116.   return A;
  117. }
  118.  
  119. inline LinConst&
  120. LinConst::set_constraint_matrix (const Matrix& amat)
  121. {
  122.   if (lb.capacity () != amat.rows ())
  123.     error ("inconsistent size for new linear constraint matrix");
  124.  
  125.   A = amat;
  126.  
  127.   return *this;
  128. }
  129.  
  130. } // extern "C++"
  131.  
  132. #endif
  133.  
  134. /*
  135. ;;; Local Variables: ***
  136. ;;; mode: C++ ***
  137. ;;; page-delimiter: "^/\\*" ***
  138. ;;; End: ***
  139. */
  140.