line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Set::Similarity::BV; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
2554
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
156
|
|
4
|
5
|
|
|
5
|
|
19
|
use warnings; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
213
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
29
|
use Carp 'croak'; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
872
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
7
|
|
|
7
|
1
|
2249
|
my $class = shift; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# uncoverable condition false |
14
|
7
|
100
|
66
|
|
|
47
|
bless @_ ? @_ > 1 ? {@_} : {%{$_[0]}} : {}, ref $class || $class; |
|
2
|
100
|
|
|
|
12
|
|
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub similarity { |
18
|
41
|
|
|
41
|
1
|
3416
|
my ($self, $hex1, $hex2) = @_; |
19
|
|
|
|
|
|
|
|
20
|
41
|
100
|
100
|
|
|
220
|
return 1 if (!($hex1 || $hex2)); # both zero |
21
|
33
|
100
|
100
|
|
|
192
|
return 0 unless ($hex1 && $hex2); # one is zero |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#return 1 if (!(hex($hex1) || hex($hex2))); # both zero |
24
|
|
|
|
|
|
|
#return 0 unless (hex($hex1) && hex($hex2) ); # one is zero |
25
|
|
|
|
|
|
|
|
26
|
5
|
|
|
5
|
|
36
|
no warnings 'portable'; # for 0xffffffffffffffff |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
801
|
|
27
|
|
|
|
|
|
|
|
28
|
21
|
|
|
|
|
86
|
return $self->from_integers( |
29
|
|
|
|
|
|
|
hex($hex1), |
30
|
|
|
|
|
|
|
hex($hex2), |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
1
|
1
|
340
|
sub from_integers { croak 'Method "from_integers" not implemented in subclass' } |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub intersection { |
38
|
21
|
|
|
21
|
1
|
24
|
my ($self,$v1,$v2) = @_; |
39
|
|
|
|
|
|
|
|
40
|
21
|
|
|
|
|
63
|
return $self->bits($v1 & $v2); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub bits { |
44
|
63
|
|
|
63
|
1
|
67
|
my $v = $_[1]; |
45
|
|
|
|
|
|
|
|
46
|
5
|
|
|
5
|
|
2760
|
use integer; |
|
5
|
|
|
|
|
71
|
|
|
5
|
|
|
|
|
28
|
|
47
|
5
|
|
|
5
|
|
171
|
no warnings 'portable'; # for 0xffffffffffffffff |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
801
|
|
48
|
|
|
|
|
|
|
|
49
|
63
|
|
|
|
|
66
|
$v = $v - (($v >> 1) & 0x5555555555555555); |
50
|
63
|
|
|
|
|
69
|
$v = ($v & 0x3333333333333333) + (($v >> 2) & 0x3333333333333333); |
51
|
|
|
|
|
|
|
# (bytesof($v) -1) * bitsofbyte = (8-1)*8 = 56 ----------------------vv |
52
|
63
|
|
|
|
|
69
|
$v = (($v + ($v >> 4) & 0x0f0f0f0f0f0f0f0f) * 0x0101010101010101) >> 56; |
53
|
|
|
|
|
|
|
|
54
|
63
|
|
|
|
|
173
|
return $v; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub combined_length { |
58
|
10
|
|
|
10
|
1
|
27
|
my ($self,$v1,$v2) = @_; |
59
|
|
|
|
|
|
|
|
60
|
10
|
|
|
|
|
18
|
return $self->bits($v1) + $self->bits($v2); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub min { |
64
|
8
|
100
|
|
8
|
1
|
51
|
($_[1] < $_[2]) |
65
|
|
|
|
|
|
|
? $_[1] : $_[2]; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |