Mercurial > hg > octave-lyh
annotate liboctave/CNDArray.cc @ 11130:7c573eb981eb
consistently give error for operator not applied to NaN values
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 21 Oct 2010 16:12:13 -0400 |
parents | 3622db30ff05 |
children | fd0a3ac60b0e |
rev | line source |
---|---|
4514 | 1 // N-D Array manipulations. |
2 /* | |
3 | |
8920 | 4 Copyright (C) 1996, 1997, 2003, 2004, 2005, 2006, 2007, 2008, |
5 2009 John W. Eaton | |
9601
a9b37bae1802
add a couple of missing copyright statements
Jaroslav Hajek <highegg@gmail.com>
parents:
9578
diff
changeset
|
6 Copyright (C) 2009 VZLU Prague, a.s. |
4514 | 7 |
8 This file is part of Octave. | |
9 | |
10 Octave is free software; you can redistribute it and/or modify it | |
11 under the terms of the GNU General Public License as published by the | |
7016 | 12 Free Software Foundation; either version 3 of the License, or (at your |
13 option) any later version. | |
4514 | 14 |
15 Octave is distributed in the hope that it will be useful, but WITHOUT | |
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
18 for more details. | |
19 | |
20 You should have received a copy of the GNU General Public License | |
7016 | 21 along with Octave; see the file COPYING. If not, see |
22 <http://www.gnu.org/licenses/>. | |
4514 | 23 |
24 */ | |
25 | |
26 #ifdef HAVE_CONFIG_H | |
27 #include <config.h> | |
28 #endif | |
29 | |
4687 | 30 #include <cfloat> |
5164 | 31 |
4780 | 32 #include <vector> |
4687 | 33 |
4588 | 34 #include "Array-util.h" |
4514 | 35 #include "CNDArray.h" |
4773 | 36 #include "f77-fcn.h" |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
37 #include "functor.h" |
4514 | 38 #include "lo-ieee.h" |
4687 | 39 #include "lo-mappers.h" |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
40 #include "MArray-defs.h" |
9523
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
41 #include "mx-base.h" |
8774
b756ce0002db
split implementation and interface in mx-op-defs and MArray-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
8751
diff
changeset
|
42 #include "mx-op-defs.h" |
4780 | 43 #include "oct-fftw.h" |
9523
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
44 #include "oct-locbuf.h" |
4773 | 45 |
9743
26abff55f6fe
optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
46 #include "bsxfun-defs.cc" |
26abff55f6fe
optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
47 |
8956
d91fa4b20bbb
ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
48 ComplexNDArray::ComplexNDArray (const charNDArray& a) |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
49 : MArray<Complex> (a.dims ()) |
8956
d91fa4b20bbb
ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
50 { |
d91fa4b20bbb
ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
51 octave_idx_type n = a.numel (); |
d91fa4b20bbb
ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
52 for (octave_idx_type i = 0; i < n; i++) |
d91fa4b20bbb
ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
53 xelem (i) = static_cast<unsigned char> (a(i)); |
d91fa4b20bbb
ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
54 } |
d91fa4b20bbb
ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
55 |
9523
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
56 #if defined (HAVE_FFTW) |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
57 |
4773 | 58 ComplexNDArray |
59 ComplexNDArray::fourier (int dim) const | |
60 { | |
61 dim_vector dv = dims (); | |
62 | |
63 if (dim > dv.length () || dim < 0) | |
64 return ComplexNDArray (); | |
65 | |
5275 | 66 octave_idx_type stride = 1; |
67 octave_idx_type n = dv(dim); | |
4773 | 68 |
69 for (int i = 0; i < dim; i++) | |
70 stride *= dv(i); | |
71 | |
5275 | 72 octave_idx_type howmany = numel () / dv (dim); |
4773 | 73 howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany)); |
5275 | 74 octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride); |
75 octave_idx_type dist = (stride == 1 ? n : 1); | |
4773 | 76 |
77 const Complex *in (fortran_vec ()); | |
78 ComplexNDArray retval (dv); | |
79 Complex *out (retval.fortran_vec ()); | |
80 | |
81 // Need to be careful here about the distance between fft's | |
5275 | 82 for (octave_idx_type k = 0; k < nloop; k++) |
4773 | 83 octave_fftw::fft (in + k * stride * n, out + k * stride * n, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
84 n, howmany, stride, dist); |
4773 | 85 |
86 return retval; | |
87 } | |
88 | |
89 ComplexNDArray | |
4816 | 90 ComplexNDArray::ifourier (int dim) const |
4773 | 91 { |
92 dim_vector dv = dims (); | |
93 | |
94 if (dim > dv.length () || dim < 0) | |
95 return ComplexNDArray (); | |
96 | |
5275 | 97 octave_idx_type stride = 1; |
98 octave_idx_type n = dv(dim); | |
4773 | 99 |
100 for (int i = 0; i < dim; i++) | |
101 stride *= dv(i); | |
102 | |
5275 | 103 octave_idx_type howmany = numel () / dv (dim); |
4773 | 104 howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany)); |
5275 | 105 octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride); |
106 octave_idx_type dist = (stride == 1 ? n : 1); | |
4773 | 107 |
108 const Complex *in (fortran_vec ()); | |
109 ComplexNDArray retval (dv); | |
110 Complex *out (retval.fortran_vec ()); | |
111 | |
112 // Need to be careful here about the distance between fft's | |
5275 | 113 for (octave_idx_type k = 0; k < nloop; k++) |
4773 | 114 octave_fftw::ifft (in + k * stride * n, out + k * stride * n, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
115 n, howmany, stride, dist); |
4773 | 116 |
117 return retval; | |
118 } | |
119 | |
120 ComplexNDArray | |
121 ComplexNDArray::fourier2d (void) const | |
122 { | |
123 dim_vector dv = dims(); | |
124 if (dv.length () < 2) | |
125 return ComplexNDArray (); | |
126 | |
127 dim_vector dv2(dv(0), dv(1)); | |
128 const Complex *in = fortran_vec (); | |
129 ComplexNDArray retval (dv); | |
130 Complex *out = retval.fortran_vec (); | |
5275 | 131 octave_idx_type howmany = numel() / dv(0) / dv(1); |
132 octave_idx_type dist = dv(0) * dv(1); | |
4773 | 133 |
5275 | 134 for (octave_idx_type i=0; i < howmany; i++) |
4773 | 135 octave_fftw::fftNd (in + i*dist, out + i*dist, 2, dv2); |
136 | |
137 return retval; | |
138 } | |
139 | |
140 ComplexNDArray | |
141 ComplexNDArray::ifourier2d (void) const | |
142 { | |
143 dim_vector dv = dims(); | |
144 if (dv.length () < 2) | |
145 return ComplexNDArray (); | |
146 | |
147 dim_vector dv2(dv(0), dv(1)); | |
148 const Complex *in = fortran_vec (); | |
149 ComplexNDArray retval (dv); | |
150 Complex *out = retval.fortran_vec (); | |
5275 | 151 octave_idx_type howmany = numel() / dv(0) / dv(1); |
152 octave_idx_type dist = dv(0) * dv(1); | |
4773 | 153 |
5275 | 154 for (octave_idx_type i=0; i < howmany; i++) |
4773 | 155 octave_fftw::ifftNd (in + i*dist, out + i*dist, 2, dv2); |
156 | |
157 return retval; | |
158 } | |
159 | |
160 ComplexNDArray | |
161 ComplexNDArray::fourierNd (void) const | |
162 { | |
163 dim_vector dv = dims (); | |
164 int rank = dv.length (); | |
165 | |
166 const Complex *in (fortran_vec ()); | |
167 ComplexNDArray retval (dv); | |
168 Complex *out (retval.fortran_vec ()); | |
169 | |
170 octave_fftw::fftNd (in, out, rank, dv); | |
171 | |
172 return retval; | |
173 } | |
174 | |
175 ComplexNDArray | |
176 ComplexNDArray::ifourierNd (void) const | |
177 { | |
178 dim_vector dv = dims (); | |
179 int rank = dv.length (); | |
180 | |
181 const Complex *in (fortran_vec ()); | |
182 ComplexNDArray retval (dv); | |
183 Complex *out (retval.fortran_vec ()); | |
184 | |
185 octave_fftw::ifftNd (in, out, rank, dv); | |
186 | |
187 return retval; | |
188 } | |
189 | |
190 #else | |
9523
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
191 |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
192 extern "C" |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
193 { |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
194 // Note that the original complex fft routines were not written for |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
195 // double complex arguments. They have been modified by adding an |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
196 // implicit double precision (a-h,o-z) statement at the beginning of |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
197 // each subroutine. |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
198 |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
199 F77_RET_T |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
200 F77_FUNC (zffti, ZFFTI) (const octave_idx_type&, Complex*); |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
201 |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
202 F77_RET_T |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
203 F77_FUNC (zfftf, ZFFTF) (const octave_idx_type&, Complex*, Complex*); |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
204 |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
205 F77_RET_T |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
206 F77_FUNC (zfftb, ZFFTB) (const octave_idx_type&, Complex*, Complex*); |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
207 } |
0ce82753dd72
more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents:
9513
diff
changeset
|
208 |
4773 | 209 ComplexNDArray |
210 ComplexNDArray::fourier (int dim) const | |
211 { | |
212 dim_vector dv = dims (); | |
213 | |
214 if (dim > dv.length () || dim < 0) | |
215 return ComplexNDArray (); | |
216 | |
217 ComplexNDArray retval (dv); | |
5275 | 218 octave_idx_type npts = dv(dim); |
219 octave_idx_type nn = 4*npts+15; | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
220 Array<Complex> wsave (nn, 1); |
4773 | 221 Complex *pwsave = wsave.fortran_vec (); |
222 | |
223 OCTAVE_LOCAL_BUFFER (Complex, tmp, npts); | |
224 | |
5275 | 225 octave_idx_type stride = 1; |
4773 | 226 |
227 for (int i = 0; i < dim; i++) | |
228 stride *= dv(i); | |
229 | |
5275 | 230 octave_idx_type howmany = numel () / npts; |
4773 | 231 howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany)); |
5275 | 232 octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride); |
233 octave_idx_type dist = (stride == 1 ? npts : 1); | |
4773 | 234 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7620
diff
changeset
|
235 F77_FUNC (zffti, ZFFTI) (npts, pwsave); |
4773 | 236 |
5275 | 237 for (octave_idx_type k = 0; k < nloop; k++) |
4773 | 238 { |
5275 | 239 for (octave_idx_type j = 0; j < howmany; j++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
240 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
241 octave_quit (); |
4773 | 242 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
243 for (octave_idx_type i = 0; i < npts; i++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
244 tmp[i] = elem((i + k*npts)*stride + j*dist); |
4773 | 245 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
246 F77_FUNC (zfftf, ZFFTF) (npts, tmp, pwsave); |
4773 | 247 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
248 for (octave_idx_type i = 0; i < npts; i++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
249 retval ((i + k*npts)*stride + j*dist) = tmp[i]; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
250 } |
4773 | 251 } |
252 | |
253 return retval; | |
254 } | |
255 | |
256 ComplexNDArray | |
257 ComplexNDArray::ifourier (int dim) const | |
258 { | |
259 dim_vector dv = dims (); | |
260 | |
261 if (dim > dv.length () || dim < 0) | |
262 return ComplexNDArray (); | |
263 | |
264 ComplexNDArray retval (dv); | |
5275 | 265 octave_idx_type npts = dv(dim); |
266 octave_idx_type nn = 4*npts+15; | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
267 Array<Complex> wsave (nn, 1); |
4773 | 268 Complex *pwsave = wsave.fortran_vec (); |
269 | |
270 OCTAVE_LOCAL_BUFFER (Complex, tmp, npts); | |
271 | |
5275 | 272 octave_idx_type stride = 1; |
4773 | 273 |
274 for (int i = 0; i < dim; i++) | |
275 stride *= dv(i); | |
276 | |
5275 | 277 octave_idx_type howmany = numel () / npts; |
4773 | 278 howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany)); |
5275 | 279 octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride); |
280 octave_idx_type dist = (stride == 1 ? npts : 1); | |
4773 | 281 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7620
diff
changeset
|
282 F77_FUNC (zffti, ZFFTI) (npts, pwsave); |
4773 | 283 |
5275 | 284 for (octave_idx_type k = 0; k < nloop; k++) |
4773 | 285 { |
5275 | 286 for (octave_idx_type j = 0; j < howmany; j++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
287 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
288 octave_quit (); |
4773 | 289 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
290 for (octave_idx_type i = 0; i < npts; i++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
291 tmp[i] = elem((i + k*npts)*stride + j*dist); |
4773 | 292 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
293 F77_FUNC (zfftb, ZFFTB) (npts, tmp, pwsave); |
4773 | 294 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
295 for (octave_idx_type i = 0; i < npts; i++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
296 retval ((i + k*npts)*stride + j*dist) = tmp[i] / |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
297 static_cast<double> (npts); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
298 } |
4773 | 299 } |
300 | |
301 return retval; | |
302 } | |
303 | |
304 ComplexNDArray | |
305 ComplexNDArray::fourier2d (void) const | |
306 { | |
307 dim_vector dv = dims (); | |
308 dim_vector dv2 (dv(0), dv(1)); | |
309 int rank = 2; | |
310 ComplexNDArray retval (*this); | |
5275 | 311 octave_idx_type stride = 1; |
4773 | 312 |
313 for (int i = 0; i < rank; i++) | |
314 { | |
5275 | 315 octave_idx_type npts = dv2(i); |
316 octave_idx_type nn = 4*npts+15; | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
317 Array<Complex> wsave (nn, 1); |
4773 | 318 Complex *pwsave = wsave.fortran_vec (); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
319 Array<Complex> row (npts, 1); |
4773 | 320 Complex *prow = row.fortran_vec (); |
321 | |
5275 | 322 octave_idx_type howmany = numel () / npts; |
4773 | 323 howmany = (stride == 1 ? howmany : |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
324 (howmany > stride ? stride : howmany)); |
5275 | 325 octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride); |
326 octave_idx_type dist = (stride == 1 ? npts : 1); | |
4773 | 327 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7620
diff
changeset
|
328 F77_FUNC (zffti, ZFFTI) (npts, pwsave); |
4773 | 329 |
5275 | 330 for (octave_idx_type k = 0; k < nloop; k++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
331 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
332 for (octave_idx_type j = 0; j < howmany; j++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
333 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
334 octave_quit (); |
4773 | 335 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
336 for (octave_idx_type l = 0; l < npts; l++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
337 prow[l] = retval ((l + k*npts)*stride + j*dist); |
4773 | 338 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
339 F77_FUNC (zfftf, ZFFTF) (npts, prow, pwsave); |
4773 | 340 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
341 for (octave_idx_type l = 0; l < npts; l++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
342 retval ((l + k*npts)*stride + j*dist) = prow[l]; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
343 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
344 } |
4773 | 345 |
346 stride *= dv2(i); | |
347 } | |
348 | |
349 return retval; | |
350 } | |
351 | |
352 ComplexNDArray | |
353 ComplexNDArray::ifourier2d (void) const | |
354 { | |
355 dim_vector dv = dims(); | |
356 dim_vector dv2 (dv(0), dv(1)); | |
357 int rank = 2; | |
358 ComplexNDArray retval (*this); | |
5275 | 359 octave_idx_type stride = 1; |
4773 | 360 |
361 for (int i = 0; i < rank; i++) | |
362 { | |
5275 | 363 octave_idx_type npts = dv2(i); |
364 octave_idx_type nn = 4*npts+15; | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
365 Array<Complex> wsave (nn, 1); |
4773 | 366 Complex *pwsave = wsave.fortran_vec (); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
367 Array<Complex> row (npts, 1); |
4773 | 368 Complex *prow = row.fortran_vec (); |
369 | |
5275 | 370 octave_idx_type howmany = numel () / npts; |
4773 | 371 howmany = (stride == 1 ? howmany : |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
372 (howmany > stride ? stride : howmany)); |
5275 | 373 octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride); |
374 octave_idx_type dist = (stride == 1 ? npts : 1); | |
4773 | 375 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7620
diff
changeset
|
376 F77_FUNC (zffti, ZFFTI) (npts, pwsave); |
4773 | 377 |
5275 | 378 for (octave_idx_type k = 0; k < nloop; k++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
379 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
380 for (octave_idx_type j = 0; j < howmany; j++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
381 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
382 octave_quit (); |
4773 | 383 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
384 for (octave_idx_type l = 0; l < npts; l++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
385 prow[l] = retval ((l + k*npts)*stride + j*dist); |
4773 | 386 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
387 F77_FUNC (zfftb, ZFFTB) (npts, prow, pwsave); |
4773 | 388 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
389 for (octave_idx_type l = 0; l < npts; l++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
390 retval ((l + k*npts)*stride + j*dist) = prow[l] / |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
391 static_cast<double> (npts); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
392 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
393 } |
4773 | 394 |
395 stride *= dv2(i); | |
396 } | |
397 | |
398 return retval; | |
399 } | |
400 | |
401 ComplexNDArray | |
402 ComplexNDArray::fourierNd (void) const | |
403 { | |
404 dim_vector dv = dims (); | |
405 int rank = dv.length (); | |
406 ComplexNDArray retval (*this); | |
5275 | 407 octave_idx_type stride = 1; |
4773 | 408 |
409 for (int i = 0; i < rank; i++) | |
410 { | |
5275 | 411 octave_idx_type npts = dv(i); |
412 octave_idx_type nn = 4*npts+15; | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
413 Array<Complex> wsave (nn, 1); |
4773 | 414 Complex *pwsave = wsave.fortran_vec (); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
415 Array<Complex> row (npts, 1); |
4773 | 416 Complex *prow = row.fortran_vec (); |
417 | |
5275 | 418 octave_idx_type howmany = numel () / npts; |
4773 | 419 howmany = (stride == 1 ? howmany : |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
420 (howmany > stride ? stride : howmany)); |
5275 | 421 octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride); |
422 octave_idx_type dist = (stride == 1 ? npts : 1); | |
4773 | 423 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7620
diff
changeset
|
424 F77_FUNC (zffti, ZFFTI) (npts, pwsave); |
4773 | 425 |
5275 | 426 for (octave_idx_type k = 0; k < nloop; k++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
427 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
428 for (octave_idx_type j = 0; j < howmany; j++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
429 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
430 octave_quit (); |
4773 | 431 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
432 for (octave_idx_type l = 0; l < npts; l++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
433 prow[l] = retval ((l + k*npts)*stride + j*dist); |
4773 | 434 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
435 F77_FUNC (zfftf, ZFFTF) (npts, prow, pwsave); |
4773 | 436 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
437 for (octave_idx_type l = 0; l < npts; l++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
438 retval ((l + k*npts)*stride + j*dist) = prow[l]; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
439 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
440 } |
4773 | 441 |
442 stride *= dv(i); | |
443 } | |
444 | |
445 return retval; | |
446 } | |
447 | |
448 ComplexNDArray | |
449 ComplexNDArray::ifourierNd (void) const | |
450 { | |
451 dim_vector dv = dims (); | |
452 int rank = dv.length (); | |
453 ComplexNDArray retval (*this); | |
5275 | 454 octave_idx_type stride = 1; |
4773 | 455 |
456 for (int i = 0; i < rank; i++) | |
457 { | |
5275 | 458 octave_idx_type npts = dv(i); |
459 octave_idx_type nn = 4*npts+15; | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
460 Array<Complex> wsave (nn, 1); |
4773 | 461 Complex *pwsave = wsave.fortran_vec (); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
462 Array<Complex> row (npts, 1); |
4773 | 463 Complex *prow = row.fortran_vec (); |
464 | |
5275 | 465 octave_idx_type howmany = numel () / npts; |
4773 | 466 howmany = (stride == 1 ? howmany : |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
467 (howmany > stride ? stride : howmany)); |
5275 | 468 octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride); |
469 octave_idx_type dist = (stride == 1 ? npts : 1); | |
4773 | 470 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7620
diff
changeset
|
471 F77_FUNC (zffti, ZFFTI) (npts, pwsave); |
4773 | 472 |
5275 | 473 for (octave_idx_type k = 0; k < nloop; k++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
474 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
475 for (octave_idx_type j = 0; j < howmany; j++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
476 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
477 octave_quit (); |
4773 | 478 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
479 for (octave_idx_type l = 0; l < npts; l++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
480 prow[l] = retval ((l + k*npts)*stride + j*dist); |
4773 | 481 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
482 F77_FUNC (zfftb, ZFFTB) (npts, prow, pwsave); |
4773 | 483 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
484 for (octave_idx_type l = 0; l < npts; l++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
485 retval ((l + k*npts)*stride + j*dist) = prow[l] / |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
486 static_cast<double> (npts); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
487 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
488 } |
4773 | 489 |
490 stride *= dv(i); | |
491 } | |
492 | |
493 return retval; | |
494 } | |
495 | |
496 #endif | |
497 | |
4543 | 498 // unary operations |
499 | |
500 boolNDArray | |
501 ComplexNDArray::operator ! (void) const | |
502 { | |
11130
7c573eb981eb
consistently give error for operator not applied to NaN values
John W. Eaton <jwe@octave.org>
parents:
11008
diff
changeset
|
503 if (any_element_is_nan ()) |
7c573eb981eb
consistently give error for operator not applied to NaN values
John W. Eaton <jwe@octave.org>
parents:
11008
diff
changeset
|
504 gripe_nan_to_logical_conversion (); |
7c573eb981eb
consistently give error for operator not applied to NaN values
John W. Eaton <jwe@octave.org>
parents:
11008
diff
changeset
|
505 |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
506 return do_mx_unary_op<bool, Complex> (*this, mx_inline_not); |
4543 | 507 } |
508 | |
5775 | 509 // FIXME -- this is not quite the right thing. |
4514 | 510 |
4687 | 511 bool |
7922
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
512 ComplexNDArray::any_element_is_nan (void) const |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
513 { |
11008
3622db30ff05
simplify some array tests in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10362
diff
changeset
|
514 return do_mx_check<Complex> (*this, mx_inline_any_nan); |
7922
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
515 } |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
516 |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
517 bool |
4687 | 518 ComplexNDArray::any_element_is_inf_or_nan (void) const |
519 { | |
11008
3622db30ff05
simplify some array tests in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10362
diff
changeset
|
520 return ! do_mx_check<Complex> (*this, mx_inline_all_finite); |
4687 | 521 } |
522 | |
523 // Return true if no elements have imaginary components. | |
524 | |
525 bool | |
526 ComplexNDArray::all_elements_are_real (void) const | |
527 { | |
11008
3622db30ff05
simplify some array tests in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10362
diff
changeset
|
528 return do_mx_check<Complex> (*this, mx_inline_all_real); |
4687 | 529 } |
530 | |
531 // Return nonzero if any element of CM has a non-integer real or | |
532 // imaginary part. Also extract the largest and smallest (real or | |
533 // imaginary) values and return them in MAX_VAL and MIN_VAL. | |
534 | |
535 bool | |
536 ComplexNDArray::all_integers (double& max_val, double& min_val) const | |
537 { | |
5275 | 538 octave_idx_type nel = nelem (); |
4687 | 539 |
540 if (nel > 0) | |
541 { | |
542 Complex val = elem (0); | |
543 | |
5260 | 544 double r_val = std::real (val); |
545 double i_val = std::imag (val); | |
4687 | 546 |
547 max_val = r_val; | |
548 min_val = r_val; | |
549 | |
550 if (i_val > max_val) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
551 max_val = i_val; |
4687 | 552 |
553 if (i_val < max_val) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
554 min_val = i_val; |
4687 | 555 } |
556 else | |
557 return false; | |
558 | |
5275 | 559 for (octave_idx_type i = 0; i < nel; i++) |
4687 | 560 { |
561 Complex val = elem (i); | |
562 | |
5260 | 563 double r_val = std::real (val); |
564 double i_val = std::imag (val); | |
4687 | 565 |
566 if (r_val > max_val) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
567 max_val = r_val; |
4687 | 568 |
569 if (i_val > max_val) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
570 max_val = i_val; |
4687 | 571 |
572 if (r_val < min_val) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
573 min_val = r_val; |
4687 | 574 |
575 if (i_val < min_val) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
576 min_val = i_val; |
4687 | 577 |
578 if (D_NINT (r_val) != r_val || D_NINT (i_val) != i_val) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
579 return false; |
4687 | 580 } |
581 | |
582 return true; | |
583 } | |
584 | |
585 bool | |
586 ComplexNDArray::too_large_for_float (void) const | |
587 { | |
5275 | 588 octave_idx_type nel = nelem (); |
4687 | 589 |
5275 | 590 for (octave_idx_type i = 0; i < nel; i++) |
4687 | 591 { |
592 Complex val = elem (i); | |
593 | |
5260 | 594 double r_val = std::real (val); |
595 double i_val = std::imag (val); | |
4687 | 596 |
5389 | 597 if ((! (xisnan (r_val) || xisinf (r_val)) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
598 && fabs (r_val) > FLT_MAX) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
599 || (! (xisnan (i_val) || xisinf (i_val)) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
600 && fabs (i_val) > FLT_MAX)) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
601 return true; |
4687 | 602 } |
603 | |
604 return false; | |
605 } | |
606 | |
4556 | 607 boolNDArray |
4514 | 608 ComplexNDArray::all (int dim) const |
609 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
610 return do_mx_red_op<bool, Complex> (*this, dim, mx_inline_all); |
4514 | 611 } |
612 | |
4556 | 613 boolNDArray |
4514 | 614 ComplexNDArray::any (int dim) const |
615 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
616 return do_mx_red_op<bool, Complex> (*this, dim, mx_inline_any); |
4569 | 617 } |
618 | |
4584 | 619 ComplexNDArray |
4569 | 620 ComplexNDArray::cumprod (int dim) const |
621 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
622 return do_mx_cum_op<Complex, Complex> (*this, dim, mx_inline_cumprod); |
4569 | 623 } |
624 | |
4584 | 625 ComplexNDArray |
4569 | 626 ComplexNDArray::cumsum (int dim) const |
627 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
628 return do_mx_cum_op<Complex, Complex> (*this, dim, mx_inline_cumsum); |
4569 | 629 } |
630 | |
631 ComplexNDArray | |
632 ComplexNDArray::prod (int dim) const | |
633 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
634 return do_mx_red_op<Complex, Complex> (*this, dim, mx_inline_prod); |
8736
53b4fdeacc2e
improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8650
diff
changeset
|
635 } |
53b4fdeacc2e
improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8650
diff
changeset
|
636 |
53b4fdeacc2e
improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8650
diff
changeset
|
637 ComplexNDArray |
53b4fdeacc2e
improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8650
diff
changeset
|
638 ComplexNDArray::sum (int dim) const |
53b4fdeacc2e
improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8650
diff
changeset
|
639 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
640 return do_mx_red_op<Complex, Complex> (*this, dim, mx_inline_sum); |
4569 | 641 } |
642 | |
643 ComplexNDArray | |
9721
192d94cff6c1
improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents:
9612
diff
changeset
|
644 ComplexNDArray::xsum (int dim) const |
192d94cff6c1
improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents:
9612
diff
changeset
|
645 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
646 return do_mx_red_op<Complex, Complex> (*this, dim, mx_inline_xsum); |
9721
192d94cff6c1
improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents:
9612
diff
changeset
|
647 } |
192d94cff6c1
improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents:
9612
diff
changeset
|
648 |
192d94cff6c1
improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents:
9612
diff
changeset
|
649 ComplexNDArray |
4569 | 650 ComplexNDArray::sumsq (int dim) const |
651 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
652 return do_mx_red_op<double, Complex> (*this, dim, mx_inline_sumsq); |
4569 | 653 } |
654 | |
4915 | 655 ComplexNDArray |
9513
9f870f73ab7d
implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
656 ComplexNDArray::diff (octave_idx_type order, int dim) const |
9f870f73ab7d
implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
657 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
658 return do_mx_diff_op<Complex> (*this, dim, order, mx_inline_diff); |
9513
9f870f73ab7d
implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
659 } |
9f870f73ab7d
implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
660 |
9f870f73ab7d
implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
661 ComplexNDArray |
5275 | 662 ComplexNDArray::concat (const ComplexNDArray& rb, const Array<octave_idx_type>& ra_idx) |
4915 | 663 { |
4940 | 664 if (rb.numel () > 0) |
5073 | 665 insert (rb, ra_idx); |
666 return *this; | |
4915 | 667 } |
668 | |
669 ComplexNDArray | |
5275 | 670 ComplexNDArray::concat (const NDArray& rb, const Array<octave_idx_type>& ra_idx) |
4758 | 671 { |
4915 | 672 ComplexNDArray tmp (rb); |
4940 | 673 if (rb.numel () > 0) |
5073 | 674 insert (tmp, ra_idx); |
675 return *this; | |
4915 | 676 } |
677 | |
678 ComplexNDArray | |
5275 | 679 concat (NDArray& ra, ComplexNDArray& rb, const Array<octave_idx_type>& ra_idx) |
4915 | 680 { |
681 ComplexNDArray retval (ra); | |
4940 | 682 if (rb.numel () > 0) |
4915 | 683 retval.insert (rb, ra_idx); |
684 return retval; | |
4758 | 685 } |
686 | |
4844 | 687 static const Complex Complex_NaN_result (octave_NaN, octave_NaN); |
688 | |
689 ComplexNDArray | |
690 ComplexNDArray::max (int dim) const | |
691 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
692 return do_mx_minmax_op<Complex> (*this, dim, mx_inline_max); |
4844 | 693 } |
694 | |
695 ComplexNDArray | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9721
diff
changeset
|
696 ComplexNDArray::max (Array<octave_idx_type>& idx_arg, int dim) const |
4844 | 697 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
698 return do_mx_minmax_op<Complex> (*this, idx_arg, dim, mx_inline_max); |
4844 | 699 } |
700 | |
701 ComplexNDArray | |
702 ComplexNDArray::min (int dim) const | |
703 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
704 return do_mx_minmax_op<Complex> (*this, dim, mx_inline_min); |
4844 | 705 } |
706 | |
707 ComplexNDArray | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9721
diff
changeset
|
708 ComplexNDArray::min (Array<octave_idx_type>& idx_arg, int dim) const |
4844 | 709 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
710 return do_mx_minmax_op<Complex> (*this, idx_arg, dim, mx_inline_min); |
4844 | 711 } |
712 | |
8777
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
713 ComplexNDArray |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
714 ComplexNDArray::cummax (int dim) const |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
715 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
716 return do_mx_cumminmax_op<Complex> (*this, dim, mx_inline_cummax); |
8777
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
717 } |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
718 |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
719 ComplexNDArray |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9721
diff
changeset
|
720 ComplexNDArray::cummax (Array<octave_idx_type>& idx_arg, int dim) const |
8777
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
721 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
722 return do_mx_cumminmax_op<Complex> (*this, idx_arg, dim, mx_inline_cummax); |
8777
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
723 } |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
724 |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
725 ComplexNDArray |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
726 ComplexNDArray::cummin (int dim) const |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
727 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
728 return do_mx_cumminmax_op<Complex> (*this, dim, mx_inline_cummin); |
8777
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
729 } |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
730 |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
731 ComplexNDArray |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9721
diff
changeset
|
732 ComplexNDArray::cummin (Array<octave_idx_type>& idx_arg, int dim) const |
8777
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
733 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
734 return do_mx_cumminmax_op<Complex> (*this, idx_arg, dim, mx_inline_cummin); |
8777
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
735 } |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
736 |
4634 | 737 NDArray |
4569 | 738 ComplexNDArray::abs (void) const |
739 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
740 return do_mx_unary_map<double, Complex, std::abs> (*this); |
8650
a1ae2aae903e
abs,real,imag,conj: use code from mx-inlines rather than the generic map
Jaroslav Hajek <highegg@gmail.com>
parents:
8377
diff
changeset
|
741 } |
4634 | 742 |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
743 boolNDArray |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
744 ComplexNDArray::isnan (void) const |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
745 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
746 return do_mx_unary_map<bool, Complex, xisnan> (*this); |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
747 } |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
748 |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
749 boolNDArray |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
750 ComplexNDArray::isinf (void) const |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
751 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
752 return do_mx_unary_map<bool, Complex, xisinf> (*this); |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
753 } |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
754 |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
755 boolNDArray |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
756 ComplexNDArray::isfinite (void) const |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
757 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
758 return do_mx_unary_map<bool, Complex, xfinite> (*this); |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
759 } |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
760 |
8650
a1ae2aae903e
abs,real,imag,conj: use code from mx-inlines rather than the generic map
Jaroslav Hajek <highegg@gmail.com>
parents:
8377
diff
changeset
|
761 ComplexNDArray |
a1ae2aae903e
abs,real,imag,conj: use code from mx-inlines rather than the generic map
Jaroslav Hajek <highegg@gmail.com>
parents:
8377
diff
changeset
|
762 conj (const ComplexNDArray& a) |
a1ae2aae903e
abs,real,imag,conj: use code from mx-inlines rather than the generic map
Jaroslav Hajek <highegg@gmail.com>
parents:
8377
diff
changeset
|
763 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
764 return do_mx_unary_map<Complex, Complex, std::conj> (a); |
4514 | 765 } |
766 | |
4765 | 767 ComplexNDArray& |
5275 | 768 ComplexNDArray::insert (const NDArray& a, octave_idx_type r, octave_idx_type c) |
4765 | 769 { |
770 dim_vector a_dv = a.dims (); | |
771 | |
772 int n = a_dv.length (); | |
773 | |
774 if (n == dimensions.length ()) | |
775 { | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
776 Array<octave_idx_type> a_ra_idx (a_dv.length (), 1, 0); |
4765 | 777 |
778 a_ra_idx.elem (0) = r; | |
779 a_ra_idx.elem (1) = c; | |
780 | |
781 for (int i = 0; i < n; i++) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
782 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
783 if (a_ra_idx (i) < 0 || (a_ra_idx (i) + a_dv (i)) > dimensions (i)) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
784 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
785 (*current_liboctave_error_handler) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
786 ("Array<T>::insert: range error for insert"); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
787 return *this; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
788 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
789 } |
4765 | 790 |
791 a_ra_idx.elem (0) = 0; | |
792 a_ra_idx.elem (1) = 0; | |
793 | |
5275 | 794 octave_idx_type n_elt = a.numel (); |
4765 | 795 |
796 // IS make_unique () NECCESSARY HERE?? | |
797 | |
5275 | 798 for (octave_idx_type i = 0; i < n_elt; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
799 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
800 Array<octave_idx_type> ra_idx = a_ra_idx; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
801 |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
802 ra_idx.elem (0) = a_ra_idx (0) + r; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
803 ra_idx.elem (1) = a_ra_idx (1) + c; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
804 |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
805 elem (ra_idx) = a.elem (a_ra_idx); |
4765 | 806 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
807 increment_index (a_ra_idx, a_dv); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
808 } |
4765 | 809 } |
810 else | |
811 (*current_liboctave_error_handler) | |
812 ("Array<T>::insert: invalid indexing operation"); | |
813 | |
814 return *this; | |
815 } | |
816 | |
817 ComplexNDArray& | |
5275 | 818 ComplexNDArray::insert (const ComplexNDArray& a, octave_idx_type r, octave_idx_type c) |
4765 | 819 { |
820 Array<Complex>::insert (a, r, c); | |
821 return *this; | |
822 } | |
823 | |
4915 | 824 ComplexNDArray& |
5275 | 825 ComplexNDArray::insert (const ComplexNDArray& a, const Array<octave_idx_type>& ra_idx) |
4915 | 826 { |
827 Array<Complex>::insert (a, ra_idx); | |
828 return *this; | |
829 } | |
830 | |
4514 | 831 ComplexMatrix |
832 ComplexNDArray::matrix_value (void) const | |
833 { | |
834 ComplexMatrix retval; | |
835 | |
8981
ed5055b0a476
fix & simplify ndarray->matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8956
diff
changeset
|
836 if (ndims () == 2) |
10352 | 837 retval = ComplexMatrix (Array<Complex> (*this)); |
8981
ed5055b0a476
fix & simplify ndarray->matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8956
diff
changeset
|
838 else |
ed5055b0a476
fix & simplify ndarray->matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8956
diff
changeset
|
839 (*current_liboctave_error_handler) |
ed5055b0a476
fix & simplify ndarray->matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8956
diff
changeset
|
840 ("invalid conversion of ComplexNDArray to ComplexMatrix"); |
4514 | 841 |
842 return retval; | |
843 } | |
844 | |
4532 | 845 void |
5275 | 846 ComplexNDArray::increment_index (Array<octave_idx_type>& ra_idx, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
847 const dim_vector& dimensions, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
848 int start_dimension) |
4532 | 849 { |
850 ::increment_index (ra_idx, dimensions, start_dimension); | |
851 } | |
852 | |
5275 | 853 octave_idx_type |
854 ComplexNDArray::compute_index (Array<octave_idx_type>& ra_idx, | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
855 const dim_vector& dimensions) |
4556 | 856 { |
857 return ::compute_index (ra_idx, dimensions); | |
858 } | |
859 | |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7600
diff
changeset
|
860 ComplexNDArray |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7600
diff
changeset
|
861 ComplexNDArray::diag (octave_idx_type k) const |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7600
diff
changeset
|
862 { |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
863 return MArray<Complex>::diag (k); |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7600
diff
changeset
|
864 } |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7600
diff
changeset
|
865 |
4687 | 866 // This contains no information on the array structure !!! |
867 std::ostream& | |
868 operator << (std::ostream& os, const ComplexNDArray& a) | |
869 { | |
5275 | 870 octave_idx_type nel = a.nelem (); |
4687 | 871 |
5275 | 872 for (octave_idx_type i = 0; i < nel; i++) |
4687 | 873 { |
874 os << " "; | |
875 octave_write_complex (os, a.elem (i)); | |
876 os << "\n"; | |
877 } | |
878 return os; | |
879 } | |
880 | |
881 std::istream& | |
882 operator >> (std::istream& is, ComplexNDArray& a) | |
883 { | |
5275 | 884 octave_idx_type nel = a.nelem (); |
4687 | 885 |
8999
dc07bc4157b8
allow empty matrices in stream input operators
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
886 if (nel > 0) |
4687 | 887 { |
888 Complex tmp; | |
5275 | 889 for (octave_idx_type i = 0; i < nel; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
890 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
891 tmp = octave_read_value<Complex> (is); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
892 if (is) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
893 a.elem (i) = tmp; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
894 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
895 goto done; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
896 } |
4687 | 897 } |
898 | |
899 done: | |
900 | |
901 return is; | |
902 } | |
903 | |
10329
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10314
diff
changeset
|
904 MINMAX_FCNS (ComplexNDArray, Complex) |
4844 | 905 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
906 NDS_CMP_OPS (ComplexNDArray, Complex) |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
907 NDS_BOOL_OPS (ComplexNDArray, Complex) |
4543 | 908 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
909 SND_CMP_OPS (Complex, ComplexNDArray) |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
910 SND_BOOL_OPS (Complex, ComplexNDArray) |
4543 | 911 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
912 NDND_CMP_OPS (ComplexNDArray, ComplexNDArray) |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
913 NDND_BOOL_OPS (ComplexNDArray, ComplexNDArray) |
4543 | 914 |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
915 ComplexNDArray& operator *= (ComplexNDArray& a, double s) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
916 { |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
917 if (a.is_shared ()) |
9612
66970dd627f6
further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
918 a = a * s; |
66970dd627f6
further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
919 else |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
920 do_ms_inplace_op<Complex, double> (a, s, mx_inline_mul2); |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
921 return a; |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
922 } |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
923 |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
924 ComplexNDArray& operator /= (ComplexNDArray& a, double s) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
925 { |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
926 if (a.is_shared ()) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
927 return a = a / s; |
9612
66970dd627f6
further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
928 else |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
929 do_ms_inplace_op<Complex, double> (a, s, mx_inline_div2); |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
930 return a; |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
931 } |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
932 |
9743
26abff55f6fe
optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
933 BSXFUN_STDOP_DEFS_MXLOOP (ComplexNDArray) |
26abff55f6fe
optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
934 BSXFUN_STDREL_DEFS_MXLOOP (ComplexNDArray) |
26abff55f6fe
optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
935 |
9827
c15a5ed0da58
optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents:
9825
diff
changeset
|
936 BSXFUN_OP_DEF_MXLOOP (pow, ComplexNDArray, mx_inline_pow) |