3
|
1 // LinConst.h -*- C++ -*- |
|
2 /* |
|
3 |
1011
|
4 Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton |
3
|
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 |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
3
|
21 |
|
22 */ |
|
23 |
382
|
24 #if !defined (octave_LinConst_h) |
|
25 #define octave_LinConst_h 1 |
|
26 |
1296
|
27 #if defined (__GNUG__) |
|
28 #pragma interface |
|
29 #endif |
|
30 |
238
|
31 class ostream; |
|
32 |
465
|
33 class ColumnVector; |
|
34 |
1366
|
35 #include <cfloat> |
465
|
36 |
|
37 #include "dMatrix.h" |
3
|
38 #include "Bounds.h" |
|
39 |
|
40 #ifndef Vector |
|
41 #define Vector ColumnVector |
|
42 #endif |
|
43 |
|
44 class LinConst : public Bounds |
|
45 { |
|
46 public: |
|
47 |
1321
|
48 LinConst (void) : Bounds () {} |
|
49 LinConst (int nc, int n) : Bounds (nc), A (nb, n) {} |
|
50 |
|
51 LinConst (int eq, int ineq, int n) |
|
52 : Bounds (eq+ineq), A (nb, n) {} |
3
|
53 |
1321
|
54 LinConst (const Vector& l, const Matrix& amat, const Vector& u) |
|
55 : Bounds (l, u), A (amat) |
|
56 { |
|
57 if (nb != amat.rows ()) |
|
58 error ("inconsistent sizes for constraint matrix and bounds vectors"); |
|
59 } |
3
|
60 |
|
61 LinConst (const Matrix& A_eq, const Vector& b_eq, |
|
62 const Matrix& A_ineq, const Vector& b_ineq); |
|
63 |
1321
|
64 LinConst (const LinConst& a) |
|
65 : Bounds (a.lb, a.ub), A (a.constraint_matrix ()) {} |
3
|
66 |
1321
|
67 LinConst& operator = (const LinConst& a) |
|
68 { |
|
69 nb = a.nb; |
|
70 lb = a.lb; |
|
71 A = a.A; |
|
72 ub = a.ub; |
|
73 |
|
74 return *this; |
|
75 } |
3
|
76 |
|
77 LinConst& resize (int nclin, int n); |
|
78 |
1321
|
79 Matrix constraint_matrix (void) const { return A; } |
3
|
80 |
1321
|
81 LinConst& set_constraint_matrix (const Matrix& amat) |
|
82 { |
|
83 if (lb.capacity () != amat.rows ()) |
|
84 error ("inconsistent size for new linear constraint matrix"); |
|
85 |
|
86 A = amat; |
|
87 |
|
88 return *this; |
|
89 } |
3
|
90 |
|
91 Matrix eq_constraint_matrix (void) const; |
|
92 Matrix ineq_constraint_matrix (void) const; |
|
93 |
|
94 Vector eq_constraint_vector (void) const; |
|
95 Vector ineq_constraint_vector (void) const; |
|
96 |
|
97 friend ostream& operator << (ostream& os, const LinConst& b); |
|
98 |
|
99 protected: |
|
100 |
|
101 Matrix A; |
|
102 |
|
103 private: |
|
104 |
|
105 void error (const char *msg); |
|
106 |
|
107 }; |
|
108 |
|
109 #endif |
|
110 |
|
111 /* |
|
112 ;;; Local Variables: *** |
|
113 ;;; mode: C++ *** |
|
114 ;;; page-delimiter: "^/\\*" *** |
|
115 ;;; End: *** |
|
116 */ |