line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Quantum::Superpositions::Lazy::Operation::Computational; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '1.10'; |
4
|
|
|
|
|
|
|
|
5
|
15
|
|
|
15
|
|
147
|
use v5.24; |
|
15
|
|
|
|
|
44
|
|
6
|
15
|
|
|
15
|
|
63
|
use warnings; |
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
294
|
|
7
|
15
|
|
|
15
|
|
59
|
use Moo; |
|
15
|
|
|
|
|
25
|
|
|
15
|
|
|
|
|
69
|
|
8
|
|
|
|
|
|
|
|
9
|
15
|
|
|
15
|
|
3752
|
use Types::Standard qw(Enum); |
|
15
|
|
|
|
|
38
|
|
|
15
|
|
|
|
|
143
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my %types = ( |
12
|
|
|
|
|
|
|
q{neg} => [1, sub { -$_[0] }], |
13
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
q{/} => [2, sub { $_[0] / $_[1] }], |
21
|
|
|
|
|
|
|
q{%} => [2, sub { $_[0] % $_[1] }], |
22
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
q{/=} => [2, sub { $_[0] / $_[1] }], |
30
|
|
|
|
|
|
|
q{%=} => [2, sub { $_[0] % $_[1] }], |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
q{.} => [2, sub { $_[0] . $_[1] }], |
33
|
|
|
|
|
|
|
q{x} => [2, sub { $_[0] x $_[1] }], |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
q{.=} => [2, sub { $_[0] . $_[1] }], |
36
|
|
|
|
|
|
|
q{x=} => [2, sub { $_[0] x $_[1] }], |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
q{atan2} => [2, sub { atan2 $_[0], $_[1] }], |
39
|
|
|
|
|
|
|
q{cos} => [1, sub { cos $_[0] }], |
40
|
|
|
|
|
|
|
q{sin} => [1, sub { sin $_[0] }], |
41
|
|
|
|
|
|
|
q{exp} => [1, sub { exp $_[0] }], |
42
|
|
|
|
|
|
|
q{log} => [1, sub { log $_[0] }], |
43
|
|
|
|
|
|
|
q{sqrt} => [1, sub { sqrt $_[0] }], |
44
|
|
|
|
|
|
|
q{int} => [1, sub { int $_[0] }], |
45
|
|
|
|
|
|
|
q{abs} => [1, sub { abs $_[0] }], |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
q{_transform} => [ |
48
|
|
|
|
|
|
|
[2,], |
49
|
|
|
|
|
|
|
sub { |
50
|
|
|
|
|
|
|
local $_ = shift; |
51
|
|
|
|
|
|
|
my $sub = shift; |
52
|
|
|
|
|
|
|
$sub->($_, @_); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
], |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
15
|
|
|
15
|
|
15941
|
use namespace::clean; |
|
15
|
|
|
|
|
32
|
|
|
15
|
|
|
|
|
115
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
with "Quantum::Superpositions::Lazy::Role::Operation"; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
has "+sign" => ( |
62
|
|
|
|
|
|
|
is => "ro", |
63
|
|
|
|
|
|
|
isa => Enum [keys %types], |
64
|
|
|
|
|
|
|
required => 1, |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub supported_types |
68
|
|
|
|
|
|
|
{ |
69
|
15
|
|
|
15
|
0
|
43
|
my ($self) = @_; |
70
|
|
|
|
|
|
|
|
71
|
15
|
|
|
|
|
154
|
return keys %types; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub run |
75
|
|
|
|
|
|
|
{ |
76
|
81095
|
|
|
81095
|
0
|
131397
|
my ($self, @parameters) = @_; |
77
|
|
|
|
|
|
|
|
78
|
81095
|
|
|
|
|
145373
|
my ($param_num, $code) = $types{$self->sign}->@*; |
79
|
81095
|
|
|
|
|
137353
|
@parameters = $self->_clear_parameters($param_num, @parameters); |
80
|
|
|
|
|
|
|
|
81
|
81095
|
|
|
|
|
115480
|
return $code->(@parameters); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |