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