--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-1-0b1be305eb70> in <module> 37 38 A = Matrix([2, 0, 2, 2, 1, 1, 2, 2, 0, 1, 1, 2, 0, 0, 2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]).reshape(5, 5) ---> 39 DecompositionQR(A) <ipython-input-1-0b1be305eb70> in DecompositionQR(A) 26 O = sp.eye(n) 27 for i in range(n): ---> 28 if not AA[i+1:, i].is_all_zeros(): 29 B = AA.copy() 30 for j in range(i): AttributeError: 'MutableDenseMatrix' object has no attribute 'is_all_zeros'
时间: 2023-08-15 19:22:19 浏览: 72
根据错误提示,您的代码中出现了一个 AttributeError,因为 MutableDenseMatrix 类型的对象没有 is_all_zeros() 方法。您需要将 AA[i+1:, i] 改为 AA[i+1:, i:].is_zero(),这样就可以判断 AA[i+1:, i:] 是否全部为零了。
阅读全文