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 class LinConst : public Bounds |
|
41 { |
|
42 public: |
|
43 |
1528
|
44 LinConst (void) : Bounds () { } |
1321
|
45 LinConst (int nc, int n) : Bounds (nc), A (nb, n) {} |
|
46 |
|
47 LinConst (int eq, int ineq, int n) |
|
48 : Bounds (eq+ineq), A (nb, n) {} |
3
|
49 |
1536
|
50 LinConst (const ColumnVector& l, const Matrix& amat, const ColumnVector& u) |
1321
|
51 : Bounds (l, u), A (amat) |
|
52 { |
|
53 if (nb != amat.rows ()) |
|
54 error ("inconsistent sizes for constraint matrix and bounds vectors"); |
|
55 } |
3
|
56 |
1536
|
57 LinConst (const Matrix& A_eq, const ColumnVector& b_eq, |
|
58 const Matrix& A_ineq, const ColumnVector& b_ineq); |
3
|
59 |
1321
|
60 LinConst (const LinConst& a) |
|
61 : Bounds (a.lb, a.ub), A (a.constraint_matrix ()) {} |
3
|
62 |
1321
|
63 LinConst& operator = (const LinConst& a) |
|
64 { |
|
65 nb = a.nb; |
|
66 lb = a.lb; |
|
67 A = a.A; |
|
68 ub = a.ub; |
|
69 |
|
70 return *this; |
|
71 } |
3
|
72 |
|
73 LinConst& resize (int nclin, int n); |
|
74 |
1321
|
75 Matrix constraint_matrix (void) const { return A; } |
3
|
76 |
1321
|
77 LinConst& set_constraint_matrix (const Matrix& amat) |
|
78 { |
|
79 if (lb.capacity () != amat.rows ()) |
|
80 error ("inconsistent size for new linear constraint matrix"); |
|
81 |
|
82 A = amat; |
|
83 |
|
84 return *this; |
|
85 } |
3
|
86 |
|
87 Matrix eq_constraint_matrix (void) const; |
|
88 Matrix ineq_constraint_matrix (void) const; |
|
89 |
1536
|
90 ColumnVector eq_constraint_vector (void) const; |
|
91 ColumnVector ineq_constraint_vector (void) const; |
3
|
92 |
|
93 friend ostream& operator << (ostream& os, const LinConst& b); |
|
94 |
|
95 protected: |
|
96 |
|
97 Matrix A; |
|
98 |
|
99 private: |
|
100 |
|
101 void error (const char *msg); |
|
102 |
|
103 }; |
|
104 |
|
105 #endif |
|
106 |
|
107 /* |
|
108 ;;; Local Variables: *** |
|
109 ;;; mode: C++ *** |
|
110 ;;; page-delimiter: "^/\\*" *** |
|
111 ;;; End: *** |
|
112 */ |