line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Factor::XS; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
56154
|
use strict; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
134
|
|
4
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
102
|
|
5
|
3
|
|
|
3
|
|
15
|
use base qw(Exporter); |
|
3
|
|
|
|
|
24
|
|
|
3
|
|
|
|
|
420
|
|
6
|
3
|
|
|
3
|
|
1829
|
use boolean qw(true); |
|
3
|
|
|
|
|
7526
|
|
|
3
|
|
|
|
|
16
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
270
|
use Carp qw(croak); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
218
|
|
9
|
3
|
|
|
3
|
|
3461
|
use List::MoreUtils qw(all); |
|
3
|
|
|
|
|
4685
|
|
|
3
|
|
|
|
|
288
|
|
10
|
3
|
|
|
3
|
|
113888
|
use Params::Validate ':all'; |
|
3
|
|
|
|
|
64031
|
|
|
3
|
|
|
|
|
841
|
|
11
|
3
|
|
|
3
|
|
31
|
use Scalar::Util qw(looks_like_number); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
1374
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our ($VERSION, @EXPORT_OK, %EXPORT_TAGS); |
14
|
|
|
|
|
|
|
$VERSION = '0.40'; |
15
|
|
|
|
|
|
|
@EXPORT_OK = qw(factors matches prime_factors count_prime_factors); |
16
|
|
|
|
|
|
|
%EXPORT_TAGS = (all => \@EXPORT_OK); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
validation_options( |
19
|
|
|
|
|
|
|
on_fail => sub |
20
|
|
|
|
|
|
|
{ |
21
|
|
|
|
|
|
|
my ($error) = @_; |
22
|
|
|
|
|
|
|
chomp $error; |
23
|
|
|
|
|
|
|
croak $error; |
24
|
|
|
|
|
|
|
}); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $positive_nums = sub |
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
all { looks_like_number($_) && ($_ >= 0) } |
29
|
|
|
|
|
|
|
ref $_[0] ? @{$_[0]} : ($_[0]); |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub matches |
33
|
|
|
|
|
|
|
{ |
34
|
|
|
|
|
|
|
validate_pos(@_, |
35
|
|
|
|
|
|
|
{ type => SCALAR, |
36
|
|
|
|
|
|
|
callbacks => { |
37
|
|
|
|
|
|
|
'is a positive number' => |
38
|
|
|
|
|
|
|
$positive_nums, |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
}, |
41
|
|
|
|
|
|
|
{ type => ARRAYREF, |
42
|
|
|
|
|
|
|
callbacks => { |
43
|
|
|
|
|
|
|
'factors are positive numbers' => sub |
44
|
|
|
|
|
|
|
{ |
45
|
3
|
|
|
3
|
|
5
|
my $factors = shift; |
46
|
3
|
100
|
|
|
|
15
|
!@$factors or $positive_nums->($factors); |
47
|
|
|
|
|
|
|
}, |
48
|
|
|
|
|
|
|
}, |
49
|
|
|
|
|
|
|
}, |
50
|
3
|
|
|
3
|
1
|
7152
|
{ type => HASHREF, |
51
|
|
|
|
|
|
|
optional => true, |
52
|
|
|
|
|
|
|
}, |
53
|
|
|
|
|
|
|
); |
54
|
3
|
|
|
|
|
56
|
return xs_matches(@_); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
require XSLoader; |
58
|
|
|
|
|
|
|
XSLoader::load(__PACKAGE__, $VERSION); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
__END__ |