| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=encoding utf8 |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Math::Symbolic::Custom::DefaultDumpers - Default Math::Symbolic output routines |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Math::Symbolic qw/parse_from_string/; |
|
11
|
|
|
|
|
|
|
$term = parse_from_string(...); |
|
12
|
|
|
|
|
|
|
my ($sub, $leftover_trees) = $term->to_sub(); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This is a class of default output routines for Math::Symbolic trees. Likewise, |
|
17
|
|
|
|
|
|
|
Math::Symbolic::Custom::DefaultTests defines default tree testing |
|
18
|
|
|
|
|
|
|
routines and Math::Symbolic::Custom::DefaultMods has default tree modification |
|
19
|
|
|
|
|
|
|
methods. |
|
20
|
|
|
|
|
|
|
For details on how the custom method delegation model works, please have |
|
21
|
|
|
|
|
|
|
a look at the Math::Symbolic::Custom and Math::Symbolic::Custom::Base |
|
22
|
|
|
|
|
|
|
classes. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 EXPORT |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Please see the docs for Math::Symbolic::Custom::Base for details, but |
|
27
|
|
|
|
|
|
|
you should not try to use the standard Exporter semantics with this |
|
28
|
|
|
|
|
|
|
class. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 SUBROUTINES |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
package Math::Symbolic::Custom::DefaultDumpers; |
|
35
|
|
|
|
|
|
|
|
|
36
|
23
|
|
|
23
|
|
459
|
use 5.006; |
|
|
23
|
|
|
|
|
79
|
|
|
|
23
|
|
|
|
|
942
|
|
|
37
|
23
|
|
|
23
|
|
133
|
use strict; |
|
|
23
|
|
|
|
|
48
|
|
|
|
23
|
|
|
|
|
895
|
|
|
38
|
23
|
|
|
23
|
|
251
|
use warnings; |
|
|
23
|
|
|
|
|
64
|
|
|
|
23
|
|
|
|
|
776
|
|
|
39
|
23
|
|
|
23
|
|
118
|
no warnings 'recursion'; |
|
|
23
|
|
|
|
|
42
|
|
|
|
23
|
|
|
|
|
1176
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
our $VERSION = '0.612'; |
|
42
|
|
|
|
|
|
|
|
|
43
|
23
|
|
|
23
|
|
132
|
use Math::Symbolic::Custom::Base; |
|
|
23
|
|
|
|
|
44
|
|
|
|
23
|
|
|
|
|
1252
|
|
|
44
|
23
|
|
|
23
|
|
537
|
BEGIN { *import = \&Math::Symbolic::Custom::Base::aggregate_import } |
|
45
|
|
|
|
|
|
|
|
|
46
|
23
|
|
|
23
|
|
138
|
use Math::Symbolic::ExportConstants qw/:all/; |
|
|
23
|
|
|
|
|
44
|
|
|
|
23
|
|
|
|
|
6000
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
23
|
|
|
23
|
|
140
|
use Carp; |
|
|
23
|
|
|
|
|
45
|
|
|
|
23
|
|
|
|
|
10808
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Class Data: Special variable required by Math::Symbolic::Custom |
|
51
|
|
|
|
|
|
|
# importing/exporting functionality. |
|
52
|
|
|
|
|
|
|
# All subroutines that are to be exported to the Math::Symbolic::Custom |
|
53
|
|
|
|
|
|
|
# namespace should be listed here. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
our $Aggregate_Export = [ |
|
56
|
|
|
|
|
|
|
qw/ |
|
57
|
|
|
|
|
|
|
to_code |
|
58
|
|
|
|
|
|
|
to_sub |
|
59
|
|
|
|
|
|
|
/ |
|
60
|
|
|
|
|
|
|
]; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 to_string |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
The to_string method is currently implemented in the module core namespaces |
|
65
|
|
|
|
|
|
|
and will be moved to Math::Symbolic::DefaultDumpers in a future release. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Takes one optional argument indicating whether the Math::Symbolic tree should |
|
68
|
|
|
|
|
|
|
be transformed to a string using 'postfix' notation or using 'infix' notation. |
|
69
|
|
|
|
|
|
|
Default is infix which is also more likely to be reparseable by the |
|
70
|
|
|
|
|
|
|
Math::Symbolic parser. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 to_code |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This method is a wrapper around the compile_to_code class method in the |
|
75
|
|
|
|
|
|
|
Math::Symbolic::Compiler module. Takes key/value pairs of variables and |
|
76
|
|
|
|
|
|
|
integers as argument. The integers should starting at 0 and they determine |
|
77
|
|
|
|
|
|
|
the order of the variables/parameters to the compiled code. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Returns the compiled code and a reference to an array of possible leftover |
|
80
|
|
|
|
|
|
|
tree elements that could not be compiled. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Please refer to the Math::Symbolic::Compiler man page for details. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub to_code { |
|
87
|
7
|
|
|
7
|
1
|
11
|
my $self = shift; |
|
88
|
7
|
|
|
|
|
16
|
my $args = [@_]; # \@_ would be evil. @_ is not a real Perl array |
|
89
|
7
|
|
|
|
|
71
|
return Math::Symbolic::Compiler->compile_to_code( $self, $args ); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 to_sub |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This method is a wrapper around the compile_to_sub class method in the |
|
95
|
|
|
|
|
|
|
Math::Symbolic::Compiler module. Takes key/value pairs of variables and |
|
96
|
|
|
|
|
|
|
integers as argument. The integers should starting at 0 and they determine |
|
97
|
|
|
|
|
|
|
the order of the variables/parameters to the compiled code. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Returns the compiled sub and a reference to an array of possible leftover |
|
100
|
|
|
|
|
|
|
tree elements that could not be compiled. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Please refer to the Math::Symbolic::Compiler man page for details. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub to_sub { |
|
107
|
7
|
|
|
7
|
1
|
13
|
my $self = shift; |
|
108
|
7
|
|
|
|
|
19
|
my $args = [@_]; # \@_ would be evil. @_ is not a real Perl array |
|
109
|
7
|
|
|
|
|
46
|
return Math::Symbolic::Compiler->compile_to_sub( $self, $args ); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
|
113
|
|
|
|
|
|
|
__END__ |