Construct inner and outer measures on (t1, y1) for t0.
(t0, t1, y1)
| 34 | |
| 35 | |
| 36 | def inner_outer(t0, t1, y1): |
| 37 | """Construct inner and outer measures on (t1, y1) for t0.""" |
| 38 | cy1 = torch.cat([torch.zeros_like(y1[..., :1]), |
| 39 | torch.cumsum(y1, dim=-1)], |
| 40 | dim=-1) |
| 41 | idx_lo, idx_hi = searchsorted(t1, t0) |
| 42 | |
| 43 | cy1_lo = torch.take_along_dim(cy1, idx_lo, dim=-1) |
| 44 | cy1_hi = torch.take_along_dim(cy1, idx_hi, dim=-1) |
| 45 | |
| 46 | y0_outer = cy1_hi[..., 1:] - cy1_lo[..., :-1] |
| 47 | y0_inner = torch.where(idx_hi[..., :-1] <= idx_lo[..., 1:], |
| 48 | cy1_lo[..., 1:] - cy1_hi[..., :-1], torch.zeros_like(idx_lo[..., 1:])) |
| 49 | return y0_inner, y0_outer |
| 50 | |
| 51 | |
| 52 | def lossfun_outer(t, w, t_env, w_env): |
no test coverage detected