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