update Math-Complex to CPAN version 1.57
authorZefram <zefram@fysh.org>
Wed, 18 May 2011 20:54:55 +0000 (21:54 +0100)
committerZefram <zefram@fysh.org>
Wed, 18 May 2011 21:31:50 +0000 (22:31 +0100)
* Add copy constructor and arrange for it to be called
  appropriately, problem found by David Madore and Alexandr
  Ciornii.

* Correctly format polarwise when a numeric format specifier is
  given, problem found by TomC.

* More stable great_circle_direction algorithm, problem found
  by Daniel Burr.

Porting/Maintainers.pl
cpan/Math-Complex/lib/Math/Complex.pm
cpan/Math-Complex/lib/Math/Trig.pm
cpan/Math-Complex/t/Complex.t
pod/perldelta.pod

index 446db49..e31cb02 100755 (executable)
@@ -1220,7 +1220,7 @@ use File::Glob qw(:case);
     'Math::Complex' =>
        {
        'MAINTAINER'    => 'zefram',
-       'DISTRIBUTION'  => 'JHI/Math-Complex-1.56.tar.gz',
+       'DISTRIBUTION'  => 'ZEFRAM/Math-Complex-1.57.tar.gz',
        'FILES'         => q[cpan/Math-Complex],
        'EXCLUDED'      => [
                             qw{
index 8475a2b..a46f66e 100644 (file)
@@ -11,7 +11,7 @@ use strict;
 
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $Inf $ExpInf);
 
-$VERSION = 1.56;
+$VERSION = 1.57;
 
 use Config;
 
@@ -129,10 +129,16 @@ my @pi = qw(pi pi2 pi4 pip2 pip4 Inf);
 );
 
 use overload
+       '='     => \&_copy,
+       '+='    => \&_plus,
        '+'     => \&_plus,
+       '-='    => \&_minus,
        '-'     => \&_minus,
+       '*='    => \&_multiply,
        '*'     => \&_multiply,
+       '/='    => \&_divide,
        '/'     => \&_divide,
+       '**='   => \&_power,
        '**'    => \&_power,
        '=='    => \&_numeq,
        '<=>'   => \&_spaceship,
@@ -217,6 +223,19 @@ sub _emake {
     return ($p, $q);
 }
 
+sub _copy {
+    my $self = shift;
+    my $clone = {%$self};
+    if ($self->{'cartesian'}) {
+       $clone->{'cartesian'} = [@{$self->{'cartesian'}}];
+    }
+    if ($self->{'polar'}) {
+       $clone->{'polar'} = [@{$self->{'polar'}}];
+    }
+    bless $clone,__PACKAGE__;
+    return $clone;
+}
+
 #
 # ->make
 #
@@ -1539,7 +1558,7 @@ sub _stringify_polar {
 
         if (defined $format) {
            $r     = sprintf($format, $r);
-           $theta = sprintf($format, $theta) unless defined $theta;
+           $theta = sprintf($format, $t) unless defined $theta;
        } else {
            $theta = $t unless defined $theta;
        }
@@ -2077,9 +2096,10 @@ L<Math::Trig>
 
 =head1 AUTHORS
 
-Daniel S. Lewart <F<lewart!at!uiuc.edu>>
-Jarkko Hietaniemi <F<jhi!at!iki.fi>>
-Raphael Manfredi <F<Raphael_Manfredi!at!pobox.com>>
+Daniel S. Lewart <F<lewart!at!uiuc.edu>>,
+Jarkko Hietaniemi <F<jhi!at!iki.fi>>,
+Raphael Manfredi <F<Raphael_Manfredi!at!pobox.com>>,
+Zefram <zefram@fysh.org>
 
 =head1 LICENSE
 
index b7767be..f428ad2 100644 (file)
@@ -10,14 +10,14 @@ package Math::Trig;
 use 5.005;
 use strict;
 
-use Math::Complex 1.56;
+use Math::Complex 1.57;
 use Math::Complex qw(:trig :pi);
 
 use vars qw($VERSION $PACKAGE @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 @ISA = qw(Exporter);
 
-$VERSION = 1.20;
+$VERSION = 1.21;
 
 my @angcnv = qw(rad2deg rad2grad
                deg2rad deg2grad
@@ -166,19 +166,13 @@ sub great_circle_distance {
 sub great_circle_direction {
     my ( $theta0, $phi0, $theta1, $phi1 ) = @_;
 
-    my $distance = great_circle_distance($theta0, $phi0, $theta1, $phi1);
-
     my $lat0 = pip2 - $phi0;
     my $lat1 = pip2 - $phi1;
 
-    my $direction =
-       acos_real((sin($lat1) - sin($lat0) * cos($distance)) /
-                 (cos($lat0) * sin($distance)));
-  
-    $direction = pi2 - $direction
-       if sin($theta1 - $theta0) < 0;
-
-    return rad2rad($direction);
+    return rad2rad(pi2 -
+       atan2(sin($theta0-$theta1) * cos($lat1),
+               cos($lat0) * sin($lat1) -
+                   sin($lat0) * cos($lat1) * cos($theta0-$theta1)));
 }
 
 *great_circle_bearing         = \&great_circle_direction;
@@ -755,8 +749,9 @@ L<Math::Complex>
 
 =head1 AUTHORS
 
-Jarkko Hietaniemi <F<jhi!at!iki.fi>> and 
-Raphael Manfredi <F<Raphael_Manfredi!at!pobox.com>>.
+Jarkko Hietaniemi <F<jhi!at!iki.fi>>,
+Raphael Manfredi <F<Raphael_Manfredi!at!pobox.com>>,
+Zefram <zefram@fysh.org>
 
 =head1 LICENSE
 
index 687d622..d0d83d3 100644 (file)
@@ -34,6 +34,15 @@ if ($^O eq 'unicos') {       # For some reason root() produces very inaccurate
 }                      # cos(), sin(), cosh(), sinh().  The division
                        # of doubles is the current suspect.
 
+$test++;
+push @script, "{ my \$t=$test; ".q{
+    my $a = Math::Complex->new(1);
+    my $b = $a;
+    $a += 2;
+    print "not " unless "$a" eq "3" && "$b" eq "1";
+    print "ok $t\n";
+}."}";
+
 while (<DATA>) {
        s/^\s+//;
        next if $_ eq '' || /^\#/;
@@ -287,6 +296,15 @@ EOS
     print "not " unless "\$j" =~ /^\\[1,2\\.09439510\\d+\\]\$/;
     print "ok $test\n";
 
+    \$j->display_format('style' => 'polar', 'format' => "%.4g");
+EOS
+
+    $test++;
+    push @script, <<EOS;
+    print "# j = \$j\n";
+    print "not " unless "\$j" =~ /^\\[1,2\\.094\\]\$/;
+    print "ok $test\n";
+
     \$j->display_format('style' => 'cartesian', 'format' => '(%.5g)');
 EOS
 
@@ -698,6 +716,7 @@ __END__
 [1, pi/3]:"[1,pi/3]"
 [6, -2*pi/3]:"[6,-2pi/3]"
 [0.5, -9*pi/11]:"[0.5,-9pi/11]"
+[1, 0.5]:"[1, 0.5]"
 
 { (4,3); [3,2]; (-3,4); (0,2); [2,1] }
 
index e9dbe07..dc6ee16 100644 (file)
@@ -91,6 +91,14 @@ XXX
 
 =item *
 
+C<Math::Complex> has been upgraded from version 1.56 to version 1.57.
+
+Correct copy constructor usage.
+Fix polarwise formatting with numeric format specifier.
+More stable C<great_circle_direction> algorithm.
+
+=item *
+
 C<Time::HiRes> has been upgraded from version 1.9721_01 to version 1.9722.
 
 Portability fix, and avoiding some compiler warnings.