在python中将矩阵转换成阶梯形


from sympy import *
matrix = []
print("Enter the entries of the 3x3 matrix:")
for i in range(0,3):
a =[]
for j in range(0,3):
a.append(int(input()))
matrix.append(a)
for i in range(0,3):
for j in range(0,3):
print(matrix[i][j], end = " ")
print()

for i in range(0,3):
for j in range(0,3):
M[i][j]=list(matrix[i][j])
M_rref = M.rref()
print("The Row echelon form of matrix M and the pivot columns : {}".format(M_rref))

我有一个错误,当我转移数组彼此。我只是想把3x3矩阵转换成阶梯形。TypeError: 'int'对象不可迭代,有时AttributeError: 'list'对象没有属性'rref'

matrix转换为SymPyMatrix,如下所示:

from sympy import *
matrix = []
print("Enter the entries of the 3x3 matrix:")
for i in range(0,3):
a =[]
for j in range(0,3):
a.append(int(input()))
matrix.append(a)
for i in range(0,3):
print(matrix[i])
M = Matrix(matrix)
M_rref = M.rref()
print("The Row echelon form of matrix M and the pivot columns : {}".format(M_rref))

最新更新