メインページ   クラス階層   構成   ファイル一覧   構成メンバ   ファイルメンバ  

Bounds.h

解説を見る。
00001 /*
00002 
00003 Copyright (C) 1996, 1997 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 2, or (at your option) any
00010 later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, write to the Free
00019 Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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 ;;; Local Variables: ***
00145 ;;; mode: C++ ***
00146 ;;; End: ***
00147 */

Wed Dec 29 11:50:56 2004に生成されました。 doxygen1.2.18
SEO [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送