簡體   English   中英

Python scipy.weave和STANN C ++庫

[英]Python scipy.weave and STANN C++ Library

我正在嘗試scipy.weave在Python中構建一個快速的最小生成樹程序。 不幸的是,將scipy.weave與我發現的STANN C ++庫一起使用比我想象的要困難得多。 這是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"])

到目前為止,使編織工作沒有運氣。 有什么想法讓我遇到問題嗎? 謝謝您的幫助。

干杯

用編織方式包裝外部代碼是一件脆弱而棘手的事情。 您應該看一下Cython -這種東西很棒。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM