The SymPy linear algebra module is another very simple module that provides easy-to-learn functions for matrix manipulation. It has the functionality of performing various matrix operations, including quick special matrix creation, eigenvalues, eigenvectors, transpose, determinant, and inverse. There are three methods for quick special matrix creation, namely eye
, zeros
, and ones
. The eye
method creates an identity matrix, whereas zeros
and ones
create matrices with all elements equal to 0 or 1, respectively. If required, we can delete selected rows and columns from a matrix. Basic arithmetic operators, such as +, -, *, and **, also work on matrices:
from sympy import * A = Matrix( [[1, 2, 3, 4], [5, 6, 7, 8], [ 9, 10, 11, 12], [ 13, 14, 15, 16]] ) A.row_del(3) A.col_del(3) A[0,1] # display row 0, col 1 of A A[0:2,0:3] # top-left submatrix(2x3) B = Matrix ([[1, 2, 3], [5, 6, 7], [ 9, 10, 11]] ) A.row_join(B) B.col_join(B) A + B A - B A ...