line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Quantum::Superpositions::Lazy::Operation::Computational; |
2
|
|
|
|
|
|
|
$Quantum::Superpositions::Lazy::Operation::Computational::VERSION = '1.12'; |
3
|
15
|
|
|
15
|
|
152
|
use v5.24; |
|
15
|
|
|
|
|
50
|
|
4
|
15
|
|
|
15
|
|
68
|
use warnings; |
|
15
|
|
|
|
|
38
|
|
|
15
|
|
|
|
|
309
|
|
5
|
15
|
|
|
15
|
|
64
|
use Moo; |
|
15
|
|
|
|
|
30
|
|
|
15
|
|
|
|
|
85
|
|
6
|
|
|
|
|
|
|
|
7
|
15
|
|
|
15
|
|
4229
|
use Types::Standard qw(Enum); |
|
15
|
|
|
|
|
53
|
|
|
15
|
|
|
|
|
148
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my %types = ( |
10
|
|
|
|
|
|
|
q{neg} => [1, sub { -$_[0] }], |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
q{+} => [2, sub { $_[0] + $_[1] }], |
13
|
|
|
|
|
|
|
q{-} => [2, sub { $_[0] - $_[1] }], |
14
|
|
|
|
|
|
|
q{*} => [2, sub { $_[0] * $_[1] }], |
15
|
|
|
|
|
|
|
q{**} => [2, sub { $_[0]**$_[1] }], |
16
|
|
|
|
|
|
|
q{<<} => [2, sub { $_[0] << $_[1] }], |
17
|
|
|
|
|
|
|
q{>>} => [2, sub { $_[0] >> $_[1] }], |
18
|
|
|
|
|
|
|
q{/} => [2, sub { $_[0] / $_[1] }], |
19
|
|
|
|
|
|
|
q{%} => [2, sub { $_[0] % $_[1] }], |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
q{+=} => [2, sub { $_[0] + $_[1] }], |
22
|
|
|
|
|
|
|
q{-=} => [2, sub { $_[0] - $_[1] }], |
23
|
|
|
|
|
|
|
q{*=} => [2, sub { $_[0] * $_[1] }], |
24
|
|
|
|
|
|
|
q{**=} => [2, sub { $_[0]**$_[1] }], |
25
|
|
|
|
|
|
|
q{<<=} => [2, sub { $_[0] << $_[1] }], |
26
|
|
|
|
|
|
|
q{>>=} => [2, sub { $_[0] >> $_[1] }], |
27
|
|
|
|
|
|
|
q{/=} => [2, sub { $_[0] / $_[1] }], |
28
|
|
|
|
|
|
|
q{%=} => [2, sub { $_[0] % $_[1] }], |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
q{.} => [2, sub { $_[0] . $_[1] }], |
31
|
|
|
|
|
|
|
q{x} => [2, sub { $_[0] x $_[1] }], |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
q{.=} => [2, sub { $_[0] . $_[1] }], |
34
|
|
|
|
|
|
|
q{x=} => [2, sub { $_[0] x $_[1] }], |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
q{atan2} => [2, sub { atan2 $_[0], $_[1] }], |
37
|
|
|
|
|
|
|
q{cos} => [1, sub { cos $_[0] }], |
38
|
|
|
|
|
|
|
q{sin} => [1, sub { sin $_[0] }], |
39
|
|
|
|
|
|
|
q{exp} => [1, sub { exp $_[0] }], |
40
|
|
|
|
|
|
|
q{log} => [1, sub { log $_[0] }], |
41
|
|
|
|
|
|
|
q{sqrt} => [1, sub { sqrt $_[0] }], |
42
|
|
|
|
|
|
|
q{int} => [1, sub { int $_[0] }], |
43
|
|
|
|
|
|
|
q{abs} => [1, sub { abs $_[0] }], |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
q{_transform} => [ |
46
|
|
|
|
|
|
|
[2,], |
47
|
|
|
|
|
|
|
sub { |
48
|
|
|
|
|
|
|
local $_ = shift; |
49
|
|
|
|
|
|
|
my $sub = shift; |
50
|
|
|
|
|
|
|
$sub->($_, @_); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
], |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
15
|
|
|
15
|
|
16721
|
use namespace::clean; |
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
103
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
with "Quantum::Superpositions::Lazy::Role::Operation"; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has "+sign" => ( |
60
|
|
|
|
|
|
|
is => "ro", |
61
|
|
|
|
|
|
|
isa => Enum [keys %types], |
62
|
|
|
|
|
|
|
required => 1, |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub supported_types |
66
|
|
|
|
|
|
|
{ |
67
|
15
|
|
|
15
|
0
|
46
|
my ($self) = @_; |
68
|
|
|
|
|
|
|
|
69
|
15
|
|
|
|
|
137
|
return keys %types; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub run |
73
|
|
|
|
|
|
|
{ |
74
|
81095
|
|
|
81095
|
0
|
149750
|
my ($self, @parameters) = @_; |
75
|
|
|
|
|
|
|
|
76
|
81095
|
|
|
|
|
155619
|
my ($param_num, $code) = $types{$self->sign}->@*; |
77
|
81095
|
|
|
|
|
182498
|
$self->_clear_parameters($param_num, @parameters); |
78
|
|
|
|
|
|
|
|
79
|
81095
|
|
|
|
|
125344
|
return $code->(@parameters); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|