Operators

The pyunlocbox.operators module implements the following operators:

grad(x[, dim]) Returns the gradient of an array.
div(*args, **kwargs) Returns the divergence of an array.
pyunlocbox.operators.grad(x, dim=2, **kwargs)[source]

Returns the gradient of an array.

Parameters:

dim : int

Dimension of the grad

wx : int

wy : int

wz : int

wt : int

Weights to apply on each axis

Returns:

dx, dy, dz, dt : ndarrays

Gradients following each axes, only the necessary ones are returned

Examples

>>> import numpy as np
>>> from pyunlocbox import operators
>>> x = np.arange(16).reshape(4, 4)
>>> dx, dy = operators.grad(x)
pyunlocbox.operators.div(*args, **kwargs)[source]

Returns the divergence of an array.

Parameters:

dx : array_like

dy : array_like

dz : array_like

dt : array_like

Arrays to operate on

Returns:

x : array_like

Divergence vector

Examples

>>> import numpy as np
>>> from pyunlocbox import operators
>>> x = np.arange(16).reshape(4, 4)
>>> dx, dy = operators.grad(x)
>>> divx = operators.div(dx, dy)