line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::SimpleHisto::XS::RNG; |
2
|
11
|
|
|
11
|
|
56
|
use strict; |
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
536
|
|
3
|
11
|
|
|
11
|
|
64
|
use warnings; |
|
11
|
|
|
|
|
17
|
|
|
11
|
|
|
|
|
4905
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $Gen = __PACKAGE__->new(_seed()); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub _seed { |
10
|
11
|
|
|
11
|
|
20
|
my $x; |
11
|
11
|
|
|
0
|
|
67
|
my @refs = (\$x, [], {}, sub {}); # yeah, random is different :( |
|
0
|
|
|
|
|
0
|
|
12
|
11
|
|
|
|
|
98
|
my @ints = (time, $$); |
13
|
11
|
|
|
|
|
29
|
foreach my $ref (@refs) { |
14
|
44
|
|
|
|
|
89
|
$ref = "$ref"; |
15
|
44
|
50
|
|
|
|
297
|
$ref =~ s/^\w+\(0x(\w+)\)$/$1/ or next; |
16
|
44
|
|
|
|
|
221
|
$ref = unpack("h*", $ref); |
17
|
44
|
|
|
|
|
88
|
$ref = $ref % 2**31; |
18
|
44
|
|
|
|
|
97
|
push @ints, $ref; |
19
|
|
|
|
|
|
|
} |
20
|
11
|
|
|
|
|
101
|
return @ints; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
14
|
|
|
14
|
0
|
209330
|
my $class = shift; |
26
|
14
|
100
|
|
|
|
59
|
if (@_ == 1) { |
27
|
3
|
|
|
|
|
42
|
return setup(shift); # XS |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
else { |
30
|
11
|
|
|
|
|
241
|
return setup_array(@_); # XS |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub rand { |
35
|
2
|
|
|
2
|
0
|
342
|
my ($self, $x) = @_; |
36
|
2
|
100
|
|
|
|
7
|
if (ref $self) { |
37
|
1
|
|
50
|
|
|
16
|
return ($x || 1) * $self->genrand(); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
1
|
|
|
|
|
3
|
$x = $self; |
41
|
1
|
50
|
|
|
|
4
|
$Gen = __PACKAGE__->new(_seed()) if not defined $Gen; |
42
|
1
|
|
50
|
|
|
24
|
return ($x || 1) * $Gen->genrand(); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |