GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Array3.h
Go to the documentation of this file.
1 // Template array classes
2 /*
3 
4 Copyright (C) 1996-2013 John W. Eaton
5 
6 This file is part of Octave.
7 
8 Octave is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if !defined (octave_Array3_h)
25 #define octave_Array3_h 1
26 
27 #include <cassert>
28 #include <cstdlib>
29 
30 #include "Array.h"
31 #include "lo-error.h"
32 
33 class idx_vector;
34 
35 // Three dimensional array class.
36 
37 template <class T>
38 class
39 Array3 : public Array<T>
40 {
41 public:
42 
43  Array3 (void) : Array<T> (dim_vector (0, 0, 0)) { }
44 
46  octave_idx_type p) : Array<T> (dim_vector (r, c, p)) { }
47 
49  : Array<T> (dim_vector (r, c, p), val) { }
50 
51  Array3 (const Array3<T>& a)
52  : Array<T> (a, a.dims ()) { }
53 
56  : Array<T> (a, dim_vector (r, c, p)) { }
57 
58  ~Array3 (void) { }
59 
61  {
62  if (this != &a)
64 
65  return *this;
66  }
67 
69  { Array<T>::resize (dim_vector (r, c, p)); }
70 
72  const T& val)
73  { Array<T>::resize (dim_vector (r, c, p), val); }
74 
76  {
77  Array<T> tmp = Array<T>::sort (dim, mode);
78  return Array3<T> (tmp, tmp.rows (), tmp.columns (), tmp.pages ());
79  }
80 
82  sortmode mode = ASCENDING) const
83  {
84  Array<T> tmp = Array<T>::sort (sidx, dim, mode);
85  return Array3<T> (tmp, tmp.rows (), tmp.columns (), tmp.pages ());
86  }
87 };
88 
89 // If we're with GNU C++, issue a warning.
90 #ifdef __GNUC__
91 #warning Using Array3<T> is deprecated. Use Array<T> directly.
92 #endif
93 
94 #endif