apace.clib
¶
Module Contents¶
Functions¶
|
Calculates the Twiss product of the transfer matrices and the initial |
|
Perform accumulated matrix product on array of matrices. |
|
Perform matrix product on array of matrices for given ranges. |
|
Dot product of matrices of A times matrices of B as follows: |
- apace.clib.twiss_product(transfer_matrices, twiss_0, twiss_array, from_idx, parallel=False)¶
Calculates the Twiss product of the transfer matrices and the initial Twiss parameters twiss_0 into the twiss_array:
- Parameters
transfer_matrices (np.ndarray) – Array of accumulated transfer_matrices.
twiss_0 (np.ndarray) – Initial twiss parameter.
twiss_array (np.ndarray) – Array where the result of the calculation is stored.
from_idx (int) – The index from which the matrices are accumulated.
parallel (bool) – Flag to utilize multiple cpu cores. May be slower for smaller lattices due to parallel overhead. (Default=False)
- apace.clib.matrix_product_accumulated(input_array, output_array, from_idx)¶
Perform accumulated matrix product on array of matrices.
The input matrices A[0], A[2], … of the input array (A) are accumulated into the output array (B) as follows:
B[0] = A[0] (First entry remains unchanged) B[1] = A[1] * A[0] B[2] = A[1] * A[0] * B[0] …
- Parameters
input_array (nd.ndarray) – Input array with n matrices. (n, size, size)
output_array (nd.ndarray) – The array into which the result is stored. (n, size, size)
from_idx (int) – The index from which the matrices are accumulated.
- apace.clib.matrix_product_ranges(input_array, output_array, ranges)¶
Perform matrix product on array of matrices for given ranges.
The final array has the shape (n, size, size) and contains the accumulated transfer matrices between the given indices:
B[0] = A[end_0] * A[end_0 - 1] * … * A[start_0] B[1] = A[end_1] * A[end_1 - 1] * … * A[start_1] …
where start_i = indices[i, 0] and end_i = indices[i, 1]
- Parameters
input_array (np.ndarray) – Input array with n matrices. (n_kicks, size, size)
np.ndarray – The array into which the result is stored. (n, size, size)
ranges (array-like) – The start and end indicies for the matrix accumulation, where ranges[:, 0] are the start and ranges[:, 1] are the end values.
- apace.clib.multiple_dot_products(A, B, out)¶
- Dot product of matrices of A times matrices of B as follows:
out[0] = A[0] * B[0] out[1] = A[1] * B[1] out[2] = A[2] * B[2] …
- Parameters
A (ndarray) – Input array with n matrices. Shape = (n, size, size)
B (ndarray) – Single matrix. Shape = (size, size)
out (ndarray) – The calculation is done into this array. Shape : (n, size, size)