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 |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_intNDArray_h) |
|
24 #define octave_intNDArray_h 1 |
|
25 |
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include "MArrayN.h" |
|
31 #include "boolNDArray.h" |
|
32 |
|
33 template <class T> |
|
34 class |
|
35 intNDArray : public MArrayN<T> |
|
36 { |
|
37 public: |
|
38 |
|
39 intNDArray (void) : MArrayN<T> () { } |
|
40 |
|
41 intNDArray (T val) : MArrayN<T> (dim_vector (1, 1), val) { } |
|
42 |
|
43 intNDArray (const dim_vector& dv) : MArrayN<T> (dv) { } |
|
44 |
|
45 intNDArray (const dim_vector& dv, T val) |
|
46 : MArrayN<T> (dv, val) { } |
|
47 |
|
48 template <class U> |
|
49 explicit intNDArray (const Array<U>& a) : MArrayN<T> (a) { } |
|
50 |
|
51 template <class U> |
|
52 explicit intNDArray (const ArrayN<U>& a) : MArrayN<T> (a) { } |
|
53 |
|
54 template <class U> |
|
55 intNDArray (const MArrayN<U>& a) : MArrayN<T> (a) { } |
|
56 |
|
57 template <class U> |
|
58 intNDArray (const intNDArray<U>& a) : MArrayN<T> (a) { } |
|
59 |
|
60 intNDArray& operator = (const intNDArray<T>& a) |
|
61 { |
|
62 MArrayN<T>::operator = (a); |
|
63 return *this; |
|
64 } |
|
65 |
|
66 boolNDArray operator ! (void) const; |
|
67 |
|
68 // XXX FIXME XXX -- this is not quite the right thing. |
|
69 |
|
70 boolNDArray all (int dim = -1) const; |
|
71 boolNDArray any (int dim = -1) const; |
|
72 |
|
73 intNDArray squeeze (void) const |
|
74 { return intNDArray<T> (MArrayN<T>::squeeze ()); } |
|
75 |
|
76 intNDArray transpose (void) const |
|
77 { return intNDArray<T> (MArrayN<T>::transpose ()); } |
|
78 |
4915
|
79 intNDArray& insert (const intNDArray<T>& a, int r, int c); |
|
80 intNDArray& insert (const intNDArray<T>& a, const Array<int>& ra_idx); |
|
81 |
4902
|
82 static void increment_index (Array<int>& ra_idx, |
|
83 const dim_vector& dimensions, |
|
84 int start_dimension = 0); |
|
85 |
|
86 static int compute_index (Array<int>& ra_idx, |
|
87 const dim_vector& dimensions); |
|
88 |
|
89 static T resize_fill_value (void) { return 0; } |
|
90 |
|
91 protected: |
|
92 |
|
93 intNDArray (T *d, dim_vector& dv) : MArrayN<T> (d, dv) { } |
|
94 }; |
|
95 |
|
96 // i/o |
|
97 |
|
98 template <class T> |
|
99 std::ostream& operator << (std::ostream& os, const intNDArray<T>& a); |
|
100 |
|
101 template <class T> |
|
102 std::istream& operator >> (std::istream& is, intNDArray<T>& a); |
|
103 |
|
104 #endif |
|
105 |
|
106 /* |
|
107 ;;; Local Variables: *** |
|
108 ;;; mode: C++ *** |
|
109 ;;; End: *** |
|
110 */ |