我在包装包含 std::complex 值的 4 维 std::vector 时遇到问题。它基本上是一个具有 2 个自由度的矩阵,因此是 4 维的。由于矩阵大小因这些而异,因此使用嵌套向量对我来说似乎是明智的(如果我错了,请纠正我)。
所以数据类型看起来像
std::vector<std::vector<std::vector< std::vector<gr_complex > > > > my4dimvec;
为了使它可以在 python 中访问,我创建了以下 .i 文件:
/* -*- c++ -*- */
#define DRMRX_API
%include "gnuradio.i" // the common stuff
%{
#include "drmrx_conf.h"
#include "drmrx_params.h"
%}
//load generated python docstrings
%include "drmrx_swig_doc.i"
namespace std {
%template() vector< std::vector< std::vector< std::vector<int> > > >;
%template() std::vector< std::vector< std::vector< std::vector< gr_complex > > > > ;
};
%include "drmrx_conf.h"
%include "drmrx_params.h"
gr_complex 是在 gnuradio.i 中完成的类型定义的 std::complex。顺便说一句,4 维 int-vector 工作得很好。
我得到的编译错误是
/home/felixwunsch/src/gr-drm/gr-drmrx/build/swig/drmrx_swigPYTHON_wrap.cxx: In instantiation of ‘const char* swig::type_name() [with Type = std::complex<float>]’:
/home/felixwunsch/src/gr-drm/gr-drmrx/build/swig/drmrx_swigPYTHON_wrap.cxx:3530:65: required from ‘static swig_type_info* swig::traits_info<Type>::type_info() [with Type = std::complex<float>; swig_type_info = swig_type_info]’
/home/felixwunsch/src/gr-drm/gr-drmrx/build/swig/drmrx_swigPYTHON_wrap.cxx:3537:41: required from ‘swig_type_info* swig::type_info() [with Type = std::complex<float>; swig_type_info = swig_type_info]’
/home/felixwunsch/src/gr-drm/gr-drmrx/build/swig/drmrx_swigPYTHON_wrap.cxx:3571:14: required from ‘static PyObject* swig::traits_from_ptr<Type>::from(Type*, int) [with Type = std::complex<float>; PyObject = _object]’
/home/felixwunsch/src/gr-drm/gr-drmrx/build/swig/drmrx_swigPYTHON_wrap.cxx:3577:58: required from ‘static PyObject* swig::traits_from<Type>::from(const Type&) [with Type = std::complex<float>; PyObject = _object]’
/home/felixwunsch/src/gr-drm/gr-drmrx/build/swig/drmrx_swigPYTHON_wrap.cxx:3596:39: required from ‘PyObject* swig::from(const Type&) [with Type = std::complex<float>; PyObject = _object]’
/home/felixwunsch/src/gr-drm/gr-drmrx/build/swig/drmrx_swigPYTHON_wrap.cxx:4635:4: [ skipping 7 instantiation contexts ]
/home/felixwunsch/src/gr-drm/gr-drmrx/build/swig/drmrx_swigPYTHON_wrap.cxx:4658:54: required from ‘static PyObject* swig::traits_from<std::vector<T> >::from(const std::vector<T>&) [with T = std::vector<std::vector<std::complex<float> > >; PyObject = _object]’
/home/felixwunsch/src/gr-drm/gr-drmrx/build/swig/drmrx_swigPYTHON_wrap.cxx:3596:39: required from ‘PyObject* swig::from(const Type&) [with Type = std::vector<std::vector<std::vector<std::complex<float> > > >; PyObject = _object]’
/home/felixwunsch/src/gr-drm/gr-drmrx/build/swig/drmrx_swigPYTHON_wrap.cxx:4635:4: required from ‘static PyObject* swig::traits_from_stdseq<Seq, T>::from(const sequence&) [with Seq = std::vector<std::vector<std::vector<std::vector<std::complex<float> > > > >; T = std::vector<std::vector<std::vector<std::complex<float> > > >; PyObject = _object; swig::traits_from_stdseq<Seq, T>::sequence = std::vector<std::vector<std::vector<std::vector<std::complex<float> > > > >]’
/home/felixwunsch/src/gr-drm/gr-drmrx/build/swig/drmrx_swigPYTHON_wrap.cxx:4658:54: required from ‘static PyObject* swig::traits_from<std::vector<T> >::from(const std::vector<T>&) [with T = std::vector<std::vector<std::vector<std::complex<float> > > >; PyObject = _object]’
/home/felixwunsch/src/gr-drm/gr-drmrx/build/swig/drmrx_swigPYTHON_wrap.cxx:3596:39: required from ‘PyObject* swig::from(const Type&) [with Type = std::vector<std::vector<std::vector<std::vector<std::complex<float> > > > >; PyObject = _object]’
/home/felixwunsch/src/gr-drm/gr-drmrx/build/swig/drmrx_swigPYTHON_wrap.cxx:6680:894: required from here
/home/felixwunsch/src/gr-drm/gr-drmrx/build/swig/drmrx_swigPYTHON_wrap.cxx:3520:77: error: ‘type_name’ is not a member of ‘swig::traits<std::complex<float> >’
make[2]: *** [swig/CMakeFiles/_drmrx_swig.dir/drmrx_swigPYTHON_wrap.cxx.o] Error 1
make[1]: *** [swig/CMakeFiles/_drmrx_swig.dir/all] Error 2
make: *** [all] Error 2
任何想法可能是什么问题?
谢谢你,菲利克斯