Mercurial > hg > octave-lyh
annotate liboctave/CNDArray.cc @ 10362:b47ab50a6aa8
simplify appliers in mx-inlines.cc
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 26 Feb 2010 09:47:54 +0100 |
parents | a3635bc1ea19 |
children | 3622db30ff05 |
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 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
503 return do_mx_unary_op<bool, Complex> (*this, mx_inline_not); |
4543 | 504 } |
505 | |
5775 | 506 // FIXME -- this is not quite the right thing. |
4514 | 507 |
4687 | 508 bool |
7922
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
509 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
|
510 { |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
511 octave_idx_type nel = nelem (); |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
512 |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
513 for (octave_idx_type i = 0; i < nel; i++) |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
514 { |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
515 Complex val = elem (i); |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
516 if (xisnan (val)) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
517 return true; |
7922
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
518 } |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
519 return false; |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
520 } |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
521 |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
522 bool |
4687 | 523 ComplexNDArray::any_element_is_inf_or_nan (void) const |
524 { | |
5275 | 525 octave_idx_type nel = nelem (); |
4687 | 526 |
5275 | 527 for (octave_idx_type i = 0; i < nel; i++) |
4687 | 528 { |
529 Complex val = elem (i); | |
530 if (xisinf (val) || xisnan (val)) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
531 return true; |
4687 | 532 } |
533 return false; | |
534 } | |
535 | |
536 // Return true if no elements have imaginary components. | |
537 | |
538 bool | |
539 ComplexNDArray::all_elements_are_real (void) const | |
540 { | |
9825
7483fe200fab
narrow complex values with negative zero imaginary parts
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
541 return mx_inline_all_real (numel (), data ()); |
4687 | 542 } |
543 | |
544 // Return nonzero if any element of CM has a non-integer real or | |
545 // imaginary part. Also extract the largest and smallest (real or | |
546 // imaginary) values and return them in MAX_VAL and MIN_VAL. | |
547 | |
548 bool | |
549 ComplexNDArray::all_integers (double& max_val, double& min_val) const | |
550 { | |
5275 | 551 octave_idx_type nel = nelem (); |
4687 | 552 |
553 if (nel > 0) | |
554 { | |
555 Complex val = elem (0); | |
556 | |
5260 | 557 double r_val = std::real (val); |
558 double i_val = std::imag (val); | |
4687 | 559 |
560 max_val = r_val; | |
561 min_val = r_val; | |
562 | |
563 if (i_val > max_val) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
564 max_val = i_val; |
4687 | 565 |
566 if (i_val < max_val) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
567 min_val = i_val; |
4687 | 568 } |
569 else | |
570 return false; | |
571 | |
5275 | 572 for (octave_idx_type i = 0; i < nel; i++) |
4687 | 573 { |
574 Complex val = elem (i); | |
575 | |
5260 | 576 double r_val = std::real (val); |
577 double i_val = std::imag (val); | |
4687 | 578 |
579 if (r_val > max_val) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
580 max_val = r_val; |
4687 | 581 |
582 if (i_val > max_val) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
583 max_val = i_val; |
4687 | 584 |
585 if (r_val < min_val) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
586 min_val = r_val; |
4687 | 587 |
588 if (i_val < min_val) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
589 min_val = i_val; |
4687 | 590 |
591 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
|
592 return false; |
4687 | 593 } |
594 | |
595 return true; | |
596 } | |
597 | |
598 bool | |
599 ComplexNDArray::too_large_for_float (void) const | |
600 { | |
5275 | 601 octave_idx_type nel = nelem (); |
4687 | 602 |
5275 | 603 for (octave_idx_type i = 0; i < nel; i++) |
4687 | 604 { |
605 Complex val = elem (i); | |
606 | |
5260 | 607 double r_val = std::real (val); |
608 double i_val = std::imag (val); | |
4687 | 609 |
5389 | 610 if ((! (xisnan (r_val) || xisinf (r_val)) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
611 && fabs (r_val) > FLT_MAX) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
612 || (! (xisnan (i_val) || xisinf (i_val)) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
613 && fabs (i_val) > FLT_MAX)) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
614 return true; |
4687 | 615 } |
616 | |
617 return false; | |
618 } | |
619 | |
4556 | 620 boolNDArray |
4514 | 621 ComplexNDArray::all (int dim) const |
622 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
623 return do_mx_red_op<bool, Complex> (*this, dim, mx_inline_all); |
4514 | 624 } |
625 | |
4556 | 626 boolNDArray |
4514 | 627 ComplexNDArray::any (int dim) const |
628 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
629 return do_mx_red_op<bool, Complex> (*this, dim, mx_inline_any); |
4569 | 630 } |
631 | |
4584 | 632 ComplexNDArray |
4569 | 633 ComplexNDArray::cumprod (int dim) const |
634 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
635 return do_mx_cum_op<Complex, Complex> (*this, dim, mx_inline_cumprod); |
4569 | 636 } |
637 | |
4584 | 638 ComplexNDArray |
4569 | 639 ComplexNDArray::cumsum (int dim) const |
640 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
641 return do_mx_cum_op<Complex, Complex> (*this, dim, mx_inline_cumsum); |
4569 | 642 } |
643 | |
644 ComplexNDArray | |
645 ComplexNDArray::prod (int dim) const | |
646 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
647 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
|
648 } |
53b4fdeacc2e
improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8650
diff
changeset
|
649 |
53b4fdeacc2e
improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8650
diff
changeset
|
650 ComplexNDArray |
53b4fdeacc2e
improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8650
diff
changeset
|
651 ComplexNDArray::sum (int dim) const |
53b4fdeacc2e
improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8650
diff
changeset
|
652 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
653 return do_mx_red_op<Complex, Complex> (*this, dim, mx_inline_sum); |
4569 | 654 } |
655 | |
656 ComplexNDArray | |
9721
192d94cff6c1
improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents:
9612
diff
changeset
|
657 ComplexNDArray::xsum (int dim) const |
192d94cff6c1
improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents:
9612
diff
changeset
|
658 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
659 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
|
660 } |
192d94cff6c1
improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents:
9612
diff
changeset
|
661 |
192d94cff6c1
improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents:
9612
diff
changeset
|
662 ComplexNDArray |
4569 | 663 ComplexNDArray::sumsq (int dim) const |
664 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
665 return do_mx_red_op<double, Complex> (*this, dim, mx_inline_sumsq); |
4569 | 666 } |
667 | |
4915 | 668 ComplexNDArray |
9513
9f870f73ab7d
implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
669 ComplexNDArray::diff (octave_idx_type order, int dim) const |
9f870f73ab7d
implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
670 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
671 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
|
672 } |
9f870f73ab7d
implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
673 |
9f870f73ab7d
implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
674 ComplexNDArray |
5275 | 675 ComplexNDArray::concat (const ComplexNDArray& rb, const Array<octave_idx_type>& ra_idx) |
4915 | 676 { |
4940 | 677 if (rb.numel () > 0) |
5073 | 678 insert (rb, ra_idx); |
679 return *this; | |
4915 | 680 } |
681 | |
682 ComplexNDArray | |
5275 | 683 ComplexNDArray::concat (const NDArray& rb, const Array<octave_idx_type>& ra_idx) |
4758 | 684 { |
4915 | 685 ComplexNDArray tmp (rb); |
4940 | 686 if (rb.numel () > 0) |
5073 | 687 insert (tmp, ra_idx); |
688 return *this; | |
4915 | 689 } |
690 | |
691 ComplexNDArray | |
5275 | 692 concat (NDArray& ra, ComplexNDArray& rb, const Array<octave_idx_type>& ra_idx) |
4915 | 693 { |
694 ComplexNDArray retval (ra); | |
4940 | 695 if (rb.numel () > 0) |
4915 | 696 retval.insert (rb, ra_idx); |
697 return retval; | |
4758 | 698 } |
699 | |
4844 | 700 static const Complex Complex_NaN_result (octave_NaN, octave_NaN); |
701 | |
702 ComplexNDArray | |
703 ComplexNDArray::max (int dim) const | |
704 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
705 return do_mx_minmax_op<Complex> (*this, dim, mx_inline_max); |
4844 | 706 } |
707 | |
708 ComplexNDArray | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9721
diff
changeset
|
709 ComplexNDArray::max (Array<octave_idx_type>& idx_arg, int dim) const |
4844 | 710 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
711 return do_mx_minmax_op<Complex> (*this, idx_arg, dim, mx_inline_max); |
4844 | 712 } |
713 | |
714 ComplexNDArray | |
715 ComplexNDArray::min (int dim) const | |
716 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
717 return do_mx_minmax_op<Complex> (*this, dim, mx_inline_min); |
4844 | 718 } |
719 | |
720 ComplexNDArray | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9721
diff
changeset
|
721 ComplexNDArray::min (Array<octave_idx_type>& idx_arg, int dim) const |
4844 | 722 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
723 return do_mx_minmax_op<Complex> (*this, idx_arg, dim, mx_inline_min); |
4844 | 724 } |
725 | |
8777
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
726 ComplexNDArray |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
727 ComplexNDArray::cummax (int dim) const |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
728 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
729 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
|
730 } |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
731 |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
732 ComplexNDArray |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9721
diff
changeset
|
733 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
|
734 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
735 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
|
736 } |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
737 |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
738 ComplexNDArray |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
739 ComplexNDArray::cummin (int dim) const |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
740 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
741 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
|
742 } |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
743 |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
744 ComplexNDArray |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9721
diff
changeset
|
745 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
|
746 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
747 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
|
748 } |
724c0f46d9d4
implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
749 |
4634 | 750 NDArray |
4569 | 751 ComplexNDArray::abs (void) const |
752 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
753 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
|
754 } |
4634 | 755 |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
756 boolNDArray |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
757 ComplexNDArray::isnan (void) const |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
758 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
759 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
|
760 } |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
761 |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
762 boolNDArray |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
763 ComplexNDArray::isinf (void) const |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
764 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
765 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
|
766 } |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
767 |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
768 boolNDArray |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
769 ComplexNDArray::isfinite (void) const |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
770 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
771 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
|
772 } |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8981
diff
changeset
|
773 |
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
|
774 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
|
775 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
|
776 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
777 return do_mx_unary_map<Complex, Complex, std::conj> (a); |
4514 | 778 } |
779 | |
4765 | 780 ComplexNDArray& |
5275 | 781 ComplexNDArray::insert (const NDArray& a, octave_idx_type r, octave_idx_type c) |
4765 | 782 { |
783 dim_vector a_dv = a.dims (); | |
784 | |
785 int n = a_dv.length (); | |
786 | |
787 if (n == dimensions.length ()) | |
788 { | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
789 Array<octave_idx_type> a_ra_idx (a_dv.length (), 1, 0); |
4765 | 790 |
791 a_ra_idx.elem (0) = r; | |
792 a_ra_idx.elem (1) = c; | |
793 | |
794 for (int i = 0; i < n; i++) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
795 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
796 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
|
797 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
798 (*current_liboctave_error_handler) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
799 ("Array<T>::insert: range error for insert"); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
800 return *this; |
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 } |
4765 | 803 |
804 a_ra_idx.elem (0) = 0; | |
805 a_ra_idx.elem (1) = 0; | |
806 | |
5275 | 807 octave_idx_type n_elt = a.numel (); |
4765 | 808 |
809 // IS make_unique () NECCESSARY HERE?? | |
810 | |
5275 | 811 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
|
812 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
813 Array<octave_idx_type> ra_idx = a_ra_idx; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
814 |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
815 ra_idx.elem (0) = a_ra_idx (0) + r; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
816 ra_idx.elem (1) = a_ra_idx (1) + c; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
817 |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
818 elem (ra_idx) = a.elem (a_ra_idx); |
4765 | 819 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
820 increment_index (a_ra_idx, a_dv); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
821 } |
4765 | 822 } |
823 else | |
824 (*current_liboctave_error_handler) | |
825 ("Array<T>::insert: invalid indexing operation"); | |
826 | |
827 return *this; | |
828 } | |
829 | |
830 ComplexNDArray& | |
5275 | 831 ComplexNDArray::insert (const ComplexNDArray& a, octave_idx_type r, octave_idx_type c) |
4765 | 832 { |
833 Array<Complex>::insert (a, r, c); | |
834 return *this; | |
835 } | |
836 | |
4915 | 837 ComplexNDArray& |
5275 | 838 ComplexNDArray::insert (const ComplexNDArray& a, const Array<octave_idx_type>& ra_idx) |
4915 | 839 { |
840 Array<Complex>::insert (a, ra_idx); | |
841 return *this; | |
842 } | |
843 | |
4514 | 844 ComplexMatrix |
845 ComplexNDArray::matrix_value (void) const | |
846 { | |
847 ComplexMatrix retval; | |
848 | |
8981
ed5055b0a476
fix & simplify ndarray->matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8956
diff
changeset
|
849 if (ndims () == 2) |
10352 | 850 retval = ComplexMatrix (Array<Complex> (*this)); |
8981
ed5055b0a476
fix & simplify ndarray->matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8956
diff
changeset
|
851 else |
ed5055b0a476
fix & simplify ndarray->matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8956
diff
changeset
|
852 (*current_liboctave_error_handler) |
ed5055b0a476
fix & simplify ndarray->matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8956
diff
changeset
|
853 ("invalid conversion of ComplexNDArray to ComplexMatrix"); |
4514 | 854 |
855 return retval; | |
856 } | |
857 | |
4532 | 858 void |
5275 | 859 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
|
860 const dim_vector& dimensions, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
861 int start_dimension) |
4532 | 862 { |
863 ::increment_index (ra_idx, dimensions, start_dimension); | |
864 } | |
865 | |
5275 | 866 octave_idx_type |
867 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
|
868 const dim_vector& dimensions) |
4556 | 869 { |
870 return ::compute_index (ra_idx, dimensions); | |
871 } | |
872 | |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7600
diff
changeset
|
873 ComplexNDArray |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7600
diff
changeset
|
874 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
|
875 { |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
876 return MArray<Complex>::diag (k); |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7600
diff
changeset
|
877 } |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7600
diff
changeset
|
878 |
4687 | 879 // This contains no information on the array structure !!! |
880 std::ostream& | |
881 operator << (std::ostream& os, const ComplexNDArray& a) | |
882 { | |
5275 | 883 octave_idx_type nel = a.nelem (); |
4687 | 884 |
5275 | 885 for (octave_idx_type i = 0; i < nel; i++) |
4687 | 886 { |
887 os << " "; | |
888 octave_write_complex (os, a.elem (i)); | |
889 os << "\n"; | |
890 } | |
891 return os; | |
892 } | |
893 | |
894 std::istream& | |
895 operator >> (std::istream& is, ComplexNDArray& a) | |
896 { | |
5275 | 897 octave_idx_type nel = a.nelem (); |
4687 | 898 |
8999
dc07bc4157b8
allow empty matrices in stream input operators
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
899 if (nel > 0) |
4687 | 900 { |
901 Complex tmp; | |
5275 | 902 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
|
903 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
904 tmp = octave_read_value<Complex> (is); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
905 if (is) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
906 a.elem (i) = tmp; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
907 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
908 goto done; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
909 } |
4687 | 910 } |
911 | |
912 done: | |
913 | |
914 return is; | |
915 } | |
916 | |
10329
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10314
diff
changeset
|
917 MINMAX_FCNS (ComplexNDArray, Complex) |
4844 | 918 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
919 NDS_CMP_OPS (ComplexNDArray, Complex) |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
920 NDS_BOOL_OPS (ComplexNDArray, Complex) |
4543 | 921 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
922 SND_CMP_OPS (Complex, ComplexNDArray) |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
923 SND_BOOL_OPS (Complex, ComplexNDArray) |
4543 | 924 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
925 NDND_CMP_OPS (ComplexNDArray, ComplexNDArray) |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
926 NDND_BOOL_OPS (ComplexNDArray, ComplexNDArray) |
4543 | 927 |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
928 ComplexNDArray& operator *= (ComplexNDArray& a, double s) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
929 { |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
930 if (a.is_shared ()) |
9612
66970dd627f6
further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
931 a = a * s; |
66970dd627f6
further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
932 else |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
933 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
|
934 return a; |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
935 } |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
936 |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
937 ComplexNDArray& operator /= (ComplexNDArray& a, double s) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
938 { |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
939 if (a.is_shared ()) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
940 return a = a / s; |
9612
66970dd627f6
further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
941 else |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
942 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
|
943 return a; |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
944 } |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9523
diff
changeset
|
945 |
9743
26abff55f6fe
optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
946 BSXFUN_STDOP_DEFS_MXLOOP (ComplexNDArray) |
26abff55f6fe
optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
947 BSXFUN_STDREL_DEFS_MXLOOP (ComplexNDArray) |
26abff55f6fe
optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
948 |
9827
c15a5ed0da58
optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents:
9825
diff
changeset
|
949 BSXFUN_OP_DEF_MXLOOP (pow, ComplexNDArray, mx_inline_pow) |