Eq
Eq()
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.
Parameters
Name | Type | Description | Default |
---|---|---|---|
lhs | Function or SparseFunction | The left-hand side. | required |
rhs | expr - like | The right-hand side. | 0 |
subdomain | SubDomain | To restrict the computation of the Eq to a particular sub-region in the computational domain. | None |
coefficients | Substitutions | Can be used to replace symbolic finite difference weights with user defined weights. | None |
implicit_dims | Dimension or list of Dimension | An ordered list of Dimensions that do not explicitly appear in either the left-hand side or in the right-hand side, but that should be honored when constructing an Operator. | None |
Examples
>>> from devito import Grid, Function, Eq
>>> grid = Grid(shape=(4, 4))
>>> f = Function(name='f', grid=grid)
>>> Eq(f, f + 1)
+ 1) Eq(f(x, y), f(x, y)
Any SymPy expressions may be used in the right-hand side.
>>> from devito import sin
>>> Eq(f, sin(f.dx)**2)
**2) Eq(f(x, y), sin(Derivative(f(x, y), x))
Notes
An Eq can be thought of as an assignment in an imperative programming language (e.g., a[i] = b[i]*c
).
Attributes
Name | Description |
---|---|
is_Reduction | bool(x) -> bool |
subdomain | The SubDomain in which the Eq is defined. |
Methods
Name | Description |
---|---|
func | Reconstruct self via self.__class__(*args, **kwargs) using |
func
*args, **kwargs) func(
Reconstruct self
via self.__class__(*args, **kwargs)
using self
’s __rargs__
and __rkwargs__
if and where *args
and **kwargs
lack entries.
Examples
Given
class Foo:
__rargs__ = ('a', 'b')
__rkwargs__ = ('c',)
def __init__(self, a, b, c=4):
self.a = a
self.b = b
self.c = c
a = foo(3, 5)`
Then:
* `a._rebuild() -> x(3, 5, 4)` (i.e., copy of `a`).
* `a._rebuild(4) -> x(4, 5, 4)`
* `a._rebuild(4, 7) -> x(4, 7, 4)`
* `a._rebuild(c=5) -> x(3, 5, 5)`
* `a._rebuild(1, c=7) -> x(1, 5, 7)`