| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# GENERATED WITH PDL::PP from complex.pd! Don't modify! |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
package PDL::Complex; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our @EXPORT_OK = qw(Ctan Catan re im i cplx real r2C i2C Cr2p Cp2r Cadd Csub Cmul Cprodover Cscale Cdiv Ceq Cconj Cabs Cabs2 Carg Csin Ccos Cexp Clog Cpow Csqrt Casin Cacos Csinh Ccosh Ctanh Casinh Cacosh Catanh Cproj Croots rCpolynomial Ctricpy Cmstack Caugment ); |
|
7
|
|
|
|
|
|
|
our %EXPORT_TAGS = (Func=>\@EXPORT_OK); |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
114499
|
use PDL::Core(); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
34
|
|
|
10
|
1
|
|
|
1
|
|
25
|
use PDL::Exporter; |
|
|
1
|
|
|
|
|
9
|
|
|
|
1
|
|
|
|
|
10
|
|
|
11
|
1
|
|
|
1
|
|
33
|
use DynaLoader; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
90
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
BEGIN { |
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
23
|
our @ISA = ( 'PDL::Exporter','DynaLoader','PDL' ); |
|
16
|
1
|
|
|
|
|
3
|
push @PDL::Core::PP, __PACKAGE__; |
|
17
|
1
|
|
|
|
|
925
|
bootstrap PDL::Complex ; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#line 18 "complex.pd" |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use strict; |
|
29
|
|
|
|
|
|
|
use warnings; |
|
30
|
|
|
|
|
|
|
use Carp; |
|
31
|
|
|
|
|
|
|
our $VERSION = '2.011'; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=encoding utf8 |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 NAME |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
PDL::Complex - handle complex numbers (DEPRECATED - use native complex) |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
use PDL; |
|
42
|
|
|
|
|
|
|
use PDL::Complex; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
This module is deprecated in favour of using "native complex" data types, e.g.: |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
use PDL; |
|
49
|
|
|
|
|
|
|
my $complex_pdl = cdouble('[1+3i]'); |
|
50
|
|
|
|
|
|
|
print $complex_pdl * pdl('i'); # [-3+i] |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
This module features a growing number of functions manipulating complex |
|
53
|
|
|
|
|
|
|
numbers. These are usually represented as a pair C<[ real imag ]> or |
|
54
|
|
|
|
|
|
|
C<[ magnitude phase ]>. If not explicitly mentioned, the functions can work |
|
55
|
|
|
|
|
|
|
inplace (not yet implemented!!!) and require rectangular form. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
While there is a procedural interface available (C<< $x/$y*$c <=> Cmul |
|
58
|
|
|
|
|
|
|
(Cdiv ($x, $y), $c) >>), you can also opt to cast your pdl's into the |
|
59
|
|
|
|
|
|
|
C datatype, which works just like your normal ndarrays, but |
|
60
|
|
|
|
|
|
|
with all the normal perl operators overloaded. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
The latter means that C will be evaluated using the |
|
63
|
|
|
|
|
|
|
normal rules of complex numbers, while other pdl functions (like C) |
|
64
|
|
|
|
|
|
|
just treat the ndarray as a real-valued ndarray with a lowest dimension of |
|
65
|
|
|
|
|
|
|
size 2, so C will return the maximum of all real and imaginary parts, |
|
66
|
|
|
|
|
|
|
not the "highest" (for some definition) |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 Native complex support |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
2.027 added changes in complex number handling, with support for C99 |
|
71
|
|
|
|
|
|
|
complex floating-point types, and most functions and modules in the core |
|
72
|
|
|
|
|
|
|
distribution support these as well. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
PDL can now handle complex numbers natively as scalars. This has |
|
75
|
|
|
|
|
|
|
the advantage that real and complex valued ndarrays have the same |
|
76
|
|
|
|
|
|
|
dimensions. Consider this when writing code in the future. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
See L, L, L, L, |
|
79
|
|
|
|
|
|
|
L for more. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 TIPS, TRICKS & CAVEATS |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=over 4 |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item * |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
C is a function (not, as of 2.047, a constant) exported by this module, |
|
88
|
|
|
|
|
|
|
which represents C<-1**0.5>, i.e. the imaginary unit. it can be used to |
|
89
|
|
|
|
|
|
|
quickly and conveniently write complex constants like this: C<4+3*i>. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
B This will override the PDL::Core function of the same name, which |
|
92
|
|
|
|
|
|
|
returns a native complex value. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item * |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Use C to convert from real to complex, as in C<$r |
|
97
|
|
|
|
|
|
|
= Cpow $cplx, r2C 2>. The overloaded operators automatically do that for |
|
98
|
|
|
|
|
|
|
you, all the other functions, do not. So C will return all |
|
99
|
|
|
|
|
|
|
the fifths roots of 1+1*i (due to broadcasting). |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item * |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
use C to cast from normal ndarrays into the |
|
104
|
|
|
|
|
|
|
complex datatype. Use C to cast back. This |
|
105
|
|
|
|
|
|
|
requires a copy, though. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=back |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 EXAMPLE WALK-THROUGH |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
The complex constant five is equal to C: |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
pdl> p $x = r2C 5 |
|
114
|
|
|
|
|
|
|
5 +0i |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Now calculate the three cubic roots of five: |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
pdl> p $r = Croots $x, 3 |
|
119
|
|
|
|
|
|
|
[1.70998 +0i -0.854988 +1.48088i -0.854988 -1.48088i] |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Check that these really are the roots: |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
pdl> p $r ** 3 |
|
124
|
|
|
|
|
|
|
[5 +0i 5 -1.22465e-15i 5 -7.65714e-15i] |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Duh! Could be better. Now try by multiplying C<$r> three times with itself: |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
pdl> p $r*$r*$r |
|
129
|
|
|
|
|
|
|
[5 +0i 5 -4.72647e-15i 5 -7.53694e-15i] |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Well... maybe C (which is used by the C<**> operator) isn't as |
|
132
|
|
|
|
|
|
|
bad as I thought. Now multiply by C and negate, then take the complex |
|
133
|
|
|
|
|
|
|
conjugate, which is just a very expensive way of swapping real and |
|
134
|
|
|
|
|
|
|
imaginary parts. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
pdl> p Cconj(-($r*i)) |
|
137
|
|
|
|
|
|
|
[0 +1.70998i 1.48088 -0.854988i -1.48088 -0.854988i] |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Now plot the magnitude of (part of) the complex sine. First generate the |
|
140
|
|
|
|
|
|
|
coefficients: |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
pdl> $sin = i * zeroes(50)->xlinvals(2,4) + zeroes(50)->xlinvals(0,7) |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Now plot the imaginary part, the real part and the magnitude of the sine |
|
145
|
|
|
|
|
|
|
into the same diagram: |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
pdl> use PDL::Graphics::Gnuplot |
|
148
|
|
|
|
|
|
|
pdl> gplot( with => 'lines', |
|
149
|
|
|
|
|
|
|
PDL::cat(im ( sin $sin ), |
|
150
|
|
|
|
|
|
|
re ( sin $sin ), |
|
151
|
|
|
|
|
|
|
abs( sin $sin ) )) |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
An ASCII version of this plot looks like this: |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
30 ++-----+------+------+------+------+------+------+------+------+-----++ |
|
156
|
|
|
|
|
|
|
+ + + + + + + + + + + |
|
157
|
|
|
|
|
|
|
| $$| |
|
158
|
|
|
|
|
|
|
| $ | |
|
159
|
|
|
|
|
|
|
25 ++ $$ ++ |
|
160
|
|
|
|
|
|
|
| *** | |
|
161
|
|
|
|
|
|
|
| ** *** | |
|
162
|
|
|
|
|
|
|
| $$* *| |
|
163
|
|
|
|
|
|
|
20 ++ $** ++ |
|
164
|
|
|
|
|
|
|
| $$$* #| |
|
165
|
|
|
|
|
|
|
| $$$ * # | |
|
166
|
|
|
|
|
|
|
| $$ * # | |
|
167
|
|
|
|
|
|
|
15 ++ $$$ * # ++ |
|
168
|
|
|
|
|
|
|
| $$$ ** # | |
|
169
|
|
|
|
|
|
|
| $$$$ * # | |
|
170
|
|
|
|
|
|
|
| $$$$ * # | |
|
171
|
|
|
|
|
|
|
10 ++ $$$$$ * # ++ |
|
172
|
|
|
|
|
|
|
| $$$$$ * # | |
|
173
|
|
|
|
|
|
|
| $$$$$$$ * # | |
|
174
|
|
|
|
|
|
|
5 ++ $$$############ * # ++ |
|
175
|
|
|
|
|
|
|
|*****$$$### ### * # | |
|
176
|
|
|
|
|
|
|
* #***** # * # | |
|
177
|
|
|
|
|
|
|
| ### *** ### ** # | |
|
178
|
|
|
|
|
|
|
0 ## *** # * # ++ |
|
179
|
|
|
|
|
|
|
| * # * # | |
|
180
|
|
|
|
|
|
|
| *** # ** # | |
|
181
|
|
|
|
|
|
|
| * # * # | |
|
182
|
|
|
|
|
|
|
-5 ++ ** # * # ++ |
|
183
|
|
|
|
|
|
|
| *** ## ** # | |
|
184
|
|
|
|
|
|
|
| * #* # | |
|
185
|
|
|
|
|
|
|
| **** ***## # | |
|
186
|
|
|
|
|
|
|
-10 ++ **** # # ++ |
|
187
|
|
|
|
|
|
|
| # # | |
|
188
|
|
|
|
|
|
|
| ## ## | |
|
189
|
|
|
|
|
|
|
+ + + + + + + ### + ### + + + |
|
190
|
|
|
|
|
|
|
-15 ++-----+------+------+------+------+------+-----###-----+------+-----++ |
|
191
|
|
|
|
|
|
|
0 5 10 15 20 25 30 35 40 45 50 |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 OPERATORS |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
The following operators are overloaded: |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=over 4 |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=item +, += (addition) |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item -, -= (subtraction) |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=item *, *= (multiplication; L) |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=item /, /= (division; L) |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item **, **= (exponentiation; L) |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=item atan2 (4-quadrant arc tangent) |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=item sin (L) |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item cos (L) |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=item exp (L) |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=item abs (L) |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=item log (L) |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=item sqrt (L) |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item ++, -- (increment, decrement; they affect the real part of the complex number only) |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=item "" (stringification) |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=back |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Comparing complex numbers other than for equality is a fatal error. |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=cut |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
my $i; |
|
234
|
|
|
|
|
|
|
BEGIN { $i = bless PDL->pdl(0,1) } |
|
235
|
|
|
|
|
|
|
{ |
|
236
|
|
|
|
|
|
|
no warnings 'redefine'; |
|
237
|
|
|
|
|
|
|
sub i { $i->copy + (@_ ? $_[0] : 0) }; |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
# sensible aliases from PDL::LinearAlgebra |
|
241
|
|
|
|
|
|
|
*r2p = \&Cr2p; |
|
242
|
|
|
|
|
|
|
*p2r = \&Cp2r; |
|
243
|
|
|
|
|
|
|
*conj = \&Cconj; |
|
244
|
|
|
|
|
|
|
*abs = \&Cabs; |
|
245
|
|
|
|
|
|
|
*abs2 = \&Cabs2; |
|
246
|
|
|
|
|
|
|
*arg = \&Carg; |
|
247
|
|
|
|
|
|
|
*tan = \&Ctan; |
|
248
|
|
|
|
|
|
|
*proj = \&Cproj; |
|
249
|
|
|
|
|
|
|
*asin = \&Casin; |
|
250
|
|
|
|
|
|
|
*acos = \&Cacos; |
|
251
|
|
|
|
|
|
|
*atan = \&Catan; |
|
252
|
|
|
|
|
|
|
*sinh = \&Csinh; |
|
253
|
|
|
|
|
|
|
*cosh = \&Ccosh; |
|
254
|
|
|
|
|
|
|
*tanh = \&Ctanh; |
|
255
|
|
|
|
|
|
|
*asinh = \&Casinh; |
|
256
|
|
|
|
|
|
|
*acosh = \&Cacosh; |
|
257
|
|
|
|
|
|
|
*atanh = \&Catanh; |
|
258
|
|
|
|
|
|
|
*tricpy = \&Ctricpy; |
|
259
|
|
|
|
|
|
|
*mstack = \&Cmstack; |
|
260
|
|
|
|
|
|
|
*augment = \&Caugment; |
|
261
|
|
|
|
|
|
|
#line 262 "Complex.pm" |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=cut |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
#line 333 "complex.pd" |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head2 from_native |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=for ref |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
Class method to convert a native-complex ndarray to a PDL::Complex object. |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=for usage |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
PDL::Complex->from_native($native_complex_ndarray) |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=cut |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
sub from_native { |
|
287
|
|
|
|
|
|
|
my ($class, $ndarray) = @_; |
|
288
|
|
|
|
|
|
|
return $ndarray if UNIVERSAL::isa($ndarray,'PDL::Complex'); # NOOP if P:C |
|
289
|
|
|
|
|
|
|
croak "not an ndarray" if !UNIVERSAL::isa($ndarray,'PDL'); |
|
290
|
|
|
|
|
|
|
croak "not a native complex ndarray" if $ndarray->type->real; |
|
291
|
|
|
|
|
|
|
bless PDL::append($ndarray->re->dummy(0),$ndarray->im->dummy(0)), $class; |
|
292
|
|
|
|
|
|
|
} |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=head2 as_native |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
=for ref |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
Object method to convert a PDL::Complex object to a native-complex ndarray. |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=for usage |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
$pdl_complex_obj->as_native |
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=cut |
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
sub as_native { |
|
307
|
|
|
|
|
|
|
PDL::Ops::czip(map $_[0]->slice("($_)"), 0..1); |
|
308
|
|
|
|
|
|
|
} |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=head2 cplx |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=for ref |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
Cast a real-valued ndarray to the complex datatype. |
|
315
|
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
The first dimension of the ndarray must be of size 2. After this the |
|
317
|
|
|
|
|
|
|
usual (complex) arithmetic operators are applied to this pdl, rather |
|
318
|
|
|
|
|
|
|
than the normal elementwise pdl operators. Dataflow to the complex |
|
319
|
|
|
|
|
|
|
parent works. Use C on the result if you don't want this. |
|
320
|
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
=for usage |
|
322
|
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
cplx($real_valued_pdl) |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=head2 complex |
|
326
|
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
=for ref |
|
328
|
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
Cast a real-valued ndarray to the complex datatype I dataflow |
|
330
|
|
|
|
|
|
|
and I. |
|
331
|
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
Achieved by merely reblessing an ndarray. The first dimension of the |
|
333
|
|
|
|
|
|
|
ndarray must be of size 2. |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
=for usage |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
complex($real_valued_pdl) |
|
338
|
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=head2 real |
|
340
|
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
=for ref |
|
342
|
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
Cast a complex valued pdl back to the "normal" pdl datatype. |
|
344
|
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
Afterwards the normal elementwise pdl operators are used in |
|
346
|
|
|
|
|
|
|
operations. Dataflow to the real parent works. Use C on the |
|
347
|
|
|
|
|
|
|
result if you don't want this. |
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
=for usage |
|
350
|
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
real($cplx_valued_pdl) |
|
352
|
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
=cut |
|
354
|
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
sub cplx($) { |
|
356
|
|
|
|
|
|
|
return $_[0] if UNIVERSAL::isa($_[0],'PDL::Complex'); # NOOP if just ndarray |
|
357
|
|
|
|
|
|
|
croak "first dimsize must be 2" unless $_[0]->dims > 0 && $_[0]->dim(0) == 2; |
|
358
|
|
|
|
|
|
|
bless $_[0]->slice(''); |
|
359
|
|
|
|
|
|
|
} |
|
360
|
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
sub complex($) { |
|
362
|
|
|
|
|
|
|
return $_[0] if UNIVERSAL::isa($_[0],'PDL::Complex'); # NOOP if just ndarray |
|
363
|
|
|
|
|
|
|
croak "first dimsize must be 2" unless $_[0]->dims > 0 && $_[0]->dim(0) == 2; |
|
364
|
|
|
|
|
|
|
bless $_[0]; |
|
365
|
|
|
|
|
|
|
} |
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
*PDL::cplx = \&cplx; |
|
368
|
|
|
|
|
|
|
*PDL::complex = \&complex; |
|
369
|
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
sub real($) { |
|
371
|
|
|
|
|
|
|
return $_[0] unless UNIVERSAL::isa($_[0],'PDL::Complex'); # NOOP unless complex |
|
372
|
|
|
|
|
|
|
bless $_[0]->slice(''), 'PDL'; |
|
373
|
|
|
|
|
|
|
} |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
=head2 t |
|
376
|
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
=for usage |
|
378
|
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
$pdl = $pdl->t(SCALAR(conj)) |
|
380
|
|
|
|
|
|
|
conj : Conjugate Transpose = 1 | Transpose = 0, default = 0; |
|
381
|
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
=for ref |
|
383
|
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
Convenient function for transposing real or complex 2D array(s). |
|
385
|
|
|
|
|
|
|
For complex data, if conj is true returns conjugate transposed array(s). |
|
386
|
|
|
|
|
|
|
Supports broadcasting. Not exported. |
|
387
|
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
Originally by Grégory Vanuxem. |
|
389
|
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
=cut |
|
391
|
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
sub t { |
|
393
|
|
|
|
|
|
|
my ($m, $conj) = @_; |
|
394
|
|
|
|
|
|
|
my $ndims = $m->dims; |
|
395
|
|
|
|
|
|
|
my $r = $ndims > 2 ? $m->xchg(1,2) : |
|
396
|
|
|
|
|
|
|
$ndims > 1 ? $m->dummy(1) : |
|
397
|
|
|
|
|
|
|
$m->dummy(1)->dummy(1); |
|
398
|
|
|
|
|
|
|
$conj ? $r->conj : $r; |
|
399
|
|
|
|
|
|
|
} |
|
400
|
|
|
|
|
|
|
#line 401 "Complex.pm" |
|
401
|
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
=head2 r2C |
|
404
|
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
=for sig |
|
406
|
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
Signature: (r(); [o]c(m=2)) |
|
408
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
409
|
|
|
|
|
|
|
float double ldouble) |
|
410
|
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
=for usage |
|
412
|
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
$c = r2C($r); |
|
414
|
|
|
|
|
|
|
r2C($r, $c); # all arguments given |
|
415
|
|
|
|
|
|
|
$c = $r->r2C; # method call |
|
416
|
|
|
|
|
|
|
$r->r2C($c); |
|
417
|
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
=for ref |
|
419
|
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
convert real to complex, assuming an imaginary part of zero |
|
421
|
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
=pod |
|
423
|
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
425
|
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
=for bad |
|
427
|
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
C does not process bad values. |
|
429
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
430
|
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
=cut |
|
432
|
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
undef &PDL::r2C; |
|
438
|
|
|
|
|
|
|
*PDL::r2C = \&PDL::Complex::r2C; |
|
439
|
|
|
|
|
|
|
sub PDL::Complex::r2C { |
|
440
|
133
|
50
|
|
133
|
1
|
3946
|
return $_[0] if UNIVERSAL::isa($_[0],'PDL::Complex'); |
|
441
|
133
|
|
|
|
|
269
|
my $r = __PACKAGE__->initialize; |
|
442
|
133
|
|
|
|
|
2903
|
&PDL::Complex::_r2C_int($_[0], $r); |
|
443
|
133
|
|
|
|
|
1442
|
$r } |
|
444
|
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
|
|
448
|
1
|
|
|
1
|
|
105
|
BEGIN {*r2C = \&PDL::Complex::r2C; |
|
449
|
|
|
|
|
|
|
} |
|
450
|
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
=head2 i2C |
|
456
|
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
=for sig |
|
458
|
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
Signature: (r(); [o]c(m=2)) |
|
460
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
461
|
|
|
|
|
|
|
float double ldouble) |
|
462
|
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=for usage |
|
464
|
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
$c = i2C($r); |
|
466
|
|
|
|
|
|
|
i2C($r, $c); # all arguments given |
|
467
|
|
|
|
|
|
|
$c = $r->i2C; # method call |
|
468
|
|
|
|
|
|
|
$r->i2C($c); |
|
469
|
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
=for ref |
|
471
|
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
convert imaginary to complex, assuming a real part of zero |
|
473
|
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
=pod |
|
475
|
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
477
|
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
=for bad |
|
479
|
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
C does not process bad values. |
|
481
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
482
|
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
=cut |
|
484
|
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
|
|
488
|
3
|
|
|
3
|
1
|
9
|
undef &PDL::i2C; *PDL::i2C = \&PDL::Complex::i2C; sub PDL::Complex::i2C { my $r = __PACKAGE__->initialize; &PDL::Complex::_i2C_int($_[0], $r); $r } |
|
|
3
|
|
|
|
|
67
|
|
|
|
3
|
|
|
|
|
9
|
|
|
489
|
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
|
|
491
|
1
|
|
|
1
|
|
31
|
BEGIN {*i2C = \&PDL::Complex::i2C; |
|
492
|
|
|
|
|
|
|
} |
|
493
|
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
=head2 Cr2p |
|
499
|
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
=for sig |
|
501
|
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
Signature: (r(m=2); [o]p(m=2)) |
|
503
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
504
|
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
=for usage |
|
506
|
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
$p = Cr2p($r); |
|
508
|
|
|
|
|
|
|
Cr2p($r, $p); # all arguments given |
|
509
|
|
|
|
|
|
|
$p = $r->Cr2p; # method call |
|
510
|
|
|
|
|
|
|
$r->Cr2p($p); |
|
511
|
|
|
|
|
|
|
$r->inplace->Cr2p; # can be used inplace |
|
512
|
|
|
|
|
|
|
Cr2p($r->inplace); |
|
513
|
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
=for ref |
|
515
|
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
convert complex numbers in rectangular form to polar (mod,arg) form. Works inplace |
|
517
|
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
=pod |
|
519
|
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
521
|
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
=for bad |
|
523
|
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
C does not process bad values. |
|
525
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
526
|
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
=cut |
|
528
|
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
|
|
532
|
1
|
|
|
1
|
|
27
|
BEGIN {*Cr2p = \&PDL::Complex::Cr2p; |
|
533
|
|
|
|
|
|
|
} |
|
534
|
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
=head2 Cp2r |
|
540
|
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
=for sig |
|
542
|
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
Signature: (r(m=2); [o]p(m=2)) |
|
544
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
545
|
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
=for usage |
|
547
|
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
$p = Cp2r($r); |
|
549
|
|
|
|
|
|
|
Cp2r($r, $p); # all arguments given |
|
550
|
|
|
|
|
|
|
$p = $r->Cp2r; # method call |
|
551
|
|
|
|
|
|
|
$r->Cp2r($p); |
|
552
|
|
|
|
|
|
|
$r->inplace->Cp2r; # can be used inplace |
|
553
|
|
|
|
|
|
|
Cp2r($r->inplace); |
|
554
|
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
=for ref |
|
556
|
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
convert complex numbers in polar (mod,arg) form to rectangular form. Works inplace |
|
558
|
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
=pod |
|
560
|
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
562
|
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
=for bad |
|
564
|
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
C does not process bad values. |
|
566
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
567
|
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
=cut |
|
569
|
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
|
|
573
|
1
|
|
|
1
|
|
40
|
BEGIN {*Cp2r = \&PDL::Complex::Cp2r; |
|
574
|
|
|
|
|
|
|
} |
|
575
|
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
|
|
578
|
1
|
|
|
1
|
|
49
|
BEGIN {*Cadd = \&PDL::Complex::Cadd; |
|
579
|
|
|
|
|
|
|
} |
|
580
|
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
|
|
583
|
1
|
|
|
1
|
|
47
|
BEGIN {*Csub = \&PDL::Complex::Csub; |
|
584
|
|
|
|
|
|
|
} |
|
585
|
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
=head2 Cmul |
|
591
|
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
=for sig |
|
593
|
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
Signature: (a(m=2); b(m=2); [o]c(m=2)) |
|
595
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
596
|
|
|
|
|
|
|
float double ldouble) |
|
597
|
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
=for usage |
|
599
|
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
$c = Cmul($a, $b); |
|
601
|
|
|
|
|
|
|
Cmul($a, $b, $c); # all arguments given |
|
602
|
|
|
|
|
|
|
$c = $a->Cmul($b); # method call |
|
603
|
|
|
|
|
|
|
$a->Cmul($b, $c); |
|
604
|
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
=for ref |
|
606
|
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
complex multiplication |
|
608
|
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
=pod |
|
610
|
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
612
|
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
=for bad |
|
614
|
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
C does not process bad values. |
|
616
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
617
|
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
=cut |
|
619
|
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
|
|
623
|
1
|
|
|
1
|
|
40
|
BEGIN {*Cmul = \&PDL::Complex::Cmul; |
|
624
|
|
|
|
|
|
|
} |
|
625
|
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
=head2 Cprodover |
|
631
|
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
=for sig |
|
633
|
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
Signature: (a(m=2,n); [o]c(m=2)) |
|
635
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
636
|
|
|
|
|
|
|
float double ldouble) |
|
637
|
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
=for usage |
|
639
|
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
$c = Cprodover($a); |
|
641
|
|
|
|
|
|
|
Cprodover($a, $c); # all arguments given |
|
642
|
|
|
|
|
|
|
$c = $a->Cprodover; # method call |
|
643
|
|
|
|
|
|
|
$a->Cprodover($c); |
|
644
|
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
=for ref |
|
646
|
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
Project via product to N-1 dimension |
|
648
|
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
=pod |
|
650
|
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
652
|
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
=for bad |
|
654
|
|
|
|
|
|
|
|
|
655
|
|
|
|
|
|
|
C does not process bad values. |
|
656
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
657
|
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
=cut |
|
659
|
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
|
|
663
|
1
|
|
|
1
|
|
30
|
BEGIN {*Cprodover = \&PDL::Complex::Cprodover; |
|
664
|
|
|
|
|
|
|
} |
|
665
|
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
=head2 Cscale |
|
671
|
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
=for sig |
|
673
|
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
Signature: (a(m=2); b(); [o]c(m=2)) |
|
675
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
676
|
|
|
|
|
|
|
float double ldouble) |
|
677
|
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
=for usage |
|
679
|
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
$c = Cscale($a, $b); |
|
681
|
|
|
|
|
|
|
Cscale($a, $b, $c); # all arguments given |
|
682
|
|
|
|
|
|
|
$c = $a->Cscale($b); # method call |
|
683
|
|
|
|
|
|
|
$a->Cscale($b, $c); |
|
684
|
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
=for ref |
|
686
|
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
mixed complex/real multiplication |
|
688
|
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
=pod |
|
690
|
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
692
|
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
=for bad |
|
694
|
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
C does not process bad values. |
|
696
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
697
|
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
=cut |
|
699
|
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
|
|
703
|
1
|
|
|
1
|
|
46
|
BEGIN {*Cscale = \&PDL::Complex::Cscale; |
|
704
|
|
|
|
|
|
|
} |
|
705
|
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
=head2 Cdiv |
|
711
|
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
=for sig |
|
713
|
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
Signature: (a(m=2); b(m=2); [o]c(m=2)) |
|
715
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
716
|
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
=for usage |
|
718
|
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
$c = Cdiv($a, $b); |
|
720
|
|
|
|
|
|
|
Cdiv($a, $b, $c); # all arguments given |
|
721
|
|
|
|
|
|
|
$c = $a->Cdiv($b); # method call |
|
722
|
|
|
|
|
|
|
$a->Cdiv($b, $c); |
|
723
|
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
=for ref |
|
725
|
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
complex division |
|
727
|
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
=pod |
|
729
|
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
731
|
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
=for bad |
|
733
|
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
C does not process bad values. |
|
735
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
736
|
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
=cut |
|
738
|
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
|
|
740
|
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
|
|
742
|
1
|
|
|
1
|
|
168
|
BEGIN {*Cdiv = \&PDL::Complex::Cdiv; |
|
743
|
|
|
|
|
|
|
} |
|
744
|
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
|
|
748
|
|
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
=head2 Ceq |
|
750
|
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
=for sig |
|
752
|
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
Signature: (a(m=2); b(m=2); [o]c()) |
|
754
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
755
|
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
=for usage |
|
757
|
|
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
$c = Ceq($a, $b); |
|
759
|
|
|
|
|
|
|
Ceq($a, $b, $c); # all arguments given |
|
760
|
|
|
|
|
|
|
$c = $a->Ceq($b); # method call |
|
761
|
|
|
|
|
|
|
$a->Ceq($b, $c); |
|
762
|
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
=for ref |
|
764
|
|
|
|
|
|
|
|
|
765
|
|
|
|
|
|
|
Complex equality operator. |
|
766
|
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
=pod |
|
768
|
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
770
|
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
=for bad |
|
772
|
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
C does not process bad values. |
|
774
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
775
|
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
=cut |
|
777
|
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
|
|
779
|
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
sub PDL::Complex::Ceq { |
|
782
|
8
|
50
|
|
8
|
1
|
21
|
my @args = !$_[2] ? @_[1,0] : @_[0,1]; |
|
783
|
8
|
50
|
|
|
|
55
|
$args[1] = r2C($args[1]) if ref $args[1] ne __PACKAGE__; |
|
784
|
8
|
|
|
|
|
17
|
PDL::Complex::_Ceq_int($args[0], $args[1], my $r = PDL->null); |
|
785
|
8
|
|
|
|
|
164
|
$r; |
|
786
|
|
|
|
|
|
|
} |
|
787
|
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
|
|
790
|
1
|
|
|
1
|
|
31
|
BEGIN {*Ceq = \&PDL::Complex::Ceq; |
|
791
|
|
|
|
|
|
|
} |
|
792
|
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
|
|
796
|
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
=head2 Cconj |
|
798
|
|
|
|
|
|
|
|
|
799
|
|
|
|
|
|
|
=for sig |
|
800
|
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c(m=2)) |
|
802
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
803
|
|
|
|
|
|
|
float double ldouble) |
|
804
|
|
|
|
|
|
|
|
|
805
|
|
|
|
|
|
|
=for usage |
|
806
|
|
|
|
|
|
|
|
|
807
|
|
|
|
|
|
|
$c = Cconj($a); |
|
808
|
|
|
|
|
|
|
Cconj($a, $c); # all arguments given |
|
809
|
|
|
|
|
|
|
$c = $a->Cconj; # method call |
|
810
|
|
|
|
|
|
|
$a->Cconj($c); |
|
811
|
|
|
|
|
|
|
$a->inplace->Cconj; # can be used inplace |
|
812
|
|
|
|
|
|
|
Cconj($a->inplace); |
|
813
|
|
|
|
|
|
|
|
|
814
|
|
|
|
|
|
|
=for ref |
|
815
|
|
|
|
|
|
|
|
|
816
|
|
|
|
|
|
|
complex conjugation. Works inplace |
|
817
|
|
|
|
|
|
|
|
|
818
|
|
|
|
|
|
|
=pod |
|
819
|
|
|
|
|
|
|
|
|
820
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
821
|
|
|
|
|
|
|
|
|
822
|
|
|
|
|
|
|
=for bad |
|
823
|
|
|
|
|
|
|
|
|
824
|
|
|
|
|
|
|
C does not process bad values. |
|
825
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
826
|
|
|
|
|
|
|
|
|
827
|
|
|
|
|
|
|
=cut |
|
828
|
|
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
|
|
830
|
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
|
|
832
|
1
|
|
|
1
|
|
80
|
BEGIN {*Cconj = \&PDL::Complex::Cconj; |
|
833
|
|
|
|
|
|
|
} |
|
834
|
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
|
|
836
|
|
|
|
|
|
|
|
|
837
|
|
|
|
|
|
|
|
|
838
|
|
|
|
|
|
|
|
|
839
|
|
|
|
|
|
|
=head2 Cabs |
|
840
|
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
=for sig |
|
842
|
|
|
|
|
|
|
|
|
843
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c()) |
|
844
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
845
|
|
|
|
|
|
|
|
|
846
|
|
|
|
|
|
|
=for usage |
|
847
|
|
|
|
|
|
|
|
|
848
|
|
|
|
|
|
|
$c = Cabs($a); |
|
849
|
|
|
|
|
|
|
Cabs($a, $c); # all arguments given |
|
850
|
|
|
|
|
|
|
$c = $a->Cabs; # method call |
|
851
|
|
|
|
|
|
|
$a->Cabs($c); |
|
852
|
|
|
|
|
|
|
|
|
853
|
|
|
|
|
|
|
=for ref |
|
854
|
|
|
|
|
|
|
|
|
855
|
|
|
|
|
|
|
complex C (also known as I) |
|
856
|
|
|
|
|
|
|
|
|
857
|
|
|
|
|
|
|
=pod |
|
858
|
|
|
|
|
|
|
|
|
859
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
860
|
|
|
|
|
|
|
|
|
861
|
|
|
|
|
|
|
=for bad |
|
862
|
|
|
|
|
|
|
|
|
863
|
|
|
|
|
|
|
C does not process bad values. |
|
864
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
865
|
|
|
|
|
|
|
|
|
866
|
|
|
|
|
|
|
=cut |
|
867
|
|
|
|
|
|
|
|
|
868
|
|
|
|
|
|
|
|
|
869
|
|
|
|
|
|
|
|
|
870
|
|
|
|
|
|
|
|
|
871
|
|
|
|
|
|
|
sub PDL::Complex::Cabs($) { |
|
872
|
6
|
|
|
6
|
1
|
180
|
my $pdl= shift; |
|
873
|
6
|
|
|
|
|
20
|
my $abs = PDL->null; |
|
874
|
6
|
|
|
|
|
122
|
&PDL::Complex::_Cabs_int($pdl, $abs); |
|
875
|
6
|
|
|
|
|
105
|
$abs; |
|
876
|
|
|
|
|
|
|
} |
|
877
|
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
|
|
879
|
1
|
|
|
1
|
|
73
|
BEGIN {*Cabs = \&PDL::Complex::Cabs; |
|
880
|
|
|
|
|
|
|
} |
|
881
|
|
|
|
|
|
|
|
|
882
|
|
|
|
|
|
|
|
|
883
|
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
|
|
885
|
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
=head2 Cabs2 |
|
887
|
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
=for sig |
|
889
|
|
|
|
|
|
|
|
|
890
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c()) |
|
891
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
892
|
|
|
|
|
|
|
float double ldouble) |
|
893
|
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
=for usage |
|
895
|
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
$c = Cabs2($a); |
|
897
|
|
|
|
|
|
|
Cabs2($a, $c); # all arguments given |
|
898
|
|
|
|
|
|
|
$c = $a->Cabs2; # method call |
|
899
|
|
|
|
|
|
|
$a->Cabs2($c); |
|
900
|
|
|
|
|
|
|
|
|
901
|
|
|
|
|
|
|
=for ref |
|
902
|
|
|
|
|
|
|
|
|
903
|
|
|
|
|
|
|
complex squared C (also known I) |
|
904
|
|
|
|
|
|
|
|
|
905
|
|
|
|
|
|
|
=pod |
|
906
|
|
|
|
|
|
|
|
|
907
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
908
|
|
|
|
|
|
|
|
|
909
|
|
|
|
|
|
|
=for bad |
|
910
|
|
|
|
|
|
|
|
|
911
|
|
|
|
|
|
|
C does not process bad values. |
|
912
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
913
|
|
|
|
|
|
|
|
|
914
|
|
|
|
|
|
|
=cut |
|
915
|
|
|
|
|
|
|
|
|
916
|
|
|
|
|
|
|
|
|
917
|
|
|
|
|
|
|
|
|
918
|
|
|
|
|
|
|
|
|
919
|
|
|
|
|
|
|
sub PDL::Complex::Cabs2($) { |
|
920
|
2
|
|
|
2
|
1
|
68
|
my $pdl= shift; |
|
921
|
2
|
|
|
|
|
11
|
my $abs2 = PDL->null; |
|
922
|
2
|
|
|
|
|
52
|
&PDL::Complex::_Cabs2_int($pdl, $abs2); |
|
923
|
2
|
|
|
|
|
12
|
$abs2; |
|
924
|
|
|
|
|
|
|
} |
|
925
|
|
|
|
|
|
|
|
|
926
|
|
|
|
|
|
|
|
|
927
|
1
|
|
|
1
|
|
74
|
BEGIN {*Cabs2 = \&PDL::Complex::Cabs2; |
|
928
|
|
|
|
|
|
|
} |
|
929
|
|
|
|
|
|
|
|
|
930
|
|
|
|
|
|
|
|
|
931
|
|
|
|
|
|
|
|
|
932
|
|
|
|
|
|
|
|
|
933
|
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
=head2 Carg |
|
935
|
|
|
|
|
|
|
|
|
936
|
|
|
|
|
|
|
=for sig |
|
937
|
|
|
|
|
|
|
|
|
938
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c()) |
|
939
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
940
|
|
|
|
|
|
|
|
|
941
|
|
|
|
|
|
|
=for usage |
|
942
|
|
|
|
|
|
|
|
|
943
|
|
|
|
|
|
|
$c = Carg($a); |
|
944
|
|
|
|
|
|
|
Carg($a, $c); # all arguments given |
|
945
|
|
|
|
|
|
|
$c = $a->Carg; # method call |
|
946
|
|
|
|
|
|
|
$a->Carg($c); |
|
947
|
|
|
|
|
|
|
|
|
948
|
|
|
|
|
|
|
=for ref |
|
949
|
|
|
|
|
|
|
|
|
950
|
|
|
|
|
|
|
complex argument function ("angle") |
|
951
|
|
|
|
|
|
|
|
|
952
|
|
|
|
|
|
|
=pod |
|
953
|
|
|
|
|
|
|
|
|
954
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
955
|
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
=for bad |
|
957
|
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
C does not process bad values. |
|
959
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
960
|
|
|
|
|
|
|
|
|
961
|
|
|
|
|
|
|
=cut |
|
962
|
|
|
|
|
|
|
|
|
963
|
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
|
|
965
|
|
|
|
|
|
|
|
|
966
|
|
|
|
|
|
|
sub PDL::Complex::Carg($) { |
|
967
|
2
|
|
|
2
|
1
|
60
|
my $pdl= shift; |
|
968
|
2
|
|
|
|
|
9
|
my $arg = PDL->null; |
|
969
|
2
|
|
|
|
|
71
|
&PDL::Complex::_Carg_int($pdl, $arg); |
|
970
|
2
|
|
|
|
|
13
|
$arg; |
|
971
|
|
|
|
|
|
|
} |
|
972
|
|
|
|
|
|
|
|
|
973
|
|
|
|
|
|
|
|
|
974
|
1
|
|
|
1
|
|
37
|
BEGIN {*Carg = \&PDL::Complex::Carg; |
|
975
|
|
|
|
|
|
|
} |
|
976
|
|
|
|
|
|
|
|
|
977
|
|
|
|
|
|
|
|
|
978
|
|
|
|
|
|
|
|
|
979
|
|
|
|
|
|
|
|
|
980
|
|
|
|
|
|
|
|
|
981
|
|
|
|
|
|
|
=head2 Csin |
|
982
|
|
|
|
|
|
|
|
|
983
|
|
|
|
|
|
|
=for sig |
|
984
|
|
|
|
|
|
|
|
|
985
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c(m=2)) |
|
986
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
987
|
|
|
|
|
|
|
|
|
988
|
|
|
|
|
|
|
=for usage |
|
989
|
|
|
|
|
|
|
|
|
990
|
|
|
|
|
|
|
$c = Csin($a); |
|
991
|
|
|
|
|
|
|
Csin($a, $c); # all arguments given |
|
992
|
|
|
|
|
|
|
$c = $a->Csin; # method call |
|
993
|
|
|
|
|
|
|
$a->Csin($c); |
|
994
|
|
|
|
|
|
|
$a->inplace->Csin; # can be used inplace |
|
995
|
|
|
|
|
|
|
Csin($a->inplace); |
|
996
|
|
|
|
|
|
|
|
|
997
|
|
|
|
|
|
|
=for ref |
|
998
|
|
|
|
|
|
|
|
|
999
|
|
|
|
|
|
|
sin (a) = 1/(2*i) * (exp (a*i) - exp (-a*i)). Works inplace |
|
1000
|
|
|
|
|
|
|
|
|
1001
|
|
|
|
|
|
|
=pod |
|
1002
|
|
|
|
|
|
|
|
|
1003
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1004
|
|
|
|
|
|
|
|
|
1005
|
|
|
|
|
|
|
=for bad |
|
1006
|
|
|
|
|
|
|
|
|
1007
|
|
|
|
|
|
|
C does not process bad values. |
|
1008
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1009
|
|
|
|
|
|
|
|
|
1010
|
|
|
|
|
|
|
=cut |
|
1011
|
|
|
|
|
|
|
|
|
1012
|
|
|
|
|
|
|
|
|
1013
|
|
|
|
|
|
|
|
|
1014
|
|
|
|
|
|
|
|
|
1015
|
1
|
|
|
1
|
|
28
|
BEGIN {*Csin = \&PDL::Complex::Csin; |
|
1016
|
|
|
|
|
|
|
} |
|
1017
|
|
|
|
|
|
|
|
|
1018
|
|
|
|
|
|
|
|
|
1019
|
|
|
|
|
|
|
|
|
1020
|
|
|
|
|
|
|
|
|
1021
|
|
|
|
|
|
|
|
|
1022
|
|
|
|
|
|
|
=head2 Ccos |
|
1023
|
|
|
|
|
|
|
|
|
1024
|
|
|
|
|
|
|
=for sig |
|
1025
|
|
|
|
|
|
|
|
|
1026
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c(m=2)) |
|
1027
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
1028
|
|
|
|
|
|
|
|
|
1029
|
|
|
|
|
|
|
=for usage |
|
1030
|
|
|
|
|
|
|
|
|
1031
|
|
|
|
|
|
|
$c = Ccos($a); |
|
1032
|
|
|
|
|
|
|
Ccos($a, $c); # all arguments given |
|
1033
|
|
|
|
|
|
|
$c = $a->Ccos; # method call |
|
1034
|
|
|
|
|
|
|
$a->Ccos($c); |
|
1035
|
|
|
|
|
|
|
$a->inplace->Ccos; # can be used inplace |
|
1036
|
|
|
|
|
|
|
Ccos($a->inplace); |
|
1037
|
|
|
|
|
|
|
|
|
1038
|
|
|
|
|
|
|
=for ref |
|
1039
|
|
|
|
|
|
|
|
|
1040
|
|
|
|
|
|
|
cos (a) = 1/2 * (exp (a*i) + exp (-a*i)). Works inplace |
|
1041
|
|
|
|
|
|
|
|
|
1042
|
|
|
|
|
|
|
=pod |
|
1043
|
|
|
|
|
|
|
|
|
1044
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1045
|
|
|
|
|
|
|
|
|
1046
|
|
|
|
|
|
|
=for bad |
|
1047
|
|
|
|
|
|
|
|
|
1048
|
|
|
|
|
|
|
C does not process bad values. |
|
1049
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1050
|
|
|
|
|
|
|
|
|
1051
|
|
|
|
|
|
|
=cut |
|
1052
|
|
|
|
|
|
|
|
|
1053
|
|
|
|
|
|
|
|
|
1054
|
|
|
|
|
|
|
|
|
1055
|
|
|
|
|
|
|
|
|
1056
|
1
|
|
|
1
|
|
76
|
BEGIN {*Ccos = \&PDL::Complex::Ccos; |
|
1057
|
|
|
|
|
|
|
} |
|
1058
|
|
|
|
|
|
|
|
|
1059
|
|
|
|
|
|
|
|
|
1060
|
|
|
|
|
|
|
|
|
1061
|
|
|
|
|
|
|
|
|
1062
|
|
|
|
|
|
|
#line 713 "complex.pd" |
|
1063
|
|
|
|
|
|
|
|
|
1064
|
|
|
|
|
|
|
=head2 Ctan |
|
1065
|
|
|
|
|
|
|
|
|
1066
|
|
|
|
|
|
|
=for ref |
|
1067
|
|
|
|
|
|
|
|
|
1068
|
|
|
|
|
|
|
Complex tangent |
|
1069
|
|
|
|
|
|
|
|
|
1070
|
|
|
|
|
|
|
tan (a) = -i * (exp (a*i) - exp (-a*i)) / (exp (a*i) + exp (-a*i)) |
|
1071
|
|
|
|
|
|
|
|
|
1072
|
|
|
|
|
|
|
Does not work inplace. |
|
1073
|
|
|
|
|
|
|
|
|
1074
|
|
|
|
|
|
|
=cut |
|
1075
|
|
|
|
|
|
|
|
|
1076
|
|
|
|
|
|
|
sub Ctan($) { Csin($_[0]) / Ccos($_[0]) } |
|
1077
|
|
|
|
|
|
|
#line 1078 "Complex.pm" |
|
1078
|
|
|
|
|
|
|
|
|
1079
|
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
=head2 Cexp |
|
1081
|
|
|
|
|
|
|
|
|
1082
|
|
|
|
|
|
|
=for sig |
|
1083
|
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c(m=2)) |
|
1085
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
1086
|
|
|
|
|
|
|
|
|
1087
|
|
|
|
|
|
|
=for usage |
|
1088
|
|
|
|
|
|
|
|
|
1089
|
|
|
|
|
|
|
$c = Cexp($a); |
|
1090
|
|
|
|
|
|
|
Cexp($a, $c); # all arguments given |
|
1091
|
|
|
|
|
|
|
$c = $a->Cexp; # method call |
|
1092
|
|
|
|
|
|
|
$a->Cexp($c); |
|
1093
|
|
|
|
|
|
|
$a->inplace->Cexp; # can be used inplace |
|
1094
|
|
|
|
|
|
|
Cexp($a->inplace); |
|
1095
|
|
|
|
|
|
|
|
|
1096
|
|
|
|
|
|
|
=for ref |
|
1097
|
|
|
|
|
|
|
|
|
1098
|
|
|
|
|
|
|
exp (a) = exp (real (a)) * (cos (imag (a)) + i * sin (imag (a))). Works inplace |
|
1099
|
|
|
|
|
|
|
|
|
1100
|
|
|
|
|
|
|
=pod |
|
1101
|
|
|
|
|
|
|
|
|
1102
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1103
|
|
|
|
|
|
|
|
|
1104
|
|
|
|
|
|
|
=for bad |
|
1105
|
|
|
|
|
|
|
|
|
1106
|
|
|
|
|
|
|
C does not process bad values. |
|
1107
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1108
|
|
|
|
|
|
|
|
|
1109
|
|
|
|
|
|
|
=cut |
|
1110
|
|
|
|
|
|
|
|
|
1111
|
|
|
|
|
|
|
|
|
1112
|
|
|
|
|
|
|
|
|
1113
|
|
|
|
|
|
|
|
|
1114
|
1
|
|
|
1
|
|
37
|
BEGIN {*Cexp = \&PDL::Complex::Cexp; |
|
1115
|
|
|
|
|
|
|
} |
|
1116
|
|
|
|
|
|
|
|
|
1117
|
|
|
|
|
|
|
|
|
1118
|
|
|
|
|
|
|
|
|
1119
|
|
|
|
|
|
|
|
|
1120
|
|
|
|
|
|
|
|
|
1121
|
|
|
|
|
|
|
=head2 Clog |
|
1122
|
|
|
|
|
|
|
|
|
1123
|
|
|
|
|
|
|
=for sig |
|
1124
|
|
|
|
|
|
|
|
|
1125
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c(m=2)) |
|
1126
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
1127
|
|
|
|
|
|
|
|
|
1128
|
|
|
|
|
|
|
=for usage |
|
1129
|
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
$c = Clog($a); |
|
1131
|
|
|
|
|
|
|
Clog($a, $c); # all arguments given |
|
1132
|
|
|
|
|
|
|
$c = $a->Clog; # method call |
|
1133
|
|
|
|
|
|
|
$a->Clog($c); |
|
1134
|
|
|
|
|
|
|
$a->inplace->Clog; # can be used inplace |
|
1135
|
|
|
|
|
|
|
Clog($a->inplace); |
|
1136
|
|
|
|
|
|
|
|
|
1137
|
|
|
|
|
|
|
=for ref |
|
1138
|
|
|
|
|
|
|
|
|
1139
|
|
|
|
|
|
|
log (a) = log (cabs (a)) + i * carg (a). Works inplace |
|
1140
|
|
|
|
|
|
|
|
|
1141
|
|
|
|
|
|
|
=pod |
|
1142
|
|
|
|
|
|
|
|
|
1143
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1144
|
|
|
|
|
|
|
|
|
1145
|
|
|
|
|
|
|
=for bad |
|
1146
|
|
|
|
|
|
|
|
|
1147
|
|
|
|
|
|
|
C does not process bad values. |
|
1148
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1149
|
|
|
|
|
|
|
|
|
1150
|
|
|
|
|
|
|
=cut |
|
1151
|
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
|
|
1153
|
|
|
|
|
|
|
|
|
1154
|
|
|
|
|
|
|
|
|
1155
|
1
|
|
|
1
|
|
30
|
BEGIN {*Clog = \&PDL::Complex::Clog; |
|
1156
|
|
|
|
|
|
|
} |
|
1157
|
|
|
|
|
|
|
|
|
1158
|
|
|
|
|
|
|
|
|
1159
|
|
|
|
|
|
|
|
|
1160
|
|
|
|
|
|
|
|
|
1161
|
|
|
|
|
|
|
|
|
1162
|
|
|
|
|
|
|
=head2 Cpow |
|
1163
|
|
|
|
|
|
|
|
|
1164
|
|
|
|
|
|
|
=for sig |
|
1165
|
|
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
Signature: (a(m=2); b(m=2); [o]c(m=2)) |
|
1167
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
1168
|
|
|
|
|
|
|
|
|
1169
|
|
|
|
|
|
|
=for usage |
|
1170
|
|
|
|
|
|
|
|
|
1171
|
|
|
|
|
|
|
$c = Cpow($a, $b); |
|
1172
|
|
|
|
|
|
|
Cpow($a, $b, $c); # all arguments given |
|
1173
|
|
|
|
|
|
|
$c = $a->Cpow($b); # method call |
|
1174
|
|
|
|
|
|
|
$a->Cpow($b, $c); |
|
1175
|
|
|
|
|
|
|
$a->inplace->Cpow($b); # can be used inplace |
|
1176
|
|
|
|
|
|
|
Cpow($a->inplace, $b); |
|
1177
|
|
|
|
|
|
|
|
|
1178
|
|
|
|
|
|
|
=for ref |
|
1179
|
|
|
|
|
|
|
|
|
1180
|
|
|
|
|
|
|
complex C (C<**>-operator) |
|
1181
|
|
|
|
|
|
|
|
|
1182
|
|
|
|
|
|
|
=pod |
|
1183
|
|
|
|
|
|
|
|
|
1184
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1185
|
|
|
|
|
|
|
|
|
1186
|
|
|
|
|
|
|
=for bad |
|
1187
|
|
|
|
|
|
|
|
|
1188
|
|
|
|
|
|
|
C does not process bad values. |
|
1189
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1190
|
|
|
|
|
|
|
|
|
1191
|
|
|
|
|
|
|
=cut |
|
1192
|
|
|
|
|
|
|
|
|
1193
|
|
|
|
|
|
|
|
|
1194
|
|
|
|
|
|
|
|
|
1195
|
|
|
|
|
|
|
|
|
1196
|
1
|
|
|
1
|
|
35
|
BEGIN {*Cpow = \&PDL::Complex::Cpow; |
|
1197
|
|
|
|
|
|
|
} |
|
1198
|
|
|
|
|
|
|
|
|
1199
|
|
|
|
|
|
|
|
|
1200
|
|
|
|
|
|
|
|
|
1201
|
|
|
|
|
|
|
|
|
1202
|
|
|
|
|
|
|
|
|
1203
|
|
|
|
|
|
|
=head2 Csqrt |
|
1204
|
|
|
|
|
|
|
|
|
1205
|
|
|
|
|
|
|
=for sig |
|
1206
|
|
|
|
|
|
|
|
|
1207
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c(m=2)) |
|
1208
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
1209
|
|
|
|
|
|
|
|
|
1210
|
|
|
|
|
|
|
=for usage |
|
1211
|
|
|
|
|
|
|
|
|
1212
|
|
|
|
|
|
|
$c = Csqrt($a); |
|
1213
|
|
|
|
|
|
|
Csqrt($a, $c); # all arguments given |
|
1214
|
|
|
|
|
|
|
$c = $a->Csqrt; # method call |
|
1215
|
|
|
|
|
|
|
$a->Csqrt($c); |
|
1216
|
|
|
|
|
|
|
$a->inplace->Csqrt; # can be used inplace |
|
1217
|
|
|
|
|
|
|
Csqrt($a->inplace); |
|
1218
|
|
|
|
|
|
|
|
|
1219
|
|
|
|
|
|
|
=for ref |
|
1220
|
|
|
|
|
|
|
|
|
1221
|
|
|
|
|
|
|
Works inplace |
|
1222
|
|
|
|
|
|
|
|
|
1223
|
|
|
|
|
|
|
=pod |
|
1224
|
|
|
|
|
|
|
|
|
1225
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1226
|
|
|
|
|
|
|
|
|
1227
|
|
|
|
|
|
|
=for bad |
|
1228
|
|
|
|
|
|
|
|
|
1229
|
|
|
|
|
|
|
C does not process bad values. |
|
1230
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1231
|
|
|
|
|
|
|
|
|
1232
|
|
|
|
|
|
|
=cut |
|
1233
|
|
|
|
|
|
|
|
|
1234
|
|
|
|
|
|
|
|
|
1235
|
|
|
|
|
|
|
|
|
1236
|
|
|
|
|
|
|
|
|
1237
|
1
|
|
|
1
|
|
41
|
BEGIN {*Csqrt = \&PDL::Complex::Csqrt; |
|
1238
|
|
|
|
|
|
|
} |
|
1239
|
|
|
|
|
|
|
|
|
1240
|
|
|
|
|
|
|
|
|
1241
|
|
|
|
|
|
|
|
|
1242
|
|
|
|
|
|
|
|
|
1243
|
|
|
|
|
|
|
|
|
1244
|
|
|
|
|
|
|
=head2 Casin |
|
1245
|
|
|
|
|
|
|
|
|
1246
|
|
|
|
|
|
|
=for sig |
|
1247
|
|
|
|
|
|
|
|
|
1248
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c(m=2)) |
|
1249
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
1250
|
|
|
|
|
|
|
|
|
1251
|
|
|
|
|
|
|
=for usage |
|
1252
|
|
|
|
|
|
|
|
|
1253
|
|
|
|
|
|
|
$c = Casin($a); |
|
1254
|
|
|
|
|
|
|
Casin($a, $c); # all arguments given |
|
1255
|
|
|
|
|
|
|
$c = $a->Casin; # method call |
|
1256
|
|
|
|
|
|
|
$a->Casin($c); |
|
1257
|
|
|
|
|
|
|
$a->inplace->Casin; # can be used inplace |
|
1258
|
|
|
|
|
|
|
Casin($a->inplace); |
|
1259
|
|
|
|
|
|
|
|
|
1260
|
|
|
|
|
|
|
=for ref |
|
1261
|
|
|
|
|
|
|
|
|
1262
|
|
|
|
|
|
|
Works inplace |
|
1263
|
|
|
|
|
|
|
|
|
1264
|
|
|
|
|
|
|
=pod |
|
1265
|
|
|
|
|
|
|
|
|
1266
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1267
|
|
|
|
|
|
|
|
|
1268
|
|
|
|
|
|
|
=for bad |
|
1269
|
|
|
|
|
|
|
|
|
1270
|
|
|
|
|
|
|
C does not process bad values. |
|
1271
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1272
|
|
|
|
|
|
|
|
|
1273
|
|
|
|
|
|
|
=cut |
|
1274
|
|
|
|
|
|
|
|
|
1275
|
|
|
|
|
|
|
|
|
1276
|
|
|
|
|
|
|
|
|
1277
|
|
|
|
|
|
|
|
|
1278
|
1
|
|
|
1
|
|
35
|
BEGIN {*Casin = \&PDL::Complex::Casin; |
|
1279
|
|
|
|
|
|
|
} |
|
1280
|
|
|
|
|
|
|
|
|
1281
|
|
|
|
|
|
|
|
|
1282
|
|
|
|
|
|
|
|
|
1283
|
|
|
|
|
|
|
|
|
1284
|
|
|
|
|
|
|
|
|
1285
|
|
|
|
|
|
|
=head2 Cacos |
|
1286
|
|
|
|
|
|
|
|
|
1287
|
|
|
|
|
|
|
=for sig |
|
1288
|
|
|
|
|
|
|
|
|
1289
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c(m=2)) |
|
1290
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
1291
|
|
|
|
|
|
|
|
|
1292
|
|
|
|
|
|
|
=for usage |
|
1293
|
|
|
|
|
|
|
|
|
1294
|
|
|
|
|
|
|
$c = Cacos($a); |
|
1295
|
|
|
|
|
|
|
Cacos($a, $c); # all arguments given |
|
1296
|
|
|
|
|
|
|
$c = $a->Cacos; # method call |
|
1297
|
|
|
|
|
|
|
$a->Cacos($c); |
|
1298
|
|
|
|
|
|
|
$a->inplace->Cacos; # can be used inplace |
|
1299
|
|
|
|
|
|
|
Cacos($a->inplace); |
|
1300
|
|
|
|
|
|
|
|
|
1301
|
|
|
|
|
|
|
=for ref |
|
1302
|
|
|
|
|
|
|
|
|
1303
|
|
|
|
|
|
|
Works inplace |
|
1304
|
|
|
|
|
|
|
|
|
1305
|
|
|
|
|
|
|
=pod |
|
1306
|
|
|
|
|
|
|
|
|
1307
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1308
|
|
|
|
|
|
|
|
|
1309
|
|
|
|
|
|
|
=for bad |
|
1310
|
|
|
|
|
|
|
|
|
1311
|
|
|
|
|
|
|
C does not process bad values. |
|
1312
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1313
|
|
|
|
|
|
|
|
|
1314
|
|
|
|
|
|
|
=cut |
|
1315
|
|
|
|
|
|
|
|
|
1316
|
|
|
|
|
|
|
|
|
1317
|
|
|
|
|
|
|
|
|
1318
|
|
|
|
|
|
|
|
|
1319
|
1
|
|
|
1
|
|
171
|
BEGIN {*Cacos = \&PDL::Complex::Cacos; |
|
1320
|
|
|
|
|
|
|
} |
|
1321
|
|
|
|
|
|
|
|
|
1322
|
|
|
|
|
|
|
|
|
1323
|
|
|
|
|
|
|
|
|
1324
|
|
|
|
|
|
|
|
|
1325
|
|
|
|
|
|
|
#line 859 "complex.pd" |
|
1326
|
|
|
|
|
|
|
|
|
1327
|
|
|
|
|
|
|
=head2 Catan |
|
1328
|
|
|
|
|
|
|
|
|
1329
|
|
|
|
|
|
|
=for ref |
|
1330
|
|
|
|
|
|
|
|
|
1331
|
|
|
|
|
|
|
Return the complex C. |
|
1332
|
|
|
|
|
|
|
|
|
1333
|
|
|
|
|
|
|
Does not work inplace. |
|
1334
|
|
|
|
|
|
|
|
|
1335
|
|
|
|
|
|
|
=cut |
|
1336
|
|
|
|
|
|
|
|
|
1337
|
|
|
|
|
|
|
sub Catan($) { |
|
1338
|
|
|
|
|
|
|
my $z = shift; |
|
1339
|
|
|
|
|
|
|
Cmul Clog(Cdiv (PDL::Complex::i()+$z, PDL::Complex::i()-$z)), PDL->pdl(0, 0.5); |
|
1340
|
|
|
|
|
|
|
} |
|
1341
|
|
|
|
|
|
|
#line 1342 "Complex.pm" |
|
1342
|
|
|
|
|
|
|
|
|
1343
|
|
|
|
|
|
|
|
|
1344
|
|
|
|
|
|
|
=head2 Csinh |
|
1345
|
|
|
|
|
|
|
|
|
1346
|
|
|
|
|
|
|
=for sig |
|
1347
|
|
|
|
|
|
|
|
|
1348
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c(m=2)) |
|
1349
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
1350
|
|
|
|
|
|
|
|
|
1351
|
|
|
|
|
|
|
=for usage |
|
1352
|
|
|
|
|
|
|
|
|
1353
|
|
|
|
|
|
|
$c = Csinh($a); |
|
1354
|
|
|
|
|
|
|
Csinh($a, $c); # all arguments given |
|
1355
|
|
|
|
|
|
|
$c = $a->Csinh; # method call |
|
1356
|
|
|
|
|
|
|
$a->Csinh($c); |
|
1357
|
|
|
|
|
|
|
$a->inplace->Csinh; # can be used inplace |
|
1358
|
|
|
|
|
|
|
Csinh($a->inplace); |
|
1359
|
|
|
|
|
|
|
|
|
1360
|
|
|
|
|
|
|
=for ref |
|
1361
|
|
|
|
|
|
|
|
|
1362
|
|
|
|
|
|
|
sinh (a) = (exp (a) - exp (-a)) / 2. Works inplace |
|
1363
|
|
|
|
|
|
|
|
|
1364
|
|
|
|
|
|
|
=pod |
|
1365
|
|
|
|
|
|
|
|
|
1366
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1367
|
|
|
|
|
|
|
|
|
1368
|
|
|
|
|
|
|
=for bad |
|
1369
|
|
|
|
|
|
|
|
|
1370
|
|
|
|
|
|
|
C does not process bad values. |
|
1371
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1372
|
|
|
|
|
|
|
|
|
1373
|
|
|
|
|
|
|
=cut |
|
1374
|
|
|
|
|
|
|
|
|
1375
|
|
|
|
|
|
|
|
|
1376
|
|
|
|
|
|
|
|
|
1377
|
|
|
|
|
|
|
|
|
1378
|
1
|
|
|
1
|
|
56
|
BEGIN {*Csinh = \&PDL::Complex::Csinh; |
|
1379
|
|
|
|
|
|
|
} |
|
1380
|
|
|
|
|
|
|
|
|
1381
|
|
|
|
|
|
|
|
|
1382
|
|
|
|
|
|
|
|
|
1383
|
|
|
|
|
|
|
|
|
1384
|
|
|
|
|
|
|
|
|
1385
|
|
|
|
|
|
|
=head2 Ccosh |
|
1386
|
|
|
|
|
|
|
|
|
1387
|
|
|
|
|
|
|
=for sig |
|
1388
|
|
|
|
|
|
|
|
|
1389
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c(m=2)) |
|
1390
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
1391
|
|
|
|
|
|
|
|
|
1392
|
|
|
|
|
|
|
=for usage |
|
1393
|
|
|
|
|
|
|
|
|
1394
|
|
|
|
|
|
|
$c = Ccosh($a); |
|
1395
|
|
|
|
|
|
|
Ccosh($a, $c); # all arguments given |
|
1396
|
|
|
|
|
|
|
$c = $a->Ccosh; # method call |
|
1397
|
|
|
|
|
|
|
$a->Ccosh($c); |
|
1398
|
|
|
|
|
|
|
$a->inplace->Ccosh; # can be used inplace |
|
1399
|
|
|
|
|
|
|
Ccosh($a->inplace); |
|
1400
|
|
|
|
|
|
|
|
|
1401
|
|
|
|
|
|
|
=for ref |
|
1402
|
|
|
|
|
|
|
|
|
1403
|
|
|
|
|
|
|
cosh (a) = (exp (a) + exp (-a)) / 2. Works inplace |
|
1404
|
|
|
|
|
|
|
|
|
1405
|
|
|
|
|
|
|
=pod |
|
1406
|
|
|
|
|
|
|
|
|
1407
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1408
|
|
|
|
|
|
|
|
|
1409
|
|
|
|
|
|
|
=for bad |
|
1410
|
|
|
|
|
|
|
|
|
1411
|
|
|
|
|
|
|
C does not process bad values. |
|
1412
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1413
|
|
|
|
|
|
|
|
|
1414
|
|
|
|
|
|
|
=cut |
|
1415
|
|
|
|
|
|
|
|
|
1416
|
|
|
|
|
|
|
|
|
1417
|
|
|
|
|
|
|
|
|
1418
|
|
|
|
|
|
|
|
|
1419
|
1
|
|
|
1
|
|
50
|
BEGIN {*Ccosh = \&PDL::Complex::Ccosh; |
|
1420
|
|
|
|
|
|
|
} |
|
1421
|
|
|
|
|
|
|
|
|
1422
|
|
|
|
|
|
|
|
|
1423
|
|
|
|
|
|
|
|
|
1424
|
|
|
|
|
|
|
|
|
1425
|
|
|
|
|
|
|
|
|
1426
|
|
|
|
|
|
|
=head2 Ctanh |
|
1427
|
|
|
|
|
|
|
|
|
1428
|
|
|
|
|
|
|
=for sig |
|
1429
|
|
|
|
|
|
|
|
|
1430
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c(m=2)) |
|
1431
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
1432
|
|
|
|
|
|
|
|
|
1433
|
|
|
|
|
|
|
=for usage |
|
1434
|
|
|
|
|
|
|
|
|
1435
|
|
|
|
|
|
|
$c = Ctanh($a); |
|
1436
|
|
|
|
|
|
|
Ctanh($a, $c); # all arguments given |
|
1437
|
|
|
|
|
|
|
$c = $a->Ctanh; # method call |
|
1438
|
|
|
|
|
|
|
$a->Ctanh($c); |
|
1439
|
|
|
|
|
|
|
$a->inplace->Ctanh; # can be used inplace |
|
1440
|
|
|
|
|
|
|
Ctanh($a->inplace); |
|
1441
|
|
|
|
|
|
|
|
|
1442
|
|
|
|
|
|
|
=for ref |
|
1443
|
|
|
|
|
|
|
|
|
1444
|
|
|
|
|
|
|
Works inplace |
|
1445
|
|
|
|
|
|
|
|
|
1446
|
|
|
|
|
|
|
=pod |
|
1447
|
|
|
|
|
|
|
|
|
1448
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1449
|
|
|
|
|
|
|
|
|
1450
|
|
|
|
|
|
|
=for bad |
|
1451
|
|
|
|
|
|
|
|
|
1452
|
|
|
|
|
|
|
C does not process bad values. |
|
1453
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1454
|
|
|
|
|
|
|
|
|
1455
|
|
|
|
|
|
|
=cut |
|
1456
|
|
|
|
|
|
|
|
|
1457
|
|
|
|
|
|
|
|
|
1458
|
|
|
|
|
|
|
|
|
1459
|
|
|
|
|
|
|
|
|
1460
|
1
|
|
|
1
|
|
37
|
BEGIN {*Ctanh = \&PDL::Complex::Ctanh; |
|
1461
|
|
|
|
|
|
|
} |
|
1462
|
|
|
|
|
|
|
|
|
1463
|
|
|
|
|
|
|
|
|
1464
|
|
|
|
|
|
|
|
|
1465
|
|
|
|
|
|
|
|
|
1466
|
|
|
|
|
|
|
|
|
1467
|
|
|
|
|
|
|
=head2 Casinh |
|
1468
|
|
|
|
|
|
|
|
|
1469
|
|
|
|
|
|
|
=for sig |
|
1470
|
|
|
|
|
|
|
|
|
1471
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c(m=2)) |
|
1472
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
1473
|
|
|
|
|
|
|
|
|
1474
|
|
|
|
|
|
|
=for usage |
|
1475
|
|
|
|
|
|
|
|
|
1476
|
|
|
|
|
|
|
$c = Casinh($a); |
|
1477
|
|
|
|
|
|
|
Casinh($a, $c); # all arguments given |
|
1478
|
|
|
|
|
|
|
$c = $a->Casinh; # method call |
|
1479
|
|
|
|
|
|
|
$a->Casinh($c); |
|
1480
|
|
|
|
|
|
|
$a->inplace->Casinh; # can be used inplace |
|
1481
|
|
|
|
|
|
|
Casinh($a->inplace); |
|
1482
|
|
|
|
|
|
|
|
|
1483
|
|
|
|
|
|
|
=for ref |
|
1484
|
|
|
|
|
|
|
|
|
1485
|
|
|
|
|
|
|
Works inplace |
|
1486
|
|
|
|
|
|
|
|
|
1487
|
|
|
|
|
|
|
=pod |
|
1488
|
|
|
|
|
|
|
|
|
1489
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1490
|
|
|
|
|
|
|
|
|
1491
|
|
|
|
|
|
|
=for bad |
|
1492
|
|
|
|
|
|
|
|
|
1493
|
|
|
|
|
|
|
C does not process bad values. |
|
1494
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1495
|
|
|
|
|
|
|
|
|
1496
|
|
|
|
|
|
|
=cut |
|
1497
|
|
|
|
|
|
|
|
|
1498
|
|
|
|
|
|
|
|
|
1499
|
|
|
|
|
|
|
|
|
1500
|
|
|
|
|
|
|
|
|
1501
|
1
|
|
|
1
|
|
26
|
BEGIN {*Casinh = \&PDL::Complex::Casinh; |
|
1502
|
|
|
|
|
|
|
} |
|
1503
|
|
|
|
|
|
|
|
|
1504
|
|
|
|
|
|
|
|
|
1505
|
|
|
|
|
|
|
|
|
1506
|
|
|
|
|
|
|
|
|
1507
|
|
|
|
|
|
|
|
|
1508
|
|
|
|
|
|
|
=head2 Cacosh |
|
1509
|
|
|
|
|
|
|
|
|
1510
|
|
|
|
|
|
|
=for sig |
|
1511
|
|
|
|
|
|
|
|
|
1512
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c(m=2)) |
|
1513
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
1514
|
|
|
|
|
|
|
|
|
1515
|
|
|
|
|
|
|
=for usage |
|
1516
|
|
|
|
|
|
|
|
|
1517
|
|
|
|
|
|
|
$c = Cacosh($a); |
|
1518
|
|
|
|
|
|
|
Cacosh($a, $c); # all arguments given |
|
1519
|
|
|
|
|
|
|
$c = $a->Cacosh; # method call |
|
1520
|
|
|
|
|
|
|
$a->Cacosh($c); |
|
1521
|
|
|
|
|
|
|
$a->inplace->Cacosh; # can be used inplace |
|
1522
|
|
|
|
|
|
|
Cacosh($a->inplace); |
|
1523
|
|
|
|
|
|
|
|
|
1524
|
|
|
|
|
|
|
=for ref |
|
1525
|
|
|
|
|
|
|
|
|
1526
|
|
|
|
|
|
|
Works inplace |
|
1527
|
|
|
|
|
|
|
|
|
1528
|
|
|
|
|
|
|
=pod |
|
1529
|
|
|
|
|
|
|
|
|
1530
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1531
|
|
|
|
|
|
|
|
|
1532
|
|
|
|
|
|
|
=for bad |
|
1533
|
|
|
|
|
|
|
|
|
1534
|
|
|
|
|
|
|
C does not process bad values. |
|
1535
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1536
|
|
|
|
|
|
|
|
|
1537
|
|
|
|
|
|
|
=cut |
|
1538
|
|
|
|
|
|
|
|
|
1539
|
|
|
|
|
|
|
|
|
1540
|
|
|
|
|
|
|
|
|
1541
|
|
|
|
|
|
|
|
|
1542
|
1
|
|
|
1
|
|
33
|
BEGIN {*Cacosh = \&PDL::Complex::Cacosh; |
|
1543
|
|
|
|
|
|
|
} |
|
1544
|
|
|
|
|
|
|
|
|
1545
|
|
|
|
|
|
|
|
|
1546
|
|
|
|
|
|
|
|
|
1547
|
|
|
|
|
|
|
|
|
1548
|
|
|
|
|
|
|
|
|
1549
|
|
|
|
|
|
|
=head2 Catanh |
|
1550
|
|
|
|
|
|
|
|
|
1551
|
|
|
|
|
|
|
=for sig |
|
1552
|
|
|
|
|
|
|
|
|
1553
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c(m=2)) |
|
1554
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
1555
|
|
|
|
|
|
|
|
|
1556
|
|
|
|
|
|
|
=for usage |
|
1557
|
|
|
|
|
|
|
|
|
1558
|
|
|
|
|
|
|
$c = Catanh($a); |
|
1559
|
|
|
|
|
|
|
Catanh($a, $c); # all arguments given |
|
1560
|
|
|
|
|
|
|
$c = $a->Catanh; # method call |
|
1561
|
|
|
|
|
|
|
$a->Catanh($c); |
|
1562
|
|
|
|
|
|
|
$a->inplace->Catanh; # can be used inplace |
|
1563
|
|
|
|
|
|
|
Catanh($a->inplace); |
|
1564
|
|
|
|
|
|
|
|
|
1565
|
|
|
|
|
|
|
=for ref |
|
1566
|
|
|
|
|
|
|
|
|
1567
|
|
|
|
|
|
|
Works inplace |
|
1568
|
|
|
|
|
|
|
|
|
1569
|
|
|
|
|
|
|
=pod |
|
1570
|
|
|
|
|
|
|
|
|
1571
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1572
|
|
|
|
|
|
|
|
|
1573
|
|
|
|
|
|
|
=for bad |
|
1574
|
|
|
|
|
|
|
|
|
1575
|
|
|
|
|
|
|
C does not process bad values. |
|
1576
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1577
|
|
|
|
|
|
|
|
|
1578
|
|
|
|
|
|
|
=cut |
|
1579
|
|
|
|
|
|
|
|
|
1580
|
|
|
|
|
|
|
|
|
1581
|
|
|
|
|
|
|
|
|
1582
|
|
|
|
|
|
|
|
|
1583
|
1
|
|
|
1
|
|
27
|
BEGIN {*Catanh = \&PDL::Complex::Catanh; |
|
1584
|
|
|
|
|
|
|
} |
|
1585
|
|
|
|
|
|
|
|
|
1586
|
|
|
|
|
|
|
|
|
1587
|
|
|
|
|
|
|
|
|
1588
|
|
|
|
|
|
|
|
|
1589
|
|
|
|
|
|
|
|
|
1590
|
|
|
|
|
|
|
=head2 Cproj |
|
1591
|
|
|
|
|
|
|
|
|
1592
|
|
|
|
|
|
|
=for sig |
|
1593
|
|
|
|
|
|
|
|
|
1594
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c(m=2)) |
|
1595
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
1596
|
|
|
|
|
|
|
|
|
1597
|
|
|
|
|
|
|
=for usage |
|
1598
|
|
|
|
|
|
|
|
|
1599
|
|
|
|
|
|
|
$c = Cproj($a); |
|
1600
|
|
|
|
|
|
|
Cproj($a, $c); # all arguments given |
|
1601
|
|
|
|
|
|
|
$c = $a->Cproj; # method call |
|
1602
|
|
|
|
|
|
|
$a->Cproj($c); |
|
1603
|
|
|
|
|
|
|
$a->inplace->Cproj; # can be used inplace |
|
1604
|
|
|
|
|
|
|
Cproj($a->inplace); |
|
1605
|
|
|
|
|
|
|
|
|
1606
|
|
|
|
|
|
|
=for ref |
|
1607
|
|
|
|
|
|
|
|
|
1608
|
|
|
|
|
|
|
compute the projection of a complex number to the riemann sphere. Works inplace |
|
1609
|
|
|
|
|
|
|
|
|
1610
|
|
|
|
|
|
|
=pod |
|
1611
|
|
|
|
|
|
|
|
|
1612
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1613
|
|
|
|
|
|
|
|
|
1614
|
|
|
|
|
|
|
=for bad |
|
1615
|
|
|
|
|
|
|
|
|
1616
|
|
|
|
|
|
|
C does not process bad values. |
|
1617
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1618
|
|
|
|
|
|
|
|
|
1619
|
|
|
|
|
|
|
=cut |
|
1620
|
|
|
|
|
|
|
|
|
1621
|
|
|
|
|
|
|
|
|
1622
|
|
|
|
|
|
|
|
|
1623
|
|
|
|
|
|
|
|
|
1624
|
1
|
|
|
1
|
|
101
|
BEGIN {*Cproj = \&PDL::Complex::Cproj; |
|
1625
|
|
|
|
|
|
|
} |
|
1626
|
|
|
|
|
|
|
|
|
1627
|
|
|
|
|
|
|
|
|
1628
|
|
|
|
|
|
|
|
|
1629
|
|
|
|
|
|
|
|
|
1630
|
|
|
|
|
|
|
|
|
1631
|
|
|
|
|
|
|
=head2 Croots |
|
1632
|
|
|
|
|
|
|
|
|
1633
|
|
|
|
|
|
|
=for sig |
|
1634
|
|
|
|
|
|
|
|
|
1635
|
|
|
|
|
|
|
Signature: (a(m=2); [o]c(m=2,n); int n => n) |
|
1636
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
1637
|
|
|
|
|
|
|
|
|
1638
|
|
|
|
|
|
|
=for usage |
|
1639
|
|
|
|
|
|
|
|
|
1640
|
|
|
|
|
|
|
$c = Croots($a, $n); |
|
1641
|
|
|
|
|
|
|
Croots($a, $c, $n); # all arguments given |
|
1642
|
|
|
|
|
|
|
$c = $a->Croots($n); # method call |
|
1643
|
|
|
|
|
|
|
$a->Croots($c, $n); |
|
1644
|
|
|
|
|
|
|
|
|
1645
|
|
|
|
|
|
|
=for ref |
|
1646
|
|
|
|
|
|
|
|
|
1647
|
|
|
|
|
|
|
Compute the C roots of C. C must be a positive integer. The result will always be a complex type! |
|
1648
|
|
|
|
|
|
|
|
|
1649
|
|
|
|
|
|
|
=pod |
|
1650
|
|
|
|
|
|
|
|
|
1651
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1652
|
|
|
|
|
|
|
|
|
1653
|
|
|
|
|
|
|
=for bad |
|
1654
|
|
|
|
|
|
|
|
|
1655
|
|
|
|
|
|
|
C does not process bad values. |
|
1656
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1657
|
|
|
|
|
|
|
|
|
1658
|
|
|
|
|
|
|
=cut |
|
1659
|
|
|
|
|
|
|
|
|
1660
|
|
|
|
|
|
|
|
|
1661
|
|
|
|
|
|
|
|
|
1662
|
|
|
|
|
|
|
|
|
1663
|
|
|
|
|
|
|
sub PDL::Complex::Croots($$) { |
|
1664
|
1
|
|
|
1
|
1
|
2
|
my ($pdl, $n) = @_; |
|
1665
|
1
|
|
|
|
|
3
|
my $r = PDL->null; |
|
1666
|
1
|
|
|
|
|
23
|
&PDL::Complex::_Croots_int($pdl, $r, $n); |
|
1667
|
1
|
|
|
|
|
4
|
bless $r; |
|
1668
|
|
|
|
|
|
|
} |
|
1669
|
|
|
|
|
|
|
|
|
1670
|
|
|
|
|
|
|
|
|
1671
|
1
|
|
|
1
|
|
95
|
BEGIN {*Croots = \&PDL::Complex::Croots; |
|
1672
|
|
|
|
|
|
|
} |
|
1673
|
|
|
|
|
|
|
|
|
1674
|
|
|
|
|
|
|
|
|
1675
|
|
|
|
|
|
|
|
|
1676
|
|
|
|
|
|
|
|
|
1677
|
|
|
|
|
|
|
#line 1027 "complex.pd" |
|
1678
|
|
|
|
|
|
|
|
|
1679
|
|
|
|
|
|
|
=head2 re, im |
|
1680
|
|
|
|
|
|
|
|
|
1681
|
|
|
|
|
|
|
Return the real or imaginary part of the complex number(s) given. |
|
1682
|
|
|
|
|
|
|
|
|
1683
|
|
|
|
|
|
|
These are slicing operators, so data flow works. The real and |
|
1684
|
|
|
|
|
|
|
imaginary parts are returned as ndarrays (ref eq PDL). |
|
1685
|
|
|
|
|
|
|
|
|
1686
|
|
|
|
|
|
|
=cut |
|
1687
|
|
|
|
|
|
|
|
|
1688
|
|
|
|
|
|
|
sub re($) { $_[0]->slice("(0)") } |
|
1689
|
|
|
|
|
|
|
sub im($) { $_[0]->slice("(1)") } |
|
1690
|
|
|
|
|
|
|
|
|
1691
|
|
|
|
|
|
|
{ |
|
1692
|
|
|
|
|
|
|
no warnings 'redefine'; |
|
1693
|
|
|
|
|
|
|
# if the argument does anything other than pass through 0-th dim, re-bless |
|
1694
|
|
|
|
|
|
|
sub slice :lvalue { |
|
1695
|
|
|
|
|
|
|
my $first = ref $_[1] ? $_[1][0] : (split ',', $_[1])[0]; |
|
1696
|
|
|
|
|
|
|
my $class = ($first//'') =~ /^[:x]?$/i ? ref($_[0]) : 'PDL'; |
|
1697
|
|
|
|
|
|
|
my $ret = bless $_[0]->SUPER::slice(@_[1..$#_]), $class; |
|
1698
|
|
|
|
|
|
|
$ret; |
|
1699
|
|
|
|
|
|
|
} |
|
1700
|
|
|
|
|
|
|
} |
|
1701
|
|
|
|
|
|
|
#line 1702 "Complex.pm" |
|
1702
|
|
|
|
|
|
|
|
|
1703
|
|
|
|
|
|
|
|
|
1704
|
|
|
|
|
|
|
=head2 rCpolynomial |
|
1705
|
|
|
|
|
|
|
|
|
1706
|
|
|
|
|
|
|
=for sig |
|
1707
|
|
|
|
|
|
|
|
|
1708
|
|
|
|
|
|
|
Signature: (coeffs(n); x(c=2,m); [o]out(c=2,m)) |
|
1709
|
|
|
|
|
|
|
Types: (float double ldouble) |
|
1710
|
|
|
|
|
|
|
|
|
1711
|
|
|
|
|
|
|
=for usage |
|
1712
|
|
|
|
|
|
|
|
|
1713
|
|
|
|
|
|
|
$out = rCpolynomial($coeffs, $x); |
|
1714
|
|
|
|
|
|
|
rCpolynomial($coeffs, $x, $out); # all arguments given |
|
1715
|
|
|
|
|
|
|
$out = $coeffs->rCpolynomial($x); # method call |
|
1716
|
|
|
|
|
|
|
$coeffs->rCpolynomial($x, $out); |
|
1717
|
|
|
|
|
|
|
|
|
1718
|
|
|
|
|
|
|
=for ref |
|
1719
|
|
|
|
|
|
|
|
|
1720
|
|
|
|
|
|
|
evaluate the polynomial with (real) coefficients C at the (complex) position(s) C. C is the constant term. |
|
1721
|
|
|
|
|
|
|
|
|
1722
|
|
|
|
|
|
|
=pod |
|
1723
|
|
|
|
|
|
|
|
|
1724
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1725
|
|
|
|
|
|
|
|
|
1726
|
|
|
|
|
|
|
=for bad |
|
1727
|
|
|
|
|
|
|
|
|
1728
|
|
|
|
|
|
|
C does not process bad values. |
|
1729
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1730
|
|
|
|
|
|
|
|
|
1731
|
|
|
|
|
|
|
=cut |
|
1732
|
|
|
|
|
|
|
|
|
1733
|
|
|
|
|
|
|
|
|
1734
|
|
|
|
|
|
|
|
|
1735
|
|
|
|
|
|
|
|
|
1736
|
|
|
|
|
|
|
|
|
1737
|
|
|
|
|
|
|
sub rCpolynomial { |
|
1738
|
2
|
|
|
2
|
1
|
80
|
my $coeffs = shift; |
|
1739
|
2
|
|
|
|
|
3
|
my $x = shift; |
|
1740
|
2
|
|
|
|
|
4
|
my $out = $x->copy; |
|
1741
|
2
|
|
|
|
|
84
|
_rCpolynomial_int($coeffs,$x,$out); |
|
1742
|
2
|
|
|
|
|
7
|
return PDL::complex($out); |
|
1743
|
|
|
|
|
|
|
} |
|
1744
|
|
|
|
|
|
|
|
|
1745
|
|
|
|
|
|
|
|
|
1746
|
|
|
|
|
|
|
|
|
1747
|
1
|
|
|
1
|
|
36
|
BEGIN {*rCpolynomial = \&PDL::Complex::rCpolynomial; |
|
1748
|
|
|
|
|
|
|
} |
|
1749
|
|
|
|
|
|
|
|
|
1750
|
|
|
|
|
|
|
|
|
1751
|
|
|
|
|
|
|
|
|
1752
|
|
|
|
|
|
|
|
|
1753
|
|
|
|
|
|
|
|
|
1754
|
|
|
|
|
|
|
=head2 Ctricpy |
|
1755
|
|
|
|
|
|
|
|
|
1756
|
|
|
|
|
|
|
=for sig |
|
1757
|
|
|
|
|
|
|
|
|
1758
|
|
|
|
|
|
|
Signature: (A(c=2,m,n);[o] C(c=2,m,n); int uplo) |
|
1759
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
1760
|
|
|
|
|
|
|
float double ldouble) |
|
1761
|
|
|
|
|
|
|
|
|
1762
|
|
|
|
|
|
|
=for usage |
|
1763
|
|
|
|
|
|
|
|
|
1764
|
|
|
|
|
|
|
tricpy(PDL(A), int(uplo), PDL(C)) |
|
1765
|
|
|
|
|
|
|
|
|
1766
|
|
|
|
|
|
|
=for example |
|
1767
|
|
|
|
|
|
|
|
|
1768
|
|
|
|
|
|
|
$c = $a->tricpy($uplo); # explicit uplo |
|
1769
|
|
|
|
|
|
|
$c = $a->tricpy; # default upper |
|
1770
|
|
|
|
|
|
|
|
|
1771
|
|
|
|
|
|
|
or |
|
1772
|
|
|
|
|
|
|
|
|
1773
|
|
|
|
|
|
|
tricpy($a, $uplo, $c); # modify c |
|
1774
|
|
|
|
|
|
|
|
|
1775
|
|
|
|
|
|
|
=for ref |
|
1776
|
|
|
|
|
|
|
|
|
1777
|
|
|
|
|
|
|
Copy triangular part to another matrix. If uplo == 0 copy upper triangular |
|
1778
|
|
|
|
|
|
|
part. |
|
1779
|
|
|
|
|
|
|
|
|
1780
|
|
|
|
|
|
|
Originally by Grégory Vanuxem. |
|
1781
|
|
|
|
|
|
|
|
|
1782
|
|
|
|
|
|
|
=pod |
|
1783
|
|
|
|
|
|
|
|
|
1784
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1785
|
|
|
|
|
|
|
|
|
1786
|
|
|
|
|
|
|
=for bad |
|
1787
|
|
|
|
|
|
|
|
|
1788
|
|
|
|
|
|
|
C does not process bad values. |
|
1789
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1790
|
|
|
|
|
|
|
|
|
1791
|
|
|
|
|
|
|
=cut |
|
1792
|
|
|
|
|
|
|
|
|
1793
|
|
|
|
|
|
|
|
|
1794
|
|
|
|
|
|
|
|
|
1795
|
|
|
|
|
|
|
|
|
1796
|
1
|
|
|
1
|
|
39
|
BEGIN {*Ctricpy = \&PDL::Complex::Ctricpy; |
|
1797
|
|
|
|
|
|
|
} |
|
1798
|
|
|
|
|
|
|
|
|
1799
|
|
|
|
|
|
|
|
|
1800
|
|
|
|
|
|
|
|
|
1801
|
|
|
|
|
|
|
|
|
1802
|
|
|
|
|
|
|
|
|
1803
|
|
|
|
|
|
|
=head2 Cmstack |
|
1804
|
|
|
|
|
|
|
|
|
1805
|
|
|
|
|
|
|
=for sig |
|
1806
|
|
|
|
|
|
|
|
|
1807
|
|
|
|
|
|
|
Signature: (x(c=2,n,m);y(c,n,p);[o]out(c,n,q=CALC($SIZE(m)+$SIZE(p)))) |
|
1808
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
1809
|
|
|
|
|
|
|
float double ldouble) |
|
1810
|
|
|
|
|
|
|
|
|
1811
|
|
|
|
|
|
|
=for usage |
|
1812
|
|
|
|
|
|
|
|
|
1813
|
|
|
|
|
|
|
$out = Cmstack($x, $y); |
|
1814
|
|
|
|
|
|
|
Cmstack($x, $y, $out); # all arguments given |
|
1815
|
|
|
|
|
|
|
$out = $x->Cmstack($y); # method call |
|
1816
|
|
|
|
|
|
|
$x->Cmstack($y, $out); |
|
1817
|
|
|
|
|
|
|
|
|
1818
|
|
|
|
|
|
|
=for ref |
|
1819
|
|
|
|
|
|
|
|
|
1820
|
|
|
|
|
|
|
Combine two 2D ndarrays into a single ndarray, along the second |
|
1821
|
|
|
|
|
|
|
("vertical") dim. |
|
1822
|
|
|
|
|
|
|
This routine does backward and forward dataflow automatically. |
|
1823
|
|
|
|
|
|
|
|
|
1824
|
|
|
|
|
|
|
Originally by Grégory Vanuxem. |
|
1825
|
|
|
|
|
|
|
|
|
1826
|
|
|
|
|
|
|
=pod |
|
1827
|
|
|
|
|
|
|
|
|
1828
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1829
|
|
|
|
|
|
|
Creates data-flow back and forth by default. |
|
1830
|
|
|
|
|
|
|
|
|
1831
|
|
|
|
|
|
|
=for bad |
|
1832
|
|
|
|
|
|
|
|
|
1833
|
|
|
|
|
|
|
C does not process bad values. |
|
1834
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1835
|
|
|
|
|
|
|
|
|
1836
|
|
|
|
|
|
|
=cut |
|
1837
|
|
|
|
|
|
|
|
|
1838
|
|
|
|
|
|
|
|
|
1839
|
|
|
|
|
|
|
|
|
1840
|
|
|
|
|
|
|
|
|
1841
|
1
|
|
|
1
|
|
88
|
BEGIN {*Cmstack = \&PDL::Complex::Cmstack; |
|
1842
|
|
|
|
|
|
|
} |
|
1843
|
|
|
|
|
|
|
|
|
1844
|
|
|
|
|
|
|
|
|
1845
|
|
|
|
|
|
|
|
|
1846
|
|
|
|
|
|
|
|
|
1847
|
|
|
|
|
|
|
|
|
1848
|
|
|
|
|
|
|
=head2 Caugment |
|
1849
|
|
|
|
|
|
|
|
|
1850
|
|
|
|
|
|
|
=for sig |
|
1851
|
|
|
|
|
|
|
|
|
1852
|
|
|
|
|
|
|
Signature: (x(c=2,n);y(c,p);[o]out(c,q=CALC($SIZE(n)+$SIZE(p)))) |
|
1853
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
1854
|
|
|
|
|
|
|
float double ldouble) |
|
1855
|
|
|
|
|
|
|
|
|
1856
|
|
|
|
|
|
|
=for usage |
|
1857
|
|
|
|
|
|
|
|
|
1858
|
|
|
|
|
|
|
$out = Caugment($x, $y); |
|
1859
|
|
|
|
|
|
|
Caugment($x, $y, $out); # all arguments given |
|
1860
|
|
|
|
|
|
|
$out = $x->Caugment($y); # method call |
|
1861
|
|
|
|
|
|
|
$x->Caugment($y, $out); |
|
1862
|
|
|
|
|
|
|
|
|
1863
|
|
|
|
|
|
|
=for ref |
|
1864
|
|
|
|
|
|
|
|
|
1865
|
|
|
|
|
|
|
Combine two ndarrays into a single ndarray along the 0-th ("horizontal") dim. |
|
1866
|
|
|
|
|
|
|
This routine does backward and forward dataflow automatically. |
|
1867
|
|
|
|
|
|
|
|
|
1868
|
|
|
|
|
|
|
Originally by Grégory Vanuxem. |
|
1869
|
|
|
|
|
|
|
|
|
1870
|
|
|
|
|
|
|
=pod |
|
1871
|
|
|
|
|
|
|
|
|
1872
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1873
|
|
|
|
|
|
|
Creates data-flow back and forth by default. |
|
1874
|
|
|
|
|
|
|
|
|
1875
|
|
|
|
|
|
|
=for bad |
|
1876
|
|
|
|
|
|
|
|
|
1877
|
|
|
|
|
|
|
C does not process bad values. |
|
1878
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1879
|
|
|
|
|
|
|
|
|
1880
|
|
|
|
|
|
|
=cut |
|
1881
|
|
|
|
|
|
|
|
|
1882
|
|
|
|
|
|
|
|
|
1883
|
|
|
|
|
|
|
|
|
1884
|
|
|
|
|
|
|
|
|
1885
|
1
|
|
|
1
|
|
172
|
BEGIN {*Caugment = \&PDL::Complex::Caugment; |
|
1886
|
|
|
|
|
|
|
} |
|
1887
|
|
|
|
|
|
|
|
|
1888
|
|
|
|
|
|
|
|
|
1889
|
|
|
|
|
|
|
|
|
1890
|
|
|
|
|
|
|
|
|
1891
|
|
|
|
|
|
|
|
|
1892
|
|
|
|
|
|
|
|
|
1893
|
|
|
|
|
|
|
#line 1169 "complex.pd" |
|
1894
|
|
|
|
|
|
|
|
|
1895
|
|
|
|
|
|
|
# undocumented compatibility functions (thanks to Luis Mochan!) |
|
1896
|
|
|
|
|
|
|
sub Catan2 { Clog( $_[1] + i()*$_[0])/i } |
|
1897
|
|
|
|
|
|
|
sub atan2 { Clog( $_[1] + i()*$_[0])/i } |
|
1898
|
|
|
|
|
|
|
|
|
1899
|
|
|
|
|
|
|
=begin comment |
|
1900
|
|
|
|
|
|
|
|
|
1901
|
|
|
|
|
|
|
In _gen_biop, the '+' or '-' between the operator (e.g., '*') and the |
|
1902
|
|
|
|
|
|
|
function that it overloads (e.g., 'Cmul') flags whether the operation |
|
1903
|
|
|
|
|
|
|
is ('+') or is not ('-') commutative. See the discussion of argument |
|
1904
|
|
|
|
|
|
|
swapping in the section "Calling Conventions and Magic Autogeneration" |
|
1905
|
|
|
|
|
|
|
in "perldoc overload". |
|
1906
|
|
|
|
|
|
|
|
|
1907
|
|
|
|
|
|
|
=end comment |
|
1908
|
|
|
|
|
|
|
|
|
1909
|
|
|
|
|
|
|
=cut |
|
1910
|
|
|
|
|
|
|
|
|
1911
|
|
|
|
|
|
|
my %NO_MUTATE; BEGIN { @NO_MUTATE{qw(atan2 .= ==)} = (); } |
|
1912
|
|
|
|
|
|
|
sub _gen_biop { |
|
1913
|
|
|
|
|
|
|
local $_ = shift; |
|
1914
|
|
|
|
|
|
|
my $sub; |
|
1915
|
|
|
|
|
|
|
die if !(my ($op, $commutes, $func) = /(\S+)([-+])(\w+)/); |
|
1916
|
|
|
|
|
|
|
$sub = eval 'sub { |
|
1917
|
|
|
|
|
|
|
my ($x, $y) = '.($commutes eq '+' ? '' : '$_[2] ? @_[1,0] : ').'@_[0,1]; |
|
1918
|
|
|
|
|
|
|
$_ = r2C $_ for grep ref $_ ne __PACKAGE__, $x, $y; |
|
1919
|
|
|
|
|
|
|
'.$func.'($x, $y); |
|
1920
|
|
|
|
|
|
|
}'; #need to swap? |
|
1921
|
|
|
|
|
|
|
die if $@; |
|
1922
|
|
|
|
|
|
|
($op, $sub, exists $NO_MUTATE{$op} ? () : ("$op=", $sub)); |
|
1923
|
|
|
|
|
|
|
} |
|
1924
|
|
|
|
|
|
|
|
|
1925
|
|
|
|
|
|
|
sub _gen_unop { |
|
1926
|
|
|
|
|
|
|
my ($op, $func) = split '@', $_[0]; |
|
1927
|
|
|
|
|
|
|
no strict 'refs'; |
|
1928
|
|
|
|
|
|
|
*$op = \&$func if $op =~ /\w+/; # create an alias |
|
1929
|
|
|
|
|
|
|
($op, eval 'sub { '.$func.' $_[0] }'); |
|
1930
|
|
|
|
|
|
|
} |
|
1931
|
|
|
|
|
|
|
|
|
1932
|
|
|
|
|
|
|
sub initialize { |
|
1933
|
|
|
|
|
|
|
# Bless a null PDL into the supplied 1st arg package |
|
1934
|
|
|
|
|
|
|
# If 1st arg is a ref, get the package from it |
|
1935
|
|
|
|
|
|
|
bless PDL->null, ref($_[0]) || $_[0]; |
|
1936
|
|
|
|
|
|
|
} |
|
1937
|
|
|
|
|
|
|
|
|
1938
|
|
|
|
|
|
|
# so broadcasting doesn't also assign the real value into the imaginary |
|
1939
|
|
|
|
|
|
|
sub Cassgn { |
|
1940
|
|
|
|
|
|
|
my @args = !$_[2] ? @_[1,0] : @_[0,1]; |
|
1941
|
|
|
|
|
|
|
$args[1] = r2C($args[1]) if ref $args[1] ne __PACKAGE__; |
|
1942
|
|
|
|
|
|
|
PDL::Ops::assgn(@args); |
|
1943
|
|
|
|
|
|
|
$args[1]; |
|
1944
|
|
|
|
|
|
|
} |
|
1945
|
|
|
|
|
|
|
|
|
1946
|
|
|
|
|
|
|
use overload |
|
1947
|
|
|
|
|
|
|
(map _gen_biop($_), qw(++Cadd --Csub *+Cmul /-Cdiv **-Cpow atan2-Catan2 ==+Ceq .=-Cassgn)), |
|
1948
|
|
|
|
|
|
|
(map _gen_unop($_), qw(sin@Csin cos@Ccos exp@Cexp abs@Cabs log@Clog sqrt@Csqrt)), |
|
1949
|
|
|
|
|
|
|
(map +($_ => sub { confess "Can't compare complex numbers" }), qw(< > <= >=)), |
|
1950
|
|
|
|
|
|
|
"!=" => sub { !($_[0] == $_[1]) }, |
|
1951
|
|
|
|
|
|
|
'""' => sub { $_[0]->isnull ? "PDL::Complex->null" : $_[0]->as_native->string }, |
|
1952
|
|
|
|
|
|
|
; |
|
1953
|
|
|
|
|
|
|
|
|
1954
|
|
|
|
|
|
|
sub sum { |
|
1955
|
|
|
|
|
|
|
my($x) = @_; |
|
1956
|
|
|
|
|
|
|
return $x if $x->dims==1; |
|
1957
|
|
|
|
|
|
|
my $tmp = $x->mv(0,-1)->clump(-2)->mv(1,0)->sumover; |
|
1958
|
|
|
|
|
|
|
return $tmp; |
|
1959
|
|
|
|
|
|
|
} |
|
1960
|
|
|
|
|
|
|
|
|
1961
|
|
|
|
|
|
|
sub sumover{ |
|
1962
|
|
|
|
|
|
|
my $m = shift; |
|
1963
|
|
|
|
|
|
|
PDL::Ufunc::sumover($m->transpose); |
|
1964
|
|
|
|
|
|
|
} |
|
1965
|
|
|
|
|
|
|
|
|
1966
|
|
|
|
|
|
|
*PDL::Complex::Csumover=\&sumover; # define through alias |
|
1967
|
|
|
|
|
|
|
|
|
1968
|
|
|
|
|
|
|
*PDL::Complex::prodover=\&Cprodover; # define through alias |
|
1969
|
|
|
|
|
|
|
|
|
1970
|
|
|
|
|
|
|
sub prod { |
|
1971
|
|
|
|
|
|
|
my($x) = @_; |
|
1972
|
|
|
|
|
|
|
return $x if $x->dims==1; |
|
1973
|
|
|
|
|
|
|
my $tmp = $x->mv(0,-1)->clump(-2)->mv(1,0)->prodover; |
|
1974
|
|
|
|
|
|
|
return $tmp; |
|
1975
|
|
|
|
|
|
|
} |
|
1976
|
|
|
|
|
|
|
|
|
1977
|
|
|
|
|
|
|
=head1 AUTHOR |
|
1978
|
|
|
|
|
|
|
|
|
1979
|
|
|
|
|
|
|
Copyright (C) 2000 Marc Lehmann . |
|
1980
|
|
|
|
|
|
|
All rights reserved. There is no warranty. You are allowed |
|
1981
|
|
|
|
|
|
|
to redistribute this software / documentation as described |
|
1982
|
|
|
|
|
|
|
in the file COPYING in the PDL distribution. |
|
1983
|
|
|
|
|
|
|
|
|
1984
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
1985
|
|
|
|
|
|
|
|
|
1986
|
|
|
|
|
|
|
perl(1), L. |
|
1987
|
|
|
|
|
|
|
|
|
1988
|
|
|
|
|
|
|
=cut |
|
1989
|
|
|
|
|
|
|
#line 1990 "Complex.pm" |
|
1990
|
|
|
|
|
|
|
|
|
1991
|
|
|
|
|
|
|
# Exit with OK status |
|
1992
|
|
|
|
|
|
|
|
|
1993
|
|
|
|
|
|
|
1; |