Hello,

I was very excited to learn about numpy.i for easy numpy+swigification of C 
code -- it's really handy.

Knowing that swig wraps C code, I wasn't too surprised that there was the issue 
with complex data types (as described at 
http://docs.scipy.org/doc/numpy/reference/swig.interface-file.html#other-common-types-complex),
 but still it was pretty disappointing because most of my data is complex, and 
I'm invoking methods written to use C++'s std::complex class.

After quite a bit of puzzling and not much help from previous mailing list 
posts, I created this very brief but very useful file, which I call 
numpy_std_complex.i --

/* -*- C -*-  (not really, but good for syntax highlighting) */
#ifdef SWIGPYTHON

%include "numpy.i"

%include <std_complex.i>

%numpy_typemaps(std::complex<float>,  NPY_CFLOAT , int)
%numpy_typemaps(std::complex<double>, NPY_CDOUBLE, int)

#endif /* SWIGPYTHON */


I'd really like for this to be included alongside numpy.i -- but maybe I 
overestimate the number of numpy users who use complex data (let your voice be 
heard!) and who also end up using std::complex in C++ land.

Or if anyone wants to improve upon this usage I would be very happy to hear 
about what I'm missing.

I'm sure there's a documented way to submit this file to the git repo, but let 
me simultaneously ask whether list subscribers think this is worthwhile and ask 
someone to add+push it for me …

Thanks,
Glen Mabey
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to