Skip Menu |

This queue is for tickets about the Math-Algebra-Symbols CPAN distribution.

Report information
The Basics
Id: 57148
Status: open
Priority: 0/
Queue: Math-Algebra-Symbols

People
Owner: Nobody in particular
Requestors: salvatore.bonaccorso [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Re: Bug#578941: libmath-algebra-symbols-perl: FTBFS with perl 5.12.0-1: long doubles
Date: Sun, 2 May 2010 21:47:57 +0200
To: 578941-quiet [...] bugs.debian.org, bug-Math-Algebra-Symbols [...] rt.cpan.org
From: Salvatore Bonaccorso <salvatore.bonaccorso [...] gmail.com>
Hi Niko Tyni reported to the Debian Bugtracker [1] a FTBFS for Math-Algebra-Symbols, due to Perl configured with -Duselongdouble. Bests salvatore On Fri, Apr 23, 2010 at 10:48:47PM +0300, Niko Tyni wrote: Show quoted text
> Package: libmath-algebra-symbols-perl > Version: 1.21-1 > Severity: important > User: debian-perl@lists.debian.org > Usertags: perl-5.12-transition, perl-long-double > > This package fails to build on amd64 with perl 5.12.0-1 from experimental: > > Test Summary Report > ------------------- > t/bug_2004_6_2.t (Wstat: 2560 Tests: 12 Failed: 10) > Failed tests: 1-10 > Non-zero exit status: 10 > t/pentagon.t (Wstat: 65280 Tests: 0 Failed: 0) > Non-zero exit status: 255 > Parse errors: Bad plan. You planned 1 tests but ran 0. > t/solve2.t (Wstat: 512 Tests: 2 Failed: 2) > Failed tests: 1-2 > Non-zero exit status: 2 > > Looking at > http://www.cpantesters.org/distro/M/Math-Algebra-Symbols.html > the failure is almost certainly due to 5.12.0-1 being configured with > -Duselongdouble. > -- > Niko Tyni ntyni@debian.org > > > > _______________________________________________ > pkg-perl-maintainers mailing list > pkg-perl-maintainers@lists.alioth.debian.org > http://lists.alioth.debian.org/mailman/listinfo/pkg-perl-maintainers >
Download signature.asc
application/pgp-signature 835b

Message body not shown because it is not plain text.

Subject: [PATCH] Re: Bug#578941: libmath-algebra-symbols-perl: FTBFS with perl 5.12.0-1: long doubles
On many systems with long doubles a bug is detected that goes unnoticed elswhere. The problem is a wrong optimization when calculating square roots. In order to detect whether a square root can be numerically evaluated or should rather be kept as a symbolic operation, Math::Algebra::Symbols::Term checks whether a number is equal to the square of its square root, assuming that this will be true only for precise results, like 2.5 == sqrt(6.25). This assumption, however, is too optimistic. Rounding effects can create false positives. The check should be replaced by something that is rather too pessimistic, as false negatives will not introduce mathematical errors. I have added a patch with a suggestion for such a check. It also fixes two minor issues triggering warnings when the test suite is run under perl5.16.1. -Martin
Subject: Math-Algebra-Symbols-1.21-MHASCH-04.patch
diff -rup Math-Algebra-Symbols-1.21.orig/lib/Math/Algebra/Symbols/Sum.pm Math-Algebra-Symbols-1.21/lib/Math/Algebra/Symbols/Sum.pm --- Math-Algebra-Symbols-1.21.orig/lib/Math/Algebra/Symbols/Sum.pm 2004-06-15 00:25:54.000000000 +0200 +++ Math-Algebra-Symbols-1.21/lib/Math/Algebra/Symbols/Sum.pm 2012-08-28 15:47:50.000000000 +0200 @@ -1713,7 +1713,6 @@ use overload 'sqrt' =>\&sqrt3, 'exp' =>\&exp3, 'log' =>\&log3, - 'tan' =>\&tan3, 'sin' =>\&sin3, 'cos' =>\&cos3, '""' =>\&print3, diff -rup Math-Algebra-Symbols-1.21.orig/lib/Math/Algebra/Symbols/Term.pm Math-Algebra-Symbols-1.21/lib/Math/Algebra/Symbols/Term.pm --- Math-Algebra-Symbols-1.21.orig/lib/Math/Algebra/Symbols/Term.pm 2004-06-15 00:25:54.000000000 +0200 +++ Math-Algebra-Symbols-1.21/lib/Math/Algebra/Symbols/Term.pm 2012-08-28 18:35:28.000000000 +0200 @@ -813,6 +813,16 @@ sub power($$) } +# return a square root guaranteed to be precise, or undef +sub _safe_sqrt + {my ($a) = @_; + return undef if $a >= 65536 || $a < 0; + my $s = int(sqrt($a)*256)/256; # $s now has at most 8+8 bits + return undef if $s*$s != $a; + return $s; + } + + =head3 sqrt2 Square root of a term @@ -836,8 +846,8 @@ sub sqrt2($) my ($c, $d, $i) = ($t->{c}, $t->{d}, 0); $c = -$c, $i = 1 if $c < 0; - my $c2 = sqrt($c); return undef unless $c2*$c2 == $c; - my $d2 = sqrt($d); return undef unless $d2*$d2 == $d; + my $c2 = _safe_sqrt($c); return undef if !defined $c2; + my $d2 = _safe_sqrt($d); return undef if !defined $d2; my $z = clone($t)->c($c2)->d($d2)->i($i); @@ -1093,7 +1103,7 @@ sub print($) $s .= '*$'.$_.'**'. $v->{$_} for grep {$v->{$_} > 1} @k; $s .= '/$'.$_.'**'.-$v->{$_} for grep {$v->{$_} < -1} @k; $s .= '/('. $t->{divide} .')' if $t->{divide}; - $s .= '*sqrt('. $t->{sqrt} .')' if $t->{sqrt}; + $s .= '*sqrt('. $t->{sqrt} .')' if defined $t->{sqrt}; $s .= '*exp('. $t->{exp} .')' if $t->{exp}; $s .= '*log('. $t->{log} .')' if $t->{log}; $s; diff -rup Math-Algebra-Symbols-1.21.orig/t/bug_2004_6_5.t Math-Algebra-Symbols-1.21/t/bug_2004_6_5.t --- Math-Algebra-Symbols-1.21.orig/t/bug_2004_6_5.t 2004-06-15 00:25:53.000000000 +0200 +++ Math-Algebra-Symbols-1.21/t/bug_2004_6_5.t 2012-08-28 15:47:50.000000000 +0200 @@ -25,5 +25,7 @@ print $y, "\n"; use Math::Complex; # Need complex arithmetic $x = 2; -my $sx = eval $y; +my $qy = "$y"; +$qy =~ s/-/ - /g; +my $sx = eval $qy; ok($sx>0.90 and $sx<0.91);
Subject: Re: [rt.cpan.org #57148] [PATCH] Re: Bug#578941: libmath-algebra-symbols-perl: FTBFS with perl 5.12.0-1: long doubles
Date: Wed, 5 Sep 2012 20:46:06 +0100
To: bug-Math-Algebra-Symbols [...] rt.cpan.org
From: Philip R Brenan <philiprbrenan [...] gmail.com>
HI Martin: This is very kind of you. Do I apply the patches you have supplied or is this all taken care of in CPAN for me? Thanks, Phil Philip R Brenan On Wed, Sep 5, 2012 at 4:31 PM, Martin Becker via RT < bug-Math-Algebra-Symbols@rt.cpan.org> wrote: Show quoted text
> Queue: Math-Algebra-Symbols > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=57148 > > > On many systems with long doubles a bug is detected that > goes unnoticed elswhere. > > The problem is a wrong optimization when calculating > square roots. In order to detect whether a square root > can be numerically evaluated or should rather be kept > as a symbolic operation, Math::Algebra::Symbols::Term > checks whether a number is equal to the square of its > square root, assuming that this will be true only for > precise results, like 2.5 == sqrt(6.25). > > This assumption, however, is too optimistic. Rounding > effects can create false positives. The check should > be replaced by something that is rather too pessimistic, > as false negatives will not introduce mathematical errors. > > I have added a patch with a suggestion for such a check. > It also fixes two minor issues triggering warnings when > the test suite is run under perl5.16.1. > > -Martin >
On Wed Sep 05 20:46:15 2012, philiprbrenan@gmail.com wrote: Show quoted text
> HI Martin: > > This is very kind of you. Do I apply the patches you have supplied or is > this all taken care of in CPAN for me?
CPAN will not automatically patch your distribution; you will need to do that yourself. Best wishes, Dominic.