开发者

Python scipy.weave and STANN C++ Library

I'm trying out scipy.weave to build a fast minimal spanning tree program in Python. Unfortunately, using scipy.weave with a C++ library that I found, STANN, is m开发者_如何学Goore difficult that I had assumed. Here's the link to the STANN library: http://sites.google.com/a/compgeom.com/stann/

Below is the Python with scipy.weave script that I wrote.

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"])

So far no luck in making weave work. Any ideas why I'm running into a problem? Thanks for the help.

Cheers


Wrapping external code with weave is a fragile and hacky affair. You should take a look at Cython -- it's great at this sort of stuff.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜