4902
|
1 /* |
|
2 |
|
3 Copyright (C) 2004 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
4902
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_intNDArray_h) |
|
25 #define octave_intNDArray_h 1 |
|
26 |
|
27 #include "MArrayN.h" |
|
28 #include "boolNDArray.h" |
|
29 |
|
30 template <class T> |
|
31 class |
|
32 intNDArray : public MArrayN<T> |
|
33 { |
|
34 public: |
|
35 |
|
36 intNDArray (void) : MArrayN<T> () { } |
|
37 |
|
38 intNDArray (T val) : MArrayN<T> (dim_vector (1, 1), val) { } |
|
39 |
|
40 intNDArray (const dim_vector& dv) : MArrayN<T> (dv) { } |
|
41 |
|
42 intNDArray (const dim_vector& dv, T val) |
|
43 : MArrayN<T> (dv, val) { } |
|
44 |
|
45 template <class U> |
|
46 explicit intNDArray (const Array<U>& a) : MArrayN<T> (a) { } |
|
47 |
|
48 template <class U> |
|
49 explicit intNDArray (const ArrayN<U>& a) : MArrayN<T> (a) { } |
|
50 |
|
51 template <class U> |
|
52 intNDArray (const MArrayN<U>& a) : MArrayN<T> (a) { } |
|
53 |
|
54 template <class U> |
|
55 intNDArray (const intNDArray<U>& a) : MArrayN<T> (a) { } |
|
56 |
|
57 intNDArray& operator = (const intNDArray<T>& a) |
|
58 { |
|
59 MArrayN<T>::operator = (a); |
|
60 return *this; |
|
61 } |
|
62 |
|
63 boolNDArray operator ! (void) const; |
|
64 |
5775
|
65 // FIXME -- this is not quite the right thing. |
4902
|
66 |
|
67 boolNDArray all (int dim = -1) const; |
|
68 boolNDArray any (int dim = -1) const; |
|
69 |
|
70 intNDArray squeeze (void) const |
|
71 { return intNDArray<T> (MArrayN<T>::squeeze ()); } |
|
72 |
|
73 intNDArray transpose (void) const |
|
74 { return intNDArray<T> (MArrayN<T>::transpose ()); } |
|
75 |
5275
|
76 intNDArray concat (const intNDArray<T>& rb, const Array<octave_idx_type>& ra_idx); |
5073
|
77 |
5275
|
78 intNDArray& insert (const intNDArray<T>& a, octave_idx_type r, octave_idx_type c); |
|
79 intNDArray& insert (const intNDArray<T>& a, const Array<octave_idx_type>& ra_idx); |
4915
|
80 |
5275
|
81 static void increment_index (Array<octave_idx_type>& ra_idx, |
4902
|
82 const dim_vector& dimensions, |
|
83 int start_dimension = 0); |
|
84 |
5275
|
85 static octave_idx_type compute_index (Array<octave_idx_type>& ra_idx, |
4902
|
86 const dim_vector& dimensions); |
|
87 |
|
88 static T resize_fill_value (void) { return 0; } |
|
89 |
|
90 protected: |
|
91 |
|
92 intNDArray (T *d, dim_vector& dv) : MArrayN<T> (d, dv) { } |
|
93 }; |
|
94 |
|
95 // i/o |
|
96 |
|
97 template <class T> |
|
98 std::ostream& operator << (std::ostream& os, const intNDArray<T>& a); |
|
99 |
|
100 template <class T> |
|
101 std::istream& operator >> (std::istream& is, intNDArray<T>& a); |
|
102 |
|
103 #endif |
|
104 |
|
105 /* |
|
106 ;;; Local Variables: *** |
|
107 ;;; mode: C++ *** |
|
108 ;;; End: *** |
|
109 */ |