line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Symbolic::Custom::Simplification; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
170690
|
use 5.006001; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
6
|
1
|
|
|
1
|
|
6
|
use Carp qw/cluck confess/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
62
|
|
7
|
1
|
|
|
1
|
|
5
|
use Math::Symbolic; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
260
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.01'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @Simplification_Stack; |
12
|
|
|
|
|
|
|
our %Registered; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
_reset(); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _reset { |
17
|
1
|
|
|
1
|
|
4
|
@Simplification_Stack = ( |
18
|
|
|
|
|
|
|
['Math::Symbolic::Operator', \&Math::Symbolic::Operator::simplify] |
19
|
|
|
|
|
|
|
); |
20
|
1
|
|
|
|
|
3
|
%Registered = ( |
21
|
|
|
|
|
|
|
'Math::Symbolic::Operator' => 1 |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub register { |
26
|
12
|
|
|
12
|
1
|
34782
|
my $class = shift; |
27
|
12
|
50
|
|
|
|
36
|
confess("Cannot register simplification routine when not called as class method.") if not defined $class; |
28
|
|
|
|
|
|
|
|
29
|
12
|
|
|
|
|
955
|
my $simp = eval "\\&${class}::simplify"; |
30
|
12
|
50
|
33
|
|
|
121
|
if ($@ or not defined $simp or not ref $simp eq 'CODE') { |
|
|
|
33
|
|
|
|
|
31
|
0
|
0
|
|
|
|
0
|
my $msg = $@? "Error: $@" : ''; |
32
|
0
|
|
|
|
|
0
|
confess("Could not find simplification routine as '${class}::simplify'."); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
12
|
|
|
|
|
25
|
$Registered{$class}++; |
36
|
12
|
|
|
|
|
33
|
push @Simplification_Stack, [$class, $simp]; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
1
|
|
5
|
no strict; no warnings qw/redefine/; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
199
|
|
39
|
12
|
|
|
|
|
36
|
*Math::Symbolic::Operator::simplify = $simp; |
40
|
|
|
|
|
|
|
|
41
|
12
|
|
|
|
|
42
|
return 1; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub unregister { |
46
|
13
|
|
|
13
|
1
|
26401
|
my $class = shift; |
47
|
13
|
50
|
|
|
|
38
|
confess("Cannot unregister simplification routine when not called as class method.") if not defined $class; |
48
|
|
|
|
|
|
|
|
49
|
13
|
100
|
|
|
|
41
|
return 0 if not $Registered{$class}; |
50
|
|
|
|
|
|
|
|
51
|
9
|
|
66
|
|
|
62
|
while (@Simplification_Stack and $class ne $Simplification_Stack[-1][0]) { |
52
|
2
|
|
|
|
|
3
|
my $this = pop @Simplification_Stack; |
53
|
2
|
|
|
|
|
13
|
$Registered{$this->[0]}--; |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
|
56
|
9
|
|
|
|
|
16
|
my $this = pop @Simplification_Stack; |
57
|
9
|
|
|
|
|
18
|
$Registered{$this->[0]}--; |
58
|
|
|
|
|
|
|
|
59
|
9
|
50
|
|
|
|
23
|
if (not @Simplification_Stack) { |
60
|
0
|
|
|
|
|
0
|
_reset(); |
61
|
0
|
|
|
|
|
0
|
return 0; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
1
|
|
6
|
no strict; no warnings qw/redefine/; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
86
|
|
65
|
9
|
|
|
|
|
29
|
*Math::Symbolic::Operator::simplify = $Simplification_Stack[-1][1]; |
66
|
|
|
|
|
|
|
|
67
|
9
|
|
|
|
|
25
|
return 1; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
__END__ |