matrices module¶
-
simupy.matrices.
block_matrix
(blocks)[source]¶ Construct a matrix where the elements are specified by the block structure by joining the blocks appropriately.
Parameters: blocks (two level deep iterable of sympy Matrix objects) – The block specification of the matrices used to construct the block matrix. Returns: matrix – A matrix whose elements are the elements of the blocks with the specified block structure. Return type: sympy Matrix
-
simupy.matrices.
construct_explicit_matrix
(name, n, m, symmetric=False, diagonal=0, dynamic=False, **kwass)[source]¶ construct a matrix of symbolic elements
Parameters: - name (string) – Base name for variables; each variable is name_ij, which admitedly only works clearly for n,m < 10
- n (int) – Number of rows
- m (int) – Number of columns
- symmetric (bool, optional) – Use to enforce a symmetric matrix (repeat symbols above/below diagonal)
- diagonal (bool, optional) – Zeros out off diagonals. Takes precedence over symmetry.
- dynamic (bool, optional) – Whether to use sympy.physics.mechanics dynamicsymbol. If False, use sp.symbols
- kwargs (dict) – remaining kwargs passed to symbol function
Returns: matrix – The Matrix containing explicit symbolic elements
Return type: sympy Matrix
-
simupy.matrices.
matrix_subs
(*subs)[source]¶ Generate an object that can be passed into sp.subs from matrices, replacing each element in from_matrix with the corresponding element from to_matrix
There are three ways to use this function, depending on the input: 1. A single matrix-level subsitution - from_matrix, to_matrix 2. A list or tuple of (from_matrix, to_matrix) 2-tuples 3. A dictionary of {from_matrix: to_matrix} key-value pairs
-
simupy.matrices.
system_from_matrix_DE
(mat_DE, mat_var, mat_input=None, constants={})[source]¶ Construct a symbolic DynamicalSystem using matrices. See riccati_system example.
Parameters: - mat_DE (sympy Matrix) – The matrix derivative expression (right hand side)
- mat_var (sympy Matrix) – The matrix state
- mat_input (list-like of input expressions, optional) – A list-like of input expressions in the matrix differential equation
- constants (dict, optional) – Dictionary of constants substitutions.
Returns: sys – A DynamicalSystem which can be used to numerically solve the matrix differential equation.
Return type: