v0.16.3
Loading...
Searching...
No Matches
sdf_python.py
Go to the documentation of this file.
1import numpy as np
2
3offset = 7.0
4
5
6def sdf(delta_t, t, x, y, z, tx, ty, tz, block_id):
7 if block_id == 1:
8 return np.zeros((len(x), 1))
9 if block_id == 2:
10 raise ValueError("SDF test exception")
11 if block_id == 3:
12 return np.full(len(x), np.nan)
13 # Deliberately return strided arrays, including the derivative results.
14 values = x + 2*y + 3*z + offset + delta_t + t
15 return np.column_stack((values, np.zeros(len(x))))[:, 0]
16
17
18def grad_sdf(delta_t, t, x, y, z, tx, ty, tz, block_id):
19 return np.tile([1., 99., 2., 99., 3., 99.], (len(x), 1))[:, ::2]
20
21
22def hess_sdf(delta_t, t, x, y, z, tx, ty, tz, block_id):
23 return np.tile(np.arange(12, dtype=float), (len(x), 1))[:, ::2]
Definition sdf.py:1