Mercurial > hg > octave-lyh
annotate liboctave/Array3.h @ 10312:cbc402e64d83
untabify liboctave header files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 11 Feb 2010 12:14:48 -0500 |
parents | 4c0cdbe0acca |
children | 12884915a8e4 |
rev | line source |
---|---|
1993 | 1 // Template array classes |
1988 | 2 /* |
3 | |
8920 | 4 Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008 |
7017 | 5 John W. Eaton |
1988 | 6 |
7 This file is part of Octave. | |
8 | |
9 Octave is free software; you can redistribute it and/or modify it | |
10 under the terms of the GNU General Public License as published by the | |
7016 | 11 Free Software Foundation; either version 3 of the License, or (at your |
12 option) any later version. | |
1988 | 13 |
14 Octave is distributed in the hope that it will be useful, but WITHOUT | |
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
7016 | 20 along with Octave; see the file COPYING. If not, see |
21 <http://www.gnu.org/licenses/>. | |
1988 | 22 |
23 */ | |
24 | |
25 #if !defined (octave_Array3_h) | |
26 #define octave_Array3_h 1 | |
27 | |
28 #include <cassert> | |
29 #include <cstdlib> | |
30 | |
4513 | 31 #include "Array.h" |
1988 | 32 #include "lo-error.h" |
33 | |
34 class idx_vector; | |
35 | |
36 // Three dimensional array class. | |
37 | |
38 template <class T> | |
3585 | 39 class |
4513 | 40 Array3 : public Array<T> |
1988 | 41 { |
42 protected: | |
43 | |
5275 | 44 Array3 (T *d, octave_idx_type r, octave_idx_type c, octave_idx_type p) : Array<T> (d, dim_vector (r, c, p)) { } |
1988 | 45 |
46 public: | |
47 | |
4513 | 48 Array3 (void) : Array<T> (dim_vector (0, 0, 0)) { } |
1988 | 49 |
5275 | 50 Array3 (octave_idx_type r, octave_idx_type c, octave_idx_type p) : Array<T> (dim_vector (r, c, p)) { } |
1988 | 51 |
5275 | 52 Array3 (octave_idx_type r, octave_idx_type c, octave_idx_type p, const T& val) |
4513 | 53 : Array<T> (dim_vector (r, c, p), val) { } |
1988 | 54 |
4513 | 55 Array3 (const Array3<T>& a) |
56 : Array<T> (a, a.dims ()) { } | |
57 | |
5275 | 58 Array3 (const Array<T>& a, octave_idx_type r, octave_idx_type c, octave_idx_type p) |
4513 | 59 : Array<T> (a, dim_vector (r, c, p)) { } |
1988 | 60 |
61 ~Array3 (void) { } | |
62 | |
63 Array3<T>& operator = (const Array3<T>& a) | |
64 { | |
4513 | 65 if (this != &a) |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
66 Array<T>::operator = (a); |
1988 | 67 |
68 return *this; | |
69 } | |
70 | |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7463
diff
changeset
|
71 void resize (octave_idx_type r, octave_idx_type c, octave_idx_type p) |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7463
diff
changeset
|
72 { Array<T>::resize (dim_vector (r, c, p)); } |
2306 | 73 |
5275 | 74 void resize (octave_idx_type r, octave_idx_type c, octave_idx_type p, const T& val) |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7463
diff
changeset
|
75 { Array<T>::resize_fill (dim_vector (r, c, p), val); } |
7433 | 76 |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
77 Array3<T> sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const |
7433 | 78 { |
79 Array<T> tmp = Array<T>::sort (dim, mode); | |
80 return Array3<T> (tmp, tmp.rows (), tmp.columns (), tmp.pages ()); | |
81 } | |
82 | |
83 Array3<T> sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
84 sortmode mode = ASCENDING) const |
7433 | 85 { |
86 Array<T> tmp = Array<T>::sort (sidx, dim, mode); | |
87 return Array3<T> (tmp, tmp.rows (), tmp.columns (), tmp.pages ()); | |
88 } | |
1988 | 89 }; |
90 | |
91 #endif |