1Math::Symbolic::ConstanUts(e3r)Contributed Perl DocumentMaattiho:n:Symbolic::Constant(3)
2
3
4

NAME

6       Math::Symbolic::Constant - Constants in symbolic calculations
7

SYNOPSIS

9         use Math::Symbolic::Constant;
10         my $const = Math::Symbolic::Constant->new(25);
11         my $zero  = Math::Symbolic::Constant->zero();
12         my $one   = Math::Symbolic::Constant->one();
13         my $euler = Math::Symbolic::Constant->euler();
14         # e = 2.718281828...
15

DESCRIPTION

17       This module implements numeric constants for Math::Symbolic trees.
18
19       EXPORT
20
21       None by default.
22

METHODS

24       Constructor new
25
26       Takes hash reference of key-value pairs as argument.  Special case: a
27       value for the constant instead of the hash.  Returns a Math::Sym‐
28       bolic::Constant.
29
30       Constructor zero
31
32       Arguments are treated as key-value pairs of object attributes.  Returns
33       a Math::Symbolic::Constant with value of 0.
34
35       Constructor one
36
37       Arguments are treated as key-value pairs of object attributes.  Returns
38       a Math::Symbolic::Constant with value of 1.
39
40       Constructor euler
41
42       Arguments are treated as key-value pairs of object attributes.  Returns
43       a Math::Symbolic::Constant with value of e, the Euler number.  The
44       object has its 'special' attribute set to 'euler'.
45
46       Constructor pi
47
48       Arguments are treated as key-value pairs of object attributes.  Returns
49       a Math::Symbolic::Constant with value of pi.  The object has its 'spe‐
50       cial' attribute set to 'pi'.
51
52       Method value
53
54       value() evaluates the Math::Symbolic tree to its numeric representa‐
55       tion.
56
57       value() without arguments requires that every variable in the tree con‐
58       tains a defined value attribute. Please note that this refers to every
59       variable object, not just every named variable.
60
61       value() with one argument sets the object's value if you're dealing
62       with Variables or Constants. In case of operators, a call with one
63       argument will assume that the argument is a hash reference. (see next
64       paragraph)
65
66       value() with named arguments (key/value pairs) associates variables in
67       the tree with the value-arguments if the corresponging key matches the
68       variable name.  (Can one say this any more complicated?) Since version
69       0.132, an equivalent and valid syntax is to pass a single hash refer‐
70       ence instead of a list.
71
72       Example: $tree->value(x => 1, y => 2, z => 3, t => 0) assigns the value
73       1 to any occurrances of variables of the name "x", aso.
74
75       If a variable in the tree has no value set (and no argument of value
76       sets it temporarily), the call to value() returns undef.
77
78       Method signature
79
80       signature() returns a tree's signature.
81
82       In the context of Math::Symbolic, signatures are the list of variables
83       any given tree depends on. That means the tree "v*t+x" depends on the
84       variables v, t, and x. Thus, applying signature() on the tree that
85       would be parsed from above example yields the sorted list ('t', 'v',
86       'x').
87
88       Constants do not depend on any variables and therefore return the empty
89       list.  Obviously, operators' dependencies vary.
90
91       Math::Symbolic::Variable objects, however, may have a slightly more
92       involved signature. By convention, Math::Symbolic variables depend on
93       themselves. That means their signature contains their own name. But
94       they can also depend on various other variables because variables them‐
95       selves can be viewed as placeholders for more compicated terms. For
96       example in mechanics, the acceleration of a particle depends on its
97       mass and the sum of all forces acting on it. So the variable 'accelera‐
98       tion' would have the signature ('acceleration', 'force1', 'force2',...,
99       'mass', 'time').
100
101       If you're just looking for a list of the names of all variables in the
102       tree, you should use the explicit_signature() method instead.
103
104       Method explicit_signature
105
106       explicit_signature() returns a lexicographically sorted list of vari‐
107       able names in the tree.
108
109       See also: signature().
110
111       Method special
112
113       Optional argument: sets the object's special attribute.  Returns the
114       object's special attribute.
115
116       Method to_string
117
118       Returns a string representation of the constant.
119
120       Method term_type
121
122       Returns the type of the term. (T_CONSTANT)
123

AUTHOR

125       Please send feedback, bug reports, and support requests to the
126       Math::Symbolic support mailing list: math-symbolic-support at lists dot
127       sourceforge dot net. Please consider letting us know how you use
128       Math::Symbolic. Thank you.
129
130       If you're interested in helping with the development or extending the
131       module's functionality, please contact the developers' mailing list:
132       math-symbolic-develop at lists dot sourceforge dot net.
133
134       List of contributors:
135
136         Steffen Müller, symbolic-module at steffen-mueller dot net
137         Stray Toaster, mwk at users dot sourceforge dot net
138         Oliver Ebenhöh
139

SEE ALSO

141       New versions of this module can be found on http://steffen-mueller.net
142       or CPAN. The module development takes place on Sourceforge at
143       http://sourceforge.net/projects/math-symbolic/
144
145       Math::Symbolic
146
147
148
149perl v5.8.8                       2008-02-22       Math::Symbolic::Constant(3)
Impressum