my ( $i, $ip2, %logn );
-$VERSION = sprintf("%s", q$Id: Complex.pm,v 1.25 1998/02/05 16:07:37 jhi Exp $ =~ /(\d+\.\d+)/);
+$VERSION = sprintf("%s", q$Id: Complex.pm,v 1.26 1998/11/01 00:00:00 dsl Exp $ =~ /(\d+\.\d+)/);
@ISA = qw(Exporter);
}
#
-# _zerotozero
-#
-# Die on zero raised to the zeroth.
-#
-sub _zerotozero {
- my $mess = "The zero raised to the zeroth power is not defined.\n";
-
- my @up = caller(1);
-
- $mess .= "Died at $up[1] line $up[2].\n";
-
- die $mess;
-}
-
-#
# (power)
#
# Computes z1**z2 = exp(z2 * log z1)).
#
sub power {
my ($z1, $z2, $inverted) = @_;
- my $z1z = $z1 == 0;
- my $z2z = $z2 == 0;
- _zerotozero if ($z1z and $z2z);
if ($inverted) {
- return 0 if ($z2z);
- return 1 if ($z1z or $z2 == 1);
+ return 1 if $z1 == 0 || $z2 == 1;
+ return 0 if $z2 == 0 && Re($z1) > 0;
} else {
- return 0 if ($z1z);
- return 1 if ($z2z or $z1 == 1);
+ return 1 if $z2 == 0 || $z1 == 1;
+ return 0 if $z1 == 0 && Re($z2) > 0;
}
- my $w = $inverted ? CORE::exp($z1 * CORE::log($z2)) : CORE::exp($z2 * CORE::log($z1));
+ my $w = $inverted ? CORE::exp($z1 * CORE::log($z2))
+ : CORE::exp($z2 * CORE::log($z1));
# If both arguments cartesian, return cartesian, else polar.
return $z1->{c_dirty} == 0 &&
(not ref $z2 or $z2->{c_dirty} == 0) ?
# (spaceship)
#
# Computes z1 <=> z2.
-# Sorts on the real part first, then on the imaginary part. Thus 2-4i > 3+8i.
+# Sorts on the real part first, then on the imaginary part. Thus 2-4i < 3+8i.
#
sub spaceship {
my ($z1, $z2, $inverted) = @_;
my ($a, $b) = @_;
my $id = "$a $b";
-
+
unless (exists $gcd{$id}) {
$gcd{$id} = _gcd($a, $b);
$gcd{"$b $a"} = $gcd{$id};
The division (/) and the following functions
log ln log10 logn
- tan sec csc cot
+ tan sec csc cot
atan asec acsc acot
tanh sech csch coth
atanh asech acsch acoth
use Math::Complex;
-$VERSION = sprintf("%s", q$Id: complex.t,v 1.8 1998/02/05 16:03:39 jhi Exp $ =~ /(\d+\.d+)/);
+my $VERSION = sprintf("%s", q$Id: complex.t,v 1.9 1998/11/01 00:00:00 dsl Exp $ =~ /(\d+\.d+)/);
my ($args, $op, $target, $test, $test_set, $try, $val, $zvalue, @set, @val);
'acoth(-1)',
);
-# test the 0**0
-
-sub test_ztz {
- $test++;
-
- push(@script, <<'EOT');
-eval 'cplx(0)**cplx(0)';
-print 'not ' unless ($@ =~ /zero raised to the zeroth/);
-EOT
- push(@script, qq(print "ok $test\\n";\n));
-}
-
-test_ztz;
-
# test the bad roots
sub test_broot {
(1,0):(2,3):(1,0)
(2,3):(0,0):(1,0)
(2,3):(1,0):(2,3)
+(0,0):(0,0):(1,0)
&Re
(3,4):3
( 2,-3):( 0.14694666622553, 0.23182380450040)
# eof
-