

o  i is a constant exported by this module, which represents 1**0.5, i.e. the imaginary unit. it can be used to quickly and conviniently write complex constants like this: 4+3*i. 
o  Use r2C(realvalues) to convert from real to complex, as in $r = Cpow $cplx, r2C 2. The overloaded operators automatically do that for you, all the other functions, do not. So Croots 1, 5 will return all the fifths roots of 1+1*i (due to threading). 
o  use cplx(realvaluedpiddle) to cast from normal piddles into the complex datatype. Use real(complexvaluedpiddle) to cast back. This requires a copy, though. 
o  This module has received some testing by Vanuxem Grégory (g.vanuxem at wanadoo dot fr). Please report any other errors you come across! 
The complex constant five is equal to pdl(1,0):
pdl> p $x = r2C 5 5 +0iNow calculate the three cubic roots of of five:
pdl> p $r = Croots $x, 3 [1.70998 +0i 0.854988 +1.48088i 0.854988 1.48088i]Check that these really are the roots:
pdl> p $r ** 3 [5 +0i 5 1.22465e15i 5 7.65714e15i]Duh! Could be better. Now try by multiplying $r three times with itself:
pdl> p $r*$r*$r [5 +0i 5 4.72647e15i 5 7.53694e15i]Well... maybe Cpow (which is used by the ** operator) isn’t as bad as I thought. Now multiply by i and negate, which is just a very expensive way of swapping real and imaginary parts.
pdl> p ($r*i) [0 1.70998i 1.48088 +0.854988i 1.48088 +0.854988i]Now plot the magnitude of (part of) the complex sine. First generate the coefficients:
pdl> $sin = i * zeroes(50)>xlinvals(2,4) + zeroes(50)>xlinvals(0,7)Now plot the imaginary part, the real part and the magnitude of the sine into the same diagram:
pdl> use PDL::Graphics::Gnuplot pdl> gplot( with => lines, PDL::cat(im ( sin $sin ), re ( sin $sin ), abs( sin $sin ) ))An ASCII version of this plot looks like this:
30 +++++++++++++ + + + + + + + + + + +  $$  $  25 ++ $$ ++  ***   ** ***   $$* * 20 ++ $** ++  $$$* #  $$$ * #   $$ * #  15 ++ $$$ * # ++  $$$ ** #   $$$$ * #   $$$$ * #  10 ++ $$$$$ * # ++  $$$$$ * #   $$$$$$$ * #  5 ++ $$$############ * # ++ *****$$$### ### * #  * #***** # * #   ### *** ### ** #  0 ## *** # * # ++  * # * #   *** # ** #   * # * #  5 ++ ** # * # ++  *** ## ** #   * #* #   **** ***## #  10 ++ **** # # ++  # #   ## ##  + + + + + + + ### + ### + + + 15 ++++++++###++++ 0 5 10 15 20 25 30 35 40 45 50
Cast a realvalued piddle to the complex datatype. The first dimension of the piddle must be of size 2. After this the usual (complex) arithmetic operators are applied to this pdl, rather than the normal elementwise pdl operators. Dataflow to the complex parent works. Use sever on the result if you don’t want this.
Cast a realvalued piddle to the complex datatype without dataflow and inplace. Achieved by merely reblessing a piddle. The first dimension of the piddle must be of size 2.
Cast a complex valued pdl back to the normal pdl datatype. Afterwards the normal elementwise pdl operators are used in operations. Dataflow to the real parent works. Use sever on the result if you don’t want this.
Signature: (r(); [o]c(m=2))convert real to complex, assuming an imaginary part of zero
r2C does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (r(); [o]c(m=2))convert imaginary to complex, assuming a real part of zero
i2C does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (r(m=2); float+ [o]p(m=2))convert complex numbers in rectangular form to polar (mod,arg) form. Works inplace
Cr2p does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (r(m=2); [o]p(m=2))convert complex numbers in polar (mod,arg) form to rectangular form. Works inplace
Cp2r does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); b(m=2); [o]c(m=2))complex multiplication
Cmul does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2,n); [o]c(m=2))Project via product to N1 dimension
Cprodover does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); b(); [o]c(m=2))mixed complex/real multiplication
Cscale does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); b(m=2); [o]c(m=2))complex division
Cdiv does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); b(m=2); [o]c())Complex comparison oeprator (spaceship). It orders by real first, then by imaginary. Hm, but it is mathematical nonsense! Complex numbers cannot be ordered.
Ccmp does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c(m=2))complex conjugation. Works inplace
Cconj does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c())complex abs() (also known as modulus)
Cabs does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c())complex squared abs() (also known squared modulus)
Cabs2 does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c())complex argument function (angle)
Carg does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c(m=2))
sin (a) = 1/(2*i) * (exp (a*i)  exp (a*i)). Works inplaceCsin does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c(m=2))
cos (a) = 1/2 * (exp (a*i) + exp (a*i)). Works inplaceCcos does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
tan (a) = i * (exp (a*i)  exp (a*i)) / (exp (a*i) + exp (a*i))
Signature: (a(m=2); [o]c(m=2))exp (a) = exp (real (a)) * (cos (imag (a)) + i * sin (imag (a))). Works inplace
Cexp does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c(m=2))log (a) = log (cabs (a)) + i * carg (a). Works inplace
Clog does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); b(m=2); [o]c(m=2))complex pow() (**operator)
Cpow does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c(m=2))Works inplace
Csqrt does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c(m=2))Works inplace
Casin does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c(m=2))Works inplace
Cacos does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Return the complex atan().
Signature: (a(m=2); [o]c(m=2))
sinh (a) = (exp (a)  exp (a)) / 2. Works inplaceCsinh does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c(m=2))
cosh (a) = (exp (a) + exp (a)) / 2. Works inplaceCcosh does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c(m=2))Works inplace
Ctanh does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c(m=2))Works inplace
Casinh does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c(m=2))Works inplace
Cacosh does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c(m=2))Works inplace
Catanh does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c(m=2))compute the projection of a complex number to the riemann sphere. Works inplace
Cproj does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Signature: (a(m=2); [o]c(m=2,n); int n => n)Compute the n roots of a. n must be a positive integer. The result will always be a complex type!
Croots does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Return the real or imaginary part of the complex number(s) given. These are slicing operators, so data flow works. The real and imaginary parts are returned as piddles (ref eq PDL).
Signature: (coeffs(n); x(c=2,m); [o]out(c=2,m))evaluate the polynomial with (real) coefficients coeffs at the (complex) position(s) x. coeffs[0] is the constant term.
rCpolynomial does not process bad values. It will set the badvalue flag of all output piddles if the flag is set for any of the input piddles.
Copyright (C) 2000 Marc Lehmann <pcg@goof.com>. All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation as described in the file COPYING in the PDL distribution.
perl(1), PDL.
perl v5.20.3  COMPLEX (3)  20160403 
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.