utils.py
: Utilities¶
- simba.utils.halve_matrix(mat: sympy.matrices.dense.MutableDenseMatrix)[source]¶
Halve the dimensions of the given matrix, truncating where necessary.
Throws
DimensionError
if matrix dimensions are not even.- Example:
>>>from sympy import Matrix >>>m = Matrix([[1, 2], [3, 4]]) >>>assert halve_matrix(m) == Matrix([[1]])
- simba.utils.solve_matrix_eqn(eqn, x)[source]¶
Solve matrix eqn for x, where eqn is a matrix equation or list of matrix equations (assumed equal to zero on RHS) and x is a sympy
MatrixSymbol
object.Transforms all solutions to list of matrices (same shape as x).
- simba.utils.construct_permutation_matrix(n: int) sympy.matrices.dense.MutableDenseMatrix [source]¶
Construct permutation matrix that reorders the elements so that (1, 2, 3, 11, 22, 33) -> (1, 11, 2, 22, 3, 33)