User API to specify equations.
An equal relation between two objects, the left-hand side and the right-hand side.
The left-hand side may be a Function or a SparseFunction. The right-hand side may be any arbitrary expressions with numbers, Dimensions, Constants, Functions and SparseFunctions as operands.
>>> from devito import Grid, Function, Eq >>> grid = Grid(shape=(4, 4)) >>> f = Function(name='f', grid=grid) >>> Eq(f, f + 1) Eq(f(x, y), f(x, y) + 1)
Any SymPy expressions may be used in the right-hand side.
>>> from sympy import sin >>> Eq(f, sin(f.dx)**2) Eq(f(x, y), sin(f(x, y)/h_x - f(x + h_x, y)/h_x)**2)
An Eq can be thought of as an assignment in an imperative programming language (e.g.,
a[i] = b[i]*c).
The SubDomain in which the Eq is defined.
An increment relation between two objects, the left-hand side and the right-hand side.
Inc may be used to express tensor contractions. Below, a summation along the user-defined Dimension
>>> from devito import Grid, Dimension, Function, Inc >>> grid = Grid(shape=(4, 4)) >>> x, y = grid.dimensions >>> i = Dimension(name='i') >>> f = Function(name='f', grid=grid) >>> g = Function(name='g', shape=(10, 4, 4), dimensions=(i, x, y)) >>> Inc(f, g) Inc(f(x, y), g(i, x, y))
An Inc can be thought of as the augmented assignment ‘+=’ in an imperative programming language (e.g.,
a[i] += c).
solve(eq, target, **kwargs)¶
Algebraically rearrange an Eq w.r.t. a given symbol.
This is a wrapper around
- eq (expr-like) – The equation to be rearranged.
- target (symbol) – The symbol w.r.t. which the equation is rearranged. May be a Function or any other symbolic object.
- **kwargs – Symbolic optimizations applied while rearranging the equation. For more
information. refer to