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