PDL::Complex can handle complex numbers.
SYNOPSIS
use PDL;
use PDL::Complex;
This module features a growing number of functions manipulating complex numbers. These are usually represented as a pair [ real imag ] or [ angle phase ]. If not explicitly mentioned, the functions can work inplace (not yet implemented!!!) and require rectangular form.
While there is a procedural interface available ($a/$b*$c ), you can also opt to cast your pdl's into the PDL::Complex datatype, which works just like your normal piddles, but with all the normal perl operators overloaded.
The latter means that sin($a) + $b/$c will be evaluated using the normal rules of complex numbers, while other pdl functions (like max) just treat the piddle as a real-valued piddle with a lowest dimension of size 2, so max will return the maximum of all real and imaginary parts, not the "highest" (for some definition)
TIPS, TRICKS & CAVEATS
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.
Use r2C(real-values) 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).
use cplx(real-valued-piddle) to cast from normal piddles intot he complex datatype. Use real(complex-valued-piddle) to cast back. This requires a copy, though.
This module has received some testing by Vanuxem Gr�gory (g.vanuxem at wanadoo dot fr). Please report any other errors you come across!
Product's homepage
Requirements:
· Perl