00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_Bounds_h)
00024 #define octave_Bounds_h 1
00025
00026 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION)
00027 #pragma interface
00028 #endif
00029
00030 #include <iostream>
00031
00032 #include "dColVector.h"
00033
00034 class
00035 Bounds
00036 {
00037 public:
00038
00039 Bounds (void)
00040 : lb (), ub () { }
00041
00042 Bounds (int n)
00043 : lb (n, 0.0), ub (n, 0.0) { }
00044
00045 Bounds (const ColumnVector l, const ColumnVector u)
00046 : lb (l), ub (u)
00047 {
00048 if (lb.capacity () != ub.capacity ())
00049 {
00050 error ("inconsistent sizes for lower and upper bounds");
00051 return;
00052 }
00053 }
00054
00055 Bounds (const Bounds& a)
00056 : lb (a.lb), ub (a.ub) { }
00057
00058 Bounds& operator = (const Bounds& a)
00059 {
00060 if (this != &a)
00061 {
00062 lb = a.lower_bounds ();
00063 ub = a.upper_bounds ();
00064 }
00065 return *this;
00066 }
00067
00068 ~Bounds (void) { }
00069
00070 Bounds& resize (int n)
00071 {
00072 lb.resize (n);
00073 ub.resize (n);
00074
00075 return *this;
00076 }
00077
00078 double lower_bound (int index) const { return lb.elem (index); }
00079 double upper_bound (int index) const { return ub.elem (index); }
00080
00081 ColumnVector lower_bounds (void) const { return lb; }
00082 ColumnVector upper_bounds (void) const { return ub; }
00083
00084 int size (void) const { return lb.capacity (); }
00085
00086 Bounds& set_bound (int index, double low, double high)
00087 {
00088 lb.elem (index) = low;
00089 ub.elem (index) = high;
00090 return *this;
00091 }
00092
00093 Bounds& set_bounds (double low, double high)
00094 {
00095 lb.fill (low);
00096 ub.fill (high);
00097 return *this;
00098 }
00099
00100 Bounds& set_bounds (const ColumnVector lb, const ColumnVector ub);
00101
00102 Bounds& set_lower_bound (int index, double low)
00103 {
00104 lb.elem (index) = low;
00105 return *this;
00106 }
00107
00108 Bounds& set_upper_bound (int index, double high)
00109 {
00110 ub.elem (index) = high;
00111 return *this;
00112 }
00113
00114 Bounds& set_lower_bounds (double low)
00115 {
00116 lb.fill (low);
00117 return *this;
00118 }
00119
00120 Bounds& set_upper_bounds (double high)
00121 {
00122 ub.fill (high);
00123 return *this;
00124 }
00125
00126 Bounds& set_lower_bounds (const ColumnVector lb);
00127 Bounds& set_upper_bounds (const ColumnVector ub);
00128
00129 friend std::ostream& operator << (std::ostream& os, const Bounds& b);
00130
00131 protected:
00132
00133 ColumnVector lb;
00134 ColumnVector ub;
00135
00136 private:
00137
00138 void error (const char *msg);
00139 };
00140
00141 #endif
00142
00143
00144
00145
00146
00147