Skip Menu |
 

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

Report information
The Basics
Id: 88293
Status: resolved
Priority: 0/
Queue: Math-BigInt

People
Owner: Nobody in particular
Requestors: user42 [...] zip.com.au
Cc:
AdminCc:

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



From gg [...] zip.com.au Fri Aug 30 16: 24:36 2013
MIME-Version: 1.0
X-Spam-Status: No, score=-6.752 tagged_above=-99.9 required=10 tests=[AWL=0.148, BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5] autolearn=ham
X-Spam-Flag: NO
Content-Type: multipart/mixed; boundary="=-=-="
Message-ID: <87zjrzylki.fsf [...] blah.blah>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Spam-Score: -6.752
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 2296B240633 for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Fri, 30 Aug 2013 16:24:36 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vu1aClnnAypj for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Fri, 30 Aug 2013 16:24:34 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id E6E0D24050A for <bug-Math-BigInt [...] rt.cpan.org>; Fri, 30 Aug 2013 16:24:32 -0400 (EDT)
Received: (qmail 18711 invoked by alias); 30 Aug 2013 20:24:32 -0000
Received: from mailout1-11.pacific.net.au (HELO mailout3-syd3.pacific.net.au) (125.255.80.130) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Fri, 30 Aug 2013 13:24:25 -0700
Received: from mailproxy4-syd3.pacific.net.au (mailproxy4-syd3.pacific.net.au [61.8.2.162]) by mailout3-syd3.pacific.net.au (Postfix) with ESMTP id C26ED391B23 for <bug-Math-BigInt [...] rt.cpan.org>; Sat, 31 Aug 2013 06:24:17 +1000 (EST)
Received: from blah.blah (unknown [203.26.175.75]) by mailproxy4-syd3.pacific.net.au (Postfix) with ESMTP id 921262C01A for <bug-Math-BigInt [...] rt.cpan.org>; Sat, 31 Aug 2013 06:24:12 +1000 (EST)
Received: from gg by blah.blah with local (Exim 4.80) (envelope-from <gg [...] zip.com.au>) id 1VFVEL-0003p1-68 for bug-Math-BigInt [...] rt.cpan.org; Sat, 31 Aug 2013 06:23:41 +1000
Delivered-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
Subject: BigFloat batan(1.5) infinite loop
Return-Path: <gg [...] zip.com.au>
X-RT-Mail-Extension: math-bigint
X-Original-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
X-Spam-Check-BY: la.mx.develooper.com
Date: Sat, 31 Aug 2013 06:23:41 +1000
X-Spam-Level:
To: bug-Math-BigInt [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
X-RT-Interface: Email
Content-Length: 0
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: ascii
Content-Length: 393
Download (untitled) / with headers
text/plain 393b
With Math::BigFloat 1.997 and recent debian i386 perl 5.14.2, the program foo.pl below goes into an apparently infinite loop, where I hoped it would print batan=0.982793723... There seems to be something doubtful where batan() notices abs($x) > 1 and inverts to 1/$x for the power series. If $x is an integer then $x>1 is noticed correctly, but if $x is not an integer then seems not.
Content-Type: text/x-perl
Content-Disposition: inline; filename="foo.pl"
Content-Length: 126
Download foo.pl
text/x-perl 126b
#!/usr/bin/perl -w use strict; use Math::BigFloat; my $x = Math::BigFloat->new(1.5); $x->batan(); print "batan=$x\n"; exit 0;
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: ascii
Content-Length: 105
Download (untitled) / with headers
text/plain 105b
-- Events jargon elucidated for the layman: "Wedding package" -- twice the price and non-refundable.
MIME-Version: 1.0
In-Reply-To: <87zjrzylki.fsf [...] blah.blah>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
X-RT-Interface: Web
References: <87zjrzylki.fsf [...] blah.blah>
Content-Type: multipart/mixed; boundary="----------=_1382566768-3797-5"
Message-ID: <rt-4.0.16-3797-1382566768-22.88293-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 288
Download (untitled) / with headers
text/plain 288b
The following patch fixes this. It could be made more efficient by someone more familiar with the system. It also fixes the similar problem in: https://rt.cpan.org/Ticket/Display.html?id=61139 which has a similar issue, though does not attempt to deal with the accuracy issue there.
MIME-Version: 1.0
Subject: bigfloat-batan-fix.patch
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Type: text/x-patch; name="bigfloat-batan-fix.patch"
Content-Disposition: inline; filename="bigfloat-batan-fix.patch"
Content-Transfer-Encoding: binary
Content-Length: 397
--- lib/Math/BigFloat.pm.orig 2013-10-22 10:55:47.640415285 -0700 +++ lib/Math/BigFloat.pm 2013-10-23 15:10:18.820161719 -0700 @@ -3163,7 +3163,7 @@ # to calculate PI/2 - atan(1/x): my $one = $MBI->_new(1); my $pi = undef; - if ($x->{_es} eq '+' && ($MBI->_acmp($x->{_m},$one) >= 0)) + if ($x->bacmp($x->copy->bone) >= 0) { # calculate PI/2 $pi = $self->bpi($scale - 3);
From gg [...] zip.com.au Wed Oct 23 20: 17:55 2013
MIME-Version: 1.0
X-Spam-Status: No, score=-6.748 tagged_above=-99.9 required=10 tests=[AWL=0.152, BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5] autolearn=ham
In-Reply-To: <rt-4.0.16-3797-1382566769-1252.88293-6-0 [...] rt.cpan.org> (Dana Jacobsen via's message of "Wed, 23 Oct 2013 18:19:29 -0400")
X-Spam-Flag: NO
X-RT-Interface: API
References: <RT-Ticket-88293 [...] rt.cpan.org> <87zjrzylki.fsf [...] blah.blah> <rt-4.0.16-3797-1382566769-1252.88293-6-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <87r4bby14e.fsf [...] blah.blah>
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -6.748
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 51F0461E00D for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Wed, 23 Oct 2013 20:17:55 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7t2hLRN4inS3 for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Wed, 23 Oct 2013 20:17:53 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 5514A2413B8 for <bug-Math-BigInt [...] rt.cpan.org>; Wed, 23 Oct 2013 20:17:52 -0400 (EDT)
Received: (qmail 19374 invoked by alias); 24 Oct 2013 00:17:51 -0000
Received: from mailout2-10.pacific.net.au (HELO mailout4-syd3.pacific.net.au) (125.255.80.137) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Wed, 23 Oct 2013 17:17:42 -0700
Received: from mailproxy4-syd3.pacific.net.au (mailproxy4-syd3.pacific.net.au [61.8.2.162]) by mailout4-syd3.pacific.net.au (Postfix) with ESMTP id 99516458B57 for <bug-Math-BigInt [...] rt.cpan.org>; Thu, 24 Oct 2013 11:17:36 +1100 (EST)
Received: from blah.blah (unknown [203.26.175.4]) by mailproxy4-syd3.pacific.net.au (Postfix) with ESMTP id 28F5C2C09C for <bug-Math-BigInt [...] rt.cpan.org>; Thu, 24 Oct 2013 11:17:36 +1100 (EST)
Received: from gg by blah.blah with local (Exim 4.80) (envelope-from <gg [...] blah.blah>) id 1VZ8b3-0002ha-A9 for bug-Math-BigInt [...] rt.cpan.org; Thu, 24 Oct 2013 11:16:17 +1100
Delivered-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #88293] BigFloat batan(1.5) infinite loop
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
Return-Path: <gg [...] zip.com.au>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
X-RT-Mail-Extension: math-bigint
Date: Thu, 24 Oct 2013 11:16:17 +1100
X-Spam-Level:
To: bug-Math-BigInt [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
RT-Message-ID: <rt-4.0.16-20464-1382573876-914.88293-0-0 [...] rt.cpan.org>
Content-Length: 313
Download (untitled) / with headers
text/plain 313b
"Dana Jacobsen via RT" <bug-Math-BigInt@rt.cpan.org> writes: Show quoted text
> > - if ($x->{_es} eq '+' && ($MBI->_acmp($x->{_m},$one) >= 0)) > + if ($x->bacmp($x->copy->bone) >= 0)
Yes, that's about it. $x->bacmp(1) seems enough for me if that helps. Perhaps the object style $one is only needed by the internal _acmp() ...
MIME-Version: 1.0
In-Reply-To: <rt-4.0.16-20464-1382573876-914.88293-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <RT-Ticket-88293 [...] rt.cpan.org> <87zjrzylki.fsf [...] blah.blah> <rt-4.0.16-3797-1382566769-1252.88293-6-0 [...] rt.cpan.org> <87r4bby14e.fsf [...] blah.blah> <rt-4.0.16-20464-1382573876-914.88293-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.16-20464-1382577856-1657.88293-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 1194
Download (untitled) / with headers
text/plain 1.1k
On Wed Oct 23 20:17:56 2013, user42@zip.com.au wrote: Show quoted text
> "Dana Jacobsen via RT" <bug-Math-BigInt@rt.cpan.org> writes:
> > > > - if ($x->{_es} eq '+' && ($MBI->_acmp($x->{_m},$one) >= 0)) > > + if ($x->bacmp($x->copy->bone) >= 0)
> > Yes, that's about it. $x->bacmp(1) seems enough for me if that helps. > Perhaps the object style $one is only needed by the internal _acmp() ...
$x->bacmp(1) should work fine, but I believe it is slightly slower. I've found, especially with the GMP backend, that programs using Math::BigInt can spend over half their time in Objectify caused by doing things like ->badd(1) instead of ->binc(). Converting integer arguments into BigInts outside of loops tends to speed things up a lot (e.g. making a Math::BigInt version of '2' at the top, then using bcmp($two) inside a loop instead of bcmp(2) saves lots of time). In this case it is debatable whether it is worth the trouble. NYTProf says the $x->copy->bone does save ~200 calls to new() in the big atan test file, but it's lost in the time spent in other parts of that file. Faster would be something using $x->{_es}, $MBI->_len($x->{_m}), and $MBI->_num($x->{_e}), but there are lots of weird cases.
MIME-Version: 1.0
In-Reply-To: <rt-4.0.16-20464-1382577856-1657.88293-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <RT-Ticket-88293 [...] rt.cpan.org> <87zjrzylki.fsf [...] blah.blah> <rt-4.0.16-3797-1382566769-1252.88293-6-0 [...] rt.cpan.org> <87r4bby14e.fsf [...] blah.blah> <rt-4.0.16-20464-1382573876-914.88293-0-0 [...] rt.cpan.org> <rt-4.0.16-20464-1382577856-1657.88293-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-4270-1463834679-506.88293-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 19
Fixed in v1.999701.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.