# ArithmeticSimplifier class¶

(Shortest import: from brian2.codegen.optimisation import ArithmeticSimplifier)

class brian2.codegen.optimisation.ArithmeticSimplifier(variables)[source]

Carries out the following arithmetic simplifications:

1. Constant evaluation (e.g. exp(0)=1) by attempting to evaluate the expression in an “assumptions namespace”
2. Binary operators, e.g. 0*x=0, 1*x=x, etc. You have to take care that the dtypes match here, e.g. if x is an integer, then 1.0*x shouldn’t be replaced with x but left as 1.0*x.
Parameters: variables : dict of (str, Variable) Usual definition of variables. assumptions : sequence of str Additional assumptions that can be used in simplification, each assumption is a string statement. These might be the scalar statements for example.

Methods

 render_BinOp(node) render_node(node) Assumes that the node has already been fully processed by BrianASTRenderer

Details

render_BinOp(node)[source]
render_node(node)[source]

Assumes that the node has already been fully processed by BrianASTRenderer