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

ArrayN.h

解説を見る。
00001 // Template array classes
00002 /*
00003 
00004 Copyright (C) 2000 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_ArrayN_h)
00025 #define octave_ArrayN_h 1
00026 
00027 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION)
00028 #pragma interface
00029 #endif
00030 
00031 #include <iostream>
00032 
00033 #include <cassert>
00034 #include <climits>
00035 #include <cmath>
00036 #include <cstdlib>
00037 
00038 #include "Array.h"
00039 #include "Array2.h"
00040 #include "lo-error.h"
00041 
00042 class idx_vector;
00043 
00044 // N-dimensional array class.
00045 
00046 template <class T>
00047 class
00048 ArrayN : public Array<T>
00049 {
00050 protected:
00051 
00052   ArrayN (T *d, const dim_vector& dv) : Array<T> (d, dv) { }
00053 
00054 public:
00055 
00056   // These really need to be protected (and they will be in the
00057   // future, so don't depend on them being here!), but they can't be
00058   // until template friends work correctly in g++.
00059 
00060   ArrayN (void) : Array<T> () { }
00061 
00062   ArrayN (const dim_vector& dv) : Array<T> (dv) { }
00063 
00064   ArrayN (const dim_vector& dv, const T& val)
00065     : Array<T> (dv) { fill (val); }
00066 
00067   template <class U>
00068   explicit ArrayN (const Array2<U>& a) : Array<T> (a, a.dims ()) { }
00069 
00070   template <class U>
00071   ArrayN (const ArrayN<U>& a) : Array<T> (a, a.dims ()) { }
00072 
00073   template <class U>
00074   ArrayN (const Array<U>& a) : Array<T> (a) { }
00075 
00076   template <class U>
00077   ArrayN (const Array<U>& a, const dim_vector& dv)
00078     : Array<T> (a, dv) { }
00079 
00080   ~ArrayN (void) { }
00081 
00082   ArrayN<T>& operator = (const ArrayN<T>& a)
00083     {
00084       if (this != &a)
00085         Array<T>::operator = (a);
00086 
00087       return *this;
00088     }
00089 
00090   ArrayN<T> reshape (const dim_vector& new_dims) const
00091     { return Array<T>::reshape (new_dims); }
00092 
00093   ArrayN<T> permute (const Array<int>& vec, bool inv = false) const
00094     { return Array<T>::permute (vec, inv); }
00095 
00096   ArrayN<T> ipermute (const Array<int>& vec) const
00097     { return Array<T>::ipermute (vec); }
00098 
00099   void resize (const dim_vector& dv)
00100     { this->resize_no_fill (dv); }
00101 
00102   void resize (const dim_vector& dv, const T& val)
00103     { Array<T>::resize (dv, val); }
00104 
00105   ArrayN<T> squeeze (void) const { return Array<T>::squeeze (); }
00106 
00107   ArrayN<T> transpose (void) const { return Array<T>::transpose (); }
00108 
00109   ArrayN<T>& insert (const ArrayN<T>& a, const dim_vector& dv)
00110     {
00111       Array<T>::insert (a, dv);
00112       return *this;
00113     }
00114 
00115   ArrayN<T>& insert (const ArrayN<T>& a, int r, int c)
00116   {
00117     Array<T>::insert (a, r, c);
00118     return *this;
00119   }
00120 
00121   ArrayN<T> index (idx_vector& i, int resize_ok = 0,
00122                    const T& rfv = resize_fill_value (T ())) const
00123     {
00124       Array<T> tmp = Array<T>::index (i, resize_ok, rfv);
00125       return ArrayN<T> (tmp, tmp.dims ());
00126     }
00127 
00128   ArrayN<T> index (idx_vector& i, idx_vector& j, int resize_ok = 0,
00129                    const T& rfv = resize_fill_value (T ())) const
00130     {
00131       Array<T> tmp = Array<T>::index (i, j, resize_ok, rfv);
00132       return ArrayN<T> (tmp, tmp.dims ());
00133     }
00134 
00135   ArrayN<T> index (Array<idx_vector>& ra_idx, int resize_ok = 0,
00136                    const T& rfv = resize_fill_value (T ())) const
00137     {
00138       Array<T> tmp = Array<T>::index (ra_idx, resize_ok, rfv);
00139       return ArrayN<T> (tmp, tmp.dims ());
00140     }
00141 };
00142 
00143 template <class T>
00144 std::ostream&
00145 operator << (std::ostream&, const ArrayN<T>&);
00146 
00147 #endif
00148 
00149 /*
00150 ;;; Local Variables: ***
00151 ;;; mode: C++ ***
00152 ;;; End: ***
00153 */

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