3
|
1 // Bounds.cc -*- 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 |
1296
|
24 #if defined (__GNUG__) |
|
25 #pragma implementation |
|
26 #endif |
|
27 |
238
|
28 #ifdef HAVE_CONFIG_H |
1192
|
29 #include <config.h> |
3
|
30 #endif |
|
31 |
|
32 #include <iostream.h> |
238
|
33 |
3
|
34 #include "Bounds.h" |
227
|
35 #include "lo-error.h" |
3
|
36 |
|
37 // error handling |
|
38 |
|
39 void |
|
40 Bounds::error (const char* msg) |
|
41 { |
227
|
42 (*current_liboctave_error_handler) ("fatal bounds error: ", msg); |
3
|
43 } |
|
44 |
|
45 Bounds& |
|
46 Bounds::set_bounds (const ColumnVector l, const ColumnVector u) |
|
47 { |
|
48 if (l.capacity () != u.capacity ()) |
227
|
49 { |
|
50 error ("inconsistent sizes for lower and upper bounds"); |
|
51 return *this; |
|
52 } |
3
|
53 |
|
54 lb = l; |
|
55 ub = u; |
|
56 |
|
57 return *this; |
|
58 } |
|
59 |
|
60 Bounds& |
|
61 Bounds::set_lower_bounds (const ColumnVector l) |
|
62 { |
1878
|
63 if (ub.capacity () != l.capacity ()) |
227
|
64 { |
|
65 error ("inconsistent size for lower bounds"); |
|
66 return *this; |
|
67 } |
3
|
68 |
|
69 lb = l; |
|
70 |
|
71 return *this; |
|
72 } |
|
73 |
|
74 Bounds& |
|
75 Bounds::set_upper_bounds (const ColumnVector u) |
|
76 { |
1878
|
77 if (lb.capacity () != u.capacity ()) |
227
|
78 { |
|
79 error ("inconsistent size for upper bounds"); |
|
80 return *this; |
|
81 } |
3
|
82 |
|
83 ub = u; |
|
84 |
|
85 return *this; |
|
86 } |
|
87 |
|
88 ostream& |
|
89 operator << (ostream& os, const Bounds& b) |
|
90 { |
|
91 for (int i = 0; i < b.size (); i++) |
|
92 os << b.lower_bound (i) << " " << b.upper_bound (i) << "\n"; |
|
93 |
|
94 return os; |
|
95 } |
|
96 |
|
97 /* |
|
98 ;;; Local Variables: *** |
|
99 ;;; mode: C++ *** |
|
100 ;;; page-delimiter: "^/\\*" *** |
|
101 ;;; End: *** |
|
102 */ |