我希望使用 Numba 加速我的代码的稀疏系统求解器部分。这是我到目前为止所拥有的:
# Both numba and numba-scipy packages are installed. I am using PyCharm IDE
import numba
import numba_scipy
# import other required stuff
@numba.jit(nopython=True)
def solve_using_numba(A, b):
return sp.linalg.gmres(A, b)
# total = the number of points in the system
A = sp.lil_matrix((total, total), dtype=float)
# populate A with appropriate data
A = A.tocsc()
b = np.zeros((total, 1), dtype=float)
# populate b with appropriate data
y, exit_code = solve_using_numba(A, b)
# plot solution
这会引发错误
argument 0: cannot determine Numba type of <class 'scipy.sparse.csc.csc_matrix'>
In the 官方文档 https://pypi.org/project/numba-scipy/, numba-scipy extends Numba to make it aware of SciPy.
但在这里,numba 似乎无法与 scipy 稀疏矩阵类一起使用。我哪里出了问题,我能做些什么来解决这个问题?
我只需要加快代码的稀疏系统解决方案部分的速度,因为其他内容非常轻量级,例如获取几个用户输入、构造 A 和 b 矩阵以及绘制最终结果。
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)