From: gga <gg...@ad...> - 2007-05-07 19:41:19
|
Zhong Ren wrote: > OK, I tried this: > > %module stdcomplex > %include std_complex.i > namespace std > { > %template(complexDBL) complex<double>; > } > > Why does it complain this? I think I got the include path > right. Please help. Oh, I am trying to wrap complex to Python. > It's because Python/Ruby already ships with complex numbers. So std_complex.i is somewhat inconsistent with the rest of the std_* stuff, and only defines conversion typemaps to convert between std::complex< float/double > and Python/Ruby native stuff and not a class wrapper. Just try this: %module stdcomplex %include std_complex.i %inline %{ void func( const std::complex< float >& b ) { fprintf(stderr, "-> %f %f\n", b.real(), b.imag() ); } %} ---- from python from stdcomplex import * func( complex(2,0) ) -> 2.000000 0.000000 And I also tried it with ruby and found out my code for it is currently broken :( Time to add yet another unit test :) -- Gonzalo Garramuño gg...@ad... AMD4400 - ASUS48N-E GeForce7300GT Kubuntu Edgy |