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 |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
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 |
|
35 #include <float.h> |
|
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 |
|
48 LinConst (void); |
|
49 LinConst (int nclin, int nx); |
|
50 |
|
51 LinConst (int nclin_eq, int nclin_ineq, int nx); |
|
52 |
|
53 LinConst (const Vector& lb, const Matrix& A, const Vector& ub); |
|
54 |
|
55 LinConst (const Matrix& A_eq, const Vector& b_eq, |
|
56 const Matrix& A_ineq, const Vector& b_ineq); |
|
57 |
|
58 LinConst (const LinConst& a); |
|
59 |
|
60 LinConst& operator = (const LinConst& a); |
|
61 |
|
62 LinConst& resize (int nclin, int n); |
|
63 |
|
64 Matrix constraint_matrix (void) const; |
|
65 |
|
66 LinConst& set_constraint_matrix (const Matrix& A); |
|
67 |
|
68 Matrix eq_constraint_matrix (void) const; |
|
69 Matrix ineq_constraint_matrix (void) const; |
|
70 |
|
71 Vector eq_constraint_vector (void) const; |
|
72 Vector ineq_constraint_vector (void) const; |
|
73 |
|
74 friend ostream& operator << (ostream& os, const LinConst& b); |
|
75 |
|
76 protected: |
|
77 |
|
78 Matrix A; |
|
79 |
|
80 private: |
|
81 |
|
82 void error (const char *msg); |
|
83 |
|
84 }; |
|
85 |
|
86 inline LinConst::LinConst (void) : Bounds () {} |
|
87 |
|
88 inline LinConst::LinConst (int nc, int n) : Bounds (nc), A (nb, n) {} |
|
89 |
|
90 inline LinConst::LinConst (int eq, int ineq, int n) |
|
91 : Bounds (eq+ineq), A (nb, n) {} |
|
92 |
|
93 inline LinConst::LinConst (const Vector& l, const Matrix& amat, |
|
94 const Vector& u) |
|
95 : Bounds (l, u), A (amat) |
|
96 { |
|
97 if (nb != amat.rows ()) |
|
98 error ("inconsistent sizes for constraint matrix and bounds vectors"); |
|
99 } |
|
100 |
|
101 inline LinConst::LinConst (const LinConst& a) |
|
102 : Bounds (a.lb, a.ub), A (a.constraint_matrix ()) {} |
|
103 |
|
104 inline LinConst& |
|
105 LinConst::operator = (const LinConst& a) |
|
106 { |
|
107 nb = a.nb; |
|
108 lb = a.lb; |
|
109 A = a.A; |
|
110 ub = a.ub; |
|
111 |
|
112 return *this; |
|
113 } |
|
114 |
|
115 inline Matrix |
|
116 LinConst::constraint_matrix (void) const |
|
117 { |
|
118 return A; |
|
119 } |
|
120 |
|
121 inline LinConst& |
|
122 LinConst::set_constraint_matrix (const Matrix& amat) |
|
123 { |
|
124 if (lb.capacity () != amat.rows ()) |
|
125 error ("inconsistent size for new linear constraint matrix"); |
|
126 |
|
127 A = amat; |
|
128 |
|
129 return *this; |
|
130 } |
|
131 |
|
132 #endif |
|
133 |
|
134 /* |
|
135 ;;; Local Variables: *** |
|
136 ;;; mode: C++ *** |
|
137 ;;; page-delimiter: "^/\\*" *** |
|
138 ;;; End: *** |
|
139 */ |