【发布时间】:2018-07-11 04:47:18
【问题描述】:
我无法使 scipy.integrate.nquad 与 cffi 函数一起工作。 我在网上也找不到这方面的任何例子。
假设我的 test.py 中有一个简单的 c 函数
ffibuilder.set_source("_test",
r""" #include <math.h>
double test(int n, double* xx) {
return xx[0]*xx[1];
}
""")
我正在尝试将它集成到第二个文件 test_cffi.py 中
from _test import ffi, lib
from scipy.integrate import nquad
xx = ffi.new("double[]",2)
xx[0] = 1
xx[1] = 2
# This works.
print(lib.test(2,xx))
# This I can't make to work
print(nquad(lib.test3,[[0,1],[0,1]],args=(2,)))
我应该在上面的最后一行做什么才能使集成工作? Scipy 文档说函数签名必须是 double f(int, double*)。
【问题讨论】:
标签: scipy python-cffi