3
|
1 /* |
|
2 |
1869
|
3 Copyright (C) 1996 John W. Eaton |
3
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
3
|
20 |
|
21 */ |
|
22 |
382
|
23 #if !defined (octave_Bounds_h) |
|
24 #define octave_Bounds_h 1 |
|
25 |
1296
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
461
|
30 class ostream; |
|
31 |
|
32 #include "dColVector.h" |
384
|
33 |
1869
|
34 class |
|
35 Bounds |
3
|
36 { |
|
37 public: |
|
38 |
1869
|
39 Bounds (void) |
|
40 : lb (), ub () { } |
|
41 |
|
42 Bounds (int n) |
|
43 : lb (n, 0.0), ub (n, 0.0) { } |
1528
|
44 |
1869
|
45 Bounds (const ColumnVector l, const ColumnVector u) |
|
46 : lb (l), ub (u) |
|
47 { |
|
48 if (lb.capacity () != ub.capacity ()) |
|
49 { |
|
50 error ("inconsistent sizes for lower and upper bounds"); |
|
51 return; |
|
52 } |
|
53 } |
3
|
54 |
1528
|
55 Bounds (const Bounds& a) |
1869
|
56 : lb (a.lb), ub (a.ub) { } |
1528
|
57 |
|
58 Bounds& operator = (const Bounds& a) |
|
59 { |
1869
|
60 if (this != &a) |
|
61 { |
|
62 lb = a.lower_bounds (); |
|
63 ub = a.upper_bounds (); |
|
64 } |
1528
|
65 return *this; |
|
66 } |
|
67 |
1869
|
68 ~Bounds (void) { } |
|
69 |
1528
|
70 Bounds& resize (int n) |
|
71 { |
1869
|
72 lb.resize (n); |
|
73 ub.resize (n); |
3
|
74 |
1528
|
75 return *this; |
|
76 } |
3
|
77 |
1528
|
78 double lower_bound (int index) const { return lb.elem (index); } |
|
79 double upper_bound (int index) const { return ub.elem (index); } |
|
80 |
|
81 ColumnVector lower_bounds (void) const { return lb; } |
|
82 ColumnVector upper_bounds (void) const { return ub; } |
|
83 |
1869
|
84 int size (void) const { return lb.capacity (); } |
3
|
85 |
1528
|
86 Bounds& set_bound (int index, double low, double high) |
|
87 { |
|
88 lb.elem (index) = low; |
|
89 ub.elem (index) = high; |
|
90 return *this; |
|
91 } |
3
|
92 |
1528
|
93 Bounds& set_bounds (double low, double high) |
|
94 { |
|
95 lb.fill (low); |
|
96 ub.fill (high); |
|
97 return *this; |
|
98 } |
3
|
99 |
1528
|
100 Bounds& set_bounds (const ColumnVector lb, const ColumnVector ub); |
3
|
101 |
1528
|
102 Bounds& set_lower_bound (int index, double low) |
|
103 { |
|
104 lb.elem (index) = low; |
|
105 return *this; |
|
106 } |
|
107 |
|
108 Bounds& set_upper_bound (int index, double high) |
|
109 { |
|
110 ub.elem (index) = high; |
|
111 return *this; |
|
112 } |
3
|
113 |
1528
|
114 Bounds& set_lower_bounds (double low) |
|
115 { |
|
116 lb.fill (low); |
|
117 return *this; |
|
118 } |
3
|
119 |
1528
|
120 Bounds& set_upper_bounds (double high) |
|
121 { |
|
122 ub.fill (high); |
|
123 return *this; |
|
124 } |
|
125 |
|
126 Bounds& set_lower_bounds (const ColumnVector lb); |
|
127 Bounds& set_upper_bounds (const ColumnVector ub); |
3
|
128 |
|
129 friend ostream& operator << (ostream& os, const Bounds& b); |
|
130 |
|
131 protected: |
|
132 |
1528
|
133 ColumnVector lb; |
|
134 ColumnVector ub; |
3
|
135 |
|
136 private: |
|
137 |
|
138 void error (const char *msg); |
|
139 }; |
|
140 |
|
141 #endif |
|
142 |
|
143 /* |
|
144 ;;; Local Variables: *** |
|
145 ;;; mode: C++ *** |
|
146 ;;; End: *** |
|
147 */ |