annotate liboctave/CNDArray.cc @ 14393:ba4d6343524b stable release-3-6-1

Version 3.6.1 released. * configure.ac (AC_INIT): Version is now 3.6.1. (OCTAVE_RELEASE_DATE): Release date is now 2012-02-22.
author John W. Eaton <jwe@octave.org>
date Wed, 22 Feb 2012 14:39:41 -0500
parents 72c96de7a403
children e8e86ae3abbc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4514
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
1 // N-D Array manipulations.
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
2 /*
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
3
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 13107
diff changeset
4 Copyright (C) 1996-2012 John W. Eaton
9601
a9b37bae1802 add a couple of missing copyright statements
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
5 Copyright (C) 2009 VZLU Prague, a.s.
4514
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
6
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
7 This file is part of Octave.
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
8
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
9 Octave is free software; you can redistribute it and/or modify it
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5775
diff changeset
11 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5775
diff changeset
12 option) any later version.
4514
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
13
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
14 Octave is distributed in the hope that it will be useful, but WITHOUT
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
17 for more details.
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
18
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5775
diff changeset
20 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5775
diff changeset
21 <http://www.gnu.org/licenses/>.
4514
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
22
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
23 */
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
24
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
25 #ifdef HAVE_CONFIG_H
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
26 #include <config.h>
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
27 #endif
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
28
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
29 #include <cfloat>
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5139
diff changeset
30
4780
5eb5b8aaed8a [project @ 2004-02-17 15:32:13 by jwe]
jwe
parents: 4773
diff changeset
31 #include <vector>
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
32
4588
19bfd295f400 [project @ 2003-11-10 17:18:48 by jwe]
jwe
parents: 4584
diff changeset
33 #include "Array-util.h"
4514
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
34 #include "CNDArray.h"
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
35 #include "f77-fcn.h"
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
36 #include "functor.h"
4514
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
37 #include "lo-ieee.h"
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
38 #include "lo-mappers.h"
9546
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
39 #include "MArray-defs.h"
9523
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
40 #include "mx-base.h"
8774
b756ce0002db split implementation and interface in mx-op-defs and MArray-defs
Jaroslav Hajek <highegg@gmail.com>
parents: 8751
diff changeset
41 #include "mx-op-defs.h"
4780
5eb5b8aaed8a [project @ 2004-02-17 15:32:13 by jwe]
jwe
parents: 4773
diff changeset
42 #include "oct-fftw.h"
9523
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
43 #include "oct-locbuf.h"
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
44
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
45 #include "bsxfun-defs.cc"
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
46
8956
d91fa4b20bbb ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
47 ComplexNDArray::ComplexNDArray (const charNDArray& a)
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10329
diff changeset
48 : MArray<Complex> (a.dims ())
8956
d91fa4b20bbb ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
49 {
d91fa4b20bbb ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
50 octave_idx_type n = a.numel ();
d91fa4b20bbb ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
51 for (octave_idx_type i = 0; i < n; i++)
d91fa4b20bbb ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
52 xelem (i) = static_cast<unsigned char> (a(i));
d91fa4b20bbb ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
53 }
d91fa4b20bbb ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
54
9523
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
55 #if defined (HAVE_FFTW)
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
56
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
57 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
58 ComplexNDArray::fourier (int dim) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
59 {
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
60 dim_vector dv = dims ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
61
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
62 if (dim > dv.length () || dim < 0)
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
63 return ComplexNDArray ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
64
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
65 octave_idx_type stride = 1;
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
66 octave_idx_type n = dv(dim);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
67
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
68 for (int i = 0; i < dim; i++)
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
69 stride *= dv(i);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
70
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
71 octave_idx_type howmany = numel () / dv (dim);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
72 howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
73 octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride);
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
74 octave_idx_type dist = (stride == 1 ? n : 1);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
75
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
76 const Complex *in (fortran_vec ());
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
77 ComplexNDArray retval (dv);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
78 Complex *out (retval.fortran_vec ());
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
79
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
80 // Need to be careful here about the distance between fft's
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
81 for (octave_idx_type k = 0; k < nloop; k++)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
82 octave_fftw::fft (in + k * stride * n, out + k * stride * n,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
83 n, howmany, stride, dist);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
84
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
85 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
86 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
87
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
88 ComplexNDArray
4816
4908c82cd1a1 [project @ 2004-03-04 18:13:46 by jwe]
jwe
parents: 4806
diff changeset
89 ComplexNDArray::ifourier (int dim) const
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
90 {
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
91 dim_vector dv = dims ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
92
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
93 if (dim > dv.length () || dim < 0)
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
94 return ComplexNDArray ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
95
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
96 octave_idx_type stride = 1;
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
97 octave_idx_type n = dv(dim);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
98
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
99 for (int i = 0; i < dim; i++)
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
100 stride *= dv(i);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
101
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
102 octave_idx_type howmany = numel () / dv (dim);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
103 howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
104 octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride);
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
105 octave_idx_type dist = (stride == 1 ? n : 1);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
106
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
107 const Complex *in (fortran_vec ());
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
108 ComplexNDArray retval (dv);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
109 Complex *out (retval.fortran_vec ());
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
110
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
111 // Need to be careful here about the distance between fft's
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
112 for (octave_idx_type k = 0; k < nloop; k++)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
113 octave_fftw::ifft (in + k * stride * n, out + k * stride * n,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
114 n, howmany, stride, dist);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
115
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
116 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
117 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
118
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
119 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
120 ComplexNDArray::fourier2d (void) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
121 {
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
122 dim_vector dv = dims();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
123 if (dv.length () < 2)
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
124 return ComplexNDArray ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
125
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
126 dim_vector dv2(dv(0), dv(1));
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
127 const Complex *in = fortran_vec ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
128 ComplexNDArray retval (dv);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
129 Complex *out = retval.fortran_vec ();
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
130 octave_idx_type howmany = numel() / dv(0) / dv(1);
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
131 octave_idx_type dist = dv(0) * dv(1);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
132
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
133 for (octave_idx_type i=0; i < howmany; i++)
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
134 octave_fftw::fftNd (in + i*dist, out + i*dist, 2, dv2);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
135
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
136 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
137 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
138
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
139 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
140 ComplexNDArray::ifourier2d (void) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
141 {
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
142 dim_vector dv = dims();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
143 if (dv.length () < 2)
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
144 return ComplexNDArray ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
145
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
146 dim_vector dv2(dv(0), dv(1));
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
147 const Complex *in = fortran_vec ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
148 ComplexNDArray retval (dv);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
149 Complex *out = retval.fortran_vec ();
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
150 octave_idx_type howmany = numel() / dv(0) / dv(1);
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
151 octave_idx_type dist = dv(0) * dv(1);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
152
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
153 for (octave_idx_type i=0; i < howmany; i++)
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
154 octave_fftw::ifftNd (in + i*dist, out + i*dist, 2, dv2);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
155
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
156 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
157 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
158
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
159 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
160 ComplexNDArray::fourierNd (void) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
161 {
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
162 dim_vector dv = dims ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
163 int rank = dv.length ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
164
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
165 const Complex *in (fortran_vec ());
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
166 ComplexNDArray retval (dv);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
167 Complex *out (retval.fortran_vec ());
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
168
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
169 octave_fftw::fftNd (in, out, rank, dv);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
170
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
171 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
172 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
173
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
174 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
175 ComplexNDArray::ifourierNd (void) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
176 {
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
177 dim_vector dv = dims ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
178 int rank = dv.length ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
179
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
180 const Complex *in (fortran_vec ());
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
181 ComplexNDArray retval (dv);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
182 Complex *out (retval.fortran_vec ());
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
183
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
184 octave_fftw::ifftNd (in, out, rank, dv);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
185
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
186 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
187 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
188
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
189 #else
9523
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
190
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
191 extern "C"
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
192 {
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
193 // Note that the original complex fft routines were not written for
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
194 // double complex arguments. They have been modified by adding an
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
195 // implicit double precision (a-h,o-z) statement at the beginning of
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
196 // each subroutine.
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
197
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
198 F77_RET_T
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
199 F77_FUNC (zffti, ZFFTI) (const octave_idx_type&, Complex*);
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
200
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
201 F77_RET_T
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
202 F77_FUNC (zfftf, ZFFTF) (const octave_idx_type&, Complex*, Complex*);
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
203
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
204 F77_RET_T
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
205 F77_FUNC (zfftb, ZFFTB) (const octave_idx_type&, Complex*, Complex*);
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
206 }
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9513
diff changeset
207
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
208 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
209 ComplexNDArray::fourier (int dim) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
210 {
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
211 dim_vector dv = dims ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
212
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
213 if (dim > dv.length () || dim < 0)
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
214 return ComplexNDArray ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
215
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
216 ComplexNDArray retval (dv);
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
217 octave_idx_type npts = dv(dim);
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
218 octave_idx_type nn = 4*npts+15;
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
219 Array<Complex> wsave (dim_vector (nn, 1));
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
220 Complex *pwsave = wsave.fortran_vec ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
221
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
222 OCTAVE_LOCAL_BUFFER (Complex, tmp, npts);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
223
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
224 octave_idx_type stride = 1;
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
225
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
226 for (int i = 0; i < dim; i++)
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
227 stride *= dv(i);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
228
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
229 octave_idx_type howmany = numel () / npts;
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
230 howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
231 octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
232 octave_idx_type dist = (stride == 1 ? npts : 1);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
233
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7620
diff changeset
234 F77_FUNC (zffti, ZFFTI) (npts, pwsave);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
235
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
236 for (octave_idx_type k = 0; k < nloop; k++)
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
237 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
238 for (octave_idx_type j = 0; j < howmany; j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
239 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
240 octave_quit ();
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
241
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
242 for (octave_idx_type i = 0; i < npts; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
243 tmp[i] = elem((i + k*npts)*stride + j*dist);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
244
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
245 F77_FUNC (zfftf, ZFFTF) (npts, tmp, pwsave);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
246
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
247 for (octave_idx_type i = 0; i < npts; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
248 retval ((i + k*npts)*stride + j*dist) = tmp[i];
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
249 }
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
250 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
251
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
252 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
253 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
254
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
255 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
256 ComplexNDArray::ifourier (int dim) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
257 {
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
258 dim_vector dv = dims ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
259
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
260 if (dim > dv.length () || dim < 0)
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
261 return ComplexNDArray ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
262
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
263 ComplexNDArray retval (dv);
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
264 octave_idx_type npts = dv(dim);
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
265 octave_idx_type nn = 4*npts+15;
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
266 Array<Complex> wsave (dim_vector (nn, 1));
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
267 Complex *pwsave = wsave.fortran_vec ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
268
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
269 OCTAVE_LOCAL_BUFFER (Complex, tmp, npts);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
270
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
271 octave_idx_type stride = 1;
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
272
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
273 for (int i = 0; i < dim; i++)
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
274 stride *= dv(i);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
275
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
276 octave_idx_type howmany = numel () / npts;
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
277 howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
278 octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
279 octave_idx_type dist = (stride == 1 ? npts : 1);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
280
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7620
diff changeset
281 F77_FUNC (zffti, ZFFTI) (npts, pwsave);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
282
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
283 for (octave_idx_type k = 0; k < nloop; k++)
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
284 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
285 for (octave_idx_type j = 0; j < howmany; j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
286 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
287 octave_quit ();
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
288
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
289 for (octave_idx_type i = 0; i < npts; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
290 tmp[i] = elem((i + k*npts)*stride + j*dist);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
291
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
292 F77_FUNC (zfftb, ZFFTB) (npts, tmp, pwsave);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
293
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
294 for (octave_idx_type i = 0; i < npts; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
295 retval ((i + k*npts)*stride + j*dist) = tmp[i] /
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
296 static_cast<double> (npts);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
297 }
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
298 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
299
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
300 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
301 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
302
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
303 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
304 ComplexNDArray::fourier2d (void) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
305 {
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
306 dim_vector dv = dims ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
307 dim_vector dv2 (dv(0), dv(1));
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
308 int rank = 2;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
309 ComplexNDArray retval (*this);
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
310 octave_idx_type stride = 1;
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
311
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
312 for (int i = 0; i < rank; i++)
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
313 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
314 octave_idx_type npts = dv2(i);
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
315 octave_idx_type nn = 4*npts+15;
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
316 Array<Complex> wsave (dim_vector (nn, 1));
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
317 Complex *pwsave = wsave.fortran_vec ();
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
318 Array<Complex> row (dim_vector (npts, 1));
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
319 Complex *prow = row.fortran_vec ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
320
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
321 octave_idx_type howmany = numel () / npts;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
322 howmany = (stride == 1 ? howmany :
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
323 (howmany > stride ? stride : howmany));
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
324 octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
325 octave_idx_type dist = (stride == 1 ? npts : 1);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
326
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7620
diff changeset
327 F77_FUNC (zffti, ZFFTI) (npts, pwsave);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
328
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
329 for (octave_idx_type k = 0; k < nloop; k++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
330 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
331 for (octave_idx_type j = 0; j < howmany; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
332 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
333 octave_quit ();
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
334
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
335 for (octave_idx_type l = 0; l < npts; l++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
336 prow[l] = retval ((l + k*npts)*stride + j*dist);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
337
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
338 F77_FUNC (zfftf, ZFFTF) (npts, prow, pwsave);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
339
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
340 for (octave_idx_type l = 0; l < npts; l++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
341 retval ((l + k*npts)*stride + j*dist) = prow[l];
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
342 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
343 }
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
344
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
345 stride *= dv2(i);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
346 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
347
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
348 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
349 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
350
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
351 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
352 ComplexNDArray::ifourier2d (void) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
353 {
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
354 dim_vector dv = dims();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
355 dim_vector dv2 (dv(0), dv(1));
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
356 int rank = 2;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
357 ComplexNDArray retval (*this);
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
358 octave_idx_type stride = 1;
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
359
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
360 for (int i = 0; i < rank; i++)
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
361 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
362 octave_idx_type npts = dv2(i);
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
363 octave_idx_type nn = 4*npts+15;
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
364 Array<Complex> wsave (dim_vector (nn, 1));
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
365 Complex *pwsave = wsave.fortran_vec ();
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
366 Array<Complex> row (dim_vector (npts, 1));
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
367 Complex *prow = row.fortran_vec ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
368
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
369 octave_idx_type howmany = numel () / npts;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
370 howmany = (stride == 1 ? howmany :
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
371 (howmany > stride ? stride : howmany));
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
372 octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
373 octave_idx_type dist = (stride == 1 ? npts : 1);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
374
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7620
diff changeset
375 F77_FUNC (zffti, ZFFTI) (npts, pwsave);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
376
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
377 for (octave_idx_type k = 0; k < nloop; k++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
378 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
379 for (octave_idx_type j = 0; j < howmany; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
380 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
381 octave_quit ();
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
382
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
383 for (octave_idx_type l = 0; l < npts; l++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
384 prow[l] = retval ((l + k*npts)*stride + j*dist);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
385
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
386 F77_FUNC (zfftb, ZFFTB) (npts, prow, pwsave);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
387
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
388 for (octave_idx_type l = 0; l < npts; l++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
389 retval ((l + k*npts)*stride + j*dist) = prow[l] /
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
390 static_cast<double> (npts);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
391 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
392 }
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
393
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
394 stride *= dv2(i);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
395 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
396
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
397 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
398 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
399
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
400 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
401 ComplexNDArray::fourierNd (void) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
402 {
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
403 dim_vector dv = dims ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
404 int rank = dv.length ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
405 ComplexNDArray retval (*this);
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
406 octave_idx_type stride = 1;
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
407
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
408 for (int i = 0; i < rank; i++)
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
409 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
410 octave_idx_type npts = dv(i);
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
411 octave_idx_type nn = 4*npts+15;
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
412 Array<Complex> wsave (dim_vector (nn, 1));
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
413 Complex *pwsave = wsave.fortran_vec ();
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
414 Array<Complex> row (dim_vector (npts, 1));
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
415 Complex *prow = row.fortran_vec ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
416
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
417 octave_idx_type howmany = numel () / npts;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
418 howmany = (stride == 1 ? howmany :
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
419 (howmany > stride ? stride : howmany));
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
420 octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
421 octave_idx_type dist = (stride == 1 ? npts : 1);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
422
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7620
diff changeset
423 F77_FUNC (zffti, ZFFTI) (npts, pwsave);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
424
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
425 for (octave_idx_type k = 0; k < nloop; k++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
426 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
427 for (octave_idx_type j = 0; j < howmany; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
428 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
429 octave_quit ();
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
430
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
431 for (octave_idx_type l = 0; l < npts; l++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
432 prow[l] = retval ((l + k*npts)*stride + j*dist);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
433
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
434 F77_FUNC (zfftf, ZFFTF) (npts, prow, pwsave);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
435
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
436 for (octave_idx_type l = 0; l < npts; l++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
437 retval ((l + k*npts)*stride + j*dist) = prow[l];
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
438 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
439 }
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
440
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
441 stride *= dv(i);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
442 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
443
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
444 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
445 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
446
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
447 ComplexNDArray
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
448 ComplexNDArray::ifourierNd (void) const
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
449 {
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
450 dim_vector dv = dims ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
451 int rank = dv.length ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
452 ComplexNDArray retval (*this);
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
453 octave_idx_type stride = 1;
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
454
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
455 for (int i = 0; i < rank; i++)
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
456 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
457 octave_idx_type npts = dv(i);
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
458 octave_idx_type nn = 4*npts+15;
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
459 Array<Complex> wsave (dim_vector (nn, 1));
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
460 Complex *pwsave = wsave.fortran_vec ();
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
461 Array<Complex> row (dim_vector (npts, 1));
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
462 Complex *prow = row.fortran_vec ();
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
463
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
464 octave_idx_type howmany = numel () / npts;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
465 howmany = (stride == 1 ? howmany :
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
466 (howmany > stride ? stride : howmany));
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
467 octave_idx_type nloop = (stride == 1 ? 1 : numel () / npts / stride);
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
468 octave_idx_type dist = (stride == 1 ? npts : 1);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
469
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7620
diff changeset
470 F77_FUNC (zffti, ZFFTI) (npts, pwsave);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
471
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
472 for (octave_idx_type k = 0; k < nloop; k++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
473 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
474 for (octave_idx_type j = 0; j < howmany; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
475 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
476 octave_quit ();
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
477
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
478 for (octave_idx_type l = 0; l < npts; l++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
479 prow[l] = retval ((l + k*npts)*stride + j*dist);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
480
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
481 F77_FUNC (zfftb, ZFFTB) (npts, prow, pwsave);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
482
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
483 for (octave_idx_type l = 0; l < npts; l++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
484 retval ((l + k*npts)*stride + j*dist) = prow[l] /
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
485 static_cast<double> (npts);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
486 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
487 }
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
488
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
489 stride *= dv(i);
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
490 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
491
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
492 return retval;
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
493 }
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
494
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
495 #endif
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 4770
diff changeset
496
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
497 // unary operations
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
498
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
499 boolNDArray
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
500 ComplexNDArray::operator ! (void) const
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
501 {
11130
7c573eb981eb consistently give error for operator not applied to NaN values
John W. Eaton <jwe@octave.org>
parents: 11008
diff changeset
502 if (any_element_is_nan ())
7c573eb981eb consistently give error for operator not applied to NaN values
John W. Eaton <jwe@octave.org>
parents: 11008
diff changeset
503 gripe_nan_to_logical_conversion ();
7c573eb981eb consistently give error for operator not applied to NaN values
John W. Eaton <jwe@octave.org>
parents: 11008
diff changeset
504
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
505 return do_mx_unary_op<bool, Complex> (*this, mx_inline_not);
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
506 }
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
507
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5389
diff changeset
508 // FIXME -- this is not quite the right thing.
4514
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
509
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
510 bool
7922
935be827eaf8 error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents: 7789
diff changeset
511 ComplexNDArray::any_element_is_nan (void) const
935be827eaf8 error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents: 7789
diff changeset
512 {
11008
3622db30ff05 simplify some array tests in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10362
diff changeset
513 return do_mx_check<Complex> (*this, mx_inline_any_nan);
7922
935be827eaf8 error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents: 7789
diff changeset
514 }
935be827eaf8 error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents: 7789
diff changeset
515
935be827eaf8 error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents: 7789
diff changeset
516 bool
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
517 ComplexNDArray::any_element_is_inf_or_nan (void) const
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
518 {
11008
3622db30ff05 simplify some array tests in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10362
diff changeset
519 return ! do_mx_check<Complex> (*this, mx_inline_all_finite);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
520 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
521
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
522 // Return true if no elements have imaginary components.
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
523
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
524 bool
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
525 ComplexNDArray::all_elements_are_real (void) const
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
526 {
11008
3622db30ff05 simplify some array tests in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10362
diff changeset
527 return do_mx_check<Complex> (*this, mx_inline_all_real);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
528 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
529
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
530 // Return nonzero if any element of CM has a non-integer real or
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
531 // imaginary part. Also extract the largest and smallest (real or
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
532 // imaginary) values and return them in MAX_VAL and MIN_VAL.
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
533
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
534 bool
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
535 ComplexNDArray::all_integers (double& max_val, double& min_val) const
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
536 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
537 octave_idx_type nel = nelem ();
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
538
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
539 if (nel > 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
540 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
541 Complex val = elem (0);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
542
5260
deed800e7bef [project @ 2005-03-30 23:18:58 by jwe]
jwe
parents: 5164
diff changeset
543 double r_val = std::real (val);
deed800e7bef [project @ 2005-03-30 23:18:58 by jwe]
jwe
parents: 5164
diff changeset
544 double i_val = std::imag (val);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
545
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
546 max_val = r_val;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
547 min_val = r_val;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
548
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
549 if (i_val > max_val)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
550 max_val = i_val;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
551
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
552 if (i_val < max_val)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
553 min_val = i_val;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
554 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
555 else
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
556 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
557
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
558 for (octave_idx_type i = 0; i < nel; i++)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
559 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
560 Complex val = elem (i);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
561
5260
deed800e7bef [project @ 2005-03-30 23:18:58 by jwe]
jwe
parents: 5164
diff changeset
562 double r_val = std::real (val);
deed800e7bef [project @ 2005-03-30 23:18:58 by jwe]
jwe
parents: 5164
diff changeset
563 double i_val = std::imag (val);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
564
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
565 if (r_val > max_val)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
566 max_val = r_val;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
567
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
568 if (i_val > max_val)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
569 max_val = i_val;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
570
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
571 if (r_val < min_val)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
572 min_val = r_val;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
573
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
574 if (i_val < min_val)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
575 min_val = i_val;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
576
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
577 if (D_NINT (r_val) != r_val || D_NINT (i_val) != i_val)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
578 return false;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
579 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
580
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
581 return true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
582 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
583
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
584 bool
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
585 ComplexNDArray::too_large_for_float (void) const
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
586 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
587 octave_idx_type nel = nelem ();
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
588
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
589 for (octave_idx_type i = 0; i < nel; i++)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
590 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
591 Complex val = elem (i);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
592
5260
deed800e7bef [project @ 2005-03-30 23:18:58 by jwe]
jwe
parents: 5164
diff changeset
593 double r_val = std::real (val);
deed800e7bef [project @ 2005-03-30 23:18:58 by jwe]
jwe
parents: 5164
diff changeset
594 double i_val = std::imag (val);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
595
5389
25c8956d2204 [project @ 2005-06-15 03:45:46 by jwe]
jwe
parents: 5387
diff changeset
596 if ((! (xisnan (r_val) || xisinf (r_val))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
597 && fabs (r_val) > FLT_MAX)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
598 || (! (xisnan (i_val) || xisinf (i_val))
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
599 && fabs (i_val) > FLT_MAX))
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
600 return true;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
601 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
602
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
603 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
604 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
605
4556
773a21e4fce8 [project @ 2003-10-28 05:02:10 by jwe]
jwe
parents: 4543
diff changeset
606 boolNDArray
4514
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
607 ComplexNDArray::all (int dim) const
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
608 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
609 return do_mx_red_op<bool, Complex> (*this, dim, mx_inline_all);
4514
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
610 }
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
611
4556
773a21e4fce8 [project @ 2003-10-28 05:02:10 by jwe]
jwe
parents: 4543
diff changeset
612 boolNDArray
4514
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
613 ComplexNDArray::any (int dim) const
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
614 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
615 return do_mx_red_op<bool, Complex> (*this, dim, mx_inline_any);
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
616 }
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
617
4584
f7697d703481 [project @ 2003-10-31 19:47:35 by jwe]
jwe
parents: 4569
diff changeset
618 ComplexNDArray
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
619 ComplexNDArray::cumprod (int dim) const
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
620 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
621 return do_mx_cum_op<Complex, Complex> (*this, dim, mx_inline_cumprod);
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
622 }
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
623
4584
f7697d703481 [project @ 2003-10-31 19:47:35 by jwe]
jwe
parents: 4569
diff changeset
624 ComplexNDArray
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
625 ComplexNDArray::cumsum (int dim) const
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
626 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
627 return do_mx_cum_op<Complex, Complex> (*this, dim, mx_inline_cumsum);
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
628 }
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
629
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
630 ComplexNDArray
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
631 ComplexNDArray::prod (int dim) const
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
632 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
633 return do_mx_red_op<Complex, Complex> (*this, dim, mx_inline_prod);
8736
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
634 }
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
635
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
636 ComplexNDArray
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
637 ComplexNDArray::sum (int dim) const
53b4fdeacc2e improve reduction functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8650
diff changeset
638 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
639 return do_mx_red_op<Complex, Complex> (*this, dim, mx_inline_sum);
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
640 }
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
641
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
642 ComplexNDArray
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9612
diff changeset
643 ComplexNDArray::xsum (int dim) const
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9612
diff changeset
644 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
645 return do_mx_red_op<Complex, Complex> (*this, dim, mx_inline_xsum);
9721
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9612
diff changeset
646 }
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9612
diff changeset
647
192d94cff6c1 improve sum & implement the 'extra' option, refactor some code
Jaroslav Hajek <highegg@gmail.com>
parents: 9612
diff changeset
648 ComplexNDArray
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
649 ComplexNDArray::sumsq (int dim) const
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
650 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
651 return do_mx_red_op<double, Complex> (*this, dim, mx_inline_sumsq);
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
652 }
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
653
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
654 ComplexNDArray
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 9469
diff changeset
655 ComplexNDArray::diff (octave_idx_type order, int dim) const
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 9469
diff changeset
656 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
657 return do_mx_diff_op<Complex> (*this, dim, order, mx_inline_diff);
9513
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 9469
diff changeset
658 }
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 9469
diff changeset
659
9f870f73ab7d implement built-in diff
Jaroslav Hajek <highegg@gmail.com>
parents: 9469
diff changeset
660 ComplexNDArray
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
661 ComplexNDArray::concat (const ComplexNDArray& rb, const Array<octave_idx_type>& ra_idx)
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
662 {
4940
954cc2ba6a49 [project @ 2004-08-24 19:30:31 by jwe]
jwe
parents: 4915
diff changeset
663 if (rb.numel () > 0)
5073
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
664 insert (rb, ra_idx);
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
665 return *this;
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
666 }
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
667
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
668 ComplexNDArray
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
669 ComplexNDArray::concat (const NDArray& rb, const Array<octave_idx_type>& ra_idx)
4758
a308566c8b42 [project @ 2004-02-13 23:01:34 by jwe]
jwe
parents: 4687
diff changeset
670 {
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
671 ComplexNDArray tmp (rb);
4940
954cc2ba6a49 [project @ 2004-08-24 19:30:31 by jwe]
jwe
parents: 4915
diff changeset
672 if (rb.numel () > 0)
5073
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
673 insert (tmp, ra_idx);
e71be9c548f2 [project @ 2004-11-09 18:31:25 by jwe]
jwe
parents: 4940
diff changeset
674 return *this;
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
675 }
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
676
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
677 ComplexNDArray
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
678 concat (NDArray& ra, ComplexNDArray& rb, const Array<octave_idx_type>& ra_idx)
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
679 {
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
680 ComplexNDArray retval (ra);
4940
954cc2ba6a49 [project @ 2004-08-24 19:30:31 by jwe]
jwe
parents: 4915
diff changeset
681 if (rb.numel () > 0)
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
682 retval.insert (rb, ra_idx);
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
683 return retval;
4758
a308566c8b42 [project @ 2004-02-13 23:01:34 by jwe]
jwe
parents: 4687
diff changeset
684 }
a308566c8b42 [project @ 2004-02-13 23:01:34 by jwe]
jwe
parents: 4687
diff changeset
685
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
686 static const Complex Complex_NaN_result (octave_NaN, octave_NaN);
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
687
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
688 ComplexNDArray
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
689 ComplexNDArray::max (int dim) const
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
690 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
691 return do_mx_minmax_op<Complex> (*this, dim, mx_inline_max);
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
692 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
693
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
694 ComplexNDArray
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9721
diff changeset
695 ComplexNDArray::max (Array<octave_idx_type>& idx_arg, int dim) const
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
696 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
697 return do_mx_minmax_op<Complex> (*this, idx_arg, dim, mx_inline_max);
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
698 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
699
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
700 ComplexNDArray
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
701 ComplexNDArray::min (int dim) const
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
702 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
703 return do_mx_minmax_op<Complex> (*this, dim, mx_inline_min);
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
704 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
705
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
706 ComplexNDArray
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9721
diff changeset
707 ComplexNDArray::min (Array<octave_idx_type>& idx_arg, int dim) const
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
708 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
709 return do_mx_minmax_op<Complex> (*this, idx_arg, dim, mx_inline_min);
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
710 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
711
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
712 ComplexNDArray
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
713 ComplexNDArray::cummax (int dim) const
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
714 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
715 return do_mx_cumminmax_op<Complex> (*this, dim, mx_inline_cummax);
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
716 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
717
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
718 ComplexNDArray
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9721
diff changeset
719 ComplexNDArray::cummax (Array<octave_idx_type>& idx_arg, int dim) const
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
720 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
721 return do_mx_cumminmax_op<Complex> (*this, idx_arg, dim, mx_inline_cummax);
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
722 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
723
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
724 ComplexNDArray
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
725 ComplexNDArray::cummin (int dim) const
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
726 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
727 return do_mx_cumminmax_op<Complex> (*this, dim, mx_inline_cummin);
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
728 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
729
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
730 ComplexNDArray
9732
b4fdfee405b5 remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9721
diff changeset
731 ComplexNDArray::cummin (Array<octave_idx_type>& idx_arg, int dim) const
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
732 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
733 return do_mx_cumminmax_op<Complex> (*this, idx_arg, dim, mx_inline_cummin);
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
734 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 8774
diff changeset
735
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
736 NDArray
4569
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
737 ComplexNDArray::abs (void) const
01e4957409a4 [project @ 2003-10-30 05:48:17 by jwe]
jwe
parents: 4563
diff changeset
738 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
739 return do_mx_unary_map<double, Complex, std::abs> (*this);
8650
a1ae2aae903e abs,real,imag,conj: use code from mx-inlines rather than the generic map
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
740 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents: 4588
diff changeset
741
8998
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
742 boolNDArray
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
743 ComplexNDArray::isnan (void) const
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
744 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
745 return do_mx_unary_map<bool, Complex, xisnan> (*this);
8998
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
746 }
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
747
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
748 boolNDArray
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
749 ComplexNDArray::isinf (void) const
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
750 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
751 return do_mx_unary_map<bool, Complex, xisinf> (*this);
8998
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
752 }
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
753
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
754 boolNDArray
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
755 ComplexNDArray::isfinite (void) const
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
756 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
757 return do_mx_unary_map<bool, Complex, xfinite> (*this);
8998
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
758 }
a48fba01e4ac optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents: 8981
diff changeset
759
8650
a1ae2aae903e abs,real,imag,conj: use code from mx-inlines rather than the generic map
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
760 ComplexNDArray
a1ae2aae903e abs,real,imag,conj: use code from mx-inlines rather than the generic map
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
761 conj (const ComplexNDArray& a)
a1ae2aae903e abs,real,imag,conj: use code from mx-inlines rather than the generic map
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
762 {
13107
353c71c76f22 maint: fix compilation problem with g++ -std=c++0x option
Júlio Hoffimann <julio.hoffimann@gmail.com>
parents: 11586
diff changeset
763 return do_mx_unary_map<Complex, Complex, std::conj<double> > (a);
4514
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
764 }
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
765
4765
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
766 ComplexNDArray&
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
767 ComplexNDArray::insert (const NDArray& a, octave_idx_type r, octave_idx_type c)
4765
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
768 {
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
769 dim_vector a_dv = a.dims ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
770
4765
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
771 int n = a_dv.length ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
772
4765
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
773 if (n == dimensions.length ())
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
774 {
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
775 Array<octave_idx_type> a_ra_idx (dim_vector (a_dv.length (), 1), 0);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
776
4765
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
777 a_ra_idx.elem (0) = r;
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
778 a_ra_idx.elem (1) = c;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
779
4765
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
780 for (int i = 0; i < n; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
781 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
782 if (a_ra_idx (i) < 0 || (a_ra_idx (i) + a_dv (i)) > dimensions (i))
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
783 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
784 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
785 ("Array<T>::insert: range error for insert");
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
786 return *this;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
787 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
788 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
789
4765
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
790 a_ra_idx.elem (0) = 0;
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
791 a_ra_idx.elem (1) = 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
792
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
793 octave_idx_type n_elt = a.numel ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
794
4765
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
795 // IS make_unique () NECCESSARY HERE??
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
796
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
797 for (octave_idx_type i = 0; i < n_elt; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
798 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
799 Array<octave_idx_type> ra_idx = a_ra_idx;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
800
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
801 ra_idx.elem (0) = a_ra_idx (0) + r;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
802 ra_idx.elem (1) = a_ra_idx (1) + c;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
803
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
804 elem (ra_idx) = a.elem (a_ra_idx);
4765
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
805
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
806 increment_index (a_ra_idx, a_dv);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
807 }
4765
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
808 }
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
809 else
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
810 (*current_liboctave_error_handler)
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
811 ("Array<T>::insert: invalid indexing operation");
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
812
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
813 return *this;
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
814 }
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
815
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
816 ComplexNDArray&
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
817 ComplexNDArray::insert (const ComplexNDArray& a, octave_idx_type r, octave_idx_type c)
4765
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
818 {
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
819 Array<Complex>::insert (a, r, c);
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
820 return *this;
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
821 }
e941e1470d7b [project @ 2004-02-16 05:56:50 by jwe]
jwe
parents: 4762
diff changeset
822
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
823 ComplexNDArray&
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
824 ComplexNDArray::insert (const ComplexNDArray& a, const Array<octave_idx_type>& ra_idx)
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
825 {
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
826 Array<Complex>::insert (a, ra_idx);
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
827 return *this;
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
828 }
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4902
diff changeset
829
4514
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
830 ComplexMatrix
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
831 ComplexNDArray::matrix_value (void) const
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
832 {
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
833 ComplexMatrix retval;
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
834
8981
ed5055b0a476 fix & simplify ndarray->matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 8956
diff changeset
835 if (ndims () == 2)
10352
a3635bc1ea19 remove Array2
Jaroslav Hajek <highegg@gmail.com>
parents: 10350
diff changeset
836 retval = ComplexMatrix (Array<Complex> (*this));
8981
ed5055b0a476 fix & simplify ndarray->matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 8956
diff changeset
837 else
ed5055b0a476 fix & simplify ndarray->matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 8956
diff changeset
838 (*current_liboctave_error_handler)
ed5055b0a476 fix & simplify ndarray->matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 8956
diff changeset
839 ("invalid conversion of ComplexNDArray to ComplexMatrix");
4514
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
840
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
841 return retval;
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
842 }
8373b9b41eee [project @ 2003-09-19 21:47:10 by jwe]
jwe
parents:
diff changeset
843
4532
01ee68d18069 [project @ 2003-10-10 00:49:54 by jwe]
jwe
parents: 4514
diff changeset
844 void
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
845 ComplexNDArray::increment_index (Array<octave_idx_type>& ra_idx,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
846 const dim_vector& dimensions,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
847 int start_dimension)
4532
01ee68d18069 [project @ 2003-10-10 00:49:54 by jwe]
jwe
parents: 4514
diff changeset
848 {
01ee68d18069 [project @ 2003-10-10 00:49:54 by jwe]
jwe
parents: 4514
diff changeset
849 ::increment_index (ra_idx, dimensions, start_dimension);
01ee68d18069 [project @ 2003-10-10 00:49:54 by jwe]
jwe
parents: 4514
diff changeset
850 }
01ee68d18069 [project @ 2003-10-10 00:49:54 by jwe]
jwe
parents: 4514
diff changeset
851
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
852 octave_idx_type
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
853 ComplexNDArray::compute_index (Array<octave_idx_type>& ra_idx,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
854 const dim_vector& dimensions)
4556
773a21e4fce8 [project @ 2003-10-28 05:02:10 by jwe]
jwe
parents: 4543
diff changeset
855 {
773a21e4fce8 [project @ 2003-10-28 05:02:10 by jwe]
jwe
parents: 4543
diff changeset
856 return ::compute_index (ra_idx, dimensions);
773a21e4fce8 [project @ 2003-10-28 05:02:10 by jwe]
jwe
parents: 4543
diff changeset
857 }
773a21e4fce8 [project @ 2003-10-28 05:02:10 by jwe]
jwe
parents: 4543
diff changeset
858
7620
36594d5bbe13 Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents: 7600
diff changeset
859 ComplexNDArray
36594d5bbe13 Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents: 7600
diff changeset
860 ComplexNDArray::diag (octave_idx_type k) const
36594d5bbe13 Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents: 7600
diff changeset
861 {
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10329
diff changeset
862 return MArray<Complex>::diag (k);
7620
36594d5bbe13 Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents: 7600
diff changeset
863 }
36594d5bbe13 Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents: 7600
diff changeset
864
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
865 // This contains no information on the array structure !!!
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
866 std::ostream&
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
867 operator << (std::ostream& os, const ComplexNDArray& a)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
868 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
869 octave_idx_type nel = a.nelem ();
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
870
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
871 for (octave_idx_type i = 0; i < nel; i++)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
872 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
873 os << " ";
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
874 octave_write_complex (os, a.elem (i));
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
875 os << "\n";
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
876 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
877 return os;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
878 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
879
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
880 std::istream&
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
881 operator >> (std::istream& is, ComplexNDArray& a)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
882 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
883 octave_idx_type nel = a.nelem ();
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
884
8999
dc07bc4157b8 allow empty matrices in stream input operators
Jaroslav Hajek <highegg@gmail.com>
parents: 8998
diff changeset
885 if (nel > 0)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
886 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
887 Complex tmp;
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5260
diff changeset
888 for (octave_idx_type i = 0; i < nel; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
889 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
890 tmp = octave_read_value<Complex> (is);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
891 if (is)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
892 a.elem (i) = tmp;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
893 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
894 goto done;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
895 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
896 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
897
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
898 done:
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
899
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
900 return is;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
901 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4634
diff changeset
902
10329
83fa590b8a09 simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
903 MINMAX_FCNS (ComplexNDArray, Complex)
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4816
diff changeset
904
9578
7dafdb8b062f refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents: 9553
diff changeset
905 NDS_CMP_OPS (ComplexNDArray, Complex)
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
906 NDS_BOOL_OPS (ComplexNDArray, Complex)
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
907
9578
7dafdb8b062f refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents: 9553
diff changeset
908 SND_CMP_OPS (Complex, ComplexNDArray)
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
909 SND_BOOL_OPS (Complex, ComplexNDArray)
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
910
9578
7dafdb8b062f refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents: 9553
diff changeset
911 NDND_CMP_OPS (ComplexNDArray, ComplexNDArray)
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
912 NDND_BOOL_OPS (ComplexNDArray, ComplexNDArray)
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4532
diff changeset
913
9546
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
914 ComplexNDArray& operator *= (ComplexNDArray& a, double s)
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
915 {
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
916 if (a.is_shared ())
9612
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
917 a = a * s;
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
918 else
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
919 do_ms_inplace_op<Complex, double> (a, s, mx_inline_mul2);
9546
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
920 return a;
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
921 }
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
922
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
923 ComplexNDArray& operator /= (ComplexNDArray& a, double s)
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
924 {
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
925 if (a.is_shared ())
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
926 return a = a / s;
9612
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
927 else
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
928 do_ms_inplace_op<Complex, double> (a, s, mx_inline_div2);
9546
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
929 return a;
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
930 }
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 9523
diff changeset
931
9743
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
932 BSXFUN_STDOP_DEFS_MXLOOP (ComplexNDArray)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
933 BSXFUN_STDREL_DEFS_MXLOOP (ComplexNDArray)
26abff55f6fe optimize bsxfun for common built-in operations
Jaroslav Hajek <highegg@gmail.com>
parents: 9732
diff changeset
934
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9825
diff changeset
935 BSXFUN_OP_DEF_MXLOOP (pow, ComplexNDArray, mx_inline_pow)