我想用来support_code
定义与 nd numpy 数组交互的函数。在code
参数内部,FOO3(i, j, k)
符号有效,但仅在其中,而不是在support_code
.Something 中是这样的:
import scipy
import scipy.weave
code = '''return_val = f(1);'''
support_code = '''int f(int i) {
return FOO3(i, i, i);
}''''
foo = scipy.arange(3**3).reshape(3,3,3)
print(scipy.weave.inline(code, ['foo'], support_code=support_code))