The PerformanceCriticalCode submodule#
This submodule contains the Cython code equivalent to the original R code in InlineFunctions.R from the original MHN repo as well as some functions to solve linear equations involving [I-Q].
- mhn.full_state_space.PerformanceCriticalCode.compute_inverse(double[:, :] theta, double[:] dg, double[:] b, double[:] xout, bool transp)#
Computes the solution for [I - Q] * x = b using forward (and backward) substitution.
- Parameters:
theta (np.ndarray) – Thetas used to construct Q.
dg (np.ndarray) – Vector containing the diagonal values of [I-Q].
b (np.ndarray) – A double vector representing the right-hand side of the equation.
xout (np.ndarray) – Double vector that will contain the solution after running this function.
transp (bool) – If True, returns solution for [I - Q]^T * x = b.
- mhn.full_state_space.PerformanceCriticalCode.kron_vec(double[:, :] theta_mat, int i, double[:] x_vec, bool diag=False, bool transp=False) np.ndarray#
Multiplies the Kronecker product of the ith row of the theta matrix with a vector. This is a Python wrapper for the more efficient Cython implementation.
- Parameters:
theta_mat (np.ndarray) – Matrix containing the theta values.
i (int) – Row of theta used for the Kronecker product.
x_vec (np.ndarray) – Vector that is multiplied with the Kronecker product matrix.
diag (bool, optional) – If False, the diagonal of the Kronecker product matrix is set to zero. Defaults to False.
transp (bool, optional) – If True, the Kronecker product matrix is transposed. Defaults to False.
- Returns:
Vector that will contain the result of the multiplication.
- Return type:
np.ndarray