"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "GENERATED/PDL/Complex.pm" between
PDL-2.074.tar.gz and PDL-2.075.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.074):Complex.pm  (PDL-2.075)
skipping to change at line 20 skipping to change at line 20
use PDL::Exporter; use PDL::Exporter;
use DynaLoader; use DynaLoader;
BEGIN { BEGIN {
our @ISA = ( 'PDL::Exporter','DynaLoader','PDL' ); our @ISA = ( 'PDL::Exporter','DynaLoader','PDL' );
push @PDL::Core::PP, __PACKAGE__; push @PDL::Core::PP, __PACKAGE__;
bootstrap PDL::Complex ; bootstrap PDL::Complex ;
} }
#line 18 "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); use vars qw($sep $sep2);
#line 35 "Complex.pm" #line 36 "Complex.pm"
#line 31 "complex.pd" #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;
skipping to change at line 100 skipping to change at line 101
quickly and conveniently write complex constants like this: C<4+3*i>. quickly and conveniently write complex constants like this: C<4+3*i>.
B<NB> This will override the PDL::Core function of the same name, which B<NB> This will override the PDL::Core function of the same name, which
returns a native complex value. returns a native complex value.
=item * =item *
Use C<r2C(real-values)> to convert from real to complex, as in C<$r Use C<r2C(real-values)> to convert from real to complex, as in C<$r
= 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 threading). 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 * =item *
This module has received some testing by Vanuxem Grégory This module has received some testing by Vanuxem Grégory
skipping to change at line 246 skipping to change at line 247
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 254 "Complex.pm" #line 256 "Complex.pm"
=head1 FUNCTIONS =head1 FUNCTIONS
=cut =cut
#line 326 "complex.pd" #line 325 "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 354 skipping to change at line 355
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 370 "Complex.pm" #line 373 "Complex.pm"
#line 1059 "../../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 394 "Complex.pm" #line 398 "Complex.pm"
#line 1060 "../../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 407 "Complex.pm" #line 412 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*r2C = \&PDL::Complex::r2C; BEGIN {*r2C = \&PDL::Complex::r2C;
} }
#line 414 "Complex.pm" #line 420 "Complex.pm"
#line 1059 "../../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 438 "Complex.pm" #line 445 "Complex.pm"
#line 1059 "../../blib/lib/PDL/PP.pm"
#line 1060 "../../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 444 "Complex.pm" #line 452 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*i2C = \&PDL::Complex::i2C; BEGIN {*i2C = \&PDL::Complex::i2C;
} }
#line 451 "Complex.pm" #line 460 "Complex.pm"
#line 1059 "../../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 475 "Complex.pm" #line 485 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cr2p = \&PDL::Complex::Cr2p; BEGIN {*Cr2p = \&PDL::Complex::Cr2p;
} }
#line 482 "Complex.pm" #line 493 "Complex.pm"
#line 1059 "../../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 506 "Complex.pm" #line 518 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cp2r = \&PDL::Complex::Cp2r; BEGIN {*Cp2r = \&PDL::Complex::Cp2r;
} }
#line 513 "Complex.pm" #line 526 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cadd = \&PDL::Complex::Cadd; BEGIN {*Cadd = \&PDL::Complex::Cadd;
} }
#line 520 "Complex.pm" #line 534 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Csub = \&PDL::Complex::Csub; BEGIN {*Csub = \&PDL::Complex::Csub;
} }
#line 527 "Complex.pm" #line 542 "Complex.pm"
#line 1059 "../../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 551 "Complex.pm" #line 567 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cmul = \&PDL::Complex::Cmul; BEGIN {*Cmul = \&PDL::Complex::Cmul;
} }
#line 558 "Complex.pm" #line 575 "Complex.pm"
#line 1059 "../../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 582 "Complex.pm" #line 600 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cprodover = \&PDL::Complex::Cprodover; BEGIN {*Cprodover = \&PDL::Complex::Cprodover;
} }
#line 589 "Complex.pm" #line 608 "Complex.pm"
#line 1059 "../../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 613 "Complex.pm" #line 633 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cscale = \&PDL::Complex::Cscale; BEGIN {*Cscale = \&PDL::Complex::Cscale;
} }
#line 620 "Complex.pm" #line 641 "Complex.pm"
#line 1059 "../../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 644 "Complex.pm" #line 666 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cdiv = \&PDL::Complex::Cdiv; BEGIN {*Cdiv = \&PDL::Complex::Cdiv;
} }
#line 651 "Complex.pm" #line 674 "Complex.pm"
#line 1059 "../../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 675 "Complex.pm" #line 699 "Complex.pm"
#line 1059 "../../blib/lib/PDL/PP.pm"
#line 1060 "../../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 686 "Complex.pm" #line 711 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Ceq = \&PDL::Complex::Ceq; BEGIN {*Ceq = \&PDL::Complex::Ceq;
} }
#line 693 "Complex.pm" #line 719 "Complex.pm"
#line 1059 "../../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 717 "Complex.pm" #line 744 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cconj = \&PDL::Complex::Cconj; BEGIN {*Cconj = \&PDL::Complex::Cconj;
} }
#line 724 "Complex.pm" #line 752 "Complex.pm"
#line 1059 "../../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 748 "Complex.pm" #line 777 "Complex.pm"
#line 1059 "../../blib/lib/PDL/PP.pm"
#line 1060 "../../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 759 "Complex.pm" #line 789 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cabs = \&PDL::Complex::Cabs; BEGIN {*Cabs = \&PDL::Complex::Cabs;
} }
#line 766 "Complex.pm" #line 797 "Complex.pm"
#line 1059 "../../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 790 "Complex.pm" #line 822 "Complex.pm"
#line 1059 "../../blib/lib/PDL/PP.pm"
#line 1060 "../../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 801 "Complex.pm" #line 834 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cabs2 = \&PDL::Complex::Cabs2; BEGIN {*Cabs2 = \&PDL::Complex::Cabs2;
} }
#line 808 "Complex.pm" #line 842 "Complex.pm"
#line 1059 "../../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 832 "Complex.pm" #line 867 "Complex.pm"
#line 1059 "../../blib/lib/PDL/PP.pm"
#line 1060 "../../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 843 "Complex.pm" #line 879 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Carg = \&PDL::Complex::Carg; BEGIN {*Carg = \&PDL::Complex::Carg;
} }
#line 850 "Complex.pm" #line 887 "Complex.pm"
#line 1059 "../../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 874 "Complex.pm" #line 912 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Csin = \&PDL::Complex::Csin; BEGIN {*Csin = \&PDL::Complex::Csin;
} }
#line 881 "Complex.pm" #line 920 "Complex.pm"
#line 1059 "../../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 905 "Complex.pm" #line 945 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Ccos = \&PDL::Complex::Ccos; BEGIN {*Ccos = \&PDL::Complex::Ccos;
} }
#line 912 "Complex.pm" #line 953 "Complex.pm"
#line 681 "complex.pd" #line 680 "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 931 "Complex.pm" #line 973 "Complex.pm"
#line 1059 "../../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 955 "Complex.pm" #line 998 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cexp = \&PDL::Complex::Cexp; BEGIN {*Cexp = \&PDL::Complex::Cexp;
} }
#line 962 "Complex.pm" #line 1006 "Complex.pm"
#line 1059 "../../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 986 "Complex.pm" #line 1031 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Clog = \&PDL::Complex::Clog; BEGIN {*Clog = \&PDL::Complex::Clog;
} }
#line 993 "Complex.pm" #line 1039 "Complex.pm"
#line 1059 "../../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 1017 "Complex.pm" #line 1064 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cpow = \&PDL::Complex::Cpow; BEGIN {*Cpow = \&PDL::Complex::Cpow;
} }
#line 1024 "Complex.pm" #line 1072 "Complex.pm"
#line 1059 "../../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 1048 "Complex.pm" #line 1097 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Csqrt = \&PDL::Complex::Csqrt; BEGIN {*Csqrt = \&PDL::Complex::Csqrt;
} }
#line 1055 "Complex.pm" #line 1105 "Complex.pm"
#line 1059 "../../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 1079 "Complex.pm" #line 1130 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Casin = \&PDL::Complex::Casin; BEGIN {*Casin = \&PDL::Complex::Casin;
} }
#line 1086 "Complex.pm" #line 1138 "Complex.pm"
#line 1059 "../../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 1110 "Complex.pm" #line 1163 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cacos = \&PDL::Complex::Cacos; BEGIN {*Cacos = \&PDL::Complex::Cacos;
} }
#line 1117 "Complex.pm" #line 1171 "Complex.pm"
#line 828 "complex.pd" #line 827 "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 1137 "Complex.pm" #line 1192 "Complex.pm"
#line 1059 "../../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 1161 "Complex.pm" #line 1217 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Csinh = \&PDL::Complex::Csinh; BEGIN {*Csinh = \&PDL::Complex::Csinh;
} }
#line 1168 "Complex.pm" #line 1225 "Complex.pm"
#line 1059 "../../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 1192 "Complex.pm" #line 1250 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Ccosh = \&PDL::Complex::Ccosh; BEGIN {*Ccosh = \&PDL::Complex::Ccosh;
} }
#line 1199 "Complex.pm" #line 1258 "Complex.pm"
#line 1059 "../../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 1223 "Complex.pm" #line 1283 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Ctanh = \&PDL::Complex::Ctanh; BEGIN {*Ctanh = \&PDL::Complex::Ctanh;
} }
#line 1230 "Complex.pm" #line 1291 "Complex.pm"
#line 1059 "../../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 1254 "Complex.pm" #line 1316 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Casinh = \&PDL::Complex::Casinh; BEGIN {*Casinh = \&PDL::Complex::Casinh;
} }
#line 1261 "Complex.pm" #line 1324 "Complex.pm"
#line 1059 "../../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 1285 "Complex.pm" #line 1349 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cacosh = \&PDL::Complex::Cacosh; BEGIN {*Cacosh = \&PDL::Complex::Cacosh;
} }
#line 1292 "Complex.pm" #line 1357 "Complex.pm"
#line 1059 "../../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 1316 "Complex.pm" #line 1382 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Catanh = \&PDL::Complex::Catanh; BEGIN {*Catanh = \&PDL::Complex::Catanh;
} }
#line 1323 "Complex.pm" #line 1390 "Complex.pm"
#line 1059 "../../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 1347 "Complex.pm" #line 1415 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Cproj = \&PDL::Complex::Cproj; BEGIN {*Cproj = \&PDL::Complex::Cproj;
} }
#line 1354 "Complex.pm" #line 1423 "Complex.pm"
#line 1059 "../../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 1378 "Complex.pm" #line 1448 "Complex.pm"
#line 1059 "../../blib/lib/PDL/PP.pm"
#line 1060 "../../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 1389 "Complex.pm" #line 1460 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*Croots = \&PDL::Complex::Croots; BEGIN {*Croots = \&PDL::Complex::Croots;
} }
#line 1396 "Complex.pm" #line 1468 "Complex.pm"
#line 996 "complex.pd" #line 995 "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 1210 skipping to change at line 1248
{ {
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 1424 "Complex.pm" #line 1497 "Complex.pm"
#line 1059 "../../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 1448 "Complex.pm" #line 1522 "Complex.pm"
#line 1060 "../../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 1461 "Complex.pm" #line 1536 "Complex.pm"
#line 1060 "../../blib/lib/PDL/PP.pm"
#line 1061 "../../blib/lib/PDL/PP.pm"
BEGIN {*rCpolynomial = \&PDL::Complex::rCpolynomial; BEGIN {*rCpolynomial = \&PDL::Complex::rCpolynomial;
} }
#line 1468 "Complex.pm" #line 1544 "Complex.pm"
#line 1061 "complex.pd" #line 1060 "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 1297 skipping to change at line 1336
*$op = \&$func if $op =~ /\w+/; # create an alias *$op = \&$func if $op =~ /\w+/; # create an alias
($op, eval 'sub { '.$func.' $_[0] }'); ($op, eval 'sub { '.$func.' $_[0] }');
} }
sub initialize { sub initialize {
# Bless a null PDL into the supplied 1st arg package # Bless a null PDL into the supplied 1st arg package
# If 1st arg is a ref, get the package from it # If 1st arg is a ref, get the package from it
bless PDL->null, ref($_[0]) || $_[0]; bless PDL->null, ref($_[0]) || $_[0];
} }
# so threading doesn't also assign the real value into the imaginary # so broadcasting doesn't also assign the real value into the imaginary
sub Cassgn { sub Cassgn {
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::Ops::assgn(@args); PDL::Ops::assgn(@args);
$args[1]; $args[1];
} }
use overload use overload
(map _gen_biop($_), qw(++Cadd --Csub *+Cmul /-Cdiv **-Cpow atan2-Catan2 ==+Ce q .=-Cassgn)), (map _gen_biop($_), qw(++Cadd --Csub *+Cmul /-Cdiv **-Cpow atan2-Catan2 ==+Ce q .=-Cassgn)),
(map _gen_unop($_), qw(sin@Csin cos@Ccos exp@Cexp abs@Cabs log@Clog sqrt@Csqr t)), (map _gen_unop($_), qw(sin@Csin cos@Ccos exp@Cexp abs@Cabs log@Clog sqrt@Csqr t)),
skipping to change at line 1348 skipping to change at line 1387
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 1575 "Complex.pm" #line 1652 "Complex.pm"
# Exit with OK status # Exit with OK status
1; 1;
 End of changes. 156 change blocks. 
156 lines changed or deleted 195 lines changed or added

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