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