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