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