dymad.numerics.gradients¶
Functions
|
Central difference. |
|
Complex step differentiation. |
|
Jacobian using torch.func.jacobian. |
- dymad.numerics.gradients.central_diff(f, x, h=1e-06, v=None)¶
Central difference.
- Parameters:
f – function handle that accepts and returns numpy arrays.
x – input array.
h – step size.
v – directions for directional derivative. If None, return full Jacobian.
- Returns:
derivative of f at x, possibly directional.
- Return type:
df
- dymad.numerics.gradients.complex_step(f, x, h=1e-20, v=None)¶
Complex step differentiation.
- Parameters:
f – function handle that accepts and returns numpy arrays.
x – input array.
h – step size.
v – directions for directional derivative. If None, return full Jacobian.
- Returns:
derivative of f at x, possibly directional.
- Return type:
df
- dymad.numerics.gradients.torch_jacobian(f, x, v=None, dtype=torch.float64)¶
Jacobian using torch.func.jacobian.
- Parameters:
f – function handle that accepts and returns torch tensors.
x – input array.
v – directions for directional derivative. If None, return full Jacobian.
- Returns:
derivative of f at x, possibly directional.
- Return type:
df