create_symbolic_matrix
- create_symbolic_matrix(name_format: str, row_spec, col_spec, *variables: Symbol, is_symmetric: bool = False)[source]
Create a sympy matrix with symbolic components.
Examples
Create a column vector:
>>> create_symbolic_matrix("A{row}", 2, 1) Matrix([ [A0], [A1]])
Create a symmetric matrix whose components are functions of a.
>>> create_symbolic_matrix("B{row}{col}", ["x", "y"], ["r", "s"], sy.symbols("a"), is_symmetric=True) Matrix([ [Bxr(a), Bxs(a)], [Bxs(a), Bys(a)]])
- Parameters:
name_format – A string defining the component names. The occurrence of {row} and {col} is replaced with the row and column name.
row_spec – An integer or a sequence of strings definig the number of rows and the row names. An integer defines the number of rows and the row names as “0”, “1”, …, number of rows - 1. If a sequence of string is given, the number of rows is the length of the sequence and the row names are the entries in the sequence.
col_spec – An integer or a sequence of strings definig the number of columns and the column names. An integer defines the number of columns and the column names as “0”, “1”, …, number of columns - 1. If a sequence of string is given, the number of columns is the length of the sequence and the column names are the entries in the sequence.
variables – The matrix components are functions of these variables or if variables is an empty sequence, the matrix components are independent symbols.
is_symmetric – Create a symmetric matrix if True.
- Returns:
immutable sympy matrix