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
fCNDArray.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 "fCNDArray.h"
36 #include "functor.h"
37 #include "lo-ieee.h"
38 #include "lo-mappers.h"
39 #include "mx-base.h"
40 #include "mx-op-defs.h"
41 #include "mx-fcnda-fs.h"
42 #include "oct-fftw.h"
43 #include "oct-locbuf.h"
44 
45 #include "bsxfun-defs.cc"
46 
48  : MArray<FloatComplex> (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 
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 FloatComplex *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 
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  const FloatComplex *in (fortran_vec ());
109  FloatComplex *out (retval.fortran_vec ());
110 
111  // Need to be careful here about the distance between fft's
112  for (octave_idx_type k = 0; k < nloop; k++)
113  octave_fftw::ifft (in + k * stride * n, out + k * stride * n,
114  n, howmany, stride, dist);
115 
116  return retval;
117 }
118 
121 {
122  dim_vector dv = dims ();
123  if (dv.ndims () < 2)
124  return FloatComplexNDArray ();
125 
126  dim_vector dv2 (dv(0), dv(1));
127  const FloatComplex *in = fortran_vec ();
129  FloatComplex *out = retval.fortran_vec ();
130  octave_idx_type howmany = numel () / dv(0) / dv(1);
131  octave_idx_type dist = dv(0) * dv(1);
132 
133  for (octave_idx_type i=0; i < howmany; i++)
134  octave_fftw::fftNd (in + i*dist, out + i*dist, 2, dv2);
135 
136  return retval;
137 }
138 
141 {
142  dim_vector dv = dims ();
143  if (dv.ndims () < 2)
144  return FloatComplexNDArray ();
145 
146  dim_vector dv2 (dv(0), dv(1));
147  const FloatComplex *in = fortran_vec ();
149  FloatComplex *out = retval.fortran_vec ();
150  octave_idx_type howmany = numel () / dv(0) / dv(1);
151  octave_idx_type dist = dv(0) * dv(1);
152 
153  for (octave_idx_type i=0; i < howmany; i++)
154  octave_fftw::ifftNd (in + i*dist, out + i*dist, 2, dv2);
155 
156  return retval;
157 }
158 
161 {
162  dim_vector dv = dims ();
163  int rank = dv.ndims ();
164 
165  const FloatComplex *in (fortran_vec ());
167  FloatComplex *out (retval.fortran_vec ());
168 
169  octave_fftw::fftNd (in, out, rank, dv);
170 
171  return retval;
172 }
173 
176 {
177  dim_vector dv = dims ();
178  int rank = dv.ndims ();
179 
180  const FloatComplex *in (fortran_vec ());
182  FloatComplex *out (retval.fortran_vec ());
183 
184  octave_fftw::ifftNd (in, out, rank, dv);
185 
186  return retval;
187 }
188 
189 #else
190 
191 #include "lo-fftpack-proto.h"
192 
194 FloatComplexNDArray::fourier (int dim) const
195 {
196  dim_vector dv = dims ();
197 
198  if (dim > dv.ndims () || dim < 0)
199  return FloatComplexNDArray ();
200 
202  octave_idx_type npts = dv(dim);
203  octave_idx_type nn = 4*npts+15;
204  Array<FloatComplex> wsave (dim_vector (nn, 1));
205  FloatComplex *pwsave = wsave.fortran_vec ();
206 
208 
209  octave_idx_type stride = 1;
210 
211  for (int i = 0; i < dim; i++)
212  stride *= dv(i);
213 
214  octave_idx_type howmany = numel () / npts;
215  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
216  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
217  octave_idx_type dist = (stride == 1 ? npts : 1);
218 
219  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
220 
221  for (octave_idx_type k = 0; k < nloop; k++)
222  {
223  for (octave_idx_type j = 0; j < howmany; j++)
224  {
225  octave_quit ();
226 
227  for (octave_idx_type i = 0; i < npts; i++)
228  tmp[i] = elem ((i + k*npts)*stride + j*dist);
229 
230  F77_FUNC (cfftf, CFFTF) (npts, F77_CMPLX_ARG (tmp), F77_CMPLX_ARG (pwsave));
231 
232  for (octave_idx_type i = 0; i < npts; i++)
233  retval((i + k*npts)*stride + j*dist) = tmp[i];
234  }
235  }
236 
237  return retval;
238 }
239 
241 FloatComplexNDArray::ifourier (int dim) const
242 {
243  dim_vector dv = dims ();
244 
245  if (dim > dv.ndims () || dim < 0)
246  return FloatComplexNDArray ();
247 
249  octave_idx_type npts = dv(dim);
250  octave_idx_type nn = 4*npts+15;
251  Array<FloatComplex> wsave (dim_vector (nn, 1));
252  FloatComplex *pwsave = wsave.fortran_vec ();
253 
255 
256  octave_idx_type stride = 1;
257 
258  for (int i = 0; i < dim; i++)
259  stride *= dv(i);
260 
261  octave_idx_type howmany = numel () / npts;
262  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
263  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
264  octave_idx_type dist = (stride == 1 ? npts : 1);
265 
266  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
267 
268  for (octave_idx_type k = 0; k < nloop; k++)
269  {
270  for (octave_idx_type j = 0; j < howmany; j++)
271  {
272  octave_quit ();
273 
274  for (octave_idx_type i = 0; i < npts; i++)
275  tmp[i] = elem ((i + k*npts)*stride + j*dist);
276 
277  F77_FUNC (cfftb, CFFTB) (npts, F77_CMPLX_ARG (tmp), F77_CMPLX_ARG (pwsave));
278 
279  for (octave_idx_type i = 0; i < npts; i++)
280  retval((i + k*npts)*stride + j*dist) = tmp[i] /
281  static_cast<float> (npts);
282  }
283  }
284 
285  return retval;
286 }
287 
290 {
291  dim_vector dv = dims ();
292  dim_vector dv2 (dv(0), dv(1));
293  int rank = 2;
294  FloatComplexNDArray retval (*this);
295  octave_idx_type stride = 1;
296 
297  for (int i = 0; i < rank; i++)
298  {
299  octave_idx_type npts = dv2(i);
300  octave_idx_type nn = 4*npts+15;
301  Array<FloatComplex> wsave (dim_vector (nn, 1));
302  FloatComplex *pwsave = wsave.fortran_vec ();
303  Array<FloatComplex> row (dim_vector (npts, 1));
304  FloatComplex *prow = row.fortran_vec ();
305 
306  octave_idx_type howmany = numel () / npts;
307  howmany = (stride == 1 ? howmany :
308  (howmany > stride ? stride : howmany));
309  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
310  octave_idx_type dist = (stride == 1 ? npts : 1);
311 
312  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
313 
314  for (octave_idx_type k = 0; k < nloop; k++)
315  {
316  for (octave_idx_type j = 0; j < howmany; j++)
317  {
318  octave_quit ();
319 
320  for (octave_idx_type l = 0; l < npts; l++)
321  prow[l] = retval((l + k*npts)*stride + j*dist);
322 
323  F77_FUNC (cfftf, CFFTF) (npts, F77_CMPLX_ARG (prow), F77_CMPLX_ARG (pwsave));
324 
325  for (octave_idx_type l = 0; l < npts; l++)
326  retval((l + k*npts)*stride + j*dist) = prow[l];
327  }
328  }
329 
330  stride *= dv2(i);
331  }
332 
333  return retval;
334 }
335 
338 {
339  dim_vector dv = dims ();
340  dim_vector dv2 (dv(0), dv(1));
341  int rank = 2;
342  FloatComplexNDArray retval (*this);
343  octave_idx_type stride = 1;
344 
345  for (int i = 0; i < rank; i++)
346  {
347  octave_idx_type npts = dv2(i);
348  octave_idx_type nn = 4*npts+15;
349  Array<FloatComplex> wsave (dim_vector (nn, 1));
350  FloatComplex *pwsave = wsave.fortran_vec ();
351  Array<FloatComplex> row (dim_vector (npts, 1));
352  FloatComplex *prow = row.fortran_vec ();
353 
354  octave_idx_type howmany = numel () / npts;
355  howmany = (stride == 1 ? howmany :
356  (howmany > stride ? stride : howmany));
357  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
358  octave_idx_type dist = (stride == 1 ? npts : 1);
359 
360  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
361 
362  for (octave_idx_type k = 0; k < nloop; k++)
363  {
364  for (octave_idx_type j = 0; j < howmany; j++)
365  {
366  octave_quit ();
367 
368  for (octave_idx_type l = 0; l < npts; l++)
369  prow[l] = retval((l + k*npts)*stride + j*dist);
370 
371  F77_FUNC (cfftb, CFFTB) (npts, F77_CMPLX_ARG (prow), F77_CMPLX_ARG (pwsave));
372 
373  for (octave_idx_type l = 0; l < npts; l++)
374  retval((l + k*npts)*stride + j*dist) =
375  prow[l] / static_cast<float> (npts);
376  }
377  }
378 
379  stride *= dv2(i);
380  }
381 
382  return retval;
383 }
384 
387 {
388  dim_vector dv = dims ();
389  int rank = dv.ndims ();
390  FloatComplexNDArray retval (*this);
391  octave_idx_type stride = 1;
392 
393  for (int i = 0; i < rank; i++)
394  {
395  octave_idx_type npts = dv(i);
396  octave_idx_type nn = 4*npts+15;
397  Array<FloatComplex> wsave (dim_vector (nn, 1));
398  FloatComplex *pwsave = wsave.fortran_vec ();
399  Array<FloatComplex> row (dim_vector (npts, 1));
400  FloatComplex *prow = row.fortran_vec ();
401 
402  octave_idx_type howmany = numel () / npts;
403  howmany = (stride == 1 ? howmany :
404  (howmany > stride ? stride : howmany));
405  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
406  octave_idx_type dist = (stride == 1 ? npts : 1);
407 
408  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
409 
410  for (octave_idx_type k = 0; k < nloop; k++)
411  {
412  for (octave_idx_type j = 0; j < howmany; j++)
413  {
414  octave_quit ();
415 
416  for (octave_idx_type l = 0; l < npts; l++)
417  prow[l] = retval((l + k*npts)*stride + j*dist);
418 
419  F77_FUNC (cfftf, CFFTF) (npts, F77_CMPLX_ARG (prow), F77_CMPLX_ARG (pwsave));
420 
421  for (octave_idx_type l = 0; l < npts; l++)
422  retval((l + k*npts)*stride + j*dist) = prow[l];
423  }
424  }
425 
426  stride *= dv(i);
427  }
428 
429  return retval;
430 }
431 
434 {
435  dim_vector dv = dims ();
436  int rank = dv.ndims ();
437  FloatComplexNDArray retval (*this);
438  octave_idx_type stride = 1;
439 
440  for (int i = 0; i < rank; i++)
441  {
442  octave_idx_type npts = dv(i);
443  octave_idx_type nn = 4*npts+15;
444  Array<FloatComplex> wsave (dim_vector (nn, 1));
445  FloatComplex *pwsave = wsave.fortran_vec ();
446  Array<FloatComplex> row (dim_vector (npts, 1));
447  FloatComplex *prow = row.fortran_vec ();
448 
449  octave_idx_type howmany = numel () / npts;
450  howmany = (stride == 1 ? howmany :
451  (howmany > stride ? stride : howmany));
452  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
453  octave_idx_type dist = (stride == 1 ? npts : 1);
454 
455  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
456 
457  for (octave_idx_type k = 0; k < nloop; k++)
458  {
459  for (octave_idx_type j = 0; j < howmany; j++)
460  {
461  octave_quit ();
462 
463  for (octave_idx_type l = 0; l < npts; l++)
464  prow[l] = retval((l + k*npts)*stride + j*dist);
465 
466  F77_FUNC (cfftb, CFFTB) (npts, F77_CMPLX_ARG (prow), F77_CMPLX_ARG (pwsave));
467 
468  for (octave_idx_type l = 0; l < npts; l++)
469  retval((l + k*npts)*stride + j*dist) =
470  prow[l] / static_cast<float> (npts);
471  }
472  }
473 
474  stride *= dv(i);
475  }
476 
477  return retval;
478 }
479 
480 #endif
481 
482 // unary operations
483 
486 {
487  if (any_element_is_nan ())
489 
490  return do_mx_unary_op<bool, FloatComplex> (*this, mx_inline_not);
491 }
492 
493 // FIXME: this is not quite the right thing.
494 
495 bool
497 {
498  return do_mx_check<FloatComplex> (*this, mx_inline_any_nan);
499 }
500 
501 bool
503 {
504  return ! do_mx_check<FloatComplex> (*this, mx_inline_all_finite);
505 }
506 
507 // Return true if no elements have imaginary components.
508 
509 bool
511 {
512  return do_mx_check<FloatComplex> (*this, mx_inline_all_real);
513 }
514 
515 // Return nonzero if any element of CM has a non-integer real or
516 // imaginary part. Also extract the largest and smallest (real or
517 // imaginary) values and return them in MAX_VAL and MIN_VAL.
518 
519 bool
520 FloatComplexNDArray::all_integers (float& max_val, float& min_val) const
521 {
522  octave_idx_type nel = numel ();
523 
524  if (nel > 0)
525  {
526  FloatComplex val = elem (0);
527 
528  float r_val = val.real ();
529  float i_val = val.imag ();
530 
531  max_val = r_val;
532  min_val = r_val;
533 
534  if (i_val > max_val)
535  max_val = i_val;
536 
537  if (i_val < max_val)
538  min_val = i_val;
539  }
540  else
541  return false;
542 
543  for (octave_idx_type i = 0; i < nel; i++)
544  {
545  FloatComplex val = elem (i);
546 
547  float r_val = val.real ();
548  float i_val = val.imag ();
549 
550  if (r_val > max_val)
551  max_val = r_val;
552 
553  if (i_val > max_val)
554  max_val = i_val;
555 
556  if (r_val < min_val)
557  min_val = r_val;
558 
559  if (i_val < min_val)
560  min_val = i_val;
561 
562  if (octave::math::x_nint (r_val) != r_val
563  || octave::math::x_nint (i_val) != i_val)
564  return false;
565  }
566 
567  return true;
568 }
569 
570 bool
572 {
573  return false;
574 }
575 
578 {
579  return do_mx_red_op<bool, FloatComplex> (*this, dim, mx_inline_all);
580 }
581 
584 {
585  return do_mx_red_op<bool, FloatComplex> (*this, dim, mx_inline_any);
586 }
587 
590 {
591  return do_mx_cum_op<FloatComplex, FloatComplex> (*this, dim,
593 }
594 
597 {
598  return do_mx_cum_op<FloatComplex, FloatComplex> (*this, dim,
600 }
601 
604 {
605  return do_mx_red_op<FloatComplex, FloatComplex> (*this, dim, mx_inline_prod);
606 }
607 
610 {
611  return do_mx_red_op<Complex, FloatComplex> (*this, dim, mx_inline_dprod);
612 }
613 
616 {
617  return do_mx_red_op<FloatComplex, FloatComplex> (*this, dim, mx_inline_sum);
618 }
619 
622 {
623  return do_mx_red_op<Complex, FloatComplex> (*this, dim, mx_inline_dsum);
624 }
625 
628 {
629  return do_mx_red_op<float, FloatComplex> (*this, dim, mx_inline_sumsq);
630 }
631 
634 {
635  return do_mx_diff_op<FloatComplex> (*this, dim, order, mx_inline_diff);
636 }
637 
641 {
642  if (rb.numel () > 0)
643  insert (rb, ra_idx);
644  return *this;
645 }
646 
650 {
652  if (rb.numel () > 0)
653  insert (tmp, ra_idx);
654  return *this;
655 }
656 
660 {
662  if (rb.numel () > 0)
663  retval.insert (rb, ra_idx);
664  return retval;
665 }
666 
669 
672 {
673  return do_mx_minmax_op<FloatComplex> (*this, dim, mx_inline_max);
674 }
675 
678 {
679  return do_mx_minmax_op<FloatComplex> (*this, idx_arg, dim, mx_inline_max);
680 }
681 
684 {
685  return do_mx_minmax_op<FloatComplex> (*this, dim, mx_inline_min);
686 }
687 
690 {
691  return do_mx_minmax_op<FloatComplex> (*this, idx_arg, dim, mx_inline_min);
692 }
693 
696 {
697  return do_mx_cumminmax_op<FloatComplex> (*this, dim, mx_inline_cummax);
698 }
699 
702 {
703  return do_mx_cumminmax_op<FloatComplex> (*this, idx_arg, dim,
705 }
706 
709 {
710  return do_mx_cumminmax_op<FloatComplex> (*this, dim, mx_inline_cummin);
711 }
712 
715 {
716  return do_mx_cumminmax_op<FloatComplex> (*this, idx_arg, dim,
718 }
719 
722 {
723  return do_mx_unary_map<float, FloatComplex, std::abs> (*this);
724 }
725 
728 {
729  return do_mx_unary_map<bool, FloatComplex, octave::math::isnan> (*this);
730 }
731 
734 {
735  return do_mx_unary_map<bool, FloatComplex, octave::math::isinf> (*this);
736 }
737 
740 {
741  return do_mx_unary_map<bool, FloatComplex, octave::math::finite> (*this);
742 }
743 
746 {
747  return do_mx_unary_map<FloatComplex, FloatComplex, std::conj<float> > (a);
748 }
749 
753 {
754  dim_vector a_dv = a.dims ();
755 
756  int n = a_dv.ndims ();
757 
758  if (n == dimensions.ndims ())
759  {
760  Array<octave_idx_type> a_ra_idx (dim_vector (a_dv.ndims (), 1), 0);
761 
762  a_ra_idx.elem (0) = r;
763  a_ra_idx.elem (1) = c;
764 
765  for (int i = 0; i < n; i++)
766  {
767  if (a_ra_idx(i) < 0 || (a_ra_idx(i) + a_dv(i)) > dimensions(i))
768  (*current_liboctave_error_handler)
769  ("Array<T>::insert: range error for insert");
770  }
771 
772  a_ra_idx.elem (0) = 0;
773  a_ra_idx.elem (1) = 0;
774 
775  octave_idx_type n_elt = a.numel ();
776 
777  // IS make_unique () NECESSARY HERE?
778 
779  for (octave_idx_type i = 0; i < n_elt; i++)
780  {
781  Array<octave_idx_type> ra_idx = a_ra_idx;
782 
783  ra_idx.elem (0) = a_ra_idx(0) + r;
784  ra_idx.elem (1) = a_ra_idx(1) + c;
785 
786  elem (ra_idx) = a.elem (a_ra_idx);
787 
788  increment_index (a_ra_idx, a_dv);
789  }
790  }
791  else
793  ("Array<T>::insert: invalid indexing operation");
794 
795  return *this;
796 }
797 
801 {
802  Array<FloatComplex>::insert (a, r, c);
803  return *this;
804 }
805 
809 {
810  Array<FloatComplex>::insert (a, ra_idx);
811  return *this;
812 }
813 
814 void
816  const dim_vector& dimensions,
817  int start_dimension)
818 {
819  ::increment_index (ra_idx, dimensions, start_dimension);
820 }
821 
824  const dim_vector& dimensions)
825 {
826  return ::compute_index (ra_idx, dimensions);
827 }
828 
831 {
832  return MArray<FloatComplex>::diag (k);
833 }
834 
837 {
838  return MArray<FloatComplex>::diag (m, n);
839 }
840 
841 // This contains no information on the array structure !!!
842 std::ostream&
843 operator << (std::ostream& os, const FloatComplexNDArray& a)
844 {
845  octave_idx_type nel = a.numel ();
846 
847  for (octave_idx_type i = 0; i < nel; i++)
848  {
849  os << " ";
850  octave_write_complex (os, a.elem (i));
851  os << "\n";
852  }
853  return os;
854 }
855 
856 std::istream&
858 {
859  octave_idx_type nel = a.numel ();
860 
861  if (nel > 0)
862  {
864  for (octave_idx_type i = 0; i < nel; i++)
865  {
866  tmp = octave_read_value<FloatComplex> (is);
867  if (is)
868  a.elem (i) = tmp;
869  else
870  return is;
871  }
872  }
873 
874  return is;
875 }
876 
878 
880 NDS_BOOL_OPS (FloatComplexNDArray, FloatComplex)
881 
882 SND_CMP_OPS (FloatComplex, FloatComplexNDArray)
883 SND_BOOL_OPS (FloatComplex, FloatComplexNDArray)
884 
885 NDND_CMP_OPS (FloatComplexNDArray, FloatComplexNDArray)
886 NDND_BOOL_OPS (FloatComplexNDArray, FloatComplexNDArray)
887 
888 FloatComplexNDArray& operator *= (FloatComplexNDArray& a, float s)
889 {
890  if (a.is_shared ())
891  a = a * s;
892  else
893  do_ms_inplace_op<FloatComplex, float> (a, s, mx_inline_mul2);
894  return a;
895 }
896 
898 {
899  if (a.is_shared ())
900  a = a / s;
901  else
902  do_ms_inplace_op<FloatComplex, float> (a, s, mx_inline_div2);
903  return a;
904 }
905 
908 
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
void mx_inline_mul2(size_t n, R *r, const X *x)
Definition: mx-inlines.cc:129
FloatComplexNDArray ifourier(int dim=1) const
Definition: fCNDArray.cc:89
#define NDS_BOOL_OPS(ND, S)
Definition: mx-op-defs.h:255
#define NDS_CMP_OPS(ND, S)
Definition: mx-op-defs.h:238
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
#define BSXFUN_OP_DEF_MXLOOP(OP, ARRAY, LOOP)
Definition: bsxfun-defs.cc:222
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:363
boolNDArray isinf(void) const
Definition: fCNDArray.cc:733
FloatComplexNDArray min(int dim=-1) const
Definition: fCNDArray.cc:683
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
std::istream & operator>>(std::istream &is, FloatComplexNDArray &a)
Definition: fCNDArray.cc:857
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
Definition: lo-error.c:38
FloatNDArray abs(void) const
Definition: fCNDArray.cc:721
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
FloatComplexNDArray fourier2d(void) const
Definition: fCNDArray.cc:120
void octave_write_complex(std::ostream &os, const Complex &c)
Definition: lo-utils.cc:401
bool too_large_for_float(void) const
Definition: fCNDArray.cc:571
Array< T > diag(octave_idx_type k=0) const
Get the kth super or subdiagonal.
Definition: Array.cc:2529
FloatComplex & elem(octave_idx_type n)
Definition: Array.h:482
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
FloatComplexNDArray sumsq(int dim=-1) const
Definition: fCNDArray.cc:627
ComplexNDArray dsum(int dim=-1) const
Definition: fCNDArray.cc:621
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
bool any_element_is_inf_or_nan(void) const
Definition: fCNDArray.cc:502
s
Definition: file-io.cc:2682
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 all_integers(float &max_val, float &min_val) const
Definition: fCNDArray.cc:520
bool mx_inline_any(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:716
FloatComplexNDArray ifourierNd(void) const
Definition: fCNDArray.cc:175
FloatComplexNDArray fourier(int dim=1) const
Definition: fCNDArray.cc:58
boolNDArray isfinite(void) const
Definition: fCNDArray.cc:739
static int fftNd(const double *, Complex *, const int, const dim_vector &)
Definition: oct-fftw.cc:925
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
FloatComplexNDArray cumsum(int dim=-1) const
Definition: fCNDArray.cc:596
bool any_element_is_nan(void) const
Definition: fCNDArray.cc:496
ComplexNDArray dprod(int dim=-1) const
Definition: fCNDArray.cc:609
boolNDArray all(int dim=-1) const
Definition: fCNDArray.cc:577
FloatComplexNDArray diag(octave_idx_type k=0) const
Definition: fCNDArray.cc:830
bool mx_inline_all_real(size_t n, const std::complex< T > *x)
Definition: mx-inlines.cc:295
FloatComplexNDArray cummin(int dim=-1) const
Definition: fCNDArray.cc:708
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
Definition: Array.h:439
FloatComplexNDArray cummax(int dim=-1) const
Definition: fCNDArray.cc:695
subroutine cffti(n, wsave)
Definition: cffti.f:1
std::ostream & operator<<(std::ostream &os, const FloatComplexNDArray &a)
Definition: fCNDArray.cc:843
static octave_idx_type compute_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions)
Definition: fCNDArray.cc:823
#define NDND_CMP_OPS(ND1, ND2)
Definition: mx-op-defs.h:332
#define NDND_BOOL_OPS(ND1, ND2)
Definition: mx-op-defs.h:349
static const FloatComplex FloatComplex_NaN_result(octave::numeric_limits< float >::NaN(), octave::numeric_limits< float >::NaN())
nd deftypefn *octave_map m
Definition: ov-struct.cc:2058
FloatComplexNDArray & operator/=(FloatComplexNDArray &a, float s)
Definition: fCNDArray.cc:897
subst_template_param< std::complex, T, double >::type mx_inline_dprod(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:715
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
boolNDArray any(int dim=-1) const
Definition: fCNDArray.cc:583
FloatComplexNDArray fourierNd(void) const
Definition: fCNDArray.cc:160
FloatComplexNDArray(void)
Definition: fCNDArray.h:40
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
boolNDArray operator!(void) const
Definition: fCNDArray.cc:485
F77_RET_T F77_FUNC(xstopx, XSTOPX) const
Definition: f77-fcn.c:53
void mx_inline_cummin(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:1146
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
boolNDArray isnan(void) const
Definition: fCNDArray.cc:727
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
FloatComplexNDArray max(int dim=-1) const
Definition: fCNDArray.cc:671
FloatComplex & xelem(octave_idx_type n)
Definition: Array.h:455
T mx_inline_sum(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:714
#define F77_CMPLX_ARG(x)
Definition: f77-fcn.h:339
bool all_elements_are_real(void) const
Definition: fCNDArray.cc:510
void mx_inline_cumprod(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:821
void mx_inline_cumsum(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:820
bool is_shared(void)
Definition: Array.h:588
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
octave_idx_type ndims(void) const
Number of dimensions.
Definition: dim-vector.h:301
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol NaN(Not a Number).NaN is the result of operations which do not produce a well defined 0 result.Common operations which produce a NaN are arithmetic with infinity ex($\infty-\infty $)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:200
FloatComplexNDArray cumprod(int dim=-1) const
Definition: fCNDArray.cc:589
FloatComplexNDArray sum(int dim=-1) const
Definition: fCNDArray.cc:615
std::complex< float > FloatComplex
Definition: oct-cmplx.h:32
FloatComplexNDArray ifourier2d(void) const
Definition: fCNDArray.cc:140
FloatComplexNDArray prod(int dim=-1) const
Definition: fCNDArray.cc:603
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 FloatComplex * fortran_vec(void) const
Definition: Array.h:584
void mx_inline_div2(size_t n, R *r, const X *x)
Definition: mx-inlines.cc:130
FloatComplexNDArray conj(const FloatComplexNDArray &a)
Definition: fCNDArray.cc:745
void mx_inline_not(size_t n, bool *r, const X *x)
Definition: mx-inlines.cc:182
write the output to stdout if nargout is
Definition: load-save.cc:1576
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
FloatComplexNDArray concat(NDArray &ra, FloatComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: fCNDArray.cc:658
FloatComplexNDArray diff(octave_idx_type order=1, int dim=-1) const
Definition: fCNDArray.cc:633
T mx_inline_prod(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:715
dim_vector dv
Definition: sub2ind.cc:263
T x_nint(T x)
Definition: lo-mappers.h:299
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
static void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension=0)
Definition: fCNDArray.cc:815
void mx_inline_diff(const T *v, T *r, octave_idx_type n, octave_idx_type order)
Definition: mx-inlines.cc:1343
FloatComplexNDArray concat(const FloatComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: fCNDArray.cc:639
void mx_inline_min(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:924