Sys::Syslog patch to allow unix domain sockets
[p5sagit/p5-mst-13.2.git] / lib / Math / Complex.pm
index a501b99..7a4617c 100644 (file)
@@ -320,9 +320,16 @@ sub _zerotozero {
 #
 sub power {
        my ($z1, $z2, $inverted) = @_;
-       _zerotozero if ($z1 == 0 and $z2 == 0);
-       return 1 if ($z1 == 1);
-       return 0 if ($z2 == 0);
+       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);
+       } else {
+           return 0 if ($z1z);
+           return 1 if ($z2z or $z1 == 1);
+       }
        $z2 = cplx($z2) unless ref $z2;
        unless (defined $inverted) {
                my $z3 = exp($z2 * log $z1);
@@ -741,7 +748,7 @@ sub cosh {
        my ($x, $y) = @{$z->cartesian};
        my $ex = exp($x);
        my $ex_1 = 1 / $ex;
-       return ($ex + $ex_1)/2 if $real;
+       return cplx(0.5 * ($ex + $ex_1), 0) if $real;
        return (ref $z)->make(cos($y) * ($ex + $ex_1)/2,
                              sin($y) * ($ex - $ex_1)/2);
 }
@@ -761,7 +768,7 @@ sub sinh {
        my ($x, $y) = @{$z->cartesian};
        my $ex = exp($x);
        my $ex_1 = 1 / $ex;
-       return ($ex - $ex_1)/2 if $real;
+       return cplx(0.5 * ($ex - $ex_1), 0) if $real;
        return (ref $z)->make(cos($y) * ($ex - $ex_1)/2,
                              sin($y) * ($ex + $ex_1)/2);
 }
@@ -1326,11 +1333,11 @@ The I<k>th root for C<z = [r,t]> is given by:
 
        (root(z, n))[k] = r**(1/n) * exp(i * (t + 2*k*pi)/n)
 
-The I<spaceship> comparison operator is also defined. In order to
-ensure its restriction to real numbers is conform to what you would
-expect, the comparison is run on the real part of the complex number
-first, and imaginary parts are compared only when the real parts
-match.
+The I<spaceship> comparison operator, E<lt>=E<gt>, is also defined. In
+order to ensure its restriction to real numbers is conform to what you
+would expect, the comparison is run on the real part of the complex
+number first, and imaginary parts are compared only when the real
+parts match.
 
 =head1 CREATION
 
@@ -1464,8 +1471,8 @@ operation (for instance) between two overloaded entities.
 
 =head1 AUTHORS
 
-       Raphael Manfredi <F<Raphael_Manfredi@grenoble.hp.com>>
-       Jarkko Hietaniemi <F<jhi@iki.fi>>
+Raphael Manfredi <F<Raphael_Manfredi@grenoble.hp.com>> and
+Jarkko Hietaniemi <F<jhi@iki.fi>>.
 
 =cut