Skip to content

Optimize 2 more lines in the KroneckerEK0 #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 15, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tornadox/ek0.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,17 @@ def initialize(self, ivp):
@staticmethod
@jax.jit
def compute_sigmasquared_error(P, Ql, z):
HQH = (P @ Ql @ Ql.T @ P.T)[1, 1]
_PQl = P[1, 1] * Ql[1, :]
HQH = _PQl @ _PQl.T
sigma_squared = z.T @ z / HQH / z.shape[0]
error_estimate = jnp.stack([jnp.sqrt(sigma_squared * HQH)] * z.shape[0])
return sigma_squared, error_estimate

@staticmethod
@jax.jit
def update(mp, Clp, P, H, z):
S = (P @ Clp @ Clp.T @ P.T)[1, 1]
_PClp = P[1, 1] * Clp[1, :]
S = _PClp @ _PClp.T
K = Clp @ (Clp.T @ H.T) / S # shape (n,1)
m_new = mp - K * z[None, :] # shape (n,d)
Cl_new = Clp - K @ H @ Clp
Expand Down