2013-06-26 114 views
1

我有一個包裝std :: complex值的4維std :: vector的問題。它基本上是一個具有2個自由度的矩陣,因此是4維的。由於矩陣大小因此而異,使用嵌套向量對我來說似乎是明智的(如果我錯了,請糾正我)。包裝std :: complex <float>與SWIG的4維std :: vector

所以數據類型看起來像

std::vector<std::vector<std::vector< std::vector<gr_complex > > > > my4dimvec; 

,使其在蟒蛇訪問,我創建了以下.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是一個typedef定義的std ::複雜DONE在gnuradio.i。順便說一句,4維int向量工作得很好。

編譯錯誤我得到的是

/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 

任何想法的問題可能是什麼?

謝謝 菲利克斯

回答

1

好了,不知何故,我解決了它自己。解決方案不僅是定義4維矢量,而且定義1-2維和3維矢量。最終模板的一部分,現在看起來像

namespace std { 
%template()  vector< std::vector< std::vector< std::vector<int> > > >; 
%template()  std::vector< std::vector< std::vector<gr_complex> > >; 
%template()  std::vector< std::vector< std::vector< std::vector<gr_complex> > > >; 
}; 

1,2維的版本已經在gnuradio.i文件被宣佈之前,所以我沒有在這裏一一列舉了。

相關問題