测试矩阵的增广矩阵都可以正常打印,但是一旦加入判断是否有解的代码,在测试下面的例子时:
A2 = Matrix([[0,2,3,4],[0,1,1,1],[0,2,2,2]])
b2 = Vector([4,3,4])
Ab2 = LinearSystem(A2, b2)
程序报错:
Exception has occurred: IndexError
list index out of range
line 51, in _backward
self.Ab[j] = self.Ab[j] - self.Ab[j][k] * self.Ab[i]
line 56, in gauss_jordan_elimination
self._backward()
line 23, in
if not Ab2.gauss_jordan_elimination():
而测试您给出的最后一个例子时可以正常输出No Solution,但是包括上面的这个以及一些其他的例子中就会发生报错。请问这是什么原因导致的呢?
登录后可查看更多问答,登录/注册