mpacts.core. expression

Expression statement for performing simple mathematical operations on arrays. The expression is given in python, and translated into binary C++ operations. This is typically slower than regular C++ but faster than pure python.

Example usage:

from pyDEMeter.BaseTypes.Expression import Expr as _ from pyDEMeter.BaseTypes.Expression import ExpressionCommand

mgr = ar.ArrayManager(“sheres”) F = ar.create_array(“Vector”, “F”, mgr); m = ar.create_array(“Scalar”, “m”, mgr);

mgr2 = ar.ArrayManager(“Lines”) l = ar.create_array(“LineIndex”, “vil”, mgr2); m2 = ar.create_array(“Scalar”, “m”, mgr2);

grav = _(F).i() == _(F).i()+(0, 9.81, 0)*_(m).i()

nodeToSegment = _(m2).i() == (_(m )[_(l).i()[0] ]+ _(m)[_(l).i()[1]])/2.0

cmd.ExpressionCommand( expression = nodeToSegment()) #the () is needed to “unwrap” the expression into its C++ form cmd.ExpressionCommand( expression = grav() )

In order to be able to use this module import it like this:

import mpacts.core.expression
#or assign it to a shorter name
import mpacts.core.expression as exp
mpacts.core.expression.Expr(t)
mpacts.core.expression.cross(a, b)
mpacts.core.expression.dot(a, b)
mpacts.core.expression.exp(a)
mpacts.core.expression.log(a)
mpacts.core.expression.round(a)
mpacts.core.expression.sign(a)