// Template array classes /* Copyright (C) 2000 John W. Eaton This file is part of Octave. Octave is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. Octave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Octave; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #if !defined (octave_ArrayN_h) #define octave_ArrayN_h 1 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) #pragma interface #endif #include #include #include #include #include #include "Array.h" #include "Array2.h" #include "lo-error.h" class idx_vector; // N-dimensional array class. template class ArrayN : public Array { protected: ArrayN (T *d, const dim_vector& dv) : Array (d, dv) { } public: // These really need to be protected (and they will be in the // future, so don't depend on them being here!), but they can't be // until template friends work correctly in g++. ArrayN (void) : Array () { } ArrayN (const dim_vector& dv) : Array (dv) { } ArrayN (const dim_vector& dv, const T& val) : Array (dv) { fill (val); } template explicit ArrayN (const Array2& a) : Array (a, a.dims ()) { } template ArrayN (const ArrayN& a) : Array (a, a.dims ()) { } template ArrayN (const Array& a) : Array (a) { } template ArrayN (const Array& a, const dim_vector& dv) : Array (a, dv) { } ~ArrayN (void) { } ArrayN& operator = (const ArrayN& a) { if (this != &a) Array::operator = (a); return *this; } ArrayN reshape (const dim_vector& new_dims) const { return Array::reshape (new_dims); } ArrayN permute (const Array& vec, bool inv = false) const { return Array::permute (vec, inv); } ArrayN ipermute (const Array& vec) const { return Array::ipermute (vec); } void resize (const dim_vector& dv) { this->resize_no_fill (dv); } void resize (const dim_vector& dv, const T& val) { Array::resize (dv, val); } ArrayN squeeze (void) const { return Array::squeeze (); } ArrayN transpose (void) const { return Array::transpose (); } ArrayN& insert (const ArrayN& a, const dim_vector& dv) { Array::insert (a, dv); return *this; } ArrayN& insert (const ArrayN& a, int r, int c) { Array::insert (a, r, c); return *this; } ArrayN index (idx_vector& i, int resize_ok = 0, const T& rfv = resize_fill_value (T ())) const { Array tmp = Array::index (i, resize_ok, rfv); return ArrayN (tmp, tmp.dims ()); } ArrayN index (idx_vector& i, idx_vector& j, int resize_ok = 0, const T& rfv = resize_fill_value (T ())) const { Array tmp = Array::index (i, j, resize_ok, rfv); return ArrayN (tmp, tmp.dims ()); } ArrayN index (Array& ra_idx, int resize_ok = 0, const T& rfv = resize_fill_value (T ())) const { Array tmp = Array::index (ra_idx, resize_ok, rfv); return ArrayN (tmp, tmp.dims ()); } }; template std::ostream& operator << (std::ostream&, const ArrayN&); #endif /* ;;; Local Variables: *** ;;; mode: C++ *** ;;; End: *** */