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 |
5943
|
65 bool any_element_not_one_or_zero (void) const; |
|
66 |
5775
|
67 // FIXME -- this is not quite the right thing. |
4902
|
68 |
|
69 boolNDArray all (int dim = -1) const; |
|
70 boolNDArray any (int dim = -1) const; |
|
71 |
|
72 intNDArray squeeze (void) const |
|
73 { return intNDArray<T> (MArrayN<T>::squeeze ()); } |
|
74 |
|
75 intNDArray transpose (void) const |
|
76 { return intNDArray<T> (MArrayN<T>::transpose ()); } |
|
77 |
5275
|
78 intNDArray concat (const intNDArray<T>& rb, const Array<octave_idx_type>& ra_idx); |
5073
|
79 |
5275
|
80 intNDArray& insert (const intNDArray<T>& a, octave_idx_type r, octave_idx_type c); |
|
81 intNDArray& insert (const intNDArray<T>& a, const Array<octave_idx_type>& ra_idx); |
4915
|
82 |
5275
|
83 static void increment_index (Array<octave_idx_type>& ra_idx, |
4902
|
84 const dim_vector& dimensions, |
|
85 int start_dimension = 0); |
|
86 |
5275
|
87 static octave_idx_type compute_index (Array<octave_idx_type>& ra_idx, |
4902
|
88 const dim_vector& dimensions); |
|
89 |
|
90 static T resize_fill_value (void) { return 0; } |
|
91 |
|
92 protected: |
|
93 |
|
94 intNDArray (T *d, dim_vector& dv) : MArrayN<T> (d, dv) { } |
|
95 }; |
|
96 |
|
97 // i/o |
|
98 |
|
99 template <class T> |
|
100 std::ostream& operator << (std::ostream& os, const intNDArray<T>& a); |
|
101 |
|
102 template <class T> |
|
103 std::istream& operator >> (std::istream& is, intNDArray<T>& a); |
|
104 |
|
105 #endif |
|
106 |
|
107 /* |
|
108 ;;; Local Variables: *** |
|
109 ;;; mode: C++ *** |
|
110 ;;; End: *** |
|
111 */ |