"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "GENERATED/PDL/Complex.pm" between
PDL-2.082.tar.gz and PDL-2.083.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.082):Complex.pm  (PDL-2.083)
# #
# GENERATED WITH PDL::PP! Don't modify! # GENERATED WITH PDL::PP! Don't modify!
# #
package PDL::Complex; package PDL::Complex;
our @EXPORT_OK = qw(Ctan Catan re im i cplx real r2C i2C Cr2p Cp2r Cadd Csub Cmu l 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 ); our @EXPORT_OK = qw(Ctan Catan re im i cplx real r2C i2C Cr2p Cp2r Cadd Csub Cmu l 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 );
our %EXPORT_TAGS = (Func=>\@EXPORT_OK); our %EXPORT_TAGS = (Func=>\@EXPORT_OK);
use PDL::Core; use PDL::Core();
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 17 "complex.pd" #line 18 "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::Types;
use PDL::Bad;
=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 231 skipping to change at line 228
=item "" (stringification) =item "" (stringification)
=back =back
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->pdl(0,1) }
{ {
no warnings 'redefine'; no warnings 'redefine';
sub i { $i->copy + (@_ ? $_[0] : 0) }; sub i { $i->copy + (@_ ? $_[0] : 0) };
} }
# sensible aliases from PDL::LinearAlgebra # sensible aliases from PDL::LinearAlgebra
*r2p = \&Cr2p; *r2p = \&Cr2p;
*p2r = \&Cp2r; *p2r = \&Cp2r;
*conj = \&Cconj; *conj = \&Cconj;
*abs = \&Cabs; *abs = \&Cabs;
skipping to change at line 255 skipping to change at line 252
*proj = \&Cproj; *proj = \&Cproj;
*asin = \&Casin; *asin = \&Casin;
*acos = \&Cacos; *acos = \&Cacos;
*atan = \&Catan; *atan = \&Catan;
*sinh = \&Csinh; *sinh = \&Csinh;
*cosh = \&Ccosh; *cosh = \&Ccosh;
*tanh = \&Ctanh; *tanh = \&Ctanh;
*asinh = \&Casinh; *asinh = \&Casinh;
*acosh = \&Cacosh; *acosh = \&Cacosh;
*atanh = \&Catanh; *atanh = \&Catanh;
#line 261 "Complex.pm" #line 258 "Complex.pm"
=head1 FUNCTIONS =head1 FUNCTIONS
=cut =cut
#line 332 "complex.pd" #line 330 "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 363 skipping to change at line 360
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 378 "Complex.pm" #line 370 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 403 "Complex.pm"
#line 959 "/home/osboxes/pdl-code/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 417 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*r2C = \&PDL::Complex::r2C; BEGIN {*r2C = \&PDL::Complex::r2C;
} }
#line 425 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 450 "Complex.pm"
#line 959 "/home/osboxes/pdl-code/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 457 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*i2C = \&PDL::Complex::i2C; BEGIN {*i2C = \&PDL::Complex::i2C;
} }
#line 465 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 490 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Cr2p = \&PDL::Complex::Cr2p; BEGIN {*Cr2p = \&PDL::Complex::Cr2p;
} }
#line 498 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 523 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Cp2r = \&PDL::Complex::Cp2r; BEGIN {*Cp2r = \&PDL::Complex::Cp2r;
} }
#line 531 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Cadd = \&PDL::Complex::Cadd; BEGIN {*Cadd = \&PDL::Complex::Cadd;
} }
#line 539 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Csub = \&PDL::Complex::Csub; BEGIN {*Csub = \&PDL::Complex::Csub;
} }
#line 547 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 572 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Cmul = \&PDL::Complex::Cmul; BEGIN {*Cmul = \&PDL::Complex::Cmul;
} }
#line 580 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 605 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Cprodover = \&PDL::Complex::Cprodover; BEGIN {*Cprodover = \&PDL::Complex::Cprodover;
} }
#line 613 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 638 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Cscale = \&PDL::Complex::Cscale; BEGIN {*Cscale = \&PDL::Complex::Cscale;
} }
#line 646 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 671 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Cdiv = \&PDL::Complex::Cdiv; BEGIN {*Cdiv = \&PDL::Complex::Cdiv;
} }
#line 679 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 704 "Complex.pm"
#line 959 "/home/osboxes/pdl-code/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 716 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Ceq = \&PDL::Complex::Ceq; BEGIN {*Ceq = \&PDL::Complex::Ceq;
} }
#line 724 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 749 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Cconj = \&PDL::Complex::Cconj; BEGIN {*Cconj = \&PDL::Complex::Cconj;
} }
#line 757 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 782 "Complex.pm"
#line 959 "/home/osboxes/pdl-code/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 794 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Cabs = \&PDL::Complex::Cabs; BEGIN {*Cabs = \&PDL::Complex::Cabs;
} }
#line 802 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 827 "Complex.pm"
#line 959 "/home/osboxes/pdl-code/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 839 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Cabs2 = \&PDL::Complex::Cabs2; BEGIN {*Cabs2 = \&PDL::Complex::Cabs2;
} }
#line 847 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 872 "Complex.pm"
#line 959 "/home/osboxes/pdl-code/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 884 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Carg = \&PDL::Complex::Carg; BEGIN {*Carg = \&PDL::Complex::Carg;
} }
#line 892 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 917 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Csin = \&PDL::Complex::Csin; BEGIN {*Csin = \&PDL::Complex::Csin;
} }
#line 925 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 950 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Ccos = \&PDL::Complex::Ccos; BEGIN {*Ccos = \&PDL::Complex::Ccos;
} }
#line 958 "Complex.pm"
#line 687 "complex.pd" #line 685 "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 978 "Complex.pm" #line 849 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 1003 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Cexp = \&PDL::Complex::Cexp; BEGIN {*Cexp = \&PDL::Complex::Cexp;
} }
#line 1011 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 1036 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Clog = \&PDL::Complex::Clog; BEGIN {*Clog = \&PDL::Complex::Clog;
} }
#line 1044 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 1069 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Cpow = \&PDL::Complex::Cpow; BEGIN {*Cpow = \&PDL::Complex::Cpow;
} }
#line 1077 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 1102 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Csqrt = \&PDL::Complex::Csqrt; BEGIN {*Csqrt = \&PDL::Complex::Csqrt;
} }
#line 1110 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 1135 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Casin = \&PDL::Complex::Casin; BEGIN {*Casin = \&PDL::Complex::Casin;
} }
#line 1143 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 1168 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Cacos = \&PDL::Complex::Cacos; BEGIN {*Cacos = \&PDL::Complex::Cacos;
} }
#line 1176 "Complex.pm"
#line 834 "complex.pd" #line 832 "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->pdl(0, 0.5 );
} }
#line 1197 "Complex.pm" #line 1028 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 1222 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Csinh = \&PDL::Complex::Csinh; BEGIN {*Csinh = \&PDL::Complex::Csinh;
} }
#line 1230 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 1255 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Ccosh = \&PDL::Complex::Ccosh; BEGIN {*Ccosh = \&PDL::Complex::Ccosh;
} }
#line 1263 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 1288 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Ctanh = \&PDL::Complex::Ctanh; BEGIN {*Ctanh = \&PDL::Complex::Ctanh;
} }
#line 1296 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 1321 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Casinh = \&PDL::Complex::Casinh; BEGIN {*Casinh = \&PDL::Complex::Casinh;
} }
#line 1329 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 1354 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Cacosh = \&PDL::Complex::Cacosh; BEGIN {*Cacosh = \&PDL::Complex::Cacosh;
} }
#line 1362 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 1387 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Catanh = \&PDL::Complex::Catanh; BEGIN {*Catanh = \&PDL::Complex::Catanh;
} }
#line 1395 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 1420 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Cproj = \&PDL::Complex::Cproj; BEGIN {*Cproj = \&PDL::Complex::Cproj;
} }
#line 1428 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 1453 "Complex.pm"
#line 959 "/home/osboxes/pdl-code/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 1465 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*Croots = \&PDL::Complex::Croots; BEGIN {*Croots = \&PDL::Complex::Croots;
} }
#line 1473 "Complex.pm"
#line 1002 "complex.pd" #line 1000 "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 1256 skipping to change at line 1052
{ {
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 1502 "Complex.pm" #line 1277 "Complex.pm"
#line 958 "/home/osboxes/pdl-code/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 1527 "Complex.pm"
#line 959 "/home/osboxes/pdl-code/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 1541 "Complex.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
BEGIN {*rCpolynomial = \&PDL::Complex::rCpolynomial; BEGIN {*rCpolynomial = \&PDL::Complex::rCpolynomial;
} }
#line 1549 "Complex.pm"
#line 1067 "complex.pd"
# overload must be here, so that all the functions can be seen #line 1065 "complex.pd"
# 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
function that it overloads (e.g., 'Cmul') flags whether the operation function that it overloads (e.g., 'Cmul') flags whether the operation
is ('+') or is not ('-') commutative. See the discussion of argument is ('+') or is not ('-') commutative. See the discussion of argument
swapping in the section "Calling Conventions and Magic Autogeneration" swapping in the section "Calling Conventions and Magic Autogeneration"
in "perldoc overload". in "perldoc overload".
=end comment =end comment
=cut =cut
my %NO_MUTATE; BEGIN { @NO_MUTATE{qw(atan2 .= ==)} = (); } my %NO_MUTATE; BEGIN { @NO_MUTATE{qw(atan2 .= ==)} = (); }
sub _gen_biop { sub _gen_biop {
local $_ = shift; local $_ = shift;
my $sub; my $sub;
if (/(\S+)\+(\w+)/) { #commutes die if !(my ($op, $commutes, $func) = /(\S+)([-+])(\w+)/);
$sub = eval 'sub { '.$2.' $_[0], ref $_[1] eq __PACKAGE__ ? $_[1] : r2C $_ $sub = eval 'sub {
[1] }'; my ($x, $y) = '.($commutes eq '+' ? '' : '$_[2] ? @_[1,0] : ').'@_[0,1];
} elsif (/(\S+)\-(\w+)/) { #does not commute $_ = r2C $_ for grep ref $_ ne __PACKAGE__, $x, $y;
$sub = eval 'sub { my $y = ref $_[1] eq __PACKAGE__ ? $_[1] : r2C $_[1]; '.$func.'($x, $y);
$_[2] ? '.$2.' $y, $_[0] : '.$2.' $_[0], $y }'; #need to }'; #need to swap?
swap? die if $@;
} else { ($op, $sub, exists $NO_MUTATE{$op} ? () : ("$op=", $sub));
die;
}
return ($1, $sub) if exists $NO_MUTATE{$1};
($1, $sub, "$1=", $sub);
} }
sub _gen_unop { sub _gen_unop {
my ($op, $func) = ($_[0] =~ /(.+)@(\w+)/); my ($op, $func) = split '@', $_[0];
no strict 'refs'; no strict 'refs';
*$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];
} }
skipping to change at line 1395 skipping to change at line 1178
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 1657 "Complex.pm" #line 1414 "Complex.pm"
# Exit with OK status # Exit with OK status
1; 1;
 End of changes. 89 change blocks. 
245 lines changed or deleted 26 lines changed or added

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