斯威格+ SCIPY = PyArray_TYPE 导入错误
嘿,伙计,所以我为一些 C 代码编写了一个 swig 包装器。我正在尝试弥合 scipy 数组和 C 数组之间的差距,我知道这很混乱。经过干净的编译后(嗯...不包括一些警告...),当我加载 python-swig-c 模块时,我遇到了这个问题:
undefined symbol: PyArray_TYPE
我在下面添加了我的 swig 接口文件 - 我使用了 swig -pythonc 教程来写这个东西:
%module pycimpl
%{
#define SWIG_FILE_WITH_INIT
#include "cimpl.h"
%}
%include "numpy.i"
%init %{
import_array();
%}
%include "typemaps.i"
%apply (double* INPLACE_ARRAY1, int DIM1, int* INPLACE_ARRAY2, int DIM2, int* INPLACE_ARRAY3, int DIM3, double* INPLACE_ARRAY4, int DIM4, double* OUTPUT) { (double a[], int adim, int rowidx[], int rowidxdim, int colstr[], int colstrdim, double x[], int xdim, double* zeta) }
double cimpl(double a[], int adim, int ridx[], int ridxdim, int cstr[], int cstrdim, double x[], int xdim, double* zeta);
%include "cimpl.h"
任何帮助将不胜感激!
干杯!
CT
Hey gang, so I've written a swig wrapper for some C code. I'm trying to bridge the gap between scipy arrays and C arrays, which I know is messy. After a clean compilation (well...not including some warnings...) I'm getting this issue when I load the python-swig-c module:
undefined symbol: PyArray_TYPE
I've added my swig interface file below - I've used the swig-pythonc tutorial to write this stuff:
%module pycimpl
%{
#define SWIG_FILE_WITH_INIT
#include "cimpl.h"
%}
%include "numpy.i"
%init %{
import_array();
%}
%include "typemaps.i"
%apply (double* INPLACE_ARRAY1, int DIM1, int* INPLACE_ARRAY2, int DIM2, int* INPLACE_ARRAY3, int DIM3, double* INPLACE_ARRAY4, int DIM4, double* OUTPUT) { (double a[], int adim, int rowidx[], int rowidxdim, int colstr[], int colstrdim, double x[], int xdim, double* zeta) }
double cimpl(double a[], int adim, int ridx[], int ridxdim, int cstr[], int cstrdim, double x[], int xdim, double* zeta);
%include "cimpl.h"
Any help would be greatly appreciated!
Cheers!
ct
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不使用 ctypes 或 Pyrex/cython 而不是 SWIG?
(请参阅Python:SWIG 与 ctypes)
Why don't you use ctypes or pyrex/cython instead of SWIG?
(see Python: SWIG vs ctypes)