GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
fCNDArray.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 <complex>
29 #include <iostream>
30 
31 #include "Array-util.h"
32 #include "f77-fcn.h"
33 #include "fCNDArray.h"
34 #include "functor.h"
35 #include "lo-ieee.h"
36 #include "lo-mappers.h"
37 #include "mx-base.h"
38 #include "mx-op-defs.h"
39 #include "mx-fcnda-fs.h"
40 #include "oct-fftw.h"
41 #include "oct-locbuf.h"
42 
43 #include "bsxfun-defs.cc"
44 
46  : MArray<FloatComplex> (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 
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 FloatComplex *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 
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  const FloatComplex *in (fortran_vec ());
107  FloatComplex *out (retval.fortran_vec ());
108 
109  // Need to be careful here about the distance between fft's
110  for (octave_idx_type k = 0; k < nloop; k++)
111  octave::fftw::ifft (in + k * stride * n, out + k * stride * n,
112  n, howmany, stride, dist);
113 
114  return retval;
115 }
116 
119 {
120  dim_vector dv = dims ();
121  if (dv.ndims () < 2)
122  return FloatComplexNDArray ();
123 
124  dim_vector dv2 (dv(0), dv(1));
125  const FloatComplex *in = fortran_vec ();
127  FloatComplex *out = retval.fortran_vec ();
128  octave_idx_type howmany = numel () / dv(0) / dv(1);
129  octave_idx_type dist = dv(0) * dv(1);
130 
131  for (octave_idx_type i=0; i < howmany; i++)
132  octave::fftw::fftNd (in + i*dist, out + i*dist, 2, dv2);
133 
134  return retval;
135 }
136 
139 {
140  dim_vector dv = dims ();
141  if (dv.ndims () < 2)
142  return FloatComplexNDArray ();
143 
144  dim_vector dv2 (dv(0), dv(1));
145  const FloatComplex *in = fortran_vec ();
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 (in + 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 FloatComplex *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  const FloatComplex *in (fortran_vec ());
180  FloatComplex *out (retval.fortran_vec ());
181 
182  octave::fftw::ifftNd (in, out, rank, dv);
183 
184  return retval;
185 }
186 
187 #else
188 
189 #include "lo-fftpack-proto.h"
190 
192 FloatComplexNDArray::fourier (int dim) const
193 {
194  dim_vector dv = dims ();
195 
196  if (dim > dv.ndims () || dim < 0)
197  return FloatComplexNDArray ();
198 
200  octave_idx_type npts = dv(dim);
201  octave_idx_type nn = 4*npts+15;
202  Array<FloatComplex> wsave (dim_vector (nn, 1));
203  FloatComplex *pwsave = wsave.fortran_vec ();
204 
206 
207  octave_idx_type stride = 1;
208 
209  for (int i = 0; i < dim; i++)
210  stride *= dv(i);
211 
212  octave_idx_type howmany = numel () / npts;
213  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
214  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
215  octave_idx_type dist = (stride == 1 ? npts : 1);
216 
217  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
218 
219  for (octave_idx_type k = 0; k < nloop; k++)
220  {
221  for (octave_idx_type j = 0; j < howmany; j++)
222  {
223  octave_quit ();
224 
225  for (octave_idx_type i = 0; i < npts; i++)
226  tmp[i] = elem ((i + k*npts)*stride + j*dist);
227 
228  F77_FUNC (cfftf, CFFTF) (npts, F77_CMPLX_ARG (tmp), F77_CMPLX_ARG (pwsave));
229 
230  for (octave_idx_type i = 0; i < npts; i++)
231  retval((i + k*npts)*stride + j*dist) = tmp[i];
232  }
233  }
234 
235  return retval;
236 }
237 
239 FloatComplexNDArray::ifourier (int dim) const
240 {
241  dim_vector dv = dims ();
242 
243  if (dim > dv.ndims () || dim < 0)
244  return FloatComplexNDArray ();
245 
247  octave_idx_type npts = dv(dim);
248  octave_idx_type nn = 4*npts+15;
249  Array<FloatComplex> wsave (dim_vector (nn, 1));
250  FloatComplex *pwsave = wsave.fortran_vec ();
251 
253 
254  octave_idx_type stride = 1;
255 
256  for (int i = 0; i < dim; i++)
257  stride *= dv(i);
258 
259  octave_idx_type howmany = numel () / npts;
260  howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
261  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
262  octave_idx_type dist = (stride == 1 ? npts : 1);
263 
264  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
265 
266  for (octave_idx_type k = 0; k < nloop; k++)
267  {
268  for (octave_idx_type j = 0; j < howmany; j++)
269  {
270  octave_quit ();
271 
272  for (octave_idx_type i = 0; i < npts; i++)
273  tmp[i] = elem ((i + k*npts)*stride + j*dist);
274 
275  F77_FUNC (cfftb, CFFTB) (npts, F77_CMPLX_ARG (tmp), F77_CMPLX_ARG (pwsave));
276 
277  for (octave_idx_type i = 0; i < npts; i++)
278  retval((i + k*npts)*stride + j*dist) = tmp[i] /
279  static_cast<float> (npts);
280  }
281  }
282 
283  return retval;
284 }
285 
288 {
289  dim_vector dv = dims ();
290  dim_vector dv2 (dv(0), dv(1));
291  int rank = 2;
292  FloatComplexNDArray retval (*this);
293  octave_idx_type stride = 1;
294 
295  for (int i = 0; i < rank; i++)
296  {
297  octave_idx_type npts = dv2(i);
298  octave_idx_type nn = 4*npts+15;
299  Array<FloatComplex> wsave (dim_vector (nn, 1));
300  FloatComplex *pwsave = wsave.fortran_vec ();
301  Array<FloatComplex> row (dim_vector (npts, 1));
302  FloatComplex *prow = row.fortran_vec ();
303 
304  octave_idx_type howmany = numel () / npts;
305  howmany = (stride == 1 ? howmany
306  : (howmany > stride ? stride : howmany));
307  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
308  octave_idx_type dist = (stride == 1 ? npts : 1);
309 
310  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
311 
312  for (octave_idx_type k = 0; k < nloop; k++)
313  {
314  for (octave_idx_type j = 0; j < howmany; j++)
315  {
316  octave_quit ();
317 
318  for (octave_idx_type l = 0; l < npts; l++)
319  prow[l] = retval((l + k*npts)*stride + j*dist);
320 
321  F77_FUNC (cfftf, CFFTF) (npts, F77_CMPLX_ARG (prow), F77_CMPLX_ARG (pwsave));
322 
323  for (octave_idx_type l = 0; l < npts; l++)
324  retval((l + k*npts)*stride + j*dist) = prow[l];
325  }
326  }
327 
328  stride *= dv2(i);
329  }
330 
331  return retval;
332 }
333 
336 {
337  dim_vector dv = dims ();
338  dim_vector dv2 (dv(0), dv(1));
339  int rank = 2;
340  FloatComplexNDArray retval (*this);
341  octave_idx_type stride = 1;
342 
343  for (int i = 0; i < rank; i++)
344  {
345  octave_idx_type npts = dv2(i);
346  octave_idx_type nn = 4*npts+15;
347  Array<FloatComplex> wsave (dim_vector (nn, 1));
348  FloatComplex *pwsave = wsave.fortran_vec ();
349  Array<FloatComplex> row (dim_vector (npts, 1));
350  FloatComplex *prow = row.fortran_vec ();
351 
352  octave_idx_type howmany = numel () / npts;
353  howmany = (stride == 1 ? howmany
354  : (howmany > stride ? stride : howmany));
355  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
356  octave_idx_type dist = (stride == 1 ? npts : 1);
357 
358  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
359 
360  for (octave_idx_type k = 0; k < nloop; k++)
361  {
362  for (octave_idx_type j = 0; j < howmany; j++)
363  {
364  octave_quit ();
365 
366  for (octave_idx_type l = 0; l < npts; l++)
367  prow[l] = retval((l + k*npts)*stride + j*dist);
368 
369  F77_FUNC (cfftb, CFFTB) (npts, F77_CMPLX_ARG (prow), F77_CMPLX_ARG (pwsave));
370 
371  for (octave_idx_type l = 0; l < npts; l++)
372  retval((l + k*npts)*stride + j*dist) =
373  prow[l] / static_cast<float> (npts);
374  }
375  }
376 
377  stride *= dv2(i);
378  }
379 
380  return retval;
381 }
382 
385 {
386  dim_vector dv = dims ();
387  int rank = dv.ndims ();
388  FloatComplexNDArray retval (*this);
389  octave_idx_type stride = 1;
390 
391  for (int i = 0; i < rank; i++)
392  {
393  octave_idx_type npts = dv(i);
394  octave_idx_type nn = 4*npts+15;
395  Array<FloatComplex> wsave (dim_vector (nn, 1));
396  FloatComplex *pwsave = wsave.fortran_vec ();
397  Array<FloatComplex> row (dim_vector (npts, 1));
398  FloatComplex *prow = row.fortran_vec ();
399 
400  octave_idx_type howmany = numel () / npts;
401  howmany = (stride == 1 ? howmany
402  : (howmany > stride ? stride : howmany));
403  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
404  octave_idx_type dist = (stride == 1 ? npts : 1);
405 
406  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
407 
408  for (octave_idx_type k = 0; k < nloop; k++)
409  {
410  for (octave_idx_type j = 0; j < howmany; j++)
411  {
412  octave_quit ();
413 
414  for (octave_idx_type l = 0; l < npts; l++)
415  prow[l] = retval((l + k*npts)*stride + j*dist);
416 
417  F77_FUNC (cfftf, CFFTF) (npts, F77_CMPLX_ARG (prow), F77_CMPLX_ARG (pwsave));
418 
419  for (octave_idx_type l = 0; l < npts; l++)
420  retval((l + k*npts)*stride + j*dist) = prow[l];
421  }
422  }
423 
424  stride *= dv(i);
425  }
426 
427  return retval;
428 }
429 
432 {
433  dim_vector dv = dims ();
434  int rank = dv.ndims ();
435  FloatComplexNDArray retval (*this);
436  octave_idx_type stride = 1;
437 
438  for (int i = 0; i < rank; i++)
439  {
440  octave_idx_type npts = dv(i);
441  octave_idx_type nn = 4*npts+15;
442  Array<FloatComplex> wsave (dim_vector (nn, 1));
443  FloatComplex *pwsave = wsave.fortran_vec ();
444  Array<FloatComplex> row (dim_vector (npts, 1));
445  FloatComplex *prow = row.fortran_vec ();
446 
447  octave_idx_type howmany = numel () / npts;
448  howmany = (stride == 1 ? howmany
449  : (howmany > stride ? stride : howmany));
450  octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
451  octave_idx_type dist = (stride == 1 ? npts : 1);
452 
453  F77_FUNC (cffti, CFFTI) (npts, F77_CMPLX_ARG (pwsave));
454 
455  for (octave_idx_type k = 0; k < nloop; k++)
456  {
457  for (octave_idx_type j = 0; j < howmany; j++)
458  {
459  octave_quit ();
460 
461  for (octave_idx_type l = 0; l < npts; l++)
462  prow[l] = retval((l + k*npts)*stride + j*dist);
463 
464  F77_FUNC (cfftb, CFFTB) (npts, F77_CMPLX_ARG (prow), F77_CMPLX_ARG (pwsave));
465 
466  for (octave_idx_type l = 0; l < npts; l++)
467  retval((l + k*npts)*stride + j*dist) =
468  prow[l] / static_cast<float> (npts);
469  }
470  }
471 
472  stride *= dv(i);
473  }
474 
475  return retval;
476 }
477 
478 #endif
479 
480 // unary operations
481 
484 {
485  if (any_element_is_nan ())
487 
488  return do_mx_unary_op<bool, FloatComplex> (*this, mx_inline_not);
489 }
490 
491 // FIXME: this is not quite the right thing.
492 
493 bool
495 {
496  return do_mx_check<FloatComplex> (*this, mx_inline_any_nan);
497 }
498 
499 bool
501 {
502  return ! do_mx_check<FloatComplex> (*this, mx_inline_all_finite);
503 }
504 
505 // Return true if no elements have imaginary components.
506 
507 bool
509 {
510  return do_mx_check<FloatComplex> (*this, mx_inline_all_real);
511 }
512 
513 // Return nonzero if any element of CM has a non-integer real or
514 // imaginary part. Also extract the largest and smallest (real or
515 // imaginary) values and return them in MAX_VAL and MIN_VAL.
516 
517 bool
518 FloatComplexNDArray::all_integers (float& max_val, float& min_val) const
519 {
520  octave_idx_type nel = numel ();
521 
522  if (nel > 0)
523  {
524  FloatComplex val = elem (0);
525 
526  float r_val = val.real ();
527  float i_val = val.imag ();
528 
529  max_val = r_val;
530  min_val = r_val;
531 
532  if (i_val > max_val)
533  max_val = i_val;
534 
535  if (i_val < max_val)
536  min_val = i_val;
537  }
538  else
539  return false;
540 
541  for (octave_idx_type i = 0; i < nel; i++)
542  {
543  FloatComplex val = elem (i);
544 
545  float r_val = val.real ();
546  float i_val = val.imag ();
547 
548  if (r_val > max_val)
549  max_val = r_val;
550 
551  if (i_val > max_val)
552  max_val = i_val;
553 
554  if (r_val < min_val)
555  min_val = r_val;
556 
557  if (i_val < min_val)
558  min_val = i_val;
559 
560  if (octave::math::x_nint (r_val) != r_val
561  || octave::math::x_nint (i_val) != i_val)
562  return false;
563  }
564 
565  return true;
566 }
567 
568 bool
570 {
571  return false;
572 }
573 
576 {
577  return do_mx_red_op<bool, FloatComplex> (*this, dim, mx_inline_all);
578 }
579 
582 {
583  return do_mx_red_op<bool, FloatComplex> (*this, dim, mx_inline_any);
584 }
585 
588 {
589  return do_mx_cum_op<FloatComplex, FloatComplex> (*this, dim,
591 }
592 
595 {
596  return do_mx_cum_op<FloatComplex, FloatComplex> (*this, dim,
598 }
599 
602 {
603  return do_mx_red_op<FloatComplex, FloatComplex> (*this, dim, mx_inline_prod);
604 }
605 
608 {
609  return do_mx_red_op<Complex, FloatComplex> (*this, dim, mx_inline_dprod);
610 }
611 
614 {
615  return do_mx_red_op<FloatComplex, FloatComplex> (*this, dim, mx_inline_sum);
616 }
617 
620 {
621  return do_mx_red_op<Complex, FloatComplex> (*this, dim, mx_inline_dsum);
622 }
623 
626 {
627  return do_mx_red_op<float, FloatComplex> (*this, dim, mx_inline_sumsq);
628 }
629 
632 {
633  return do_mx_diff_op<FloatComplex> (*this, dim, order, mx_inline_diff);
634 }
635 
639 {
640  if (rb.numel () > 0)
641  insert (rb, ra_idx);
642  return *this;
643 }
644 
648 {
650  if (rb.numel () > 0)
651  insert (tmp, ra_idx);
652  return *this;
653 }
654 
658 {
660  if (rb.numel () > 0)
661  retval.insert (rb, ra_idx);
662  return retval;
663 }
664 
667 
670 {
671  return do_mx_minmax_op<FloatComplex> (*this, dim, mx_inline_max);
672 }
673 
676 {
677  return do_mx_minmax_op<FloatComplex> (*this, idx_arg, dim, mx_inline_max);
678 }
679 
682 {
683  return do_mx_minmax_op<FloatComplex> (*this, dim, mx_inline_min);
684 }
685 
688 {
689  return do_mx_minmax_op<FloatComplex> (*this, idx_arg, dim, mx_inline_min);
690 }
691 
694 {
695  return do_mx_cumminmax_op<FloatComplex> (*this, dim, mx_inline_cummax);
696 }
697 
700 {
701  return do_mx_cumminmax_op<FloatComplex> (*this, idx_arg, dim,
703 }
704 
707 {
708  return do_mx_cumminmax_op<FloatComplex> (*this, dim, mx_inline_cummin);
709 }
710 
713 {
714  return do_mx_cumminmax_op<FloatComplex> (*this, idx_arg, dim,
716 }
717 
720 {
721  return do_mx_unary_map<float, FloatComplex, std::abs> (*this);
722 }
723 
726 {
727  return do_mx_unary_map<bool, FloatComplex, octave::math::isnan> (*this);
728 }
729 
732 {
733  return do_mx_unary_map<bool, FloatComplex, octave::math::isinf> (*this);
734 }
735 
738 {
739  return do_mx_unary_map<bool, FloatComplex, octave::math::isfinite> (*this);
740 }
741 
744 {
745  return do_mx_unary_map<FloatComplex, FloatComplex, std::conj<float>> (a);
746 }
747 
751 {
752  dim_vector a_dv = a.dims ();
753 
754  int n = a_dv.ndims ();
755 
756  if (n == dimensions.ndims ())
757  {
758  Array<octave_idx_type> a_ra_idx (dim_vector (a_dv.ndims (), 1), 0);
759 
760  a_ra_idx.elem (0) = r;
761  a_ra_idx.elem (1) = c;
762 
763  for (int i = 0; i < n; i++)
764  {
765  if (a_ra_idx(i) < 0 || (a_ra_idx(i) + a_dv(i)) > dimensions(i))
766  (*current_liboctave_error_handler)
767  ("Array<T>::insert: range error for insert");
768  }
769 
770  a_ra_idx.elem (0) = 0;
771  a_ra_idx.elem (1) = 0;
772 
773  octave_idx_type n_elt = a.numel ();
774 
775  // IS make_unique () NECESSARY HERE?
776 
777  for (octave_idx_type i = 0; i < n_elt; i++)
778  {
779  Array<octave_idx_type> ra_idx = a_ra_idx;
780 
781  ra_idx.elem (0) = a_ra_idx(0) + r;
782  ra_idx.elem (1) = a_ra_idx(1) + c;
783 
784  elem (ra_idx) = a.elem (a_ra_idx);
785 
786  increment_index (a_ra_idx, a_dv);
787  }
788  }
789  else
791  ("Array<T>::insert: invalid indexing operation");
792 
793  return *this;
794 }
795 
799 {
801  return *this;
802 }
803 
807 {
809  return *this;
810 }
811 
812 void
814  const dim_vector& dimensions,
815  int start_dimension)
816 {
817  ::increment_index (ra_idx, dimensions, start_dimension);
818 }
819 
822  const dim_vector& dimensions)
823 {
825 }
826 
829 {
830  return MArray<FloatComplex>::diag (k);
831 }
832 
835 {
836  return MArray<FloatComplex>::diag (m, n);
837 }
838 
839 // This contains no information on the array structure !!!
840 std::ostream&
841 operator << (std::ostream& os, const FloatComplexNDArray& a)
842 {
843  octave_idx_type nel = a.numel ();
844 
845  for (octave_idx_type i = 0; i < nel; i++)
846  {
847  os << ' ';
848  octave_write_complex (os, a.elem (i));
849  os << "\n";
850  }
851  return os;
852 }
853 
854 std::istream&
856 {
857  octave_idx_type nel = a.numel ();
858 
859  if (nel > 0)
860  {
862  for (octave_idx_type i = 0; i < nel; i++)
863  {
864  tmp = octave_read_value<FloatComplex> (is);
865  if (is)
866  a.elem (i) = tmp;
867  else
868  return is;
869  }
870  }
871 
872  return is;
873 }
874 
876 
879 
882 
885 
887 {
888  if (a.is_shared ())
889  a = a * s;
890  else
891  do_ms_inplace_op<FloatComplex, float> (a, s, mx_inline_mul2);
892  return a;
893 }
894 
896 {
897  if (a.is_shared ())
898  a = a / s;
899  else
900  do_ms_inplace_op<FloatComplex, float> (a, s, mx_inline_div2);
901  return a;
902 }
903 
906 
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
void mx_inline_mul2(size_t n, R *r, const X *x)
Definition: mx-inlines.cc:127
FloatComplexNDArray sumsq(int dim=-1) const
Definition: fCNDArray.cc:625
boolNDArray operator!(void) const
Definition: fCNDArray.cc:483
FloatComplexNDArray cumsum(int dim=-1) const
Definition: fCNDArray.cc:594
#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 all_integers(float &max_val, float &min_val) const
Definition: fCNDArray.cc:518
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
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:219
FloatComplexNDArray max(int dim=-1) const
Definition: fCNDArray.cc:669
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
std::istream & operator>>(std::istream &is, FloatComplexNDArray &a)
Definition: fCNDArray.cc:855
FloatComplexNDArray cumprod(int dim=-1) const
Definition: fCNDArray.cc:587
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
Definition: lo-error.c:38
bool mx_inline_all_finite(size_t n, const T *x)
Definition: mx-inlines.cc:269
for large enough k
Definition: lu.cc:617
FloatNDArray abs(void) const
Definition: fCNDArray.cc:719
boolNDArray all(int dim=-1) const
Definition: fCNDArray.cc:575
const FloatComplex * fortran_vec(void) const
Definition: Array.h:584
#define MINMAX_FCNS(T, S)
Definition: mx-op-defs.h:584
bool any_element_is_nan(void) const
Definition: fCNDArray.cc:494
void octave_write_complex(std::ostream &os, const Complex &c)
Definition: lo-utils.cc:408
bool all_elements_are_real(void) const
Definition: fCNDArray.cc:508
static F77_INT nn
Definition: DASPK.cc:62
FloatComplexNDArray diag(octave_idx_type k=0) const
Definition: fCNDArray.cc:828
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 sum(int dim=-1) const
Definition: fCNDArray.cc:613
FloatComplex & elem(octave_idx_type n)
Definition: Array.h:488
T mx_inline_sumsq(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:753
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
boolNDArray isinf(void) const
Definition: fCNDArray.cc:731
s
Definition: file-io.cc:2729
void err_nan_to_logical_conversion(void)
ComplexNDArray dprod(int dim=-1) const
Definition: fCNDArray.cc:607
FloatComplexNDArray ifourier(int dim=1) const
Definition: fCNDArray.cc:87
FloatComplexNDArray & insert(const NDArray &a, octave_idx_type r, octave_idx_type c)
Definition: fCNDArray.cc:749
bool mx_inline_any(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:753
bool any_element_is_inf_or_nan(void) const
Definition: fCNDArray.cc:500
FloatComplexNDArray cummin(int dim=-1) const
Definition: fCNDArray.cc:706
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
bool mx_inline_all_real(size_t n, const std::complex< T > *x)
Definition: mx-inlines.cc:308
subroutine cffti(n, wsave)
Definition: cffti.f:2
std::ostream & operator<<(std::ostream &os, const FloatComplexNDArray &a)
Definition: fCNDArray.cc:841
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
static octave_idx_type compute_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions)
Definition: fCNDArray.cc:821
#define NDND_CMP_OPS(ND1, ND2)
Definition: mx-op-defs.h:332
ComplexNDArray dsum(int dim=-1) const
Definition: fCNDArray.cc:619
FloatComplexNDArray fourierNd(void) const
Definition: fCNDArray.cc:158
#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())
FloatComplexNDArray prod(int dim=-1) const
Definition: fCNDArray.cc:601
boolNDArray any(int dim=-1) const
Definition: fCNDArray.cc:581
FloatComplexNDArray & operator/=(FloatComplexNDArray &a, float s)
Definition: fCNDArray.cc:895
subst_template_param< std::complex, T, double >::type mx_inline_dprod(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:752
bool too_large_for_float(void) const
Definition: fCNDArray.cc:569
boolNDArray isnan(void) const
Definition: fCNDArray.cc:725
FloatComplexNDArray(void)
Definition: fCNDArray.h:39
FloatComplexNDArray fourier(int dim=1) const
Definition: fCNDArray.cc:56
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
FloatComplexNDArray ifourierNd(void) const
Definition: fCNDArray.cc:173
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
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
FloatComplexNDArray min(int dim=-1) const
Definition: fCNDArray.cc:681
#define BSXFUN_STDREL_DEFS_MXLOOP(ARRAY)
Definition: bsxfun-defs.cc:242
FloatComplex & xelem(octave_idx_type n)
Definition: Array.h:458
T mx_inline_sum(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:751
#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 mx_inline_cumsum(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:857
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$)
FloatComplexNDArray cummax(int dim=-1) const
Definition: fCNDArray.cc:693
Array< T > diag(octave_idx_type k=0) const
Get the kth super or subdiagonal.
Definition: Array.cc:2530
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
for i
Definition: data.cc:5264
std::complex< float > FloatComplex
Definition: oct-cmplx.h:32
FloatComplexNDArray diff(octave_idx_type order=1, int dim=-1) const
Definition: fCNDArray.cc:631
boolNDArray isfinite(void) const
Definition: fCNDArray.cc:737
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_div2(size_t n, R *r, const X *x)
Definition: mx-inlines.cc:128
FloatComplexNDArray conj(const FloatComplexNDArray &a)
Definition: fCNDArray.cc:743
void mx_inline_not(size_t n, bool *r, const X *x)
Definition: mx-inlines.cc:180
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
FloatComplexNDArray fourier2d(void) const
Definition: fCNDArray.cc:118
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:656
FloatComplexNDArray ifourier2d(void) const
Definition: fCNDArray.cc:138
T mx_inline_prod(const T *v, octave_idx_type n)
Definition: mx-inlines.cc:752
dim_vector dv
Definition: sub2ind.cc:263
octave::stream os
Definition: file-io.cc:627
T x_nint(T x)
Definition: lo-mappers.h:284
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:813
void mx_inline_diff(const T *v, T *r, octave_idx_type n, octave_idx_type order)
Definition: mx-inlines.cc:1380
FloatComplexNDArray concat(const FloatComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: fCNDArray.cc:637
void mx_inline_min(const T *v, T *r, octave_idx_type n)
Definition: mx-inlines.cc:961