line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::ModInt::GF2; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
1254
|
use 5.006; |
|
4
|
|
|
|
|
13
|
|
4
|
4
|
|
|
4
|
|
26
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
114
|
|
5
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
221
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ----- object definition ----- |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Math::ModInt::GF2=ARRAY(...) |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# .......... index .......... # .......... value .......... |
12
|
4
|
|
|
4
|
|
30
|
use constant F_RESIDUE => 0; # residue r, either 0 or 1 |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
280
|
|
13
|
4
|
|
|
4
|
|
37
|
use constant NFIELDS => 1; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
384
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# ----- class data ----- |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
BEGIN { |
18
|
4
|
|
|
4
|
|
47
|
require Math::ModInt; |
19
|
4
|
|
|
|
|
76
|
our @ISA = qw(Math::ModInt); |
20
|
4
|
|
|
|
|
2318
|
our $VERSION = '0.013'; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my @base = map { bless [$_] } 0..1; # singletons |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# ----- private methods ----- |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
2
|
|
144
|
sub _NEG { $_[0] } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _ADD { |
30
|
4
|
|
|
4
|
|
5
|
my ($this, $that) = @_; |
31
|
4
|
|
|
|
|
11
|
return $base[$this->[F_RESIDUE] ^ $that->[F_RESIDUE]]; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _SUB { |
35
|
4
|
|
|
4
|
|
8
|
my ($this, $that) = @_; |
36
|
4
|
|
|
|
|
9
|
return $base[$this->[F_RESIDUE] ^ $that->[F_RESIDUE]]; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _MUL { |
40
|
4
|
|
|
4
|
|
6
|
my ($this, $that) = @_; |
41
|
4
|
|
|
|
|
11
|
return $base[$this->[F_RESIDUE] & $that->[F_RESIDUE]]; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _DIV { |
45
|
4
|
|
|
4
|
|
9
|
my ($this, $that) = @_; |
46
|
4
|
100
|
|
|
|
14
|
return $that->[F_RESIDUE]? $this: Math::ModInt->undefined; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _POW { |
50
|
8
|
|
|
8
|
|
15
|
my ($this, $exp) = @_; |
51
|
|
|
|
|
|
|
return |
52
|
8
|
100
|
100
|
|
|
32
|
$this->[F_RESIDUE] || $exp > 0? $this: |
|
|
100
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$exp? $this->undefined: $base[1]; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _INV { |
57
|
2
|
|
|
2
|
|
3
|
my ($this) = @_; |
58
|
2
|
100
|
|
|
|
8
|
return $this->[F_RESIDUE]? $this: Math::ModInt->undefined; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _NEW { |
62
|
16
|
|
|
16
|
|
30
|
my ($this, $int) = @_; |
63
|
16
|
|
|
|
|
48
|
return $base[$int & 1]; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _NEW2 { |
67
|
2
|
|
|
2
|
|
4
|
my ($this, $int) = @_; |
68
|
2
|
100
|
|
|
|
4
|
if ($int < 0) { |
69
|
|
|
|
|
|
|
# no arithmetic shift operation for negative perl integers, alas |
70
|
1
|
|
|
|
|
2
|
my $residue = $int & 1; |
71
|
1
|
|
|
|
|
5
|
return (($int - $residue) / 2, $base[$residue]); |
72
|
|
|
|
|
|
|
} |
73
|
1
|
|
|
|
|
10
|
return ($int >> 1, $base[$int & 1]); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub residue { |
77
|
73
|
|
|
73
|
1
|
207
|
my ($this) = @_; |
78
|
73
|
|
|
|
|
177
|
return $this->[F_RESIDUE]; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub signed_residue { |
82
|
2
|
|
|
2
|
1
|
67
|
my ($this) = @_; |
83
|
2
|
|
|
|
|
5
|
return - $this->[F_RESIDUE]; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub centered_residue { |
87
|
2
|
|
|
2
|
1
|
62
|
my ($this) = @_; |
88
|
2
|
|
|
|
|
4
|
return $this->[F_RESIDUE]; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub modulus { |
92
|
122
|
|
|
122
|
1
|
340
|
return 2; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |