我正在尝试使用scipy.weave在Python中构建一个快速的最小生成树程序。不幸的是,使用scipy.weave和我发现的C ++库STANN,比我想象的要困难得多。这是STANN库的链接:http://sites.google.com/a/compgeom.com/stann/
下面是我编写的带有scipy.weave脚本的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"])
到目前为止,编织工作没有运气。我遇到问题的任何想法?谢谢您的帮助。
干杯