GNU Octave  4.2.1
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-2017 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 #if defined (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.ndims () || 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 ());
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.ndims () || 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.ndims () < 2)
123  return FloatComplexNDArray ();
124 
125  dim_vector dv2 (dv(0), dv(1));
126  const float *in = fortran_vec ();
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.ndims () < 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.ndims ();
162 
163  const float *in (fortran_vec ());
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.ndims ();
177 
178  FloatComplexNDArray tmp (*this);
179  FloatComplex *in (tmp.fortran_vec ());
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 #include "lo-fftpack-proto.h"
191 
193 FloatNDArray::fourier (int dim) const
194 {
195  dim_vector dv = dims ();
196 
197  if (dim > dv.ndims () || dim < 0)
198  return FloatComplexNDArray ();
199 
201  octave_idx_type npts = dv(dim);
202  octave_idx_type nn = 4*npts+15;
203  Array<FloatComplex> wsave (dim_vector (nn, 1));
204  FloatComplex *pwsave = wsave.fortran_vec ();
205 
207 
208  octave_idx_type stride = 1;
209 
210  for (int i = 0; i < dim; i++)
211  stride *= dv(i);
212 
213  octave_idx_type howmany = numel () / npts;
214  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
215  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
216  octave_idx_type dist = (stride == 1 ? npts : 1);
217 
218  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
219 
220  for (octave_idx_type k = 0; k < nloop; k++)
221  {
222  for (octave_idx_type j = 0; j < howmany; j++)
223  {
224  octave_quit ();
225 
226  for (octave_idx_type i = 0; i < npts; i++)
227  tmp[i] = elem ((i + k*npts)*stride + j*dist);
228 
229  F77_FUNC (cfftf, CFFTF) (npts, F77_CMPLX_ARG (tmp), F77_CMPLX_ARG (pwsave));
230 
231  for (octave_idx_type i = 0; i < npts; i++)
232  retval((i + k*npts)*stride + j*dist) = tmp[i];
233  }
234  }
235 
236  return retval;
237 }
238 
240 FloatNDArray::ifourier (int dim) const
241 {
242  dim_vector dv = dims ();
243 
244  if (dim > dv.ndims () || dim < 0)
245  return FloatComplexNDArray ();
246 
248  octave_idx_type npts = dv(dim);
249  octave_idx_type nn = 4*npts+15;
250  Array<FloatComplex> wsave (dim_vector (nn, 1));
251  FloatComplex *pwsave = wsave.fortran_vec ();
252 
254 
255  octave_idx_type stride = 1;
256 
257  for (int i = 0; i < dim; i++)
258  stride *= dv(i);
259 
260  octave_idx_type howmany = numel () / npts;
261  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
262  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
263  octave_idx_type dist = (stride == 1 ? npts : 1);
264 
265  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
266 
267  for (octave_idx_type k = 0; k < nloop; k++)
268  {
269  for (octave_idx_type j = 0; j < howmany; j++)
270  {
271  octave_quit ();
272 
273  for (octave_idx_type i = 0; i < npts; i++)
274  tmp[i] = elem ((i + k*npts)*stride + j*dist);
275 
276  F77_FUNC (cfftb, CFFTB) (npts, F77_CMPLX_ARG (tmp), F77_CMPLX_ARG (pwsave));
277 
278  for (octave_idx_type i = 0; i < npts; i++)
279  retval((i + k*npts)*stride + j*dist) = tmp[i] /
280  static_cast<float> (npts);
281  }
282  }
283 
284  return retval;
285 }
286 
288 FloatNDArray::fourier2d (void) const
289 {
290  dim_vector dv = dims ();
291  dim_vector dv2 (dv(0), dv(1));
292  int rank = 2;
293  FloatComplexNDArray retval (*this);
294  octave_idx_type stride = 1;
295 
296  for (int i = 0; i < rank; i++)
297  {
298  octave_idx_type npts = dv2(i);
299  octave_idx_type nn = 4*npts+15;
300  Array<FloatComplex> wsave (dim_vector (nn, 1));
301  FloatComplex *pwsave = wsave.fortran_vec ();
302  Array<FloatComplex> row (dim_vector (npts, 1));
303  FloatComplex *prow = row.fortran_vec ();
304 
305  octave_idx_type howmany = numel () / npts;
306  howmany = (stride == 1 ? howmany :
307  (howmany > stride ? stride : howmany));
308  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
309  octave_idx_type dist = (stride == 1 ? npts : 1);
310 
311  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
312 
313  for (octave_idx_type k = 0; k < nloop; k++)
314  {
315  for (octave_idx_type j = 0; j < howmany; j++)
316  {
317  octave_quit ();
318 
319  for (octave_idx_type l = 0; l < npts; l++)
320  prow[l] = retval((l + k*npts)*stride + j*dist);
321 
322  F77_FUNC (cfftf, CFFTF) (npts, F77_CMPLX_ARG (prow), F77_CMPLX_ARG (pwsave));
323 
324  for (octave_idx_type l = 0; l < npts; l++)
325  retval((l + k*npts)*stride + j*dist) = prow[l];
326  }
327  }
328 
329  stride *= dv2(i);
330  }
331 
332  return retval;
333 }
334 
336 FloatNDArray::ifourier2d (void) const
337 {
338  dim_vector dv = dims ();
339  dim_vector dv2 (dv(0), dv(1));
340  int rank = 2;
341  FloatComplexNDArray retval (*this);
342  octave_idx_type stride = 1;
343 
344  for (int i = 0; i < rank; i++)
345  {
346  octave_idx_type npts = dv2(i);
347  octave_idx_type nn = 4*npts+15;
348  Array<FloatComplex> wsave (dim_vector (nn, 1));
349  FloatComplex *pwsave = wsave.fortran_vec ();
350  Array<FloatComplex> row (dim_vector (npts, 1));
351  FloatComplex *prow = row.fortran_vec ();
352 
353  octave_idx_type howmany = numel () / npts;
354  howmany = (stride == 1 ? howmany :
355  (howmany > stride ? stride : howmany));
356  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
357  octave_idx_type dist = (stride == 1 ? npts : 1);
358 
359  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
360 
361  for (octave_idx_type k = 0; k < nloop; k++)
362  {
363  for (octave_idx_type j = 0; j < howmany; j++)
364  {
365  octave_quit ();
366 
367  for (octave_idx_type l = 0; l < npts; l++)
368  prow[l] = retval((l + k*npts)*stride + j*dist);
369 
370  F77_FUNC (cfftb, CFFTB) (npts, F77_CMPLX_ARG (prow), F77_CMPLX_ARG (pwsave));
371 
372  for (octave_idx_type l = 0; l < npts; l++)
373  retval((l + k*npts)*stride + j*dist) =
374  prow[l] / static_cast<float> (npts);
375  }
376  }
377 
378  stride *= dv2(i);
379  }
380 
381  return retval;
382 }
383 
385 FloatNDArray::fourierNd (void) const
386 {
387  dim_vector dv = dims ();
388  int rank = dv.ndims ();
389  FloatComplexNDArray retval (*this);
390  octave_idx_type stride = 1;
391 
392  for (int i = 0; i < rank; i++)
393  {
394  octave_idx_type npts = dv(i);
395  octave_idx_type nn = 4*npts+15;
396  Array<FloatComplex> wsave (dim_vector (nn, 1));
397  FloatComplex *pwsave = wsave.fortran_vec ();
398  Array<FloatComplex> row (dim_vector (npts, 1));
399  FloatComplex *prow = row.fortran_vec ();
400 
401  octave_idx_type howmany = numel () / npts;
402  howmany = (stride == 1 ? howmany :
403  (howmany > stride ? stride : howmany));
404  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
405  octave_idx_type dist = (stride == 1 ? npts : 1);
406 
407  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
408 
409  for (octave_idx_type k = 0; k < nloop; k++)
410  {
411  for (octave_idx_type j = 0; j < howmany; j++)
412  {
413  octave_quit ();
414 
415  for (octave_idx_type l = 0; l < npts; l++)
416  prow[l] = retval((l + k*npts)*stride + j*dist);
417 
418  F77_FUNC (cfftf, CFFTF) (npts, F77_CMPLX_ARG (prow), F77_CMPLX_ARG (pwsave));
419 
420  for (octave_idx_type l = 0; l < npts; l++)
421  retval((l + k*npts)*stride + j*dist) = prow[l];
422  }
423  }
424 
425  stride *= dv(i);
426  }
427 
428  return retval;
429 }
430 
432 FloatNDArray::ifourierNd (void) const
433 {
434  dim_vector dv = dims ();
435  int rank = dv.ndims ();
436  FloatComplexNDArray retval (*this);
437  octave_idx_type stride = 1;
438 
439  for (int i = 0; i < rank; i++)
440  {
441  octave_idx_type npts = dv(i);
442  octave_idx_type nn = 4*npts+15;
443  Array<FloatComplex> wsave (dim_vector (nn, 1));
444  FloatComplex *pwsave = wsave.fortran_vec ();
445  Array<FloatComplex> row (dim_vector (npts, 1));
446  FloatComplex *prow = row.fortran_vec ();
447 
448  octave_idx_type howmany = numel () / npts;
449  howmany = (stride == 1 ? howmany :
450  (howmany > stride ? stride : howmany));
451  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
452  octave_idx_type dist = (stride == 1 ? npts : 1);
453 
454  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
455 
456  for (octave_idx_type k = 0; k < nloop; k++)
457  {
458  for (octave_idx_type j = 0; j < howmany; j++)
459  {
460  octave_quit ();
461 
462  for (octave_idx_type l = 0; l < npts; l++)
463  prow[l] = retval((l + k*npts)*stride + j*dist);
464 
465  F77_FUNC (cfftb, CFFTB) (npts, F77_CMPLX_ARG (prow), F77_CMPLX_ARG (pwsave));
466 
467  for (octave_idx_type l = 0; l < npts; l++)
468  retval((l + k*npts)*stride + j*dist) =
469  prow[l] / static_cast<float> (npts);
470  }
471  }
472 
473  stride *= dv(i);
474  }
475 
476  return retval;
477 }
478 
479 #endif
480 
481 // unary operations
482 
485 {
486  if (any_element_is_nan ())
488 
489  return do_mx_unary_op<bool, float> (*this, mx_inline_not);
490 }
491 
492 bool
494 {
495  return (neg_zero ? test_all (octave::math::negative_sign)
496  : do_mx_check<float> (*this, mx_inline_any_negative));
497 }
498 
499 bool
501 {
502  return (neg_zero ? test_all (octave::math::positive_sign)
503  : do_mx_check<float> (*this, mx_inline_any_positive));
504 }
505 
506 bool
508 {
509  return do_mx_check<float> (*this, mx_inline_any_nan);
510 }
511 
512 bool
514 {
515  return ! do_mx_check<float> (*this, mx_inline_all_finite);
516 }
517 
518 bool
520 {
521  return ! test_all (xis_one_or_zero);
522 }
523 
524 bool
526 {
527  return test_all (xis_zero);
528 }
529 
530 bool
532 {
534 }
535 
536 // Return nonzero if any element of M is not an integer. Also extract
537 // the largest and smallest values and return them in MAX_VAL and MIN_VAL.
538 
539 bool
540 FloatNDArray::all_integers (float& max_val, float& min_val) const
541 {
542  octave_idx_type nel = numel ();
543 
544  if (nel > 0)
545  {
546  max_val = elem (0);
547  min_val = elem (0);
548  }
549  else
550  return false;
551 
552  for (octave_idx_type i = 0; i < nel; i++)
553  {
554  float val = elem (i);
555 
556  if (val > max_val)
557  max_val = val;
558 
559  if (val < min_val)
560  min_val = val;
561 
562  if (! octave::math::isinteger (val))
563  return false;
564  }
565 
566  return true;
567 }
568 
569 bool
571 {
573 }
574 
575 bool
577 {
578  return false;
579 }
580 
581 // FIXME: this is not quite the right thing.
582 
584 FloatNDArray::all (int dim) const
585 {
586  return do_mx_red_op<bool, float> (*this, dim, mx_inline_all);
587 }
588 
590 FloatNDArray::any (int dim) const
591 {
592  return do_mx_red_op<bool, float> (*this, dim, mx_inline_any);
593 }
594 
596 FloatNDArray::cumprod (int dim) const
597 {
598  return do_mx_cum_op<float, float> (*this, dim, mx_inline_cumprod);
599 }
600 
602 FloatNDArray::cumsum (int dim) const
603 {
604  return do_mx_cum_op<float, float> (*this, dim, mx_inline_cumsum);
605 }
606 
608 FloatNDArray::prod (int dim) const
609 {
610  return do_mx_red_op<float, float> (*this, dim, mx_inline_prod);
611 }
612 
613 NDArray
614 FloatNDArray::dprod (int dim) const
615 {
616  return do_mx_red_op<double, float> (*this, dim, mx_inline_dprod);
617 }
618 
620 FloatNDArray::sum (int dim) const
621 {
622  return do_mx_red_op<float, float> (*this, dim, mx_inline_sum);
623 }
624 
625 NDArray
626 FloatNDArray::dsum (int dim) const
627 {
628  return do_mx_red_op<double, float> (*this, dim, mx_inline_dsum);
629 }
630 
632 FloatNDArray::sumsq (int dim) const
633 {
634  return do_mx_red_op<float, float> (*this, dim, mx_inline_sumsq);
635 }
636 
638 FloatNDArray::max (int dim) const
639 {
640  return do_mx_minmax_op<float> (*this, dim, mx_inline_max);
641 }
642 
644 FloatNDArray::max (Array<octave_idx_type>& idx_arg, int dim) const
645 {
646  return do_mx_minmax_op<float> (*this, idx_arg, dim, mx_inline_max);
647 }
648 
650 FloatNDArray::min (int dim) const
651 {
652  return do_mx_minmax_op<float> (*this, dim, mx_inline_min);
653 }
654 
656 FloatNDArray::min (Array<octave_idx_type>& idx_arg, int dim) const
657 {
658  return do_mx_minmax_op<float> (*this, idx_arg, dim, mx_inline_min);
659 }
660 
662 FloatNDArray::cummax (int dim) const
663 {
664  return do_mx_cumminmax_op<float> (*this, dim, mx_inline_cummax);
665 }
666 
669 {
670  return do_mx_cumminmax_op<float> (*this, idx_arg, dim, mx_inline_cummax);
671 }
672 
674 FloatNDArray::cummin (int dim) const
675 {
676  return do_mx_cumminmax_op<float> (*this, dim, mx_inline_cummin);
677 }
678 
681 {
682  return do_mx_cumminmax_op<float> (*this, idx_arg, dim, mx_inline_cummin);
683 }
684 
686 FloatNDArray::diff (octave_idx_type order, int dim) const
687 {
688  return do_mx_diff_op<float> (*this, dim, order, mx_inline_diff);
689 }
690 
694 {
695  if (rb.numel () > 0)
696  insert (rb, ra_idx);
697  return *this;
698 }
699 
703 {
704  FloatComplexNDArray retval (*this);
705  if (rb.numel () > 0)
706  retval.insert (rb, ra_idx);
707  return retval;
708 }
709 
713 {
714  charNDArray retval (dims ());
715  octave_idx_type nel = numel ();
716 
717  for (octave_idx_type i = 0; i < nel; i++)
718  {
719  float d = elem (i);
720 
721  if (octave::math::isnan (d))
722  (*current_liboctave_error_handler)
723  ("invalid conversion from NaN to character");
724 
726 
727  if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
728  // FIXME: is there something better to do? Should we warn the user?
729  ival = 0;
730 
731  retval.elem (i) = static_cast<char>(ival);
732  }
733 
734  if (rb.is_empty ())
735  return retval;
736 
737  retval.insert (rb, ra_idx);
738  return retval;
739 }
740 
743 {
744  return do_mx_unary_op<float, FloatComplex> (a, mx_inline_real);
745 }
746 
749 {
750  return do_mx_unary_op<float, FloatComplex> (a, mx_inline_imag);
751 }
752 
756 {
757  Array<float>::insert (a, r, c);
758  return *this;
759 }
760 
764 {
765  Array<float>::insert (a, ra_idx);
766  return *this;
767 }
768 
770 FloatNDArray::abs (void) const
771 {
772  return do_mx_unary_map<float, float, std::abs> (*this);
773 }
774 
777 {
778  return do_mx_unary_map<bool, float, octave::math::isnan> (*this);
779 }
780 
783 {
784  return do_mx_unary_map<bool, float, octave::math::isinf> (*this);
785 }
786 
789 {
790  return do_mx_unary_map<bool, float, octave::math::finite> (*this);
791 }
792 
793 void
795  const dim_vector& dimensions,
796  int start_dimension)
797 {
798  ::increment_index (ra_idx, dimensions, start_dimension);
799 }
800 
803  const dim_vector& dimensions)
804 {
805  return ::compute_index (ra_idx, dimensions);
806 }
807 
810 {
811  return MArray<float>::diag (k);
812 }
813 
816 {
817  return MArray<float>::diag (m, n);
818 }
819 
820 // This contains no information on the array structure !!!
821 std::ostream&
822 operator << (std::ostream& os, const FloatNDArray& a)
823 {
824  octave_idx_type nel = a.numel ();
825 
826  for (octave_idx_type i = 0; i < nel; i++)
827  {
828  os << " ";
829  octave_write_float (os, a.elem (i));
830  os << "\n";
831  }
832  return os;
833 }
834 
835 std::istream&
836 operator >> (std::istream& is, FloatNDArray& a)
837 {
838  octave_idx_type nel = a.numel ();
839 
840  if (nel > 0)
841  {
842  float tmp;
843  for (octave_idx_type i = 0; i < nel; i++)
844  {
845  tmp = octave_read_value<float> (is);
846  if (is)
847  a.elem (i) = tmp;
848  else
849  return is;
850  }
851  }
852 
853  return is;
854 }
855 
857 
859 NDS_BOOL_OPS (FloatNDArray, float)
860 
861 SND_CMP_OPS (float, FloatNDArray)
862 SND_BOOL_OPS (float, FloatNDArray)
863 
864 NDND_CMP_OPS (FloatNDArray, FloatNDArray)
865 NDND_BOOL_OPS (FloatNDArray, FloatNDArray)
866 
869 
871 BSXFUN_OP2_DEF_MXLOOP (pow, FloatComplexNDArray, FloatComplexNDArray,
872  FloatNDArray, mx_inline_pow)
873 BSXFUN_OP2_DEF_MXLOOP (pow, FloatComplexNDArray, FloatNDArray,
874  FloatComplexNDArray, mx_inline_pow)
dim_vector dimensions
Definition: Array.h:214
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
Definition: Array-util.cc:176
bool isinteger(double x)
Definition: lo-mappers.h:255
FloatNDArray concat(const FloatNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: fNDArray.cc:692
FloatComplexNDArray fourier(int dim=1) const
Definition: fNDArray.cc:58
NDArray dsum(int dim=-1) const
Definition: fNDArray.cc:626
#define NDS_BOOL_OPS(ND, S)
Definition: mx-op-defs.h:255
#define NDS_CMP_OPS(ND, S)
Definition: mx-op-defs.h:238
bool is_empty(void) const
Definition: Array.h:575
bool all_integers(void) const
Definition: fNDArray.cc:570
bool all_elements_are_int_or_inf_or_nan(void) const
Definition: fNDArray.cc:531
boolNDArray operator!(void) const
Definition: fNDArray.cc:484
void mx_inline_cummax(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:1147
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:860
const octave_base_value const Array< octave_idx_type > & ra_idx
#define SND_CMP_OPS(S, ND)
Definition: mx-op-defs.h:285
FloatNDArray diff(octave_idx_type order=1, int dim=-1) const
Definition: fNDArray.cc:686
#define BSXFUN_OP_DEF_MXLOOP(OP, ARRAY, LOOP)
Definition: bsxfun-defs.cc:222
FloatNDArray max(int dim=-1) const
Definition: fNDArray.cc:638
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:363
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:5068
static octave_idx_type nn
Definition: DASPK.cc:71
FloatNDArray cumsum(int dim=-1) const
Definition: fNDArray.cc:602
void mx_inline_real(size_t n, T *r, const std::complex< T > *x)
Definition: mx-inlines.cc:315
bool isnan(double x)
Definition: lo-mappers.cc:347
bool mx_inline_all_finite(size_t n, const T *x)
Definition: mx-inlines.cc:256
for large enough k
Definition: lu.cc:606
#define MINMAX_FCNS(T, S)
Definition: mx-op-defs.h:584
bool xis_zero(double x)
Definition: lo-utils.cc:51
FloatNDArray diag(octave_idx_type k=0) const
Definition: fNDArray.cc:809
Array< T > diag(octave_idx_type k=0) const
Get the kth super or subdiagonal.
Definition: Array.cc:2529
std::istream & operator>>(std::istream &is, FloatNDArray &a)
Definition: fNDArray.cc:836
FloatNDArray sumsq(int dim=-1) const
Definition: fNDArray.cc:632
bool any_element_is_nan(void) const
Definition: fNDArray.cc:507
float & elem(octave_idx_type n)
Definition: Array.h:482
FloatComplexNDArray ifourier(int dim=1) const
Definition: fNDArray.cc:89
Template for N-dimensional array classes with like-type math operators.
Definition: MArray.h:32
T mx_inline_sumsq(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:716
bool mx_inline_any_negative(size_t n, const T *x)
Definition: mx-inlines.cc:269
bool positive_sign(double x)
Definition: lo-mappers.h:60
bool all_elements_are_zero(void) const
Definition: fNDArray.cc:525
void mx_inline_max(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:925
subroutine cfftb(n, c, wsave)
Definition: cfftb.f:1
void err_nan_to_logical_conversion(void)
FloatComplexNDArray & insert(const NDArray &a, octave_idx_type r, octave_idx_type c)
Definition: fCNDArray.cc:751
bool mx_inline_any(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:716
FloatNDArray abs(void) const
Definition: fNDArray.cc:770
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &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 F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
FloatNDArray sum(int dim=-1) const
Definition: fNDArray.cc:620
static int fftNd(const double *, Complex *, const int, const dim_vector &)
Definition: oct-fftw.cc:925
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:322
boolNDArray any(int dim=-1) const
Definition: fNDArray.cc:590
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:1601
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:398
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
Definition: Array.h:439
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:332
static octave_idx_type compute_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions)
Definition: fNDArray.cc:802
#define NDND_BOOL_OPS(ND1, ND2)
Definition: mx-op-defs.h:349
bool any_element_is_positive(bool=false) const
Definition: fNDArray.cc:500
nd deftypefn *octave_map m
Definition: ov-struct.cc:2058
FloatNDArray(void)
Definition: fNDArray.h:42
subst_template_param< std::complex, T, double >::type mx_inline_dprod(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:715
FloatNDArray real(const FloatComplexNDArray &a)
Definition: fNDArray.cc:742
bool any_element_not_one_or_zero(void) const
Definition: fNDArray.cc:519
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:900
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
double tmp
Definition: data.cc:6300
subroutine cfftf(n, c, wsave)
Definition: cfftf.f:1
octave_value retval
Definition: data.cc:6294
#define SND_BOOL_OPS(S, ND)
Definition: mx-op-defs.h:302
F77_RET_T F77_FUNC(xstopx, XSTOPX) const
Definition: f77-fcn.c:53
bool mx_inline_any_positive(size_t n, const T *x)
Definition: mx-inlines.cc:282
FloatNDArray prod(int dim=-1) const
Definition: fNDArray.cc:608
FloatComplexNDArray fourierNd(void) const
Definition: fNDArray.cc:158
FloatNDArray imag(const FloatComplexNDArray &a)
Definition: fNDArray.cc:748
void mx_inline_cummin(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:1146
bool any_element_is_negative(bool=false) const
Definition: fNDArray.cc:493
void mx_inline_pow(size_t n, R *r, const X *x, const Y *y)
Definition: mx-inlines.cc:402
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
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:243
subst_template_param< std::complex, T, double >::type mx_inline_dsum(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:714
static int ifftNd(const Complex *, Complex *, const int, const dim_vector &)
Definition: oct-fftw.cc:971
#define BSXFUN_STDREL_DEFS_MXLOOP(ARRAY)
Definition: bsxfun-defs.cc:245
float & xelem(octave_idx_type n)
Definition: Array.h:455
bool any_element_is_inf_or_nan(void) const
Definition: fNDArray.cc:513
T mx_inline_sum(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:714
bool too_large_for_float(void) const
Definition: fNDArray.cc:576
charNDArray & insert(const charNDArray &a, octave_idx_type r, octave_idx_type c)
Definition: chNDArray.cc:164
bool test_all(F fcn) const
Definition: Array.h:815
FloatNDArray max(float d, const FloatNDArray &m)
Definition: fNDArray.cc:856
#define F77_CMPLX_ARG(x)
Definition: f77-fcn.h:339
FloatNDArray cumprod(int dim=-1) const
Definition: fNDArray.cc:596
void mx_inline_cumprod(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:821
boolNDArray isnan(void) const
Definition: fNDArray.cc:776
void octave_write_float(std::ostream &os, float d)
Definition: lo-utils.cc:411
boolNDArray all(int dim=-1) const
Definition: fNDArray.cc:584
void mx_inline_cumsum(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:820
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
octave_idx_type nint_big(double x)
Definition: lo-mappers.cc:409
bool negative_sign(double x)
Definition: lo-mappers.cc:324
FloatNDArray cummin(int dim=-1) const
Definition: fNDArray.cc:674
octave_idx_type ndims(void) const
Number of dimensions.
Definition: dim-vector.h:301
boolNDArray isinf(void) const
Definition: fNDArray.cc:782
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:200
#define BSXFUN_OP2_DEF_MXLOOP(OP, ARRAY, ARRAY1, ARRAY2, LOOP)
Definition: bsxfun-defs.cc:227
FloatNDArray & insert(const FloatNDArray &a, octave_idx_type r, octave_idx_type c)
Definition: fNDArray.cc:754
std::complex< float > FloatComplex
Definition: oct-cmplx.h:32
FloatNDArray cummax(int dim=-1) const
Definition: fNDArray.cc:662
std::ostream & operator<<(std::ostream &os, const FloatNDArray &a)
Definition: fNDArray.cc:822
bool mx_inline_all(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:716
#define BSXFUN_STDOP_DEFS_MXLOOP(ARRAY)
Definition: bsxfun-defs.cc:237
const float * fortran_vec(void) const
Definition: Array.h:584
void mx_inline_not(size_t n, bool *r, const X *x)
Definition: mx-inlines.cc:182
static void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension=0)
Definition: fNDArray.cc:794
write the output to stdout if nargout is
Definition: load-save.cc:1576
FloatNDArray min(int dim=-1) const
Definition: fNDArray.cc:650
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
T mx_inline_prod(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:715
dim_vector dv
Definition: sub2ind.cc:263
bool xis_one_or_zero(double x)
Definition: lo-utils.cc:48
NDArray dprod(int dim=-1) const
Definition: fNDArray.cc:614
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
void mx_inline_diff(const T *v, T *r, octave_idx_type n, octave_idx_type order)
Definition: mx-inlines.cc:1343
bool xis_int_or_inf_or_nan(double x)
Definition: lo-utils.cc:45
void mx_inline_min(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:924
boolNDArray isfinite(void) const
Definition: fNDArray.cc:788