我不熟悉将 C++ 代码嵌入到 Python 中。我正在测试 weave.inline。但是,在运行我的代码时出现分段错误。有人可以告诉我我做错了什么吗?这是我的代码:
from scipy import weave
def cpp_call(np_points):
assert(type(np_points) == type(1))
code = """
double z[np_points+1][np_points+1];
for (int x = 0; x <= np_points; x++)
{
for (int y = 0; y <= np_points; y++)
{
z[x][y] = x*y;
}
}
"""
return weave.inline(code,'np_points')