目前在numba中处理高阶函数的最佳方法是什么?
def secant_method_curried (f):
def inner (x_minus1, x_0, consecutive_tolerance):
x_new = x_0
x_old = x_minus1
x_oldest = None
while abs(x_new - x_old) > consecutive_tolerance:
x_oldest = x_old
x_old = x_new
x_new = x_old - f(x_old)*((x_old-x_oldest)/(f(x_old)-f(x_oldest)))
return x_new
return numba.jit(nopython=False)(inner)
问题是没有办法告诉numba f是doube(double),所以上面的代码打破了nopython = True:
TypingError: Failed at nopython (nopython frontend)
Untyped global name 'f'
On this page,他们提到了一个名为numba.addressof()的东西,这看起来很有帮助,但又可以追溯到4年前.