pykbe.misc module#
- pykbe.misc.accum_mat_into_tens3(mat, tensor, q, alpha=1.0, conj=False)[source]#
Accumulate a matrix into a tensor of rank 3.
Performs the operation
tensor[:, q, :] += alpha * mat.- Parameters:
- mat(N, M) array_like
2D array.
- tensor(N, _, M) array_like
3D array.
- q
int Second index of tens4.
- alphascalar, optional
Scalar multiplier.
- conjbool, optional
Whether to take the elementwise conjugate of mat.
- pykbe.misc.accum_mat_into_tens4(mat, tensor, p, q, alpha=1.0, conj=False, beta=0.0)[source]#
Accumulate a matrix into a tensor of rank 4.
Performs the operation
tensor[p, :, q, :] += alpha * mat.- Parameters:
- mat(N, M) array_like
2D array.
- tensor(_, N, _, M) array_like
4D array.
- p
int First index of tens4.
- q
int Third index of tens4.
- alphascalar, optional
Scalar multiplier.
- betascalar, optional
Scalar to add entrywise.
- conjbool, optional
Whether to take the elementwise conjugate of mat.
- pykbe.misc.fast_matexp(eigvals, eigvecs, out=None)[source]#
Compute the matrix exponential of a diagonalized matrix.
- Parameters:
- eigvals(N,) array_like
Eigenvalues.
- eigvecs(N, N) array_like
Eigenvectors.
- Returns:
- matexp(N, N)
ndarray Matrix exponential.
- matexp(N, N)
- pykbe.misc.parallel_set(arr, val)[source]#
Broadcast value to array.
Set all elements of a contiguous array to a given value. Fails if the array is not contiguous.
- Parameters:
- arrarray_like
Array to set.
- valscalar
Value to set.
- pykbe.misc.unpack_dim3_into_dim2(dest, src, q)[source]#
Unpack a slice of a 3D array into a 2D array.
Unpacks a slice of a 3D array into a 2D array. Make sure everything is row-major.
- Parameters:
- dest(N, M) array_like
2D array.
- src(N, _, M) array_like
3D array.
- q
int Second index of src.