<< Value SYMSCI Toolbox Vec >>

SYMSCI Toolbox >> SYMSCI Toolbox > Variable

Variable

symbolic variable

Calling Sequence

s = Variable( a )
s = %( a )

Arguments

a

symbolic object

s

symbolic variable

Description

Converts any symbolic object a to a symbolic variable and returns it. This operation works in-place.

Symbolic variables are never deleted by the garbage collection mechanism (cf. gc(..).

Symbolic variables must be deleted manually using free(..) or reset(..).

The value of a symbolic variable may be changed using the Assign(..) operator.

Examples

// tabula rasa
reset();

// manual gc mode (default)
gc(%f)

//
x = %(Sym("x")) // prefer this
y = Sym("y")    // avoid that, see below ...

// do some calculations ...
x + y
2*y + 5
x*x + x

// assign new value to "x"
x: 2*y + 5

// so far, everything worked fine, but the ":" operator does not
// allow (on purpose) a symbolic value as lhs, so the following
// will fail ...
y: x*x + x

// furthermore, if we switch to automatic gc ...
gc(%t)

// even the following fails ... because "y" gets automatically
// deleted after its first usage within "x+y"
x + y
2*y + 5
x*x + x

// clean-up
gc(%f);
reset();
clear x y;

See Also

Authors

Bibliography

SymEngine: C++ library for fast symbolic manipulation.


Report an issue
<< Value SYMSCI Toolbox Vec >>