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

Array2.h

解説を見る。
00001 // Template array classes
00002 /*
00003 
00004 Copyright (C) 1996, 1997 John W. Eaton
00005 
00006 This file is part of Octave.
00007 
00008 Octave is free software; you can redistribute it and/or modify it
00009 under the terms of the GNU General Public License as published by the
00010 Free Software Foundation; either version 2, or (at your option) any
00011 later version.
00012 
00013 Octave is distributed in the hope that it will be useful, but WITHOUT
00014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00016 for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with Octave; see the file COPYING.  If not, write to the Free
00020 Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00021 
00022 */
00023 
00024 #if !defined (octave_Array2_h)
00025 #define octave_Array2_h 1
00026 
00027 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION)
00028 #pragma interface
00029 #endif
00030 
00031 #include <cassert>
00032 #include <climits>
00033 #include <cmath>
00034 #include <cstdlib>
00035 
00036 #include "Array.h"
00037 #include "lo-error.h"
00038 
00039 class idx_vector;
00040 
00041 // Two dimensional array class.
00042 
00043 template <class T>
00044 class
00045 Array2 : public Array<T>
00046 {
00047 protected:
00048 
00049   static int get_size (int r, int c) { return Array<T>::get_size (r, c); }
00050 
00051   Array2 (T *d, int r, int c) : Array<T> (d, dim_vector (r, c)) { }
00052 
00053 public:
00054 
00055   Array2 (void) : Array<T> (dim_vector (0, 0)) { }
00056 
00057   Array2 (int r, int c) : Array<T> (dim_vector (r, c)) { }
00058 
00059   Array2 (int r, int c, const T& val)
00060     : Array<T> (dim_vector (r, c), val) { }
00061 
00062   Array2 (const Array2<T>& a) : Array<T> (a, a.dims ()) { }
00063 
00064   Array2 (const Array<T>& a, int r, int c)
00065     : Array<T> (a, dim_vector (r, c)) { }
00066 
00067   ~Array2 (void) { }
00068 
00069   Array2<T>& operator = (const Array2<T>& a)
00070     {
00071       if (this != &a)
00072         Array<T>::operator = (a);
00073 
00074       return *this;
00075     }
00076 
00077   void resize (int r, int c) { this->resize_no_fill (r, c); }
00078 
00079   void resize (int r, int c, const T& val)
00080     { this->resize_and_fill (r, c, val); }
00081 
00082   Array2<T>& insert (const Array2<T>& a, int r, int c)
00083     {
00084       Array<T>::insert (a, r, c);
00085       return *this;
00086     }
00087 
00088   Array2<T> transpose (void) const
00089     {
00090       Array<T> tmp = Array<T>::transpose ();
00091       return Array2<T> (tmp, tmp.rows (), tmp.columns ());
00092     }
00093 
00094   Array2<T> index (idx_vector& i, int resize_ok = 0,
00095                    const T& rfv = resize_fill_value (T ())) const
00096     {
00097       Array<T> tmp = Array<T>::index (i, resize_ok, rfv);
00098       return Array2<T> (tmp, tmp.rows (), tmp.columns ());
00099     }
00100 
00101   Array2<T> index (idx_vector& i, idx_vector& j, int resize_ok = 0,
00102                    const T& rfv = resize_fill_value (T ())) const
00103     {
00104       Array<T> tmp = Array<T>::index (i, j, resize_ok, rfv);
00105       return Array2<T> (tmp, tmp.rows (), tmp.columns ());
00106     }
00107 };
00108 
00109 #endif
00110 
00111 /*
00112 ;;; Local Variables: ***
00113 ;;; mode: C++ ***
00114 ;;; End: ***
00115 */

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