vanloan module¶
- itrails.vanloan.vanloan(trans_mat, path, tim, omega_dict)[source]¶
This function performs the van Loan (1978) method for finding the integral of a product of matrix exponentials. Function generalizes to any number of matrices.
- Parameters:
trans_mat (Numpy array of type: float64[:, :].) – Transition rate matrix for the CTMC.
path (Numpy array of type: int64[:, :].) – Subpath of omega values followed by the CTMC.
tim (float64.) – Time at which to evaluate the integral.
omega_dict (Numba dictionary of key: Tuple((int64, int64)) and value: np.array of boolean.) – Numba dictionary of combinations of omega values and the possible final states of each as array of booleans.
- Returns:
Result of the integral of the series of multiplying matrix exponentials.
- Return type:
Numpy array of type: float64[:, :].
- itrails.vanloan.vanloan_identify(current, omega_fin, omega_nonrev_counts, inverted_omega_nonrev_counts, path, depth, key_indices, key_array, paths_array, subpath_counts, num_keys_array, max_num_keys, max_num_subpaths_per_key, max_path_length, all_paths_array, path_lengths, path_key_indices, total_subpaths_array, max_total_subpaths, by_l=-1, by_r=-1)[source]¶
Recursive function that identifies, in each iteration, the possible paths that can be taken from the current state to the final state. The function is called recursively until the final state is reached. The function stores the paths in the paths_array and all_paths_array arrays.
- Parameters:
current (Tuple of int) – Current omega state in the recursion
omega_fin (Tuple of int) – Omega state to reach
omega_nonrev_counts (Numba typed Dict) – Dictionary containing the number of non-reversible coalescents (value) for each omega state (key)
inverted_omega_nonrev_counts (Numba typed Dict) – Dictionary containing the omega states (value) for each number of non-reversible coalescents (key)
path (Numpy array) – Current path in the recursion
depth (int) – Current depth in the recursion
key_indices (Numpy array) – Helper array to store the indices of the omega subpath being taken
key_array (Numpy array) – Array to store current omega state of each step
paths_array (Numpy array) – Array storing every subpath taken
subpath_counts (Numpy array) – Array storing the number of subpaths taken for each complete path
num_keys_array (Numpy array) – Array storing the number of keys
max_num_keys (int) – Upper limit for the number of keys
max_num_subpaths_per_key (int) – Upper limit for the number of subpaths per key
max_path_length (int) – Upper limit for the path length
all_paths_array (Numpy array) – Array storing all possible subpaths
path_lengths (Numpy array) – Array storing the length of each path
path_key_indices (Numpy array) – Array storing the key index for each path
total_subpaths_array (Numpy array) – Array storing the total number of subpaths
max_total_subpaths (int) – Upper limit for the total number of subpaths
by_l (int, optional) – Current omega left subpath, defaults to -1 (initial placeholder value)
by_r (int, optional) – Current omega right subpath, defaults to -1 (initial placeholder value)
- Returns:
None
- Return type:
None
- itrails.vanloan.vanloan_identify_wrapper(omega_init, omega_fin, omega_nonrev_counts, inverted_omega_nonrev_counts, l_tuple, r_tuple, l_row, r_row, max_num_keys, max_num_subpaths_per_key, max_path_length, max_total_subpaths)[source]¶
Wrapper function for the vanloan_identify function. This function initializes the arrays and dictionaries needed for the recursion and calls the vanloan_identify function. In the end it returns the transformed keys and the paths.
- Parameters:
omega_init (Tuple of int) – Initial omega state
omega_fin (Tuple of int) – End omega state
omega_nonrev_counts (Numba typed Dict) – Dictionary containing the number of non-reversible coalescents (value) for each omega state (key)
inverted_omega_nonrev_counts (Numba typed Dict) – Dictionary containing the omega states (value) for each number of non-reversible coalescents (key)
l_tuple (Numba typed Tuple) – Tuple containing the left omega state
r_tuple (Numba typed Tuple) – Tuple containing the right omega state
l_row (Tuple of int) – Resulting left state
r_row (Tuple of int) – Resulting right state
max_num_keys (int) – Upper limit for the number of keys
max_num_subpaths_per_key (int) – Upper limit for the number of subpaths per key
max_path_length (int) – Upper limit for the path length
max_total_subpaths (int) – Upper limit for the total number of subpaths
- Returns:
Resulting keys and paths
- Return type:
Tuple(Array, Array)