Error solving Matrix equation with numpy

﹥>﹥吖頭↗ 提交于 2019-12-03 13:14:06
miradulo

Your issue is in your second for loop.

for fnc in fncList:
    res2 = fnc
    for i in range(len(varz)):
        res2 = res2.subs(varz[i], x0[i])
    fx0.append(res2)

When you append to fx0, you need to ensure that you are appending the same type (float64) such that NumPy can compute the determinant of your system with LAPACK (see this answer for more info). You are currently appending <class 'sympy.core.numbers.Float'> - your errror message is telling you that you have an incorrect type signature for usage.

To correct this issue, you can simply append numpy.array with a dtype specification for float64 as you did above

for fnc in fncList:
    res2 = fnc
    for i in range(len(varz)):
        res2 = res2.subs(varz[i], x0[i])
    fx0.append(numpy.array(res2, dtype='float'))
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!