4511
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 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 |
4513
|
23 #if !defined (octave_NDArray_h) |
|
24 #define octave_NDArray_h 1 |
4511
|
25 |
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include "MArrayN.h" |
4513
|
31 #include "dMatrix.h" |
4902
|
32 #include "intNDArray.h" |
4511
|
33 |
|
34 #include "mx-defs.h" |
|
35 #include "mx-op-defs.h" |
|
36 |
|
37 #include "data-conv.h" |
|
38 #include "mach-info.h" |
|
39 |
4513
|
40 class |
|
41 NDArray : public MArrayN<double> |
4511
|
42 { |
4513
|
43 public: |
4511
|
44 |
|
45 NDArray (void) : MArrayN<double> () { } |
|
46 |
4587
|
47 NDArray (const dim_vector& dv) : MArrayN<double> (dv) { } |
4511
|
48 |
4587
|
49 NDArray (const dim_vector& dv, double val) |
|
50 : MArrayN<double> (dv, val) { } |
4511
|
51 |
4513
|
52 NDArray (const NDArray& a) : MArrayN<double> (a) { } |
|
53 |
|
54 NDArray (const Matrix& a) : MArrayN<double> (a) { } |
4511
|
55 |
|
56 NDArray (const MArrayN<double>& a) : MArrayN<double> (a) { } |
|
57 |
4902
|
58 template <class U> |
|
59 explicit NDArray (const intNDArray<U>& a) : MArrayN<double> (a) { } |
4543
|
60 |
4511
|
61 NDArray& operator = (const NDArray& a) |
|
62 { |
|
63 MArrayN<double>::operator = (a); |
|
64 return *this; |
|
65 } |
|
66 |
4543
|
67 // unary operations |
|
68 |
|
69 boolNDArray operator ! (void) const; |
|
70 |
4634
|
71 bool any_element_is_negative (bool = false) const; |
|
72 bool any_element_is_inf_or_nan (void) const; |
|
73 bool all_elements_are_int_or_inf_or_nan (void) const; |
|
74 bool all_integers (double& max_val, double& min_val) const; |
|
75 bool too_large_for_float (void) const; |
|
76 |
4513
|
77 // XXX FIXME XXX -- this is not quite the right thing. |
|
78 |
4556
|
79 boolNDArray all (int dim = -1) const; |
|
80 boolNDArray any (int dim = -1) const; |
4513
|
81 |
4584
|
82 NDArray cumprod (int dim = -1) const; |
|
83 NDArray cumsum (int dim = -1) const; |
4569
|
84 NDArray prod (int dim = -1) const; |
|
85 NDArray sum (int dim = -1) const; |
|
86 NDArray sumsq (int dim = -1) const; |
4806
|
87 int cat (const NDArray& ra_arg, int dim, int iidx, int move); |
4844
|
88 |
|
89 NDArray max (int dim = 0) const; |
|
90 NDArray max (ArrayN<int>& index, int dim = 0) const; |
|
91 NDArray min (int dim = 0) const; |
|
92 NDArray min (ArrayN<int>& index, int dim = 0) const; |
|
93 |
4634
|
94 NDArray abs (void) const; |
|
95 |
4773
|
96 ComplexNDArray fourier (int dim = 1) const; |
|
97 ComplexNDArray ifourier (int dim = 1) const; |
|
98 |
|
99 ComplexNDArray fourier2d (void) const; |
|
100 ComplexNDArray ifourier2d (void) const; |
|
101 |
|
102 ComplexNDArray fourierNd (void) const; |
|
103 ComplexNDArray ifourierNd (void) const; |
|
104 |
4634
|
105 friend NDArray real (const ComplexNDArray& a); |
|
106 friend NDArray imag (const ComplexNDArray& a); |
4569
|
107 |
4513
|
108 Matrix matrix_value (void) const; |
|
109 |
4902
|
110 NDArray squeeze (void) const { return MArrayN<double>::squeeze (); } |
4532
|
111 |
|
112 static void increment_index (Array<int>& ra_idx, |
|
113 const dim_vector& dimensions, |
|
114 int start_dimension = 0); |
|
115 |
4556
|
116 static int compute_index (Array<int>& ra_idx, |
|
117 const dim_vector& dimensions); |
|
118 |
4511
|
119 // i/o |
|
120 |
4687
|
121 friend std::ostream& operator << (std::ostream& os, const NDArray& a); |
|
122 friend std::istream& operator >> (std::istream& is, NDArray& a); |
4511
|
123 |
|
124 static double resize_fill_value (void) { return 0; } |
|
125 |
4513
|
126 private: |
4511
|
127 |
4634
|
128 NDArray (double *d, const dim_vector& dv) : MArrayN<double> (d, dv) { } |
4511
|
129 }; |
|
130 |
4844
|
131 extern NDArray min (double d, const NDArray& m); |
|
132 extern NDArray min (const NDArray& m, double d); |
|
133 extern NDArray min (const NDArray& a, const NDArray& b); |
|
134 |
|
135 extern NDArray max (double d, const NDArray& m); |
|
136 extern NDArray max (const NDArray& m, double d); |
|
137 extern NDArray max (const NDArray& a, const NDArray& b); |
|
138 |
4543
|
139 NDS_CMP_OP_DECLS (NDArray, double) |
|
140 NDS_BOOL_OP_DECLS (NDArray, double) |
|
141 |
|
142 SND_CMP_OP_DECLS (double, NDArray) |
|
143 SND_BOOL_OP_DECLS (double, NDArray) |
|
144 |
|
145 NDND_CMP_OP_DECLS (NDArray, NDArray) |
|
146 NDND_BOOL_OP_DECLS (NDArray, NDArray) |
|
147 |
4511
|
148 MARRAY_FORWARD_DEFS (MArrayN, NDArray, double) |
|
149 |
|
150 #endif |
4513
|
151 |
|
152 /* |
|
153 ;;; Local Variables: *** |
|
154 ;;; mode: C++ *** |
|
155 ;;; End: *** |
|
156 */ |