3
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 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 |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
3
|
21 |
|
22 */ |
|
23 |
238
|
24 #ifdef HAVE_CONFIG_H |
1192
|
25 #include <config.h> |
3
|
26 #endif |
|
27 |
3503
|
28 #include <iostream> |
238
|
29 |
3
|
30 #include "Bounds.h" |
227
|
31 #include "lo-error.h" |
3
|
32 |
|
33 // error handling |
|
34 |
|
35 void |
|
36 Bounds::error (const char* msg) |
|
37 { |
227
|
38 (*current_liboctave_error_handler) ("fatal bounds error: ", msg); |
3
|
39 } |
|
40 |
|
41 Bounds& |
|
42 Bounds::set_bounds (const ColumnVector l, const ColumnVector u) |
|
43 { |
|
44 if (l.capacity () != u.capacity ()) |
227
|
45 { |
|
46 error ("inconsistent sizes for lower and upper bounds"); |
|
47 return *this; |
|
48 } |
3
|
49 |
|
50 lb = l; |
|
51 ub = u; |
|
52 |
|
53 return *this; |
|
54 } |
|
55 |
|
56 Bounds& |
|
57 Bounds::set_lower_bounds (const ColumnVector l) |
|
58 { |
1878
|
59 if (ub.capacity () != l.capacity ()) |
227
|
60 { |
|
61 error ("inconsistent size for lower bounds"); |
|
62 return *this; |
|
63 } |
3
|
64 |
|
65 lb = l; |
|
66 |
|
67 return *this; |
|
68 } |
|
69 |
|
70 Bounds& |
|
71 Bounds::set_upper_bounds (const ColumnVector u) |
|
72 { |
1878
|
73 if (lb.capacity () != u.capacity ()) |
227
|
74 { |
|
75 error ("inconsistent size for upper bounds"); |
|
76 return *this; |
|
77 } |
3
|
78 |
|
79 ub = u; |
|
80 |
|
81 return *this; |
|
82 } |
|
83 |
3504
|
84 std::ostream& |
|
85 operator << (std::ostream& os, const Bounds& b) |
3
|
86 { |
5275
|
87 for (octave_idx_type i = 0; i < b.size (); i++) |
3
|
88 os << b.lower_bound (i) << " " << b.upper_bound (i) << "\n"; |
|
89 |
|
90 return os; |
|
91 } |
|
92 |
|
93 /* |
|
94 ;;; Local Variables: *** |
|
95 ;;; mode: C++ *** |
|
96 ;;; End: *** |
|
97 */ |