GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
fNDArray.cc
Go to the documentation of this file.
1 // N-D Array manipulations.
2 /*
3 
4 Copyright (C) 1996-2015 John W. Eaton
5 Copyright (C) 2009 VZLU Prague, a.s.
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
11 Free Software Foundation; either version 3 of the License, or (at your
12 option) any later version.
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
20 along with Octave; see the file COPYING. If not, see
21 <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 #ifdef HAVE_CONFIG_H
26 #include <config.h>
27 #endif
28 
29 #include <cfloat>
30 
31 #include <vector>
32 
33 #include "Array-util.h"
34 #include "f77-fcn.h"
35 #include "fNDArray.h"
36 #include "functor.h"
37 #include "lo-error.h"
38 #include "lo-ieee.h"
39 #include "lo-mappers.h"
40 #include "mx-base.h"
41 #include "mx-op-defs.h"
42 #include "oct-fftw.h"
43 #include "oct-locbuf.h"
44 
45 #include "bsxfun-defs.cc"
46 
48  : MArray<float> (a.dims ())
49 {
50  octave_idx_type n = a.numel ();
51  for (octave_idx_type i = 0; i < n; i++)
52  xelem (i) = static_cast<unsigned char> (a(i));
53 }
54 
55 #if defined (HAVE_FFTW)
56 
58 FloatNDArray::fourier (int dim) const
59 {
60  dim_vector dv = dims ();
61 
62  if (dim > dv.length () || dim < 0)
63  return FloatComplexNDArray ();
64 
65  octave_idx_type stride = 1;
66  octave_idx_type n = dv(dim);
67 
68  for (int i = 0; i < dim; i++)
69  stride *= dv(i);
70 
71  octave_idx_type howmany = numel () / dv (dim);
72  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
73  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride);
74  octave_idx_type dist = (stride == 1 ? n : 1);
75 
76  const float *in (fortran_vec ());
77  FloatComplexNDArray retval (dv);
78  FloatComplex *out (retval.fortran_vec ());
79 
80  // Need to be careful here about the distance between fft's
81  for (octave_idx_type k = 0; k < nloop; k++)
82  octave_fftw::fft (in + k * stride * n, out + k * stride * n,
83  n, howmany, stride, dist);
84 
85  return retval;
86 }
87 
89 FloatNDArray::ifourier (int dim) const
90 {
91  dim_vector dv = dims ();
92 
93  if (dim > dv.length () || dim < 0)
94  return FloatComplexNDArray ();
95 
96  octave_idx_type stride = 1;
97  octave_idx_type n = dv(dim);
98 
99  for (int i = 0; i < dim; i++)
100  stride *= dv(i);
101 
102  octave_idx_type howmany = numel () / dv (dim);
103  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
104  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride);
105  octave_idx_type dist = (stride == 1 ? n : 1);
106 
107  FloatComplexNDArray retval (*this);
108  FloatComplex *out (retval.fortran_vec ());
109 
110  // Need to be careful here about the distance between fft's
111  for (octave_idx_type k = 0; k < nloop; k++)
112  octave_fftw::ifft (out + k * stride * n, out + k * stride * n,
113  n, howmany, stride, dist);
114 
115  return retval;
116 }
117 
120 {
121  dim_vector dv = dims ();
122  if (dv.length () < 2)
123  return FloatComplexNDArray ();
124 
125  dim_vector dv2(dv(0), dv(1));
126  const float *in = fortran_vec ();
127  FloatComplexNDArray retval (dv);
128  FloatComplex *out = retval.fortran_vec ();
129  octave_idx_type howmany = numel () / dv(0) / dv(1);
130  octave_idx_type dist = dv(0) * dv(1);
131 
132  for (octave_idx_type i=0; i < howmany; i++)
133  octave_fftw::fftNd (in + i*dist, out + i*dist, 2, dv2);
134 
135  return retval;
136 }
137 
140 {
141  dim_vector dv = dims ();
142  if (dv.length () < 2)
143  return FloatComplexNDArray ();
144 
145  dim_vector dv2(dv(0), dv(1));
146  FloatComplexNDArray retval (*this);
147  FloatComplex *out = retval.fortran_vec ();
148  octave_idx_type howmany = numel () / dv(0) / dv(1);
149  octave_idx_type dist = dv(0) * dv(1);
150 
151  for (octave_idx_type i=0; i < howmany; i++)
152  octave_fftw::ifftNd (out + i*dist, out + i*dist, 2, dv2);
153 
154  return retval;
155 }
156 
159 {
160  dim_vector dv = dims ();
161  int rank = dv.length ();
162 
163  const float *in (fortran_vec ());
164  FloatComplexNDArray retval (dv);
165  FloatComplex *out (retval.fortran_vec ());
166 
167  octave_fftw::fftNd (in, out, rank, dv);
168 
169  return retval;
170 }
171 
174 {
175  dim_vector dv = dims ();
176  int rank = dv.length ();
177 
178  FloatComplexNDArray tmp (*this);
179  FloatComplex *in (tmp.fortran_vec ());
180  FloatComplexNDArray retval (dv);
181  FloatComplex *out (retval.fortran_vec ());
182 
183  octave_fftw::ifftNd (in, out, rank, dv);
184 
185  return retval;
186 }
187 
188 #else
189 
190 extern "C"
191 {
192  // Note that the original complex fft routines were not written for
193  // float complex arguments. They have been modified by adding an
194  // implicit float precision (a-h,o-z) statement at the beginning of
195  // each subroutine.
196 
197  F77_RET_T
198  F77_FUNC (cffti, CFFTI) (const octave_idx_type&, FloatComplex*);
199 
200  F77_RET_T
201  F77_FUNC (cfftf, CFFTF) (const octave_idx_type&, FloatComplex*,
202  FloatComplex*);
203 
204  F77_RET_T
205  F77_FUNC (cfftb, CFFTB) (const octave_idx_type&, FloatComplex*,
206  FloatComplex*);
207 }
208 
210 FloatNDArray::fourier (int dim) const
211 {
212  dim_vector dv = dims ();
213 
214  if (dim > dv.length () || dim < 0)
215  return FloatComplexNDArray ();
216 
217  FloatComplexNDArray retval (dv);
218  octave_idx_type npts = dv(dim);
219  octave_idx_type nn = 4*npts+15;
220  Array<FloatComplex> wsave (dim_vector (nn, 1));
221  FloatComplex *pwsave = wsave.fortran_vec ();
222 
223  OCTAVE_LOCAL_BUFFER (FloatComplex, tmp, npts);
224 
225  octave_idx_type stride = 1;
226 
227  for (int i = 0; i < dim; i++)
228  stride *= dv(i);
229 
230  octave_idx_type howmany = numel () / npts;
231  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
232  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
233  octave_idx_type dist = (stride == 1 ? npts : 1);
234 
235  F77_FUNC (cffti, CFFTI) (npts, pwsave);
236 
237  for (octave_idx_type k = 0; k < nloop; k++)
238  {
239  for (octave_idx_type j = 0; j < howmany; j++)
240  {
241  octave_quit ();
242 
243  for (octave_idx_type i = 0; i < npts; i++)
244  tmp[i] = elem ((i + k*npts)*stride + j*dist);
245 
246  F77_FUNC (cfftf, CFFTF) (npts, tmp, pwsave);
247 
248  for (octave_idx_type i = 0; i < npts; i++)
249  retval((i + k*npts)*stride + j*dist) = tmp[i];
250  }
251  }
252 
253  return retval;
254 }
255 
257 FloatNDArray::ifourier (int dim) const
258 {
259  dim_vector dv = dims ();
260 
261  if (dim > dv.length () || dim < 0)
262  return FloatComplexNDArray ();
263 
264  FloatComplexNDArray retval (dv);
265  octave_idx_type npts = dv(dim);
266  octave_idx_type nn = 4*npts+15;
267  Array<FloatComplex> wsave (dim_vector (nn, 1));
268  FloatComplex *pwsave = wsave.fortran_vec ();
269 
270  OCTAVE_LOCAL_BUFFER (FloatComplex, tmp, npts);
271 
272  octave_idx_type stride = 1;
273 
274  for (int i = 0; i < dim; i++)
275  stride *= dv(i);
276 
277  octave_idx_type howmany = numel () / npts;
278  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
279  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
280  octave_idx_type dist = (stride == 1 ? npts : 1);
281 
282  F77_FUNC (cffti, CFFTI) (npts, pwsave);
283 
284  for (octave_idx_type k = 0; k < nloop; k++)
285  {
286  for (octave_idx_type j = 0; j < howmany; j++)
287  {
288  octave_quit ();
289 
290  for (octave_idx_type i = 0; i < npts; i++)
291  tmp[i] = elem ((i + k*npts)*stride + j*dist);
292 
293  F77_FUNC (cfftb, CFFTB) (npts, tmp, pwsave);
294 
295  for (octave_idx_type i = 0; i < npts; i++)
296  retval((i + k*npts)*stride + j*dist) = tmp[i] /
297  static_cast<float> (npts);
298  }
299  }
300 
301  return retval;
302 }
303 
305 FloatNDArray::fourier2d (void) const
306 {
307  dim_vector dv = dims ();
308  dim_vector dv2 (dv(0), dv(1));
309  int rank = 2;
310  FloatComplexNDArray retval (*this);
311  octave_idx_type stride = 1;
312 
313  for (int i = 0; i < rank; i++)
314  {
315  octave_idx_type npts = dv2(i);
316  octave_idx_type nn = 4*npts+15;
317  Array<FloatComplex> wsave (dim_vector (nn, 1));
318  FloatComplex *pwsave = wsave.fortran_vec ();
319  Array<FloatComplex> row (dim_vector (npts, 1));
320  FloatComplex *prow = row.fortran_vec ();
321 
322  octave_idx_type howmany = numel () / npts;
323  howmany = (stride == 1 ? howmany :
324  (howmany > stride ? stride : howmany));
325  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
326  octave_idx_type dist = (stride == 1 ? npts : 1);
327 
328  F77_FUNC (cffti, CFFTI) (npts, pwsave);
329 
330  for (octave_idx_type k = 0; k < nloop; k++)
331  {
332  for (octave_idx_type j = 0; j < howmany; j++)
333  {
334  octave_quit ();
335 
336  for (octave_idx_type l = 0; l < npts; l++)
337  prow[l] = retval((l + k*npts)*stride + j*dist);
338 
339  F77_FUNC (cfftf, CFFTF) (npts, prow, pwsave);
340 
341  for (octave_idx_type l = 0; l < npts; l++)
342  retval((l + k*npts)*stride + j*dist) = prow[l];
343  }
344  }
345 
346  stride *= dv2(i);
347  }
348 
349  return retval;
350 }
351 
353 FloatNDArray::ifourier2d (void) const
354 {
355  dim_vector dv = dims ();
356  dim_vector dv2 (dv(0), dv(1));
357  int rank = 2;
358  FloatComplexNDArray retval (*this);
359  octave_idx_type stride = 1;
360 
361  for (int i = 0; i < rank; i++)
362  {
363  octave_idx_type npts = dv2(i);
364  octave_idx_type nn = 4*npts+15;
365  Array<FloatComplex> wsave (dim_vector (nn, 1));
366  FloatComplex *pwsave = wsave.fortran_vec ();
367  Array<FloatComplex> row (dim_vector (npts, 1));
368  FloatComplex *prow = row.fortran_vec ();
369 
370  octave_idx_type howmany = numel () / npts;
371  howmany = (stride == 1 ? howmany :
372  (howmany > stride ? stride : howmany));
373  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
374  octave_idx_type dist = (stride == 1 ? npts : 1);
375 
376  F77_FUNC (cffti, CFFTI) (npts, pwsave);
377 
378  for (octave_idx_type k = 0; k < nloop; k++)
379  {
380  for (octave_idx_type j = 0; j < howmany; j++)
381  {
382  octave_quit ();
383 
384  for (octave_idx_type l = 0; l < npts; l++)
385  prow[l] = retval((l + k*npts)*stride + j*dist);
386 
387  F77_FUNC (cfftb, CFFTB) (npts, prow, pwsave);
388 
389  for (octave_idx_type l = 0; l < npts; l++)
390  retval((l + k*npts)*stride + j*dist) =
391  prow[l] / static_cast<float> (npts);
392  }
393  }
394 
395  stride *= dv2(i);
396  }
397 
398  return retval;
399 }
400 
402 FloatNDArray::fourierNd (void) const
403 {
404  dim_vector dv = dims ();
405  int rank = dv.length ();
406  FloatComplexNDArray retval (*this);
407  octave_idx_type stride = 1;
408 
409  for (int i = 0; i < rank; i++)
410  {
411  octave_idx_type npts = dv(i);
412  octave_idx_type nn = 4*npts+15;
413  Array<FloatComplex> wsave (dim_vector (nn, 1));
414  FloatComplex *pwsave = wsave.fortran_vec ();
415  Array<FloatComplex> row (dim_vector (npts, 1));
416  FloatComplex *prow = row.fortran_vec ();
417 
418  octave_idx_type howmany = numel () / npts;
419  howmany = (stride == 1 ? howmany :
420  (howmany > stride ? stride : howmany));
421  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
422  octave_idx_type dist = (stride == 1 ? npts : 1);
423 
424  F77_FUNC (cffti, CFFTI) (npts, pwsave);
425 
426  for (octave_idx_type k = 0; k < nloop; k++)
427  {
428  for (octave_idx_type j = 0; j < howmany; j++)
429  {
430  octave_quit ();
431 
432  for (octave_idx_type l = 0; l < npts; l++)
433  prow[l] = retval((l + k*npts)*stride + j*dist);
434 
435  F77_FUNC (cfftf, CFFTF) (npts, prow, pwsave);
436 
437  for (octave_idx_type l = 0; l < npts; l++)
438  retval((l + k*npts)*stride + j*dist) = prow[l];
439  }
440  }
441 
442  stride *= dv(i);
443  }
444 
445  return retval;
446 }
447 
449 FloatNDArray::ifourierNd (void) const
450 {
451  dim_vector dv = dims ();
452  int rank = dv.length ();
453  FloatComplexNDArray retval (*this);
454  octave_idx_type stride = 1;
455 
456  for (int i = 0; i < rank; i++)
457  {
458  octave_idx_type npts = dv(i);
459  octave_idx_type nn = 4*npts+15;
460  Array<FloatComplex> wsave (dim_vector (nn, 1));
461  FloatComplex *pwsave = wsave.fortran_vec ();
462  Array<FloatComplex> row (dim_vector (npts, 1));
463  FloatComplex *prow = row.fortran_vec ();
464 
465  octave_idx_type howmany = numel () / npts;
466  howmany = (stride == 1 ? howmany :
467  (howmany > stride ? stride : howmany));
468  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
469  octave_idx_type dist = (stride == 1 ? npts : 1);
470 
471  F77_FUNC (cffti, CFFTI) (npts, pwsave);
472 
473  for (octave_idx_type k = 0; k < nloop; k++)
474  {
475  for (octave_idx_type j = 0; j < howmany; j++)
476  {
477  octave_quit ();
478 
479  for (octave_idx_type l = 0; l < npts; l++)
480  prow[l] = retval((l + k*npts)*stride + j*dist);
481 
482  F77_FUNC (cfftb, CFFTB) (npts, prow, pwsave);
483 
484  for (octave_idx_type l = 0; l < npts; l++)
485  retval((l + k*npts)*stride + j*dist) =
486  prow[l] / static_cast<float> (npts);
487  }
488  }
489 
490  stride *= dv(i);
491  }
492 
493  return retval;
494 }
495 
496 #endif
497 
498 // unary operations
499 
502 {
503  if (any_element_is_nan ())
505 
506  return do_mx_unary_op<bool, float> (*this, mx_inline_not);
507 }
508 
509 bool
511 {
512  return (neg_zero ? test_all (xnegative_sign)
513  : do_mx_check<float> (*this, mx_inline_any_negative));
514 }
515 
516 bool
518 {
519  return (neg_zero ? test_all (xpositive_sign)
520  : do_mx_check<float> (*this, mx_inline_any_positive));
521 }
522 
523 bool
525 {
526  return do_mx_check<float> (*this, mx_inline_any_nan);
527 }
528 
529 bool
531 {
532  return ! do_mx_check<float> (*this, mx_inline_all_finite);
533 }
534 
535 bool
537 {
538  return ! test_all (xis_one_or_zero);
539 }
540 
541 bool
543 {
544  return test_all (xis_zero);
545 }
546 
547 bool
549 {
551 }
552 
553 // Return nonzero if any element of M is not an integer. Also extract
554 // the largest and smallest values and return them in MAX_VAL and MIN_VAL.
555 
556 bool
557 FloatNDArray::all_integers (float& max_val, float& min_val) const
558 {
559  octave_idx_type nel = nelem ();
560 
561  if (nel > 0)
562  {
563  max_val = elem (0);
564  min_val = elem (0);
565  }
566  else
567  return false;
568 
569  for (octave_idx_type i = 0; i < nel; i++)
570  {
571  float val = elem (i);
572 
573  if (val > max_val)
574  max_val = val;
575 
576  if (val < min_val)
577  min_val = val;
578 
579  if (! xisinteger (val))
580  return false;
581  }
582 
583  return true;
584 }
585 
586 bool
588 {
589  return test_all (xisinteger);
590 }
591 
592 bool
594 {
595  return false;
596 }
597 
598 // FIXME: this is not quite the right thing.
599 
601 FloatNDArray::all (int dim) const
602 {
603  return do_mx_red_op<bool, float> (*this, dim, mx_inline_all);
604 }
605 
607 FloatNDArray::any (int dim) const
608 {
609  return do_mx_red_op<bool, float> (*this, dim, mx_inline_any);
610 }
611 
613 FloatNDArray::cumprod (int dim) const
614 {
615  return do_mx_cum_op<float, float> (*this, dim, mx_inline_cumprod);
616 }
617 
619 FloatNDArray::cumsum (int dim) const
620 {
621  return do_mx_cum_op<float, float> (*this, dim, mx_inline_cumsum);
622 }
623 
625 FloatNDArray::prod (int dim) const
626 {
627  return do_mx_red_op<float, float> (*this, dim, mx_inline_prod);
628 }
629 
630 NDArray
631 FloatNDArray::dprod (int dim) const
632 {
633  return do_mx_red_op<double, float> (*this, dim, mx_inline_dprod);
634 }
635 
637 FloatNDArray::sum (int dim) const
638 {
639  return do_mx_red_op<float, float> (*this, dim, mx_inline_sum);
640 }
641 
642 NDArray
643 FloatNDArray::dsum (int dim) const
644 {
645  return do_mx_red_op<double, float> (*this, dim, mx_inline_dsum);
646 }
647 
649 FloatNDArray::sumsq (int dim) const
650 {
651  return do_mx_red_op<float, float> (*this, dim, mx_inline_sumsq);
652 }
653 
655 FloatNDArray::max (int dim) const
656 {
657  return do_mx_minmax_op<float> (*this, dim, mx_inline_max);
658 }
659 
661 FloatNDArray::max (Array<octave_idx_type>& idx_arg, int dim) const
662 {
663  return do_mx_minmax_op<float> (*this, idx_arg, dim, mx_inline_max);
664 }
665 
667 FloatNDArray::min (int dim) const
668 {
669  return do_mx_minmax_op<float> (*this, dim, mx_inline_min);
670 }
671 
673 FloatNDArray::min (Array<octave_idx_type>& idx_arg, int dim) const
674 {
675  return do_mx_minmax_op<float> (*this, idx_arg, dim, mx_inline_min);
676 }
677 
679 FloatNDArray::cummax (int dim) const
680 {
681  return do_mx_cumminmax_op<float> (*this, dim, mx_inline_cummax);
682 }
683 
686 {
687  return do_mx_cumminmax_op<float> (*this, idx_arg, dim, mx_inline_cummax);
688 }
689 
691 FloatNDArray::cummin (int dim) const
692 {
693  return do_mx_cumminmax_op<float> (*this, dim, mx_inline_cummin);
694 }
695 
698 {
699  return do_mx_cumminmax_op<float> (*this, idx_arg, dim, mx_inline_cummin);
700 }
701 
703 FloatNDArray::diff (octave_idx_type order, int dim) const
704 {
705  return do_mx_diff_op<float> (*this, dim, order, mx_inline_diff);
706 }
707 
711 {
712  if (rb.numel () > 0)
713  insert (rb, ra_idx);
714  return *this;
715 }
716 
720 {
721  FloatComplexNDArray retval (*this);
722  if (rb.numel () > 0)
723  retval.insert (rb, ra_idx);
724  return retval;
725 }
726 
730 {
731  charNDArray retval (dims ());
732  octave_idx_type nel = numel ();
733 
734  for (octave_idx_type i = 0; i < nel; i++)
735  {
736  float d = elem (i);
737 
738  if (xisnan (d))
739  {
740  (*current_liboctave_error_handler)
741  ("invalid conversion from NaN to character");
742  return retval;
743  }
744  else
745  {
746  octave_idx_type ival = NINTbig (d);
747 
748  if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
749  // FIXME: is there something better to do? Should we warn the user?
750  ival = 0;
751 
752  retval.elem (i) = static_cast<char>(ival);
753  }
754  }
755 
756  if (rb.numel () == 0)
757  return retval;
758 
759  retval.insert (rb, ra_idx);
760  return retval;
761 }
762 
765 {
766  return do_mx_unary_op<float, FloatComplex> (a, mx_inline_real);
767 }
768 
771 {
772  return do_mx_unary_op<float, FloatComplex> (a, mx_inline_imag);
773 }
774 
778 {
779  Array<float>::insert (a, r, c);
780  return *this;
781 }
782 
786 {
787  Array<float>::insert (a, ra_idx);
788  return *this;
789 }
790 
792 FloatNDArray::abs (void) const
793 {
794  return do_mx_unary_map<float, float, std::abs> (*this);
795 }
796 
799 {
800  return do_mx_unary_map<bool, float, xisnan> (*this);
801 }
802 
805 {
806  return do_mx_unary_map<bool, float, xisinf> (*this);
807 }
808 
811 {
812  return do_mx_unary_map<bool, float, xfinite> (*this);
813 }
814 
815 void
817  const dim_vector& dimensions,
818  int start_dimension)
819 {
820  ::increment_index (ra_idx, dimensions, start_dimension);
821 }
822 
825  const dim_vector& dimensions)
826 {
827  return ::compute_index (ra_idx, dimensions);
828 }
829 
832 {
833  return MArray<float>::diag (k);
834 }
835 
838 {
839  return MArray<float>::diag (m, n);
840 }
841 
842 // This contains no information on the array structure !!!
843 std::ostream&
844 operator << (std::ostream& os, const FloatNDArray& a)
845 {
846  octave_idx_type nel = a.nelem ();
847 
848  for (octave_idx_type i = 0; i < nel; i++)
849  {
850  os << " ";
851  octave_write_float (os, a.elem (i));
852  os << "\n";
853  }
854  return os;
855 }
856 
857 std::istream&
858 operator >> (std::istream& is, FloatNDArray& a)
859 {
860  octave_idx_type nel = a.nelem ();
861 
862  if (nel > 0)
863  {
864  float tmp;
865  for (octave_idx_type i = 0; i < nel; i++)
866  {
867  tmp = octave_read_value<float> (is);
868  if (is)
869  a.elem (i) = tmp;
870  else
871  goto done;
872  }
873  }
874 
875 done:
876 
877  return is;
878 }
879 
881 
883 NDS_BOOL_OPS (FloatNDArray, float)
884 
885 SND_CMP_OPS (float, FloatNDArray)
886 SND_BOOL_OPS (float, FloatNDArray)
887 
888 NDND_CMP_OPS (FloatNDArray, FloatNDArray)
889 NDND_BOOL_OPS (FloatNDArray, FloatNDArray)
890 
893 
895 BSXFUN_OP2_DEF_MXLOOP (pow, FloatComplexNDArray, FloatComplexNDArray,
896  FloatNDArray, mx_inline_pow)
897 BSXFUN_OP2_DEF_MXLOOP (pow, FloatComplexNDArray, FloatNDArray,
898  FloatComplexNDArray, mx_inline_pow)
dim_vector dimensions
Definition: Array.h:127
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
Definition: Array-util.cc:178
FloatNDArray concat(const FloatNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: fNDArray.cc:709
FloatComplexNDArray fourier(int dim=1) const
Definition: fNDArray.cc:58
NDArray dsum(int dim=-1) const
Definition: fNDArray.cc:643
#define NDS_BOOL_OPS(ND, S)
Definition: mx-op-defs.h:253
#define NDS_CMP_OPS(ND, S)
Definition: mx-op-defs.h:236
bool all_integers(void) const
Definition: fNDArray.cc:587
bool all_elements_are_int_or_inf_or_nan(void) const
Definition: fNDArray.cc:548
boolNDArray operator!(void) const
Definition: fNDArray.cc:501
void mx_inline_cummax(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:894
static int fft(const double *in, Complex *out, size_t npts, size_t nsamples=1, octave_idx_type stride=1, octave_idx_type dist=-1)
Definition: oct-fftw.cc:827
const octave_base_value const Array< octave_idx_type > & ra_idx
#define SND_CMP_OPS(S, ND)
Definition: mx-op-defs.h:283
FloatNDArray diff(octave_idx_type order=1, int dim=-1) const
Definition: fNDArray.cc:703
bool xisnan(double x)
Definition: lo-mappers.cc:144
#define BSXFUN_OP_DEF_MXLOOP(OP, ARRAY, LOOP)
Definition: bsxfun-defs.cc:221
FloatNDArray max(int dim=-1) const
Definition: fNDArray.cc:655
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:275
static octave_idx_type nn
Definition: DASPK.cc:71
FloatNDArray cumsum(int dim=-1) const
Definition: fNDArray.cc:619
void mx_inline_real(size_t n, T *r, const std::complex< T > *x)
Definition: mx-inlines.cc:251
bool mx_inline_all_finite(size_t n, const T *x)
Definition: mx-inlines.cc:195
#define MINMAX_FCNS(T, S)
Definition: mx-op-defs.h:590
bool xnegative_sign(double x)
Definition: lo-mappers.cc:618
bool xis_zero(double x)
Definition: lo-utils.cc:53
FloatNDArray diag(octave_idx_type k=0) const
Definition: fNDArray.cc:831
Array< T > diag(octave_idx_type k=0) const
Get the kth super or subdiagonal.
Definition: Array.cc:2526
std::istream & operator>>(std::istream &is, FloatNDArray &a)
Definition: fNDArray.cc:858
FloatNDArray sumsq(int dim=-1) const
Definition: fNDArray.cc:649
bool any_element_is_nan(void) const
Definition: fNDArray.cc:524
float & elem(octave_idx_type n)
Definition: Array.h:380
FloatComplexNDArray ifourier(int dim=1) const
Definition: fNDArray.cc:89
Definition: MArray.h:36
T mx_inline_sumsq(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:524
bool mx_inline_any_negative(size_t n, const T *x)
Definition: mx-inlines.cc:208
bool all_elements_are_zero(void) const
Definition: fNDArray.cc:542
void mx_inline_max(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:719
subroutine cfftb(n, c, wsave)
Definition: cfftb.f:1
FloatComplexNDArray & insert(const NDArray &a, octave_idx_type r, octave_idx_type c)
Definition: fCNDArray.cc:763
bool mx_inline_any(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:524
F77_RET_T const double const double double * d
FloatNDArray abs(void) const
Definition: fNDArray.cc:792
FloatNDArray sum(int dim=-1) const
Definition: fNDArray.cc:637
static int fftNd(const double *, Complex *, const int, const dim_vector &)
Definition: oct-fftw.cc:889
FloatComplexNDArray ifourierNd(void) const
Definition: fNDArray.cc:173
FloatComplexNDArray fourier2d(void) const
Definition: fNDArray.cc:119
void mx_inline_imag(size_t n, T *r, const std::complex< T > *x)
Definition: mx-inlines.cc:254
boolNDArray any(int dim=-1) const
Definition: fNDArray.cc:607
Array< T > & insert(const Array< T > &a, const Array< octave_idx_type > &idx)
Insert an array into another at a specified position.
Definition: Array.cc:1591
octave_idx_type nelem(void) const
Number of elements in the array.
Definition: Array.h:271
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
Definition: Array.h:337
subroutine cffti(n, wsave)
Definition: cffti.f:1
FloatComplexNDArray ifourier2d(void) const
Definition: fNDArray.cc:139
#define NDND_CMP_OPS(ND1, ND2)
Definition: mx-op-defs.h:330
static octave_idx_type compute_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions)
Definition: fNDArray.cc:824
#define NDND_BOOL_OPS(ND1, ND2)
Definition: mx-op-defs.h:347
bool any_element_is_positive(bool=false) const
Definition: fNDArray.cc:517
FloatNDArray(void)
Definition: fNDArray.h:39
subst_template_param< std::complex, T, double >::type mx_inline_dprod(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:523
void gripe_nan_to_logical_conversion(void)
FloatNDArray real(const FloatComplexNDArray &a)
Definition: fNDArray.cc:764
bool any_element_not_one_or_zero(void) const
Definition: fNDArray.cc:536
static int ifft(const Complex *in, Complex *out, size_t npts, size_t nsamples=1, octave_idx_type stride=1, octave_idx_type dist=-1)
Definition: oct-fftw.cc:865
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
subroutine cfftf(n, c, wsave)
Definition: cfftf.f:1
#define SND_BOOL_OPS(S, ND)
Definition: mx-op-defs.h:300
bool mx_inline_any_positive(size_t n, const T *x)
Definition: mx-inlines.cc:221
FloatNDArray prod(int dim=-1) const
Definition: fNDArray.cc:625
FloatComplexNDArray fourierNd(void) const
Definition: fNDArray.cc:158
#define F77_RET_T
Definition: f77-fcn.h:264
FloatNDArray imag(const FloatComplexNDArray &a)
Definition: fNDArray.cc:770
void mx_inline_cummin(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:893
bool any_element_is_negative(bool=false) const
Definition: fNDArray.cc:510
void mx_inline_pow(size_t n, R *r, const X *x, const Y *y)
Definition: mx-inlines.cc:311
bool mx_inline_any_nan(size_t n, const T *x)
Definition: mx-inlines.cc:182
subst_template_param< std::complex, T, double >::type mx_inline_dsum(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:522
static int ifftNd(const Complex *, Complex *, const int, const dim_vector &)
Definition: oct-fftw.cc:933
#define BSXFUN_STDREL_DEFS_MXLOOP(ARRAY)
Definition: bsxfun-defs.cc:244
float & xelem(octave_idx_type n)
Definition: Array.h:353
bool any_element_is_inf_or_nan(void) const
Definition: fNDArray.cc:530
T mx_inline_sum(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:522
bool too_large_for_float(void) const
Definition: fNDArray.cc:593
charNDArray & insert(const charNDArray &a, octave_idx_type r, octave_idx_type c)
Definition: chNDArray.cc:169
bool test_all(F fcn) const
Definition: Array.h:714
FloatNDArray max(float d, const FloatNDArray &m)
Definition: fNDArray.cc:880
FloatNDArray cumprod(int dim=-1) const
Definition: fNDArray.cc:613
void mx_inline_cumprod(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:628
boolNDArray isnan(void) const
Definition: fNDArray.cc:798
bool xisinteger(double x)
Definition: lo-mappers.h:206
void octave_write_float(std::ostream &os, float d)
Definition: lo-utils.cc:409
boolNDArray all(int dim=-1) const
Definition: fNDArray.cc:601
void mx_inline_cumsum(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:627
bool xpositive_sign(double x)
Definition: lo-mappers.h:222
FloatNDArray cummin(int dim=-1) const
Definition: fNDArray.cc:691
F77_RET_T F77_FUNC(zgemv, ZGEMV)(F77_CONST_CHAR_ARG_DECL
boolNDArray isinf(void) const
Definition: fNDArray.cc:804
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:197
#define BSXFUN_OP2_DEF_MXLOOP(OP, ARRAY, ARRAY1, ARRAY2, LOOP)
Definition: bsxfun-defs.cc:226
FloatNDArray & insert(const FloatNDArray &a, octave_idx_type r, octave_idx_type c)
Definition: fNDArray.cc:776
std::complex< float > FloatComplex
Definition: oct-cmplx.h:30
FloatNDArray cummax(int dim=-1) const
Definition: fNDArray.cc:679
std::ostream & operator<<(std::ostream &os, const FloatNDArray &a)
Definition: fNDArray.cc:844
bool mx_inline_all(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:524
#define BSXFUN_STDOP_DEFS_MXLOOP(ARRAY)
Definition: bsxfun-defs.cc:236
const float * fortran_vec(void) const
Definition: Array.h:481
octave_idx_type NINTbig(double x)
Definition: lo-mappers.cc:635
void mx_inline_not(size_t n, bool *r, const X *x)
Definition: mx-inlines.cc:126
static void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension=0)
Definition: fNDArray.cc:816
FloatComplexRowVector row(octave_idx_type i) const
Definition: fCMatrix.cc:996
FloatNDArray min(int dim=-1) const
Definition: fNDArray.cc:667
int length(void) const
Definition: dim-vector.h:281
T mx_inline_prod(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:523
bool xis_one_or_zero(double x)
Definition: lo-utils.cc:50
NDArray dprod(int dim=-1) const
Definition: fNDArray.cc:631
void mx_inline_diff(const T *v, T *r, octave_idx_type n, octave_idx_type order)
Definition: mx-inlines.cc:1036
bool xis_int_or_inf_or_nan(double x)
Definition: lo-utils.cc:47
void mx_inline_min(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:718
boolNDArray isfinite(void) const
Definition: fNDArray.cc:810