"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "GENERATED/PDL/Complex.pm" between
PDL-2.077.tar.gz and PDL-2.078.tar.gz

About: PDL (Perl Data Language) aims to turn perl into an efficient numerical language for scientific computing (similar to IDL and MatLab).

Complex.pm  (PDL-2.077):Complex.pm  (PDL-2.078)
skipping to change at line 30 skipping to change at line 30
#line 17 "complex.pd" #line 17 "complex.pd"
use strict; use strict;
use warnings; use warnings;
use Carp; use Carp;
our $VERSION = '2.009'; our $VERSION = '2.009';
use PDL::Slices; use PDL::Slices;
use PDL::Types; use PDL::Types;
use PDL::Bad; use PDL::Bad;
use vars qw($sep $sep2);
#line 36 "Complex.pm"
#line 30 "complex.pd"
=encoding iso-8859-1 =encoding iso-8859-1
=head1 NAME =head1 NAME
PDL::Complex - handle complex numbers (DEPRECATED - use native complex) PDL::Complex - handle complex numbers (DEPRECATED - use native complex)
=head1 SYNOPSIS =head1 SYNOPSIS
use PDL; use PDL;
use PDL::Complex; use PDL::Complex;
skipping to change at line 109 skipping to change at line 104
= Cpow $cplx, r2C 2>. The overloaded operators automatically do that for = Cpow $cplx, r2C 2>. The overloaded operators automatically do that for
you, all the other functions, do not. So C<Croots 1, 5> will return all you, all the other functions, do not. So C<Croots 1, 5> will return all
the fifths roots of 1+1*i (due to broadcasting). the fifths roots of 1+1*i (due to broadcasting).
=item * =item *
use C<cplx(real-valued-ndarray)> to cast from normal ndarrays into the use C<cplx(real-valued-ndarray)> to cast from normal ndarrays into the
complex datatype. Use C<real(complex-valued-ndarray)> to cast back. This complex datatype. Use C<real(complex-valued-ndarray)> to cast back. This
requires a copy, though. requires a copy, though.
=item *
This module has received some testing by Vanuxem Grégory
(g.vanuxem at wanadoo dot fr). Please report any other errors you
come across!
=back =back
=head1 EXAMPLE WALK-THROUGH =head1 EXAMPLE WALK-THROUGH
The complex constant five is equal to C<pdl(1,0)>: The complex constant five is equal to C<pdl(1,0)>:
pdl> p $x = r2C 5 pdl> p $x = r2C 5
5 +0i 5 +0i
Now calculate the three cubic roots of five: Now calculate the three cubic roots of five:
skipping to change at line 247 skipping to change at line 236
Comparing complex numbers other than for equality is a fatal error. Comparing complex numbers other than for equality is a fatal error.
=cut =cut
my $i; my $i;
BEGIN { $i = bless pdl 0,1 } BEGIN { $i = bless pdl 0,1 }
{ {
no warnings 'redefine'; no warnings 'redefine';
sub i { $i->copy + (@_ ? $_[0] : 0) }; sub i { $i->copy + (@_ ? $_[0] : 0) };
} }
#line 256 "Complex.pm"
# sensible aliases from PDL::LinearAlgebra
*r2p = \&Cr2p;
*p2r = \&Cp2r;
*conj = \&Cconj;
*abs = \&Cabs;
*abs2 = \&Cabs2;
*arg = \&Carg;
*tan = \&Ctan;
*proj = \&Cproj;
*asin = \&Casin;
*acos = \&Cacos;
*atan = \&Catan;
*sinh = \&Csinh;
*cosh = \&Ccosh;
*tanh = \&Ctanh;
*asinh = \&Casinh;
*acosh = \&Cacosh;
*atanh = \&Catanh;
#line 261 "Complex.pm"
=head1 FUNCTIONS =head1 FUNCTIONS
=cut =cut
#line 325 "complex.pd" #line 332 "complex.pd"
=head2 from_native =head2 from_native
=for ref =for ref
Class method to convert a native-complex ndarray to a PDL::Complex object. Class method to convert a native-complex ndarray to a PDL::Complex object.
=for usage =for usage
PDL::Complex->from_native($native_complex_ndarray) PDL::Complex->from_native($native_complex_ndarray)
skipping to change at line 355 skipping to change at line 363
bless $_[0]; bless $_[0];
} }
*PDL::cplx = \&cplx; *PDL::cplx = \&cplx;
*PDL::complex = \&complex; *PDL::complex = \&complex;
sub real($) { sub real($) {
return $_[0] unless UNIVERSAL::isa($_[0],'PDL::Complex'); # NOOP unless compl ex return $_[0] unless UNIVERSAL::isa($_[0],'PDL::Complex'); # NOOP unless compl ex
bless $_[0]->slice(''), 'PDL'; bless $_[0]->slice(''), 'PDL';
} }
#line 373 "Complex.pm" #line 378 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 r2C =head2 r2C
=for sig =for sig
Signature: (r(); [o]c(m=2)) Signature: (r(); [o]c(m=2))
=for ref =for ref
convert real to complex, assuming an imaginary part of zero convert real to complex, assuming an imaginary part of zero
=for bad =for bad
r2C does not process bad values. r2C does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 398 "Complex.pm" #line 403 "Complex.pm"
#line 1059 "../../blib/lib/PDL/PP.pm" #line 1059 "../../blib/lib/PDL/PP.pm"
undef &PDL::r2C; undef &PDL::r2C;
*PDL::r2C = \&PDL::Complex::r2C; *PDL::r2C = \&PDL::Complex::r2C;
sub PDL::Complex::r2C { sub PDL::Complex::r2C {
return $_[0] if UNIVERSAL::isa($_[0],'PDL::Complex'); return $_[0] if UNIVERSAL::isa($_[0],'PDL::Complex');
my $r = __PACKAGE__->initialize; my $r = __PACKAGE__->initialize;
&PDL::Complex::_r2C_int($_[0], $r); &PDL::Complex::_r2C_int($_[0], $r);
$r } $r }
#line 412 "Complex.pm" #line 417 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*r2C = \&PDL::Complex::r2C; BEGIN {*r2C = \&PDL::Complex::r2C;
} }
#line 420 "Complex.pm" #line 425 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 i2C =head2 i2C
=for sig =for sig
Signature: (r(); [o]c(m=2)) Signature: (r(); [o]c(m=2))
=for ref =for ref
convert imaginary to complex, assuming a real part of zero convert imaginary to complex, assuming a real part of zero
=for bad =for bad
i2C does not process bad values. i2C does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 445 "Complex.pm" #line 450 "Complex.pm"
#line 1059 "../../blib/lib/PDL/PP.pm" #line 1059 "../../blib/lib/PDL/PP.pm"
undef &PDL::i2C; *PDL::i2C = \&PDL::Complex::i2C; sub PDL::Complex::i2C { my $r = __PACKAGE__->initialize; &PDL::Complex::_i2C_int($_[0], $r); $r } undef &PDL::i2C; *PDL::i2C = \&PDL::Complex::i2C; sub PDL::Complex::i2C { my $r = __PACKAGE__->initialize; &PDL::Complex::_i2C_int($_[0], $r); $r }
#line 452 "Complex.pm" #line 457 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*i2C = \&PDL::Complex::i2C; BEGIN {*i2C = \&PDL::Complex::i2C;
} }
#line 460 "Complex.pm" #line 465 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Cr2p =head2 Cr2p
=for sig =for sig
Signature: (r(m=2); float+ [o]p(m=2)) Signature: (r(m=2); float+ [o]p(m=2))
=for ref =for ref
convert complex numbers in rectangular form to polar (mod,arg) form. Works inpla ce convert complex numbers in rectangular form to polar (mod,arg) form. Works inpla ce
=for bad =for bad
Cr2p does not process bad values. Cr2p does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 485 "Complex.pm" #line 490 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cr2p = \&PDL::Complex::Cr2p; BEGIN {*Cr2p = \&PDL::Complex::Cr2p;
} }
#line 493 "Complex.pm" #line 498 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Cp2r =head2 Cp2r
=for sig =for sig
Signature: (r(m=2); [o]p(m=2)) Signature: (r(m=2); [o]p(m=2))
=for ref =for ref
convert complex numbers in polar (mod,arg) form to rectangular form. Works inpla ce convert complex numbers in polar (mod,arg) form to rectangular form. Works inpla ce
=for bad =for bad
Cp2r does not process bad values. Cp2r does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 518 "Complex.pm" #line 523 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cp2r = \&PDL::Complex::Cp2r; BEGIN {*Cp2r = \&PDL::Complex::Cp2r;
} }
#line 526 "Complex.pm" #line 531 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cadd = \&PDL::Complex::Cadd; BEGIN {*Cadd = \&PDL::Complex::Cadd;
} }
#line 534 "Complex.pm" #line 539 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Csub = \&PDL::Complex::Csub; BEGIN {*Csub = \&PDL::Complex::Csub;
} }
#line 542 "Complex.pm" #line 547 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Cmul =head2 Cmul
=for sig =for sig
Signature: (a(m=2); b(m=2); [o]c(m=2)) Signature: (a(m=2); b(m=2); [o]c(m=2))
=for ref =for ref
complex multiplication complex multiplication
=for bad =for bad
Cmul does not process bad values. Cmul does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 567 "Complex.pm" #line 572 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cmul = \&PDL::Complex::Cmul; BEGIN {*Cmul = \&PDL::Complex::Cmul;
} }
#line 575 "Complex.pm" #line 580 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Cprodover =head2 Cprodover
=for sig =for sig
Signature: (a(m=2,n); [o]c(m=2)) Signature: (a(m=2,n); [o]c(m=2))
=for ref =for ref
Project via product to N-1 dimension Project via product to N-1 dimension
=for bad =for bad
Cprodover does not process bad values. Cprodover does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 600 "Complex.pm" #line 605 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cprodover = \&PDL::Complex::Cprodover; BEGIN {*Cprodover = \&PDL::Complex::Cprodover;
} }
#line 608 "Complex.pm" #line 613 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Cscale =head2 Cscale
=for sig =for sig
Signature: (a(m=2); b(); [o]c(m=2)) Signature: (a(m=2); b(); [o]c(m=2))
=for ref =for ref
mixed complex/real multiplication mixed complex/real multiplication
=for bad =for bad
Cscale does not process bad values. Cscale does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 633 "Complex.pm" #line 638 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cscale = \&PDL::Complex::Cscale; BEGIN {*Cscale = \&PDL::Complex::Cscale;
} }
#line 641 "Complex.pm" #line 646 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Cdiv =head2 Cdiv
=for sig =for sig
Signature: (a(m=2); b(m=2); [o]c(m=2)) Signature: (a(m=2); b(m=2); [o]c(m=2))
=for ref =for ref
complex division complex division
=for bad =for bad
Cdiv does not process bad values. Cdiv does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 666 "Complex.pm" #line 671 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cdiv = \&PDL::Complex::Cdiv; BEGIN {*Cdiv = \&PDL::Complex::Cdiv;
} }
#line 674 "Complex.pm" #line 679 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Ceq =head2 Ceq
=for sig =for sig
Signature: (a(m=2); b(m=2); [o]c()) Signature: (a(m=2); b(m=2); [o]c())
=for ref =for ref
Complex equality operator. Complex equality operator.
=for bad =for bad
Ceq does not process bad values. Ceq does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 699 "Complex.pm" #line 704 "Complex.pm"
#line 1059 "../../blib/lib/PDL/PP.pm" #line 1059 "../../blib/lib/PDL/PP.pm"
sub PDL::Complex::Ceq { sub PDL::Complex::Ceq {
my @args = !$_[2] ? @_[1,0] : @_[0,1]; my @args = !$_[2] ? @_[1,0] : @_[0,1];
$args[1] = r2C($args[1]) if ref $args[1] ne __PACKAGE__; $args[1] = r2C($args[1]) if ref $args[1] ne __PACKAGE__;
PDL::Complex::_Ceq_int($args[0], $args[1], my $r = PDL->null); PDL::Complex::_Ceq_int($args[0], $args[1], my $r = PDL->null);
$r; $r;
} }
#line 711 "Complex.pm" #line 716 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Ceq = \&PDL::Complex::Ceq; BEGIN {*Ceq = \&PDL::Complex::Ceq;
} }
#line 719 "Complex.pm" #line 724 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Cconj =head2 Cconj
=for sig =for sig
Signature: (a(m=2); [o]c(m=2)) Signature: (a(m=2); [o]c(m=2))
=for ref =for ref
complex conjugation. Works inplace complex conjugation. Works inplace
=for bad =for bad
Cconj does not process bad values. Cconj does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 744 "Complex.pm" #line 749 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cconj = \&PDL::Complex::Cconj; BEGIN {*Cconj = \&PDL::Complex::Cconj;
} }
#line 752 "Complex.pm" #line 757 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Cabs =head2 Cabs
=for sig =for sig
Signature: (a(m=2); [o]c()) Signature: (a(m=2); [o]c())
=for ref =for ref
complex C<abs()> (also known as I<modulus>) complex C<abs()> (also known as I<modulus>)
=for bad =for bad
Cabs does not process bad values. Cabs does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 777 "Complex.pm" #line 782 "Complex.pm"
#line 1059 "../../blib/lib/PDL/PP.pm" #line 1059 "../../blib/lib/PDL/PP.pm"
sub PDL::Complex::Cabs($) { sub PDL::Complex::Cabs($) {
my $pdl= shift; my $pdl= shift;
my $abs = PDL->null; my $abs = PDL->null;
&PDL::Complex::_Cabs_int($pdl, $abs); &PDL::Complex::_Cabs_int($pdl, $abs);
$abs; $abs;
} }
#line 789 "Complex.pm" #line 794 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cabs = \&PDL::Complex::Cabs; BEGIN {*Cabs = \&PDL::Complex::Cabs;
} }
#line 797 "Complex.pm" #line 802 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Cabs2 =head2 Cabs2
=for sig =for sig
Signature: (a(m=2); [o]c()) Signature: (a(m=2); [o]c())
=for ref =for ref
complex squared C<abs()> (also known I<squared modulus>) complex squared C<abs()> (also known I<squared modulus>)
=for bad =for bad
Cabs2 does not process bad values. Cabs2 does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 822 "Complex.pm" #line 827 "Complex.pm"
#line 1059 "../../blib/lib/PDL/PP.pm" #line 1059 "../../blib/lib/PDL/PP.pm"
sub PDL::Complex::Cabs2($) { sub PDL::Complex::Cabs2($) {
my $pdl= shift; my $pdl= shift;
my $abs2 = PDL->null; my $abs2 = PDL->null;
&PDL::Complex::_Cabs2_int($pdl, $abs2); &PDL::Complex::_Cabs2_int($pdl, $abs2);
$abs2; $abs2;
} }
#line 834 "Complex.pm" #line 839 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cabs2 = \&PDL::Complex::Cabs2; BEGIN {*Cabs2 = \&PDL::Complex::Cabs2;
} }
#line 842 "Complex.pm" #line 847 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Carg =head2 Carg
=for sig =for sig
Signature: (a(m=2); [o]c()) Signature: (a(m=2); [o]c())
=for ref =for ref
complex argument function ("angle") complex argument function ("angle")
=for bad =for bad
Carg does not process bad values. Carg does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 867 "Complex.pm" #line 872 "Complex.pm"
#line 1059 "../../blib/lib/PDL/PP.pm" #line 1059 "../../blib/lib/PDL/PP.pm"
sub PDL::Complex::Carg($) { sub PDL::Complex::Carg($) {
my $pdl= shift; my $pdl= shift;
my $arg = PDL->null; my $arg = PDL->null;
&PDL::Complex::_Carg_int($pdl, $arg); &PDL::Complex::_Carg_int($pdl, $arg);
$arg; $arg;
} }
#line 879 "Complex.pm" #line 884 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Carg = \&PDL::Complex::Carg; BEGIN {*Carg = \&PDL::Complex::Carg;
} }
#line 887 "Complex.pm" #line 892 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Csin =head2 Csin
=for sig =for sig
Signature: (a(m=2); [o]c(m=2)) Signature: (a(m=2); [o]c(m=2))
=for ref =for ref
sin (a) = 1/(2*i) * (exp (a*i) - exp (-a*i)). Works inplace sin (a) = 1/(2*i) * (exp (a*i) - exp (-a*i)). Works inplace
=for bad =for bad
Csin does not process bad values. Csin does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 912 "Complex.pm" #line 917 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Csin = \&PDL::Complex::Csin; BEGIN {*Csin = \&PDL::Complex::Csin;
} }
#line 920 "Complex.pm" #line 925 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Ccos =head2 Ccos
=for sig =for sig
Signature: (a(m=2); [o]c(m=2)) Signature: (a(m=2); [o]c(m=2))
=for ref =for ref
cos (a) = 1/2 * (exp (a*i) + exp (-a*i)). Works inplace cos (a) = 1/2 * (exp (a*i) + exp (-a*i)). Works inplace
=for bad =for bad
Ccos does not process bad values. Ccos does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 945 "Complex.pm" #line 950 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Ccos = \&PDL::Complex::Ccos; BEGIN {*Ccos = \&PDL::Complex::Ccos;
} }
#line 953 "Complex.pm" #line 958 "Complex.pm"
#line 680 "complex.pd" #line 687 "complex.pd"
=head2 Ctan =head2 Ctan
=for ref =for ref
Complex tangent Complex tangent
tan (a) = -i * (exp (a*i) - exp (-a*i)) / (exp (a*i) + exp (-a*i)) tan (a) = -i * (exp (a*i) - exp (-a*i)) / (exp (a*i) + exp (-a*i))
Does not work inplace. Does not work inplace.
=cut =cut
sub Ctan($) { Csin($_[0]) / Ccos($_[0]) } sub Ctan($) { Csin($_[0]) / Ccos($_[0]) }
#line 973 "Complex.pm" #line 978 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Cexp =head2 Cexp
=for sig =for sig
Signature: (a(m=2); [o]c(m=2)) Signature: (a(m=2); [o]c(m=2))
=for ref =for ref
exp (a) = exp (real (a)) * (cos (imag (a)) + i * sin (imag (a))). Works inplac e exp (a) = exp (real (a)) * (cos (imag (a)) + i * sin (imag (a))). Works inplac e
=for bad =for bad
Cexp does not process bad values. Cexp does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 998 "Complex.pm" #line 1003 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cexp = \&PDL::Complex::Cexp; BEGIN {*Cexp = \&PDL::Complex::Cexp;
} }
#line 1006 "Complex.pm" #line 1011 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Clog =head2 Clog
=for sig =for sig
Signature: (a(m=2); [o]c(m=2)) Signature: (a(m=2); [o]c(m=2))
=for ref =for ref
log (a) = log (cabs (a)) + i * carg (a). Works inplace log (a) = log (cabs (a)) + i * carg (a). Works inplace
=for bad =for bad
Clog does not process bad values. Clog does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 1031 "Complex.pm" #line 1036 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Clog = \&PDL::Complex::Clog; BEGIN {*Clog = \&PDL::Complex::Clog;
} }
#line 1039 "Complex.pm" #line 1044 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Cpow =head2 Cpow
=for sig =for sig
Signature: (a(m=2); b(m=2); [o]c(m=2)) Signature: (a(m=2); b(m=2); [o]c(m=2))
=for ref =for ref
complex C<pow()> (C<**>-operator) complex C<pow()> (C<**>-operator)
=for bad =for bad
Cpow does not process bad values. Cpow does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 1064 "Complex.pm" #line 1069 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cpow = \&PDL::Complex::Cpow; BEGIN {*Cpow = \&PDL::Complex::Cpow;
} }
#line 1072 "Complex.pm" #line 1077 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Csqrt =head2 Csqrt
=for sig =for sig
Signature: (a(m=2); [o]c(m=2)) Signature: (a(m=2); [o]c(m=2))
=for ref =for ref
Works inplace Works inplace
=for bad =for bad
Csqrt does not process bad values. Csqrt does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 1097 "Complex.pm" #line 1102 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Csqrt = \&PDL::Complex::Csqrt; BEGIN {*Csqrt = \&PDL::Complex::Csqrt;
} }
#line 1105 "Complex.pm" #line 1110 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Casin =head2 Casin
=for sig =for sig
Signature: (a(m=2); [o]c(m=2)) Signature: (a(m=2); [o]c(m=2))
=for ref =for ref
Works inplace Works inplace
=for bad =for bad
Casin does not process bad values. Casin does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 1130 "Complex.pm" #line 1135 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Casin = \&PDL::Complex::Casin; BEGIN {*Casin = \&PDL::Complex::Casin;
} }
#line 1138 "Complex.pm" #line 1143 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Cacos =head2 Cacos
=for sig =for sig
Signature: (a(m=2); [o]c(m=2)) Signature: (a(m=2); [o]c(m=2))
=for ref =for ref
Works inplace Works inplace
=for bad =for bad
Cacos does not process bad values. Cacos does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 1163 "Complex.pm" #line 1168 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cacos = \&PDL::Complex::Cacos; BEGIN {*Cacos = \&PDL::Complex::Cacos;
} }
#line 1171 "Complex.pm" #line 1176 "Complex.pm"
#line 827 "complex.pd" #line 834 "complex.pd"
=head2 Catan =head2 Catan
=for ref =for ref
Return the complex C<atan()>. Return the complex C<atan()>.
Does not work inplace. Does not work inplace.
=cut =cut
sub Catan($) { sub Catan($) {
my $z = shift; my $z = shift;
Cmul Clog(Cdiv (PDL::Complex::i()+$z, PDL::Complex::i()-$z)), pdl(0, 0.5); Cmul Clog(Cdiv (PDL::Complex::i()+$z, PDL::Complex::i()-$z)), pdl(0, 0.5);
} }
#line 1192 "Complex.pm" #line 1197 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Csinh =head2 Csinh
=for sig =for sig
Signature: (a(m=2); [o]c(m=2)) Signature: (a(m=2); [o]c(m=2))
=for ref =for ref
sinh (a) = (exp (a) - exp (-a)) / 2. Works inplace sinh (a) = (exp (a) - exp (-a)) / 2. Works inplace
=for bad =for bad
Csinh does not process bad values. Csinh does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 1217 "Complex.pm" #line 1222 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Csinh = \&PDL::Complex::Csinh; BEGIN {*Csinh = \&PDL::Complex::Csinh;
} }
#line 1225 "Complex.pm" #line 1230 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Ccosh =head2 Ccosh
=for sig =for sig
Signature: (a(m=2); [o]c(m=2)) Signature: (a(m=2); [o]c(m=2))
=for ref =for ref
cosh (a) = (exp (a) + exp (-a)) / 2. Works inplace cosh (a) = (exp (a) + exp (-a)) / 2. Works inplace
=for bad =for bad
Ccosh does not process bad values. Ccosh does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 1250 "Complex.pm" #line 1255 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Ccosh = \&PDL::Complex::Ccosh; BEGIN {*Ccosh = \&PDL::Complex::Ccosh;
} }
#line 1258 "Complex.pm" #line 1263 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Ctanh =head2 Ctanh
=for sig =for sig
Signature: (a(m=2); [o]c(m=2)) Signature: (a(m=2); [o]c(m=2))
=for ref =for ref
Works inplace Works inplace
=for bad =for bad
Ctanh does not process bad values. Ctanh does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 1283 "Complex.pm" #line 1288 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Ctanh = \&PDL::Complex::Ctanh; BEGIN {*Ctanh = \&PDL::Complex::Ctanh;
} }
#line 1291 "Complex.pm" #line 1296 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Casinh =head2 Casinh
=for sig =for sig
Signature: (a(m=2); [o]c(m=2)) Signature: (a(m=2); [o]c(m=2))
=for ref =for ref
Works inplace Works inplace
=for bad =for bad
Casinh does not process bad values. Casinh does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 1316 "Complex.pm" #line 1321 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Casinh = \&PDL::Complex::Casinh; BEGIN {*Casinh = \&PDL::Complex::Casinh;
} }
#line 1324 "Complex.pm" #line 1329 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Cacosh =head2 Cacosh
=for sig =for sig
Signature: (a(m=2); [o]c(m=2)) Signature: (a(m=2); [o]c(m=2))
=for ref =for ref
Works inplace Works inplace
=for bad =for bad
Cacosh does not process bad values. Cacosh does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 1349 "Complex.pm" #line 1354 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cacosh = \&PDL::Complex::Cacosh; BEGIN {*Cacosh = \&PDL::Complex::Cacosh;
} }
#line 1357 "Complex.pm" #line 1362 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Catanh =head2 Catanh
=for sig =for sig
Signature: (a(m=2); [o]c(m=2)) Signature: (a(m=2); [o]c(m=2))
=for ref =for ref
Works inplace Works inplace
=for bad =for bad
Catanh does not process bad values. Catanh does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 1382 "Complex.pm" #line 1387 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Catanh = \&PDL::Complex::Catanh; BEGIN {*Catanh = \&PDL::Complex::Catanh;
} }
#line 1390 "Complex.pm" #line 1395 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Cproj =head2 Cproj
=for sig =for sig
Signature: (a(m=2); [o]c(m=2)) Signature: (a(m=2); [o]c(m=2))
=for ref =for ref
compute the projection of a complex number to the riemann sphere. Works inplace compute the projection of a complex number to the riemann sphere. Works inplace
=for bad =for bad
Cproj does not process bad values. Cproj does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 1415 "Complex.pm" #line 1420 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cproj = \&PDL::Complex::Cproj; BEGIN {*Cproj = \&PDL::Complex::Cproj;
} }
#line 1423 "Complex.pm" #line 1428 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 Croots =head2 Croots
=for sig =for sig
Signature: (a(m=2); [o]c(m=2,n); int n => n) Signature: (a(m=2); [o]c(m=2,n); int n => n)
=for ref =for ref
Compute the C<n> roots of C<a>. C<n> must be a positive integer. The result will always be a complex type! Compute the C<n> roots of C<a>. C<n> must be a positive integer. The result will always be a complex type!
=for bad =for bad
Croots does not process bad values. Croots does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 1448 "Complex.pm" #line 1453 "Complex.pm"
#line 1059 "../../blib/lib/PDL/PP.pm" #line 1059 "../../blib/lib/PDL/PP.pm"
sub PDL::Complex::Croots($$) { sub PDL::Complex::Croots($$) {
my ($pdl, $n) = @_; my ($pdl, $n) = @_;
my $r = PDL->null; my $r = PDL->null;
&PDL::Complex::_Croots_int($pdl, $r, $n); &PDL::Complex::_Croots_int($pdl, $r, $n);
bless $r; bless $r;
} }
#line 1460 "Complex.pm" #line 1465 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*Croots = \&PDL::Complex::Croots; BEGIN {*Croots = \&PDL::Complex::Croots;
} }
#line 1468 "Complex.pm" #line 1473 "Complex.pm"
#line 995 "complex.pd" #line 1002 "complex.pd"
=head2 re, im =head2 re, im
Return the real or imaginary part of the complex number(s) given. Return the real or imaginary part of the complex number(s) given.
These are slicing operators, so data flow works. The real and These are slicing operators, so data flow works. The real and
imaginary parts are returned as ndarrays (ref eq PDL). imaginary parts are returned as ndarrays (ref eq PDL).
=cut =cut
skipping to change at line 1248 skipping to change at line 1256
{ {
no warnings 'redefine'; no warnings 'redefine';
# if the argument does anything other than pass through 0-th dim, re-bless # if the argument does anything other than pass through 0-th dim, re-bless
sub slice :lvalue { sub slice :lvalue {
my $first = ref $_[1] ? $_[1][0] : (split ',', $_[1])[0]; my $first = ref $_[1] ? $_[1][0] : (split ',', $_[1])[0];
my $class = ($first//'') =~ /^[:x]?$/i ? ref($_[0]) : 'PDL'; my $class = ($first//'') =~ /^[:x]?$/i ? ref($_[0]) : 'PDL';
my $ret = bless $_[0]->SUPER::slice(@_[1..$#_]), $class; my $ret = bless $_[0]->SUPER::slice(@_[1..$#_]), $class;
$ret; $ret;
} }
} }
#line 1497 "Complex.pm" #line 1502 "Complex.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 rCpolynomial =head2 rCpolynomial
=for sig =for sig
Signature: (coeffs(n); x(c=2,m); [o]out(c=2,m)) Signature: (coeffs(n); x(c=2,m); [o]out(c=2,m))
=for ref =for ref
evaluate the polynomial with (real) coefficients C<coeffs> at the (complex) posi tion(s) C<x>. C<coeffs[0]> is the constant term. evaluate the polynomial with (real) coefficients C<coeffs> at the (complex) posi tion(s) C<x>. C<coeffs[0]> is the constant term.
=for bad =for bad
rCpolynomial does not process bad values. rCpolynomial does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 1522 "Complex.pm" #line 1527 "Complex.pm"
#line 1059 "../../blib/lib/PDL/PP.pm" #line 1059 "../../blib/lib/PDL/PP.pm"
sub rCpolynomial { sub rCpolynomial {
my $coeffs = shift; my $coeffs = shift;
my $x = shift; my $x = shift;
my $out = $x->copy; my $out = $x->copy;
_rCpolynomial_int($coeffs,$x,$out); _rCpolynomial_int($coeffs,$x,$out);
return PDL::complex($out); return PDL::complex($out);
} }
#line 1536 "Complex.pm" #line 1541 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
BEGIN {*rCpolynomial = \&PDL::Complex::rCpolynomial; BEGIN {*rCpolynomial = \&PDL::Complex::rCpolynomial;
} }
#line 1544 "Complex.pm" #line 1549 "Complex.pm"
#line 1060 "complex.pd" #line 1067 "complex.pd"
# overload must be here, so that all the functions can be seen # overload must be here, so that all the functions can be seen
# undocumented compatibility functions (thanks to Luis Mochan!) # undocumented compatibility functions (thanks to Luis Mochan!)
sub Catan2($$) { Clog( $_[1] + i()*$_[0])/i } sub Catan2($$) { Clog( $_[1] + i()*$_[0])/i }
sub atan2($$) { Clog( $_[1] + i()*$_[0])/i } sub atan2($$) { Clog( $_[1] + i()*$_[0])/i }
=begin comment =begin comment
In _gen_biop, the '+' or '-' between the operator (e.g., '*') and the In _gen_biop, the '+' or '-' between the operator (e.g., '*') and the
skipping to change at line 1387 skipping to change at line 1395
Copyright (C) 2000 Marc Lehmann <pcg@goof.com>. Copyright (C) 2000 Marc Lehmann <pcg@goof.com>.
All rights reserved. There is no warranty. You are allowed All rights reserved. There is no warranty. You are allowed
to redistribute this software / documentation as described to redistribute this software / documentation as described
in the file COPYING in the PDL distribution. in the file COPYING in the PDL distribution.
=head1 SEE ALSO =head1 SEE ALSO
perl(1), L<PDL>. perl(1), L<PDL>.
=cut =cut
#line 1652 "Complex.pm" #line 1657 "Complex.pm"
# Exit with OK status # Exit with OK status
1; 1;
 End of changes. 83 change blocks. 
92 lines changed or deleted 100 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)