Mercurial > hg > octave-lyh
comparison liboctave/LinConst.h @ 3:9a4c07481e61
[project @ 1993-08-08 01:20:23 by jwe]
Initial revision
author | jwe |
---|---|
date | Sun, 08 Aug 1993 01:21:46 +0000 |
parents | |
children | 780cbbc57b7c |
comparison
equal
deleted
inserted
replaced
2:c0190df9885d | 3:9a4c07481e61 |
---|---|
1 // LinConst.h -*- C++ -*- | |
2 /* | |
3 | |
4 Copyright (C) 1992, 1993 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 (_LinConst_h) | |
25 #define _LinConst_h 1 | |
26 | |
27 #ifdef __GNUG__ | |
28 #pragma interface | |
29 #endif | |
30 | |
31 #include <float.h> | |
32 #include "Matrix.h" | |
33 #include "Bounds.h" | |
34 | |
35 #ifndef Vector | |
36 #define Vector ColumnVector | |
37 #endif | |
38 | |
39 class LinConst : public Bounds | |
40 { | |
41 public: | |
42 | |
43 LinConst (void); | |
44 LinConst (int nclin, int nx); | |
45 | |
46 LinConst (int nclin_eq, int nclin_ineq, int nx); | |
47 | |
48 LinConst (const Vector& lb, const Matrix& A, const Vector& ub); | |
49 | |
50 LinConst (const Matrix& A_eq, const Vector& b_eq, | |
51 const Matrix& A_ineq, const Vector& b_ineq); | |
52 | |
53 LinConst (const LinConst& a); | |
54 | |
55 LinConst& operator = (const LinConst& a); | |
56 | |
57 LinConst& resize (int nclin, int n); | |
58 | |
59 Matrix constraint_matrix (void) const; | |
60 | |
61 LinConst& set_constraint_matrix (const Matrix& A); | |
62 | |
63 Matrix eq_constraint_matrix (void) const; | |
64 Matrix ineq_constraint_matrix (void) const; | |
65 | |
66 Vector eq_constraint_vector (void) const; | |
67 Vector ineq_constraint_vector (void) const; | |
68 | |
69 friend ostream& operator << (ostream& os, const LinConst& b); | |
70 | |
71 protected: | |
72 | |
73 Matrix A; | |
74 | |
75 private: | |
76 | |
77 void error (const char *msg); | |
78 | |
79 }; | |
80 | |
81 inline LinConst::LinConst (void) : Bounds () {} | |
82 | |
83 inline LinConst::LinConst (int nc, int n) : Bounds (nc), A (nb, n) {} | |
84 | |
85 inline LinConst::LinConst (int eq, int ineq, int n) | |
86 : Bounds (eq+ineq), A (nb, n) {} | |
87 | |
88 inline LinConst::LinConst (const Vector& l, const Matrix& amat, | |
89 const Vector& u) | |
90 : Bounds (l, u), A (amat) | |
91 { | |
92 if (nb != amat.rows ()) | |
93 error ("inconsistent sizes for constraint matrix and bounds vectors"); | |
94 } | |
95 | |
96 inline LinConst::LinConst (const LinConst& a) | |
97 : Bounds (a.lb, a.ub), A (a.constraint_matrix ()) {} | |
98 | |
99 inline LinConst& | |
100 LinConst::operator = (const LinConst& a) | |
101 { | |
102 nb = a.nb; | |
103 lb = a.lb; | |
104 A = a.A; | |
105 ub = a.ub; | |
106 | |
107 return *this; | |
108 } | |
109 | |
110 inline Matrix | |
111 LinConst::constraint_matrix (void) const | |
112 { | |
113 return A; | |
114 } | |
115 | |
116 inline LinConst& | |
117 LinConst::set_constraint_matrix (const Matrix& amat) | |
118 { | |
119 if (lb.capacity () != amat.rows ()) | |
120 error ("inconsistent size for new linear constraint matrix"); | |
121 | |
122 A = amat; | |
123 | |
124 return *this; | |
125 } | |
126 | |
127 #endif | |
128 | |
129 /* | |
130 ;;; Local Variables: *** | |
131 ;;; mode: C++ *** | |
132 ;;; page-delimiter: "^/\\*" *** | |
133 ;;; End: *** | |
134 */ |