Skip Menu |

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

Report information
The Basics
Id: 77856
Status: resolved
Priority: 0/
Queue: Math-Factor-XS

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

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



Subject: factors() on BigInt
Date: Sat, 16 Jun 2012 11:31:49 +1000
To: bug-Math-Factor-XS [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
The program foo.pl below gets an error Parameter #1 ("123") to Math::Factor::XS::factors was a 'hashref object', which is not one of the allowed types: scalar at foo.pl line 8 where I hoped that a BigInt or other overloaded number class could be passed to factors() -- as long as the value is within the range supported (32 bits). I'd like to reduce the parameter checking from factors() to just a range check like I put in prime_factors(). I believe this could be a large speedup, since some TimeThis below for me has factors() taking almost 10x longer than its underlying xs_factors().
#!/usr/bin/perl -w use strict; use Math::Factor::XS 'factors'; use Math::BigInt; my $small = 123; my $big = Math::BigInt->new(123); print factors($small),"\n"; print factors($big),"\n";
use strict; use Math::Factor::XS 'factors'; use Devel::TimeThis; my $num = 50000; { my $t = Devel::TimeThis->new('factors'); foreach (1 .. $num) { factors($_); } } { my $t = Devel::TimeThis->new('xs_factors'); foreach (1 .. $num) { Math::Factor::XS::xs_factors($_); } } exit 0;
Fixed by me in 0.40.