不能将numpy.linalg.solve用于documentation,a must be square and of full-rank, i.e., all rows (or, equivalently, columns) must be linearly independent中提到的非方阵。您的矩阵不是正方形的,但是文档中也提到了这一点,if either is not true, use lstsq for the least-squares best “solution” of the system/equation.
下面是一个例子,应该对你有用
c = array([[1, 1, 1], [.07, .08, .09]])
d = array([24000, 1870])
z = linalg.lstsq(c, d)[0]
print(z)
# compare d and c*z to be sure
print(numpy.allclose(d,numpy.dot(c,z))) # should be true
不能将
numpy.linalg.solve
用于documentation,a must be square and of full-rank, i.e., all rows (or, equivalently, columns) must be linearly independent
中提到的非方阵。您的矩阵不是正方形的,但是文档中也提到了这一点,if either is not true, use lstsq for the least-squares best “solution” of the system/equation.
下面是一个例子,应该对你有用
相关问题 更多 >
编程相关推荐