Mercurial > hg > octave-nkf
annotate liboctave/Array3.h @ 14026:3781981be535 ss-3-5-90
snapshot 3.5.90
* configure.ac (AC_INIT): Version is now 3.5.90.
(OCTAVE_API_VERSION_NUMBER): Now 46.
(OCTAVE_RELEASE_DATE): Now 2011-12-11.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 11 Dec 2011 23:18:31 -0500 |
parents | 12df7854fa7c |
children | 72c96de7a403 |
rev | line source |
---|---|
1993 | 1 // Template array classes |
1988 | 2 /* |
3 | |
11523 | 4 Copyright (C) 1996-2011 John W. Eaton |
1988 | 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 | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1988 | 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 | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1988 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_Array3_h) | |
25 #define octave_Array3_h 1 | |
26 | |
27 #include <cassert> | |
28 #include <cstdlib> | |
29 | |
4513 | 30 #include "Array.h" |
1988 | 31 #include "lo-error.h" |
32 | |
33 class idx_vector; | |
34 | |
35 // Three dimensional array class. | |
36 | |
37 template <class T> | |
3585 | 38 class |
4513 | 39 Array3 : public Array<T> |
1988 | 40 { |
41 public: | |
42 | |
4513 | 43 Array3 (void) : Array<T> (dim_vector (0, 0, 0)) { } |
1988 | 44 |
5275 | 45 Array3 (octave_idx_type r, octave_idx_type c, octave_idx_type p) : Array<T> (dim_vector (r, c, p)) { } |
1988 | 46 |
5275 | 47 Array3 (octave_idx_type r, octave_idx_type c, octave_idx_type p, const T& val) |
4513 | 48 : Array<T> (dim_vector (r, c, p), val) { } |
1988 | 49 |
4513 | 50 Array3 (const Array3<T>& a) |
51 : Array<T> (a, a.dims ()) { } | |
52 | |
5275 | 53 Array3 (const Array<T>& a, octave_idx_type r, octave_idx_type c, octave_idx_type p) |
4513 | 54 : Array<T> (a, dim_vector (r, c, p)) { } |
1988 | 55 |
56 ~Array3 (void) { } | |
57 | |
58 Array3<T>& operator = (const Array3<T>& a) | |
59 { | |
4513 | 60 if (this != &a) |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
61 Array<T>::operator = (a); |
1988 | 62 |
63 return *this; | |
64 } | |
65 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
66 void resize (octave_idx_type r, octave_idx_type c, octave_idx_type p) |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7463
diff
changeset
|
67 { Array<T>::resize (dim_vector (r, c, p)); } |
2306 | 68 |
5275 | 69 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
|
70 { Array<T>::resize (dim_vector (r, c, p), val); } |
7433 | 71 |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
72 Array3<T> sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const |
7433 | 73 { |
74 Array<T> tmp = Array<T>::sort (dim, mode); | |
75 return Array3<T> (tmp, tmp.rows (), tmp.columns (), tmp.pages ()); | |
76 } | |
77 | |
78 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
|
79 sortmode mode = ASCENDING) const |
7433 | 80 { |
81 Array<T> tmp = Array<T>::sort (sidx, dim, mode); | |
82 return Array3<T> (tmp, tmp.rows (), tmp.columns (), tmp.pages ()); | |
83 } | |
1988 | 84 }; |
85 | |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
86 // If we're with GNU C++, issue a warning. |
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
87 #ifdef __GNUC__ |
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
88 #warning Using Array3<T> is deprecated. Use Array<T> directly. |
1988 | 89 #endif |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
90 |
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
91 #endif |