GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
fNDArray.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2018 John W. Eaton
4 Copyright (C) 2009 VZLU Prague, a.s.
5 
6 This file is part of Octave.
7 
8 Octave is free software: you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if defined (HAVE_CONFIG_H)
25 # include "config.h"
26 #endif
27 
28 #include <iostream>
29 #include <limits>
30 
31 #include "Array-util.h"
32 #include "f77-fcn.h"
33 #include "fNDArray.h"
34 #include "functor.h"
35 #include "lo-error.h"
36 #include "lo-ieee.h"
37 #include "lo-mappers.h"
38 #include "mx-base.h"
39 #include "mx-op-defs.h"
40 #include "oct-fftw.h"
41 #include "oct-locbuf.h"
42 
43 #include "bsxfun-defs.cc"
44 
46  : MArray<float> (a.dims ())
47 {
48  octave_idx_type n = a.numel ();
49  for (octave_idx_type i = 0; i < n; i++)
50  xelem (i) = static_cast<unsigned char> (a(i));
51 }
52 
53 #if defined (HAVE_FFTW)
54 
56 FloatNDArray::fourier (int dim) const
57 {
58  dim_vector dv = dims ();
59 
60  if (dim > dv.ndims () || dim < 0)
61  return FloatComplexNDArray ();
62 
63  octave_idx_type stride = 1;
64  octave_idx_type n = dv(dim);
65 
66  for (int i = 0; i < dim; i++)
67  stride *= dv(i);
68 
69  octave_idx_type howmany = numel () / dv(dim);
70  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
71  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride);
72  octave_idx_type dist = (stride == 1 ? n : 1);
73 
74  const float *in (fortran_vec ());
76  FloatComplex *out (retval.fortran_vec ());
77 
78  // Need to be careful here about the distance between fft's
79  for (octave_idx_type k = 0; k < nloop; k++)
80  octave::fftw::fft (in + k * stride * n, out + k * stride * n,
81  n, howmany, stride, dist);
82 
83  return retval;
84 }
85 
87 FloatNDArray::ifourier (int dim) const
88 {
89  dim_vector dv = dims ();
90 
91  if (dim > dv.ndims () || dim < 0)
92  return FloatComplexNDArray ();
93 
94  octave_idx_type stride = 1;
95  octave_idx_type n = dv(dim);
96 
97  for (int i = 0; i < dim; i++)
98  stride *= dv(i);
99 
100  octave_idx_type howmany = numel () / dv(dim);
101  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
102  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride);
103  octave_idx_type dist = (stride == 1 ? n : 1);
104 
105  FloatComplexNDArray retval (*this);
106  FloatComplex *out (retval.fortran_vec ());
107 
108  // Need to be careful here about the distance between fft's
109  for (octave_idx_type k = 0; k < nloop; k++)
110  octave::fftw::ifft (out + k * stride * n, out + k * stride * n,
111  n, howmany, stride, dist);
112 
113  return retval;
114 }
115 
118 {
119  dim_vector dv = dims ();
120  if (dv.ndims () < 2)
121  return FloatComplexNDArray ();
122 
123  dim_vector dv2 (dv(0), dv(1));
124  const float *in = fortran_vec ();
126  FloatComplex *out = retval.fortran_vec ();
127  octave_idx_type howmany = numel () / dv(0) / dv(1);
128  octave_idx_type dist = dv(0) * dv(1);
129 
130  for (octave_idx_type i=0; i < howmany; i++)
131  octave::fftw::fftNd (in + i*dist, out + i*dist, 2, dv2);
132 
133  return retval;
134 }
135 
138 {
139  dim_vector dv = dims ();
140  if (dv.ndims () < 2)
141  return FloatComplexNDArray ();
142 
143  dim_vector dv2 (dv(0), dv(1));
144  FloatComplexNDArray retval (*this);
145  FloatComplex *out = retval.fortran_vec ();
146  octave_idx_type howmany = numel () / dv(0) / dv(1);
147  octave_idx_type dist = dv(0) * dv(1);
148 
149  for (octave_idx_type i=0; i < howmany; i++)
150  octave::fftw::ifftNd (out + i*dist, out + i*dist, 2, dv2);
151 
152  return retval;
153 }
154 
157 {
158  dim_vector dv = dims ();
159  int rank = dv.ndims ();
160 
161  const float *in (fortran_vec ());
163  FloatComplex *out (retval.fortran_vec ());
164 
165  octave::fftw::fftNd (in, out, rank, dv);
166 
167  return retval;
168 }
169 
172 {
173  dim_vector dv = dims ();
174  int rank = dv.ndims ();
175 
176  FloatComplexNDArray tmp (*this);
177  FloatComplex *in (tmp.fortran_vec ());
179  FloatComplex *out (retval.fortran_vec ());
180 
181  octave::fftw::ifftNd (in, out, rank, dv);
182 
183  return retval;
184 }
185 
186 #else
187 
188 #include "lo-fftpack-proto.h"
189 
191 FloatNDArray::fourier (int dim) const
192 {
193  dim_vector dv = dims ();
194 
195  if (dim > dv.ndims () || dim < 0)
196  return FloatComplexNDArray ();
197 
199  octave_idx_type npts = dv(dim);
200  octave_idx_type nn = 4*npts+15;
201  Array<FloatComplex> wsave (dim_vector (nn, 1));
202  FloatComplex *pwsave = wsave.fortran_vec ();
203 
205 
206  octave_idx_type stride = 1;
207 
208  for (int i = 0; i < dim; i++)
209  stride *= dv(i);
210 
211  octave_idx_type howmany = numel () / npts;
212  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
213  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
214  octave_idx_type dist = (stride == 1 ? npts : 1);
215 
216  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
217 
218  for (octave_idx_type k = 0; k < nloop; k++)
219  {
220  for (octave_idx_type j = 0; j < howmany; j++)
221  {
222  octave_quit ();
223 
224  for (octave_idx_type i = 0; i < npts; i++)
225  tmp[i] = elem ((i + k*npts)*stride + j*dist);
226 
227  F77_FUNC (cfftf, CFFTF) (npts, F77_CMPLX_ARG (tmp), F77_CMPLX_ARG (pwsave));
228 
229  for (octave_idx_type i = 0; i < npts; i++)
230  retval((i + k*npts)*stride + j*dist) = tmp[i];
231  }
232  }
233 
234  return retval;
235 }
236 
238 FloatNDArray::ifourier (int dim) const
239 {
240  dim_vector dv = dims ();
241 
242  if (dim > dv.ndims () || dim < 0)
243  return FloatComplexNDArray ();
244 
246  octave_idx_type npts = dv(dim);
247  octave_idx_type nn = 4*npts+15;
248  Array<FloatComplex> wsave (dim_vector (nn, 1));
249  FloatComplex *pwsave = wsave.fortran_vec ();
250 
252 
253  octave_idx_type stride = 1;
254 
255  for (int i = 0; i < dim; i++)
256  stride *= dv(i);
257 
258  octave_idx_type howmany = numel () / npts;
259  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
260  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
261  octave_idx_type dist = (stride == 1 ? npts : 1);
262 
263  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
264 
265  for (octave_idx_type k = 0; k < nloop; k++)
266  {
267  for (octave_idx_type j = 0; j < howmany; j++)
268  {
269  octave_quit ();
270 
271  for (octave_idx_type i = 0; i < npts; i++)
272  tmp[i] = elem ((i + k*npts)*stride + j*dist);
273 
274  F77_FUNC (cfftb, CFFTB) (npts, F77_CMPLX_ARG (tmp), F77_CMPLX_ARG (pwsave));
275 
276  for (octave_idx_type i = 0; i < npts; i++)
277  retval((i + k*npts)*stride + j*dist) = tmp[i] /
278  static_cast<float> (npts);
279  }
280  }
281 
282  return retval;
283 }
284 
286 FloatNDArray::fourier2d (void) const
287 {
288  dim_vector dv = dims ();
289  dim_vector dv2 (dv(0), dv(1));
290  int rank = 2;
291  FloatComplexNDArray retval (*this);
292  octave_idx_type stride = 1;
293 
294  for (int i = 0; i < rank; i++)
295  {
296  octave_idx_type npts = dv2(i);
297  octave_idx_type nn = 4*npts+15;
298  Array<FloatComplex> wsave (dim_vector (nn, 1));
299  FloatComplex *pwsave = wsave.fortran_vec ();
300  Array<FloatComplex> row (dim_vector (npts, 1));
301  FloatComplex *prow = row.fortran_vec ();
302 
303  octave_idx_type howmany = numel () / npts;
304  howmany = (stride == 1 ? howmany
305  : (howmany > stride ? stride : howmany));
306  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
307  octave_idx_type dist = (stride == 1 ? npts : 1);
308 
309  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
310 
311  for (octave_idx_type k = 0; k < nloop; k++)
312  {
313  for (octave_idx_type j = 0; j < howmany; j++)
314  {
315  octave_quit ();
316 
317  for (octave_idx_type l = 0; l < npts; l++)
318  prow[l] = retval((l + k*npts)*stride + j*dist);
319 
320  F77_FUNC (cfftf, CFFTF) (npts, F77_CMPLX_ARG (prow), F77_CMPLX_ARG (pwsave));
321 
322  for (octave_idx_type l = 0; l < npts; l++)
323  retval((l + k*npts)*stride + j*dist) = prow[l];
324  }
325  }
326 
327  stride *= dv2(i);
328  }
329 
330  return retval;
331 }
332 
334 FloatNDArray::ifourier2d (void) const
335 {
336  dim_vector dv = dims ();
337  dim_vector dv2 (dv(0), dv(1));
338  int rank = 2;
339  FloatComplexNDArray retval (*this);
340  octave_idx_type stride = 1;
341 
342  for (int i = 0; i < rank; i++)
343  {
344  octave_idx_type npts = dv2(i);
345  octave_idx_type nn = 4*npts+15;
346  Array<FloatComplex> wsave (dim_vector (nn, 1));
347  FloatComplex *pwsave = wsave.fortran_vec ();
348  Array<FloatComplex> row (dim_vector (npts, 1));
349  FloatComplex *prow = row.fortran_vec ();
350 
351  octave_idx_type howmany = numel () / npts;
352  howmany = (stride == 1 ? howmany
353  : (howmany > stride ? stride : howmany));
354  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
355  octave_idx_type dist = (stride == 1 ? npts : 1);
356 
357  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
358 
359  for (octave_idx_type k = 0; k < nloop; k++)
360  {
361  for (octave_idx_type j = 0; j < howmany; j++)
362  {
363  octave_quit ();
364 
365  for (octave_idx_type l = 0; l < npts; l++)
366  prow[l] = retval((l + k*npts)*stride + j*dist);
367 
368  F77_FUNC (cfftb, CFFTB) (npts, F77_CMPLX_ARG (prow), F77_CMPLX_ARG (pwsave));
369 
370  for (octave_idx_type l = 0; l < npts; l++)
371  retval((l + k*npts)*stride + j*dist) =
372  prow[l] / static_cast<float> (npts);
373  }
374  }
375 
376  stride *= dv2(i);
377  }
378 
379  return retval;
380 }
381 
383 FloatNDArray::fourierNd (void) const
384 {
385  dim_vector dv = dims ();
386  int rank = dv.ndims ();
387  FloatComplexNDArray retval (*this);
388  octave_idx_type stride = 1;
389 
390  for (int i = 0; i < rank; i++)
391  {
392  octave_idx_type npts = dv(i);
393  octave_idx_type nn = 4*npts+15;
394  Array<FloatComplex> wsave (dim_vector (nn, 1));
395  FloatComplex *pwsave = wsave.fortran_vec ();
396  Array<FloatComplex> row (dim_vector (npts, 1));
397  FloatComplex *prow = row.fortran_vec ();
398 
399  octave_idx_type howmany = numel () / npts;
400  howmany = (stride == 1 ? howmany
401  : (howmany > stride ? stride : howmany));
402  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
403  octave_idx_type dist = (stride == 1 ? npts : 1);
404 
405  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
406 
407  for (octave_idx_type k = 0; k < nloop; k++)
408  {
409  for (octave_idx_type j = 0; j < howmany; j++)
410  {
411  octave_quit ();
412 
413  for (octave_idx_type l = 0; l < npts; l++)
414  prow[l] = retval((l + k*npts)*stride + j*dist);
415 
416  F77_FUNC (cfftf, CFFTF) (npts, F77_CMPLX_ARG (prow), F77_CMPLX_ARG (pwsave));
417 
418  for (octave_idx_type l = 0; l < npts; l++)
419  retval((l + k*npts)*stride + j*dist) = prow[l];
420  }
421  }
422 
423  stride *= dv(i);
424  }
425 
426  return retval;
427 }
428 
430 FloatNDArray::ifourierNd (void) const
431 {
432  dim_vector dv = dims ();
433  int rank = dv.ndims ();
434  FloatComplexNDArray retval (*this);
435  octave_idx_type stride = 1;
436 
437  for (int i = 0; i < rank; i++)
438  {
439  octave_idx_type npts = dv(i);
440  octave_idx_type nn = 4*npts+15;
441  Array<FloatComplex> wsave (dim_vector (nn, 1));
442  FloatComplex *pwsave = wsave.fortran_vec ();
443  Array<FloatComplex> row (dim_vector (npts, 1));
444  FloatComplex *prow = row.fortran_vec ();
445 
446  octave_idx_type howmany = numel () / npts;
447  howmany = (stride == 1 ? howmany
448  : (howmany > stride ? stride : howmany));
449  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
450  octave_idx_type dist = (stride == 1 ? npts : 1);
451 
452  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
453 
454  for (octave_idx_type k = 0; k < nloop; k++)
455  {
456  for (octave_idx_type j = 0; j < howmany; j++)
457  {
458  octave_quit ();
459 
460  for (octave_idx_type l = 0; l < npts; l++)
461  prow[l] = retval((l + k*npts)*stride + j*dist);
462 
463  F77_FUNC (cfftb, CFFTB) (npts, F77_CMPLX_ARG (prow), F77_CMPLX_ARG (pwsave));
464 
465  for (octave_idx_type l = 0; l < npts; l++)
466  retval((l + k*npts)*stride + j*dist) =
467  prow[l] / static_cast<float> (npts);
468  }
469  }
470 
471  stride *= dv(i);
472  }
473 
474  return retval;
475 }
476 
477 #endif
478 
479 // unary operations
480 
483 {
484  if (any_element_is_nan ())
486 
487  return do_mx_unary_op<bool, float> (*this, mx_inline_not);
488 }
489 
490 bool
492 {
493  return (neg_zero ? test_all (octave::math::negative_sign)
494  : do_mx_check<float> (*this, mx_inline_any_negative));
495 }
496 
497 bool
499 {
500  return (neg_zero ? test_all (octave::math::positive_sign)
501  : do_mx_check<float> (*this, mx_inline_any_positive));
502 }
503 
504 bool
506 {
507  return do_mx_check<float> (*this, mx_inline_any_nan);
508 }
509 
510 bool
512 {
513  return ! do_mx_check<float> (*this, mx_inline_all_finite);
514 }
515 
516 bool
518 {
519  return ! test_all (xis_one_or_zero);
520 }
521 
522 bool
524 {
525  return test_all (xis_zero);
526 }
527 
528 bool
530 {
532 }
533 
534 // Return nonzero if any element of M is not an integer. Also extract
535 // the largest and smallest values and return them in MAX_VAL and MIN_VAL.
536 
537 bool
538 FloatNDArray::all_integers (float& max_val, float& min_val) const
539 {
540  octave_idx_type nel = numel ();
541 
542  if (nel > 0)
543  {
544  max_val = elem (0);
545  min_val = elem (0);
546  }
547  else
548  return false;
549 
550  for (octave_idx_type i = 0; i < nel; i++)
551  {
552  float val = elem (i);
553 
554  if (val > max_val)
555  max_val = val;
556 
557  if (val < min_val)
558  min_val = val;
559 
561  return false;
562  }
563 
564  return true;
565 }
566 
567 bool
569 {
571 }
572 
573 bool
575 {
576  return false;
577 }
578 
579 // FIXME: this is not quite the right thing.
580 
582 FloatNDArray::all (int dim) const
583 {
584  return do_mx_red_op<bool, float> (*this, dim, mx_inline_all);
585 }
586 
588 FloatNDArray::any (int dim) const
589 {
590  return do_mx_red_op<bool, float> (*this, dim, mx_inline_any);
591 }
592 
594 FloatNDArray::cumprod (int dim) const
595 {
596  return do_mx_cum_op<float, float> (*this, dim, mx_inline_cumprod);
597 }
598 
600 FloatNDArray::cumsum (int dim) const
601 {
602  return do_mx_cum_op<float, float> (*this, dim, mx_inline_cumsum);
603 }
604 
606 FloatNDArray::prod (int dim) const
607 {
608  return do_mx_red_op<float, float> (*this, dim, mx_inline_prod);
609 }
610 
611 NDArray
612 FloatNDArray::dprod (int dim) const
613 {
614  return do_mx_red_op<double, float> (*this, dim, mx_inline_dprod);
615 }
616 
618 FloatNDArray::sum (int dim) const
619 {
620  return do_mx_red_op<float, float> (*this, dim, mx_inline_sum);
621 }
622 
623 NDArray
624 FloatNDArray::dsum (int dim) const
625 {
626  return do_mx_red_op<double, float> (*this, dim, mx_inline_dsum);
627 }
628 
630 FloatNDArray::sumsq (int dim) const
631 {
632  return do_mx_red_op<float, float> (*this, dim, mx_inline_sumsq);
633 }
634 
636 FloatNDArray::max (int dim) const
637 {
638  return do_mx_minmax_op<float> (*this, dim, mx_inline_max);
639 }
640 
642 FloatNDArray::max (Array<octave_idx_type>& idx_arg, int dim) const
643 {
644  return do_mx_minmax_op<float> (*this, idx_arg, dim, mx_inline_max);
645 }
646 
648 FloatNDArray::min (int dim) const
649 {
650  return do_mx_minmax_op<float> (*this, dim, mx_inline_min);
651 }
652 
654 FloatNDArray::min (Array<octave_idx_type>& idx_arg, int dim) const
655 {
656  return do_mx_minmax_op<float> (*this, idx_arg, dim, mx_inline_min);
657 }
658 
660 FloatNDArray::cummax (int dim) const
661 {
662  return do_mx_cumminmax_op<float> (*this, dim, mx_inline_cummax);
663 }
664 
667 {
668  return do_mx_cumminmax_op<float> (*this, idx_arg, dim, mx_inline_cummax);
669 }
670 
672 FloatNDArray::cummin (int dim) const
673 {
674  return do_mx_cumminmax_op<float> (*this, dim, mx_inline_cummin);
675 }
676 
679 {
680  return do_mx_cumminmax_op<float> (*this, idx_arg, dim, mx_inline_cummin);
681 }
682 
684 FloatNDArray::diff (octave_idx_type order, int dim) const
685 {
686  return do_mx_diff_op<float> (*this, dim, order, mx_inline_diff);
687 }
688 
692 {
693  if (rb.numel () > 0)
694  insert (rb, ra_idx);
695  return *this;
696 }
697 
701 {
702  FloatComplexNDArray retval (*this);
703  if (rb.numel () > 0)
704  retval.insert (rb, ra_idx);
705  return retval;
706 }
707 
711 {
712  charNDArray retval (dims ());
713  octave_idx_type nel = numel ();
714 
715  for (octave_idx_type i = 0; i < nel; i++)
716  {
717  float d = elem (i);
718 
719  if (octave::math::isnan (d))
720  (*current_liboctave_error_handler)
721  ("invalid conversion from NaN to character");
722 
724 
725  if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
726  // FIXME: is there something better to do? Should we warn the user?
727  ival = 0;
728 
729  retval.elem (i) = static_cast<char>(ival);
730  }
731 
732  if (rb.isempty ())
733  return retval;
734 
735  retval.insert (rb, ra_idx);
736  return retval;
737 }
738 
741 {
742  return do_mx_unary_op<float, FloatComplex> (a, mx_inline_real);
743 }
744 
747 {
748  return do_mx_unary_op<float, FloatComplex> (a, mx_inline_imag);
749 }
750 
754 {
755  Array<float>::insert (a, r, c);
756  return *this;
757 }
758 
762 {
764  return *this;
765 }
766 
768 FloatNDArray::abs (void) const
769 {
770  return do_mx_unary_map<float, float, std::abs> (*this);
771 }
772 
775 {
776  return do_mx_unary_map<bool, float, octave::math::isnan> (*this);
777 }
778 
781 {
782  return do_mx_unary_map<bool, float, octave::math::isinf> (*this);
783 }
784 
787 {
788  return do_mx_unary_map<bool, float, octave::math::isfinite> (*this);
789 }
790 
791 void
793  const dim_vector& dimensions,
794  int start_dimension)
795 {
796  ::increment_index (ra_idx, dimensions, start_dimension);
797 }
798 
801  const dim_vector& dimensions)
802 {
804 }
805 
808 {
809  return MArray<float>::diag (k);
810 }
811 
814 {
815  return MArray<float>::diag (m, n);
816 }
817 
818 // This contains no information on the array structure !!!
819 std::ostream&
820 operator << (std::ostream& os, const FloatNDArray& a)
821 {
822  octave_idx_type nel = a.numel ();
823 
824  for (octave_idx_type i = 0; i < nel; i++)
825  {
826  os << ' ';
827  octave_write_float (os, a.elem (i));
828  os << "\n";
829  }
830  return os;
831 }
832 
833 std::istream&
834 operator >> (std::istream& is, FloatNDArray& a)
835 {
836  octave_idx_type nel = a.numel ();
837 
838  if (nel > 0)
839  {
840  float tmp;
841  for (octave_idx_type i = 0; i < nel; i++)
842  {
843  tmp = octave_read_value<float> (is);
844  if (is)
845  a.elem (i) = tmp;
846  else
847  return is;
848  }
849  }
850 
851  return is;
852 }
853 
855 
858 
861 
864 
867 
dim_vector dimensions
Definition: Array.h:216
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
Definition: Array-util.cc:175
bool isinteger(double x)
Definition: lo-mappers.h:240
FloatNDArray concat(const FloatNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: fNDArray.cc:690
boolNDArray operator!(void) const
Definition: fNDArray.cc:482
#define NDS_BOOL_OPS(ND, S)
Definition: mx-op-defs.h:255
#define NDS_CMP_OPS(ND, S)
Definition: mx-op-defs.h:238
Template for N-dimensional array classes with like-type math operators.
Definition: MArray.h:32
void mx_inline_cummax(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:1184
bool all_elements_are_int_or_inf_or_nan(void) const
Definition: fNDArray.cc:529
const octave_base_value const Array< octave_idx_type > & ra_idx
#define SND_CMP_OPS(S, ND)
Definition: mx-op-defs.h:285
NDArray dsum(int dim=-1) const
Definition: fNDArray.cc:624
FloatNDArray max(int dim=-1) const
Definition: fNDArray.cc:636
#define BSXFUN_OP_DEF_MXLOOP(OP, ARRAY, LOOP)
Definition: bsxfun-defs.cc:219
bool isempty(void) const
Definition: Array.h:565
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
void mx_inline_real(size_t n, T *r, const std::complex< T > *x)
Definition: mx-inlines.cc:320
bool any_element_is_positive(bool=false) const
Definition: fNDArray.cc:498
bool mx_inline_all_finite(size_t n, const T *x)
Definition: mx-inlines.cc:269
for large enough k
Definition: lu.cc:617
boolNDArray isinf(void) const
Definition: fNDArray.cc:780
const float * fortran_vec(void) const
Definition: Array.h:584
#define MINMAX_FCNS(T, S)
Definition: mx-op-defs.h:584
boolNDArray isnan(void) const
Definition: fNDArray.cc:774
FloatComplexNDArray ifourierNd(void) const
Definition: fNDArray.cc:171
bool isnan(bool)
Definition: lo-mappers.h:187
bool xis_zero(double x)
Definition: lo-utils.cc:48
static F77_INT nn
Definition: DASPK.cc:62
bool any_element_is_nan(void) const
Definition: fNDArray.cc:505
FloatNDArray cummin(int dim=-1) const
Definition: fNDArray.cc:672
std::istream & operator>>(std::istream &is, FloatNDArray &a)
Definition: fNDArray.cc:834
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
Definition: Array.h:442
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:897
static int fftNd(const double *, Complex *, const int, const dim_vector &)
Definition: oct-fftw.cc:921
FloatComplexNDArray fourier(int dim=1) const
Definition: fNDArray.cc:56
bool all_elements_are_zero(void) const
Definition: fNDArray.cc:523
float & elem(octave_idx_type n)
Definition: Array.h:488
FloatNDArray sumsq(int dim=-1) const
Definition: fNDArray.cc:630
T mx_inline_sumsq(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:753
bool mx_inline_any_negative(size_t n, const T *x)
Definition: mx-inlines.cc:282
bool positive_sign(double x)
Definition: lo-mappers.h:71
void mx_inline_max(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:962
subroutine cfftb(n, c, wsave)
Definition: cfftb.f:2
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
Definition: file-io.cc:587
void err_nan_to_logical_conversion(void)
bool mx_inline_any(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:753
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
FloatNDArray prod(int dim=-1) const
Definition: fNDArray.cc:606
void mx_inline_imag(size_t n, T *r, const std::complex< T > *x)
Definition: mx-inlines.cc:327
boolNDArray all(int dim=-1) const
Definition: fNDArray.cc:582
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:1583
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
FloatNDArray cumsum(int dim=-1) const
Definition: fNDArray.cc:600
boolNDArray any(int dim=-1) const
Definition: fNDArray.cc:588
subroutine cffti(n, wsave)
Definition: cffti.f:2
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:857
#define NDND_CMP_OPS(ND1, ND2)
Definition: mx-op-defs.h:332
bool any_element_not_one_or_zero(void) const
Definition: fNDArray.cc:517
static octave_idx_type compute_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions)
Definition: fNDArray.cc:800
#define NDND_BOOL_OPS(ND1, ND2)
Definition: mx-op-defs.h:349
FloatNDArray(void)
Definition: fNDArray.h:41
subst_template_param< std::complex, T, double >::type mx_inline_dprod(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:752
FloatNDArray real(const FloatComplexNDArray &a)
Definition: fNDArray.cc:740
FloatNDArray cumprod(int dim=-1) const
Definition: fNDArray.cc:594
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
double tmp
Definition: data.cc:6252
subroutine cfftf(n, c, wsave)
Definition: cfftf.f:2
octave_value retval
Definition: data.cc:6246
#define SND_BOOL_OPS(S, ND)
Definition: mx-op-defs.h:302
bool mx_inline_any_positive(size_t n, const T *x)
Definition: mx-inlines.cc:295
FloatNDArray imag(const FloatComplexNDArray &a)
Definition: fNDArray.cc:746
void mx_inline_cummin(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:1183
void mx_inline_pow(size_t n, R *r, const X *x, const Y *y)
Definition: mx-inlines.cc:413
FloatNDArray min(int dim=-1) const
Definition: fNDArray.cc:648
the exceeded dimensions are set to if fewer subscripts than dimensions are the exceeding dimensions are merged into the final requested dimension For consider the following dims
Definition: sub2ind.cc:255
bool mx_inline_any_nan(size_t n, const T *x)
Definition: mx-inlines.cc:256
subst_template_param< std::complex, T, double >::type mx_inline_dsum(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:751
F77_RET_T F77_FUNC(xerbla, XERBLA)
Definition: xerbla.c:57
#define BSXFUN_STDREL_DEFS_MXLOOP(ARRAY)
Definition: bsxfun-defs.cc:242
float & xelem(octave_idx_type n)
Definition: Array.h:458
bool test_all(F fcn) const
Definition: Array.h:819
T mx_inline_sum(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:751
FloatComplexNDArray fourier2d(void) const
Definition: fNDArray.cc:117
FloatNDArray sum(int dim=-1) const
Definition: fNDArray.cc:618
FloatNDArray max(float d, const FloatNDArray &m)
Definition: fNDArray.cc:854
#define F77_CMPLX_ARG(x)
Definition: f77-fcn.h:309
void mx_inline_cumprod(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:858
void octave_write_float(std::ostream &os, float d)
Definition: lo-utils.cc:418
void mx_inline_cumsum(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:857
bool all_integers(void) const
Definition: fNDArray.cc:568
octave_idx_type nint_big(double x)
Definition: lo-mappers.cc:182
bool negative_sign(double x)
Definition: lo-mappers.cc:176
Array< T > diag(octave_idx_type k=0) const
Get the kth super or subdiagonal.
Definition: Array.cc:2530
FloatNDArray diag(octave_idx_type k=0) const
Definition: fNDArray.cc:807
FloatNDArray cummax(int dim=-1) const
Definition: fNDArray.cc:660
static int ifftNd(const Complex *, Complex *, const int, const dim_vector &)
Definition: oct-fftw.cc:967
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:41
#define BSXFUN_OP2_DEF_MXLOOP(OP, ARRAY, ARRAY1, ARRAY2, LOOP)
Definition: bsxfun-defs.cc:224
bool too_large_for_float(void) const
Definition: fNDArray.cc:574
FloatNDArray & insert(const FloatNDArray &a, octave_idx_type r, octave_idx_type c)
Definition: fNDArray.cc:752
FloatComplexNDArray ifourier2d(void) const
Definition: fNDArray.cc:137
FloatNDArray abs(void) const
Definition: fNDArray.cc:768
for i
Definition: data.cc:5264
bool any_element_is_negative(bool=false) const
Definition: fNDArray.cc:491
std::complex< float > FloatComplex
Definition: oct-cmplx.h:32
std::ostream & operator<<(std::ostream &os, const FloatNDArray &a)
Definition: fNDArray.cc:820
NDArray dprod(int dim=-1) const
Definition: fNDArray.cc:612
octave_idx_type ndims(void) const
Number of dimensions.
Definition: dim-vector.h:295
bool mx_inline_all(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:753
#define BSXFUN_STDOP_DEFS_MXLOOP(ARRAY)
Definition: bsxfun-defs.cc:234
void mx_inline_not(size_t n, bool *r, const X *x)
Definition: mx-inlines.cc:180
static void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension=0)
Definition: fNDArray.cc:792
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:366
write the output to stdout if nargout is
Definition: load-save.cc:1612
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
FloatComplexNDArray fourierNd(void) const
Definition: fNDArray.cc:156
FloatComplexNDArray ifourier(int dim=1) const
Definition: fNDArray.cc:87
boolNDArray isfinite(void) const
Definition: fNDArray.cc:786
T mx_inline_prod(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:752
dim_vector dv
Definition: sub2ind.cc:263
bool xis_one_or_zero(double x)
Definition: lo-utils.cc:45
octave::stream os
Definition: file-io.cc:627
bool any_element_is_inf_or_nan(void) const
Definition: fNDArray.cc:511
where the brackets indicate optional arguments and and character or cell array For character arrays the conversion is repeated for every row
Definition: str2double.cc:342
FloatNDArray diff(octave_idx_type order=1, int dim=-1) const
Definition: fNDArray.cc:684
void mx_inline_diff(const T *v, T *r, octave_idx_type n, octave_idx_type order)
Definition: mx-inlines.cc:1380
bool xis_int_or_inf_or_nan(double x)
Definition: lo-utils.cc:42
void mx_inline_min(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:961