offtopic? Math::BigFloat
C. Abney
cabney at ucsd.edu
Mon Dec 23 15:09:19 CST 2002
~sdpm~
On Sun, 2002-12-22 at 02:51, Douglas Wilson wrote:
> You mentioned privately that the routines were slow (pure perl never has
> been that
> good at arbitrary precision number crunching), but I've since noticed that
> there are options to Math::BigFloat to use Bit::Vector, Math::Pari, or
> Math::GMP as backends (and they are all C or XS libraries), and
> I though it might be worth sharing with
> the group. It may help, I don't know if it'll help you
> enough, but it may be worth looking into. You might have to change
> the 'use Math::BigFloat' statement within Math::NumberCruncher, or
> maybe it would be enough to pass in your own Math::BigFloat
> numbers to the Math::NumberCruncher routines.
No this was a problem with the code, or at least the way I was using
it. My solution was to graft ->Ln() and its dependencies out into my
own code, and make some minor changes. The code section:
=8<======
$X->bfround( -$modP );
return -Ln( 1 / $X, $P ) if $X < 1;
=8<======
was changed to:
=8<======
if ( 0 > $X->bcmp(1) ) {
my $N = $X->copy();
$N->bone();
$N->bdiv($X);
return -Ln($N, $P);
}
$X->bfround( -$modP );
=8<======
This was necessary because the existing code was rounding my really
small number to zero But it wasn't doing it /explicitly/, rather as a
consequence of assuming it was a normal sized number, and doing a normal
division on it. Also, $X->bfround( -$modP ) is evaluated twice if $X <
1 in the original code. There's probably a more efficient way to
accomplish the changes I made, but I have a deadline (and this is a
prototype). :-/
Again, thanks to Douglas for pointing out Math::NumberCruncher, which
has a lot of really nice goodies.
Yours,
Charles
--
Charles Abney
Polymorphism Research Laboratory, 0603
UCSD School of Medicine
9500 Gilman Dr.
La Jolla, CA 92093-0603
~sdpm~
The posting address is: san-diego-pm-list at hfb.pm.org
List requests should be sent to: majordomo at hfb.pm.org
If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:
unsubscribe san-diego-pm-list
If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.
More information about the San-Diego-pm
mailing list