Let's experiment with different ways to access individual elements and parts of a matrix. Enter and evaluate the following code:
A = Matrix(QQ, [[0, -1, -1, 1], [1, 1, 1, 1], [2, 4, 1, -2], [3, 1, -2, 2]]) print("Matrix A:") show(A) # Getting elements of a matrix print("A[0] = {0}".format(A[0])) print("A[1, 2] = {0}".format(A[1, 2])) print("A[2, 1] = {0}".format(A[2, 1])) print("A[0:2]") show(A[0:2]) print("A[0, 2:4] = {0}".format(A[0, 2:4])) print("A[:,0]:") show(A[:,0]) # Getting parts of a matrix print("Third row:") print(A.row(2)) print("Second column:") print(A.column(1)) print("Lower right submatrix:") show(A.submatrix(2, 2, 2, 2))
The result should look like this: