我在尝试细纹织物在Python中构建一个快速的最小生成树程序。不幸的是,使用细纹织物我发现,C++的库,STANN,比我想象的更困难。以下是到STANN库的链接:http://sites.google.com/a/compgeom.com/stann/
下面是Python细纹织物我写的剧本。在
import scipy.weave as weave
from scipy.weave import inline
import numpy
def gmst(points):
# computing GMST with STANN headers
assert(type(points) == type(numpy.array([])))
# now the c++ code
code = """
using namespace std;
typedef reviver::dpoint<double,2> Point;
typedef vector<Point>::size_type stype;
vector< std::pair<stype,stype> > outputmst;
PyArrayObject *py_val
gmst(points,outputmst);
return_val = outputmst;
"""
return inline(code,['points'],
headers = ["<iostream>","<gmst.hpp>","<dpoint.hpp>","<test.hpp>"],
include_dirs=["/home/tree/usr/STANN/include"])
到目前为止,织布还没有成功。你知道我为什么会遇到麻烦吗?谢谢你的帮助。在
干杯
用编织来包装外部代码是一件脆弱而老套的事情。你应该看看Cython这类东西很好。在
相关问题 更多 >
编程相关推荐