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
fCNDArray.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 "fCNDArray.h"
36 #include "functor.h"
37 #include "lo-ieee.h"
38 #include "lo-mappers.h"
39 #include "MArray-defs.h"
40 #include "mx-base.h"
41 #include "mx-op-defs.h"
42 #include "mx-fcnda-fs.h"
43 #include "oct-fftw.h"
44 #include "oct-locbuf.h"
45 
46 #include "bsxfun-defs.cc"
47 
49  : MArray<FloatComplex> (a.dims ())
50 {
51  octave_idx_type n = a.numel ();
52  for (octave_idx_type i = 0; i < n; i++)
53  xelem (i) = static_cast<unsigned char> (a(i));
54 }
55 
56 #if defined (HAVE_FFTW)
57 
60 {
61  dim_vector dv = dims ();
62 
63  if (dim > dv.length () || dim < 0)
64  return FloatComplexNDArray ();
65 
66  octave_idx_type stride = 1;
67  octave_idx_type n = dv(dim);
68 
69  for (int i = 0; i < dim; i++)
70  stride *= dv(i);
71 
72  octave_idx_type howmany = numel () / dv (dim);
73  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
74  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride);
75  octave_idx_type dist = (stride == 1 ? n : 1);
76 
77  const FloatComplex *in (fortran_vec ());
78  FloatComplexNDArray retval (dv);
79  FloatComplex *out (retval.fortran_vec ());
80 
81  // Need to be careful here about the distance between fft's
82  for (octave_idx_type k = 0; k < nloop; k++)
83  octave_fftw::fft (in + k * stride * n, out + k * stride * n,
84  n, howmany, stride, dist);
85 
86  return retval;
87 }
88 
91 {
92  dim_vector dv = dims ();
93 
94  if (dim > dv.length () || dim < 0)
95  return FloatComplexNDArray ();
96 
97  octave_idx_type stride = 1;
98  octave_idx_type n = dv(dim);
99 
100  for (int i = 0; i < dim; i++)
101  stride *= dv(i);
102 
103  octave_idx_type howmany = numel () / dv (dim);
104  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
105  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride);
106  octave_idx_type dist = (stride == 1 ? n : 1);
107 
108  const FloatComplex *in (fortran_vec ());
109  FloatComplexNDArray retval (dv);
110  FloatComplex *out (retval.fortran_vec ());
111 
112  // Need to be careful here about the distance between fft's
113  for (octave_idx_type k = 0; k < nloop; k++)
114  octave_fftw::ifft (in + k * stride * n, out + k * stride * n,
115  n, howmany, stride, dist);
116 
117  return retval;
118 }
119 
122 {
123  dim_vector dv = dims ();
124  if (dv.length () < 2)
125  return FloatComplexNDArray ();
126 
127  dim_vector dv2(dv(0), dv(1));
128  const FloatComplex *in = fortran_vec ();
129  FloatComplexNDArray retval (dv);
130  FloatComplex *out = retval.fortran_vec ();
131  octave_idx_type howmany = numel () / dv(0) / dv(1);
132  octave_idx_type dist = dv(0) * dv(1);
133 
134  for (octave_idx_type i=0; i < howmany; i++)
135  octave_fftw::fftNd (in + i*dist, out + i*dist, 2, dv2);
136 
137  return retval;
138 }
139 
142 {
143  dim_vector dv = dims ();
144  if (dv.length () < 2)
145  return FloatComplexNDArray ();
146 
147  dim_vector dv2(dv(0), dv(1));
148  const FloatComplex *in = fortran_vec ();
149  FloatComplexNDArray retval (dv);
150  FloatComplex *out = retval.fortran_vec ();
151  octave_idx_type howmany = numel () / dv(0) / dv(1);
152  octave_idx_type dist = dv(0) * dv(1);
153 
154  for (octave_idx_type i=0; i < howmany; i++)
155  octave_fftw::ifftNd (in + i*dist, out + i*dist, 2, dv2);
156 
157  return retval;
158 }
159 
162 {
163  dim_vector dv = dims ();
164  int rank = dv.length ();
165 
166  const FloatComplex *in (fortran_vec ());
167  FloatComplexNDArray retval (dv);
168  FloatComplex *out (retval.fortran_vec ());
169 
170  octave_fftw::fftNd (in, out, rank, dv);
171 
172  return retval;
173 }
174 
177 {
178  dim_vector dv = dims ();
179  int rank = dv.length ();
180 
181  const FloatComplex *in (fortran_vec ());
182  FloatComplexNDArray retval (dv);
183  FloatComplex *out (retval.fortran_vec ());
184 
185  octave_fftw::ifftNd (in, out, rank, dv);
186 
187  return retval;
188 }
189 
190 #else
191 
192 extern "C"
193 {
194  F77_RET_T
195  F77_FUNC (cffti, CFFTI) (const octave_idx_type&, FloatComplex*);
196 
197  F77_RET_T
198  F77_FUNC (cfftf, CFFTF) (const octave_idx_type&, FloatComplex*,
199  FloatComplex*);
200 
201  F77_RET_T
202  F77_FUNC (cfftb, CFFTB) (const octave_idx_type&, FloatComplex*,
203  FloatComplex*);
204 }
205 
207 FloatComplexNDArray::fourier (int dim) const
208 {
209  dim_vector dv = dims ();
210 
211  if (dim > dv.length () || dim < 0)
212  return FloatComplexNDArray ();
213 
214  FloatComplexNDArray retval (dv);
215  octave_idx_type npts = dv(dim);
216  octave_idx_type nn = 4*npts+15;
217  Array<FloatComplex> wsave (dim_vector (nn, 1));
218  FloatComplex *pwsave = wsave.fortran_vec ();
219 
220  OCTAVE_LOCAL_BUFFER (FloatComplex, tmp, npts);
221 
222  octave_idx_type stride = 1;
223 
224  for (int i = 0; i < dim; i++)
225  stride *= dv(i);
226 
227  octave_idx_type howmany = numel () / npts;
228  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
229  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
230  octave_idx_type dist = (stride == 1 ? npts : 1);
231 
232  F77_FUNC (cffti, CFFTI) (npts, pwsave);
233 
234  for (octave_idx_type k = 0; k < nloop; k++)
235  {
236  for (octave_idx_type j = 0; j < howmany; j++)
237  {
238  octave_quit ();
239 
240  for (octave_idx_type i = 0; i < npts; i++)
241  tmp[i] = elem ((i + k*npts)*stride + j*dist);
242 
243  F77_FUNC (cfftf, CFFTF) (npts, tmp, pwsave);
244 
245  for (octave_idx_type i = 0; i < npts; i++)
246  retval((i + k*npts)*stride + j*dist) = tmp[i];
247  }
248  }
249 
250  return retval;
251 }
252 
254 FloatComplexNDArray::ifourier (int dim) const
255 {
256  dim_vector dv = dims ();
257 
258  if (dim > dv.length () || dim < 0)
259  return FloatComplexNDArray ();
260 
261  FloatComplexNDArray retval (dv);
262  octave_idx_type npts = dv(dim);
263  octave_idx_type nn = 4*npts+15;
264  Array<FloatComplex> wsave (dim_vector (nn, 1));
265  FloatComplex *pwsave = wsave.fortran_vec ();
266 
267  OCTAVE_LOCAL_BUFFER (FloatComplex, tmp, npts);
268 
269  octave_idx_type stride = 1;
270 
271  for (int i = 0; i < dim; i++)
272  stride *= dv(i);
273 
274  octave_idx_type howmany = numel () / npts;
275  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
276  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
277  octave_idx_type dist = (stride == 1 ? npts : 1);
278 
279  F77_FUNC (cffti, CFFTI) (npts, pwsave);
280 
281  for (octave_idx_type k = 0; k < nloop; k++)
282  {
283  for (octave_idx_type j = 0; j < howmany; j++)
284  {
285  octave_quit ();
286 
287  for (octave_idx_type i = 0; i < npts; i++)
288  tmp[i] = elem ((i + k*npts)*stride + j*dist);
289 
290  F77_FUNC (cfftb, CFFTB) (npts, tmp, pwsave);
291 
292  for (octave_idx_type i = 0; i < npts; i++)
293  retval((i + k*npts)*stride + j*dist) = tmp[i] /
294  static_cast<float> (npts);
295  }
296  }
297 
298  return retval;
299 }
300 
303 {
304  dim_vector dv = dims ();
305  dim_vector dv2 (dv(0), dv(1));
306  int rank = 2;
307  FloatComplexNDArray retval (*this);
308  octave_idx_type stride = 1;
309 
310  for (int i = 0; i < rank; i++)
311  {
312  octave_idx_type npts = dv2(i);
313  octave_idx_type nn = 4*npts+15;
314  Array<FloatComplex> wsave (dim_vector (nn, 1));
315  FloatComplex *pwsave = wsave.fortran_vec ();
316  Array<FloatComplex> row (dim_vector (npts, 1));
317  FloatComplex *prow = row.fortran_vec ();
318 
319  octave_idx_type howmany = numel () / npts;
320  howmany = (stride == 1 ? howmany :
321  (howmany > stride ? stride : howmany));
322  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
323  octave_idx_type dist = (stride == 1 ? npts : 1);
324 
325  F77_FUNC (cffti, CFFTI) (npts, pwsave);
326 
327  for (octave_idx_type k = 0; k < nloop; k++)
328  {
329  for (octave_idx_type j = 0; j < howmany; j++)
330  {
331  octave_quit ();
332 
333  for (octave_idx_type l = 0; l < npts; l++)
334  prow[l] = retval((l + k*npts)*stride + j*dist);
335 
336  F77_FUNC (cfftf, CFFTF) (npts, prow, pwsave);
337 
338  for (octave_idx_type l = 0; l < npts; l++)
339  retval((l + k*npts)*stride + j*dist) = prow[l];
340  }
341  }
342 
343  stride *= dv2(i);
344  }
345 
346  return retval;
347 }
348 
351 {
352  dim_vector dv = dims ();
353  dim_vector dv2 (dv(0), dv(1));
354  int rank = 2;
355  FloatComplexNDArray retval (*this);
356  octave_idx_type stride = 1;
357 
358  for (int i = 0; i < rank; i++)
359  {
360  octave_idx_type npts = dv2(i);
361  octave_idx_type nn = 4*npts+15;
362  Array<FloatComplex> wsave (dim_vector (nn, 1));
363  FloatComplex *pwsave = wsave.fortran_vec ();
364  Array<FloatComplex> row (dim_vector (npts, 1));
365  FloatComplex *prow = row.fortran_vec ();
366 
367  octave_idx_type howmany = numel () / npts;
368  howmany = (stride == 1 ? howmany :
369  (howmany > stride ? stride : howmany));
370  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
371  octave_idx_type dist = (stride == 1 ? npts : 1);
372 
373  F77_FUNC (cffti, CFFTI) (npts, pwsave);
374 
375  for (octave_idx_type k = 0; k < nloop; k++)
376  {
377  for (octave_idx_type j = 0; j < howmany; j++)
378  {
379  octave_quit ();
380 
381  for (octave_idx_type l = 0; l < npts; l++)
382  prow[l] = retval((l + k*npts)*stride + j*dist);
383 
384  F77_FUNC (cfftb, CFFTB) (npts, prow, pwsave);
385 
386  for (octave_idx_type l = 0; l < npts; l++)
387  retval((l + k*npts)*stride + j*dist) =
388  prow[l] / static_cast<float> (npts);
389  }
390  }
391 
392  stride *= dv2(i);
393  }
394 
395  return retval;
396 }
397 
400 {
401  dim_vector dv = dims ();
402  int rank = dv.length ();
403  FloatComplexNDArray retval (*this);
404  octave_idx_type stride = 1;
405 
406  for (int i = 0; i < rank; i++)
407  {
408  octave_idx_type npts = dv(i);
409  octave_idx_type nn = 4*npts+15;
410  Array<FloatComplex> wsave (dim_vector (nn, 1));
411  FloatComplex *pwsave = wsave.fortran_vec ();
412  Array<FloatComplex> row (dim_vector (npts, 1));
413  FloatComplex *prow = row.fortran_vec ();
414 
415  octave_idx_type howmany = numel () / npts;
416  howmany = (stride == 1 ? howmany :
417  (howmany > stride ? stride : howmany));
418  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
419  octave_idx_type dist = (stride == 1 ? npts : 1);
420 
421  F77_FUNC (cffti, CFFTI) (npts, pwsave);
422 
423  for (octave_idx_type k = 0; k < nloop; k++)
424  {
425  for (octave_idx_type j = 0; j < howmany; j++)
426  {
427  octave_quit ();
428 
429  for (octave_idx_type l = 0; l < npts; l++)
430  prow[l] = retval((l + k*npts)*stride + j*dist);
431 
432  F77_FUNC (cfftf, CFFTF) (npts, prow, pwsave);
433 
434  for (octave_idx_type l = 0; l < npts; l++)
435  retval((l + k*npts)*stride + j*dist) = prow[l];
436  }
437  }
438 
439  stride *= dv(i);
440  }
441 
442  return retval;
443 }
444 
447 {
448  dim_vector dv = dims ();
449  int rank = dv.length ();
450  FloatComplexNDArray retval (*this);
451  octave_idx_type stride = 1;
452 
453  for (int i = 0; i < rank; i++)
454  {
455  octave_idx_type npts = dv(i);
456  octave_idx_type nn = 4*npts+15;
457  Array<FloatComplex> wsave (dim_vector (nn, 1));
458  FloatComplex *pwsave = wsave.fortran_vec ();
459  Array<FloatComplex> row (dim_vector (npts, 1));
460  FloatComplex *prow = row.fortran_vec ();
461 
462  octave_idx_type howmany = numel () / npts;
463  howmany = (stride == 1 ? howmany :
464  (howmany > stride ? stride : howmany));
465  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
466  octave_idx_type dist = (stride == 1 ? npts : 1);
467 
468  F77_FUNC (cffti, CFFTI) (npts, pwsave);
469 
470  for (octave_idx_type k = 0; k < nloop; k++)
471  {
472  for (octave_idx_type j = 0; j < howmany; j++)
473  {
474  octave_quit ();
475 
476  for (octave_idx_type l = 0; l < npts; l++)
477  prow[l] = retval((l + k*npts)*stride + j*dist);
478 
479  F77_FUNC (cfftb, CFFTB) (npts, prow, pwsave);
480 
481  for (octave_idx_type l = 0; l < npts; l++)
482  retval((l + k*npts)*stride + j*dist) =
483  prow[l] / static_cast<float> (npts);
484  }
485  }
486 
487  stride *= dv(i);
488  }
489 
490  return retval;
491 }
492 
493 #endif
494 
495 // unary operations
496 
499 {
500  if (any_element_is_nan ())
502 
503  return do_mx_unary_op<bool, FloatComplex> (*this, mx_inline_not);
504 }
505 
506 // FIXME: this is not quite the right thing.
507 
508 bool
510 {
511  return do_mx_check<FloatComplex> (*this, mx_inline_any_nan);
512 }
513 
514 bool
516 {
517  return ! do_mx_check<FloatComplex> (*this, mx_inline_all_finite);
518 }
519 
520 // Return true if no elements have imaginary components.
521 
522 bool
524 {
525  return do_mx_check<FloatComplex> (*this, mx_inline_all_real);
526 }
527 
528 // Return nonzero if any element of CM has a non-integer real or
529 // imaginary part. Also extract the largest and smallest (real or
530 // imaginary) values and return them in MAX_VAL and MIN_VAL.
531 
532 bool
533 FloatComplexNDArray::all_integers (float& max_val, float& min_val) const
534 {
535  octave_idx_type nel = nelem ();
536 
537  if (nel > 0)
538  {
539  FloatComplex val = elem (0);
540 
541  float r_val = std::real (val);
542  float i_val = std::imag (val);
543 
544  max_val = r_val;
545  min_val = r_val;
546 
547  if (i_val > max_val)
548  max_val = i_val;
549 
550  if (i_val < max_val)
551  min_val = i_val;
552  }
553  else
554  return false;
555 
556  for (octave_idx_type i = 0; i < nel; i++)
557  {
558  FloatComplex val = elem (i);
559 
560  float r_val = std::real (val);
561  float i_val = std::imag (val);
562 
563  if (r_val > max_val)
564  max_val = r_val;
565 
566  if (i_val > max_val)
567  max_val = i_val;
568 
569  if (r_val < min_val)
570  min_val = r_val;
571 
572  if (i_val < min_val)
573  min_val = i_val;
574 
575  if (D_NINT (r_val) != r_val || D_NINT (i_val) != i_val)
576  return false;
577  }
578 
579  return true;
580 }
581 
582 bool
584 {
585  return false;
586 }
587 
590 {
591  return do_mx_red_op<bool, FloatComplex> (*this, dim, mx_inline_all);
592 }
593 
596 {
597  return do_mx_red_op<bool, FloatComplex> (*this, dim, mx_inline_any);
598 }
599 
602 {
603  return do_mx_cum_op<FloatComplex, FloatComplex> (*this, dim,
605 }
606 
609 {
610  return do_mx_cum_op<FloatComplex, FloatComplex> (*this, dim,
612 }
613 
616 {
617  return do_mx_red_op<FloatComplex, FloatComplex> (*this, dim, mx_inline_prod);
618 }
619 
622 {
623  return do_mx_red_op<Complex, FloatComplex> (*this, dim, mx_inline_dprod);
624 }
625 
628 {
629  return do_mx_red_op<FloatComplex, FloatComplex> (*this, dim, mx_inline_sum);
630 }
631 
634 {
635  return do_mx_red_op<Complex, FloatComplex> (*this, dim, mx_inline_dsum);
636 }
637 
640 {
641  return do_mx_red_op<float, FloatComplex> (*this, dim, mx_inline_sumsq);
642 }
643 
646 {
647  return do_mx_diff_op<FloatComplex> (*this, dim, order, mx_inline_diff);
648 }
649 
653 {
654  if (rb.numel () > 0)
655  insert (rb, ra_idx);
656  return *this;
657 }
658 
662 {
663  FloatComplexNDArray tmp (rb);
664  if (rb.numel () > 0)
665  insert (tmp, ra_idx);
666  return *this;
667 }
668 
672 {
673  FloatComplexNDArray retval (ra);
674  if (rb.numel () > 0)
675  retval.insert (rb, ra_idx);
676  return retval;
677 }
678 
681 
684 {
685  return do_mx_minmax_op<FloatComplex> (*this, dim, mx_inline_max);
686 }
687 
690 {
691  return do_mx_minmax_op<FloatComplex> (*this, idx_arg, dim, mx_inline_max);
692 }
693 
696 {
697  return do_mx_minmax_op<FloatComplex> (*this, dim, mx_inline_min);
698 }
699 
702 {
703  return do_mx_minmax_op<FloatComplex> (*this, idx_arg, dim, mx_inline_min);
704 }
705 
708 {
709  return do_mx_cumminmax_op<FloatComplex> (*this, dim, mx_inline_cummax);
710 }
711 
714 {
715  return do_mx_cumminmax_op<FloatComplex> (*this, idx_arg, dim,
717 }
718 
721 {
722  return do_mx_cumminmax_op<FloatComplex> (*this, dim, mx_inline_cummin);
723 }
724 
727 {
728  return do_mx_cumminmax_op<FloatComplex> (*this, idx_arg, dim,
730 }
731 
734 {
735  return do_mx_unary_map<float, FloatComplex, std::abs> (*this);
736 }
737 
740 {
741  return do_mx_unary_map<bool, FloatComplex, xisnan> (*this);
742 }
743 
746 {
747  return do_mx_unary_map<bool, FloatComplex, xisinf> (*this);
748 }
749 
752 {
753  return do_mx_unary_map<bool, FloatComplex, xfinite> (*this);
754 }
755 
758 {
759  return do_mx_unary_map<FloatComplex, FloatComplex, std::conj<float> > (a);
760 }
761 
765 {
766  dim_vector a_dv = a.dims ();
767 
768  int n = a_dv.length ();
769 
770  if (n == dimensions.length ())
771  {
772  Array<octave_idx_type> a_ra_idx (dim_vector (a_dv.length (), 1), 0);
773 
774  a_ra_idx.elem (0) = r;
775  a_ra_idx.elem (1) = c;
776 
777  for (int i = 0; i < n; i++)
778  {
779  if (a_ra_idx (i) < 0 || (a_ra_idx (i) + a_dv (i)) > dimensions (i))
780  {
781  (*current_liboctave_error_handler)
782  ("Array<T>::insert: range error for insert");
783  return *this;
784  }
785  }
786 
787  a_ra_idx.elem (0) = 0;
788  a_ra_idx.elem (1) = 0;
789 
790  octave_idx_type n_elt = a.numel ();
791 
792  // IS make_unique () NECCESSARY HERE??
793 
794  for (octave_idx_type i = 0; i < n_elt; i++)
795  {
796  Array<octave_idx_type> ra_idx = a_ra_idx;
797 
798  ra_idx.elem (0) = a_ra_idx (0) + r;
799  ra_idx.elem (1) = a_ra_idx (1) + c;
800 
801  elem (ra_idx) = a.elem (a_ra_idx);
802 
803  increment_index (a_ra_idx, a_dv);
804  }
805  }
806  else
808  ("Array<T>::insert: invalid indexing operation");
809 
810  return *this;
811 }
812 
816 {
817  Array<FloatComplex>::insert (a, r, c);
818  return *this;
819 }
820 
824 {
825  Array<FloatComplex>::insert (a, ra_idx);
826  return *this;
827 }
828 
829 void
831  const dim_vector& dimensions,
832  int start_dimension)
833 {
834  ::increment_index (ra_idx, dimensions, start_dimension);
835 }
836 
839  const dim_vector& dimensions)
840 {
841  return ::compute_index (ra_idx, dimensions);
842 }
843 
846 {
847  return MArray<FloatComplex>::diag (k);
848 }
849 
852 {
853  return MArray<FloatComplex>::diag (m, n);
854 }
855 
856 // This contains no information on the array structure !!!
857 std::ostream&
858 operator << (std::ostream& os, const FloatComplexNDArray& a)
859 {
860  octave_idx_type nel = a.nelem ();
861 
862  for (octave_idx_type i = 0; i < nel; i++)
863  {
864  os << " ";
865  octave_write_complex (os, a.elem (i));
866  os << "\n";
867  }
868  return os;
869 }
870 
871 std::istream&
872 operator >> (std::istream& is, FloatComplexNDArray& a)
873 {
874  octave_idx_type nel = a.nelem ();
875 
876  if (nel > 0)
877  {
878  FloatComplex tmp;
879  for (octave_idx_type i = 0; i < nel; i++)
880  {
881  tmp = octave_read_value<FloatComplex> (is);
882  if (is)
883  a.elem (i) = tmp;
884  else
885  goto done;
886  }
887  }
888 
889 done:
890 
891  return is;
892 }
893 
895 
897 NDS_BOOL_OPS (FloatComplexNDArray, FloatComplex)
898 
899 SND_CMP_OPS (FloatComplex, FloatComplexNDArray)
900 SND_BOOL_OPS (FloatComplex, FloatComplexNDArray)
901 
902 NDND_CMP_OPS (FloatComplexNDArray, FloatComplexNDArray)
903 NDND_BOOL_OPS (FloatComplexNDArray, FloatComplexNDArray)
904 
905 FloatComplexNDArray& operator *= (FloatComplexNDArray& a, float s)
906 {
907  if (a.is_shared ())
908  a = a * s;
909  else
910  do_ms_inplace_op<FloatComplex, float> (a, s, mx_inline_mul2);
911  return a;
912 }
913 
915 {
916  if (a.is_shared ())
917  a = a / s;
918  else
919  do_ms_inplace_op<FloatComplex, float> (a, s, mx_inline_div2);
920  return a;
921 }
922 
925 
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
void mx_inline_mul2(size_t n, R *r, const X *x)
Definition: mx-inlines.cc:97
FloatComplexNDArray ifourier(int dim=1) const
Definition: fCNDArray.cc:90
#define NDS_BOOL_OPS(ND, S)
Definition: mx-op-defs.h:253
#define NDS_CMP_OPS(ND, S)
Definition: mx-op-defs.h:236
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
#define BSXFUN_OP_DEF_MXLOOP(OP, ARRAY, LOOP)
Definition: bsxfun-defs.cc:221
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:275
boolNDArray isinf(void) const
Definition: fCNDArray.cc:745
FloatComplexNDArray min(int dim=-1) const
Definition: fCNDArray.cc:695
static octave_idx_type nn
Definition: DASPK.cc:71
std::istream & operator>>(std::istream &is, FloatComplexNDArray &a)
Definition: fCNDArray.cc:872
FloatNDArray abs(void) const
Definition: fCNDArray.cc:733
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
FloatComplexNDArray fourier2d(void) const
Definition: fCNDArray.cc:121
void octave_write_complex(std::ostream &os, const Complex &c)
Definition: lo-utils.cc:399
bool too_large_for_float(void) const
Definition: fCNDArray.cc:583
Array< T > diag(octave_idx_type k=0) const
Get the kth super or subdiagonal.
Definition: Array.cc:2526
FloatComplex & elem(octave_idx_type n)
Definition: Array.h:380
Definition: MArray.h:36
#define octave_Float_NaN
Definition: lo-ieee.h:46
T mx_inline_sumsq(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:524
FloatComplexNDArray sumsq(int dim=-1) const
Definition: fCNDArray.cc:639
ComplexNDArray dsum(int dim=-1) const
Definition: fCNDArray.cc:633
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
bool any_element_is_inf_or_nan(void) const
Definition: fCNDArray.cc:515
FloatComplexNDArray & insert(const NDArray &a, octave_idx_type r, octave_idx_type c)
Definition: fCNDArray.cc:763
bool all_integers(float &max_val, float &min_val) const
Definition: fCNDArray.cc:533
bool mx_inline_any(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:524
FloatComplexNDArray ifourierNd(void) const
Definition: fCNDArray.cc:176
FloatComplexNDArray fourier(int dim=1) const
Definition: fCNDArray.cc:59
boolNDArray isfinite(void) const
Definition: fCNDArray.cc:751
static int fftNd(const double *, Complex *, const int, const dim_vector &)
Definition: oct-fftw.cc:889
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
FloatComplexNDArray cumsum(int dim=-1) const
Definition: fCNDArray.cc:608
bool any_element_is_nan(void) const
Definition: fCNDArray.cc:509
ComplexNDArray dprod(int dim=-1) const
Definition: fCNDArray.cc:621
boolNDArray all(int dim=-1) const
Definition: fCNDArray.cc:589
FloatComplexNDArray diag(octave_idx_type k=0) const
Definition: fCNDArray.cc:845
bool mx_inline_all_real(size_t n, const std::complex< T > *x)
Definition: mx-inlines.cc:234
FloatComplexNDArray cummin(int dim=-1) const
Definition: fCNDArray.cc:720
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
Definition: Array.h:337
FloatComplexNDArray cummax(int dim=-1) const
Definition: fCNDArray.cc:707
subroutine cffti(n, wsave)
Definition: cffti.f:1
liboctave_error_handler current_liboctave_error_handler
Definition: lo-error.c:38
std::ostream & operator<<(std::ostream &os, const FloatComplexNDArray &a)
Definition: fCNDArray.cc:858
static const FloatComplex FloatComplex_NaN_result((lo_ieee_float_nan_value()),(lo_ieee_float_nan_value()))
static octave_idx_type compute_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions)
Definition: fCNDArray.cc:838
#define NDND_CMP_OPS(ND1, ND2)
Definition: mx-op-defs.h:330
#define NDND_BOOL_OPS(ND1, ND2)
Definition: mx-op-defs.h:347
FloatComplexNDArray & operator/=(FloatComplexNDArray &a, float s)
Definition: fCNDArray.cc:914
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)
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
boolNDArray any(int dim=-1) const
Definition: fCNDArray.cc:595
FloatComplexNDArray fourierNd(void) const
Definition: fCNDArray.cc:161
FloatComplexNDArray(void)
Definition: fCNDArray.h:38
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
boolNDArray operator!(void) const
Definition: fCNDArray.cc:498
#define F77_RET_T
Definition: f77-fcn.h:264
void mx_inline_cummin(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:893
OCTAVE_API double D_NINT(double x)
Definition: lo-mappers.h:240
void mx_inline_pow(size_t n, R *r, const X *x, const Y *y)
Definition: mx-inlines.cc:311
boolNDArray isnan(void) const
Definition: fCNDArray.cc:739
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
FloatComplexNDArray max(int dim=-1) const
Definition: fCNDArray.cc:683
FloatComplex & xelem(octave_idx_type n)
Definition: Array.h:353
T mx_inline_sum(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:522
bool all_elements_are_real(void) const
Definition: fCNDArray.cc:523
void mx_inline_cumprod(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:628
void mx_inline_cumsum(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:627
bool is_shared(void)
Definition: Array.h:485
F77_RET_T F77_FUNC(zgemv, ZGEMV)(F77_CONST_CHAR_ARG_DECL
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:197
FloatComplexNDArray cumprod(int dim=-1) const
Definition: fCNDArray.cc:601
FloatComplexNDArray sum(int dim=-1) const
Definition: fCNDArray.cc:627
ColumnVector imag(const ComplexColumnVector &a)
Definition: dColVector.cc:162
std::complex< float > FloatComplex
Definition: oct-cmplx.h:30
FloatComplexNDArray ifourier2d(void) const
Definition: fCNDArray.cc:141
FloatComplexNDArray prod(int dim=-1) const
Definition: fCNDArray.cc:615
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 FloatComplex * fortran_vec(void) const
Definition: Array.h:481
void mx_inline_div2(size_t n, R *r, const X *x)
Definition: mx-inlines.cc:98
FloatComplexNDArray conj(const FloatComplexNDArray &a)
Definition: fCNDArray.cc:757
void mx_inline_not(size_t n, bool *r, const X *x)
Definition: mx-inlines.cc:126
ColumnVector real(const ComplexColumnVector &a)
Definition: dColVector.cc:156
FloatComplexNDArray concat(NDArray &ra, FloatComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: fCNDArray.cc:670
FloatComplexNDArray diff(octave_idx_type order=1, int dim=-1) const
Definition: fCNDArray.cc:645
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
static void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension=0)
Definition: fCNDArray.cc:830
void mx_inline_diff(const T *v, T *r, octave_idx_type n, octave_idx_type order)
Definition: mx-inlines.cc:1036
FloatComplexNDArray concat(const FloatComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: fCNDArray.cc:651
void mx_inline_min(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:718