Array3.h

Go to the documentation of this file.
00001 // Template array classes
00002 /*
00003 
00004 Copyright (C) 1996-2012 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 3 of the License, or (at your
00011 option) any 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, see
00020 <http://www.gnu.org/licenses/>.
00021 
00022 */
00023 
00024 #if !defined (octave_Array3_h)
00025 #define octave_Array3_h 1
00026 
00027 #include <cassert>
00028 #include <cstdlib>
00029 
00030 #include "Array.h"
00031 #include "lo-error.h"
00032 
00033 class idx_vector;
00034 
00035 // Three dimensional array class.
00036 
00037 template <class T>
00038 class
00039 Array3 : public Array<T>
00040 {
00041 public:
00042 
00043   Array3 (void) : Array<T> (dim_vector (0, 0, 0)) { }
00044 
00045   Array3 (octave_idx_type r, octave_idx_type c, octave_idx_type p) : Array<T> (dim_vector (r, c, p)) { }
00046 
00047   Array3 (octave_idx_type r, octave_idx_type c, octave_idx_type p, const T& val)
00048     : Array<T> (dim_vector (r, c, p), val) { }
00049 
00050   Array3 (const Array3<T>& a)
00051     : Array<T> (a, a.dims ()) { }
00052 
00053   Array3 (const Array<T>& a, octave_idx_type r, octave_idx_type c, octave_idx_type p)
00054     : Array<T> (a, dim_vector (r, c, p)) { }
00055 
00056   ~Array3 (void) { }
00057 
00058   Array3<T>& operator = (const Array3<T>& a)
00059     {
00060       if (this != &a)
00061         Array<T>::operator = (a);
00062 
00063       return *this;
00064     }
00065 
00066   void resize (octave_idx_type r, octave_idx_type c, octave_idx_type p)
00067     { Array<T>::resize (dim_vector (r, c, p)); }
00068 
00069   void resize (octave_idx_type r, octave_idx_type c, octave_idx_type p, const T& val)
00070     { Array<T>::resize (dim_vector (r, c, p), val); }
00071 
00072   Array3<T> sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const
00073     {
00074       Array<T> tmp = Array<T>::sort (dim, mode);
00075       return Array3<T> (tmp, tmp.rows (), tmp.columns (), tmp.pages ());
00076     }
00077 
00078   Array3<T> sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0,
00079                  sortmode mode = ASCENDING) const
00080     {
00081       Array<T> tmp = Array<T>::sort (sidx, dim, mode);
00082       return Array3<T> (tmp, tmp.rows (), tmp.columns (), tmp.pages ());
00083     }
00084 };
00085 
00086 // If we're with GNU C++, issue a warning.
00087 #ifdef __GNUC__
00088 #warning Using Array3<T> is deprecated. Use Array<T> directly.
00089 #endif
00090 
00091 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines