1Math::Symbolic::VariablUes(e3r)Contributed Perl DocumentMaattiho:n:Symbolic::Variable(3)
2
3
4

NAME

6       Math::Symbolic::Variable - Variable in symbolic calculations
7

SYNOPSIS

9         use Math::Symbolic::Variable;
10
11         my $var1 = Math::Symbolic::Variable->new('name');
12         $var1->value(5);
13
14         my $var2 = Math::Symbolic::Variable->new('x', 2);
15
16         my $var3 =
17           Math::Symbolic::Variable->new(
18             {
19               name  => 'variable',
20               value => 1,
21             }
22           );
23

DESCRIPTION

25       This class implements variables for Math::Symbolic trees.  The objects
26       are overloaded in stringification context to return their names.
27
28       EXPORT
29
30       None by default.
31

METHODS

33       Constructor new
34
35       First argument is expected to be a hash reference of key-value pairs
36       which will be used as object attributes.
37
38       In particular, a variable is required to have a 'name'. Optional argu‐
39       ments include a 'value', and a 'signature'. The value expected for the
40       signature key is a reference to an array of identifiers.
41
42       Special case: First argument is not a hash reference. In this case,
43       first argument is treated as variable name, second as value.  This spe‐
44       cial case disallows cloning of objects (when used as object method).
45
46       Returns a Math::Symbolic::Variable.
47
48       Method value
49
50       value() evaluates the Math::Symbolic tree to its numeric representa‐
51       tion.
52
53       value() without arguments requires that every variable in the tree con‐
54       tains a defined value attribute. Please note that this refers to every
55       variable object, not just every named variable.
56
57       value() with one argument sets the object's value if you're dealing
58       with Variables or Constants. In case of operators, a call with one
59       argument will assume that the argument is a hash reference. (see next
60       paragraph)
61
62       value() with named arguments (key/value pairs) associates variables in
63       the tree with the value-arguments if the corresponging key matches the
64       variable name.  (Can one say this any more complicated?) Since version
65       0.132, an equivalent and valid syntax is to pass a single hash refer‐
66       ence instead of a list.
67
68       Example: $tree->value(x => 1, y => 2, z => 3, t => 0) assigns the value
69       1 to any occurrances of variables of the name "x", aso.
70
71       If a variable in the tree has no value set (and no argument of value
72       sets it temporarily), the call to value() returns undef.
73
74       Method name
75
76       Optional argument: sets the object's name.  Returns the object's name.
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 set_signature
112
113       set_signature expects any number of variable identifiers as arguments.
114       It sets a variable's signature to this list of identifiers.
115
116       Method to_string
117
118       Returns a string representation of the variable.
119
120       Method term_type
121
122       Returns the type of the term. (T_VARIABLE)
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::Variable(3)
Impressum