Mercurial > hg > octave-nkf
annotate liboctave/Array3.h @ 10396:a0b51ac0f88a
optimize accumdim with summation
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 05 Mar 2010 12:31:30 +0100 |
parents | 96ed7c629bbd |
children | fd0a3ac60b0e |
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 public: | |
43 | |
4513 | 44 Array3 (void) : Array<T> (dim_vector (0, 0, 0)) { } |
1988 | 45 |
5275 | 46 Array3 (octave_idx_type r, octave_idx_type c, octave_idx_type p) : Array<T> (dim_vector (r, c, p)) { } |
1988 | 47 |
5275 | 48 Array3 (octave_idx_type r, octave_idx_type c, octave_idx_type p, const T& val) |
4513 | 49 : Array<T> (dim_vector (r, c, p), val) { } |
1988 | 50 |
4513 | 51 Array3 (const Array3<T>& a) |
52 : Array<T> (a, a.dims ()) { } | |
53 | |
5275 | 54 Array3 (const Array<T>& a, octave_idx_type r, octave_idx_type c, octave_idx_type p) |
4513 | 55 : Array<T> (a, dim_vector (r, c, p)) { } |
1988 | 56 |
57 ~Array3 (void) { } | |
58 | |
59 Array3<T>& operator = (const Array3<T>& a) | |
60 { | |
4513 | 61 if (this != &a) |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
62 Array<T>::operator = (a); |
1988 | 63 |
64 return *this; | |
65 } | |
66 | |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7463
diff
changeset
|
67 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
|
68 { Array<T>::resize (dim_vector (r, c, p)); } |
2306 | 69 |
5275 | 70 void resize (octave_idx_type r, octave_idx_type c, octave_idx_type p, const T& val) |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
71 { Array<T>::resize (dim_vector (r, c, p), val); } |
7433 | 72 |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
73 Array3<T> sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const |
7433 | 74 { |
75 Array<T> tmp = Array<T>::sort (dim, mode); | |
76 return Array3<T> (tmp, tmp.rows (), tmp.columns (), tmp.pages ()); | |
77 } | |
78 | |
79 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
|
80 sortmode mode = ASCENDING) const |
7433 | 81 { |
82 Array<T> tmp = Array<T>::sort (sidx, dim, mode); | |
83 return Array3<T> (tmp, tmp.rows (), tmp.columns (), tmp.pages ()); | |
84 } | |
1988 | 85 }; |
86 | |
87 #endif |