|
C complex vs. python complex: msg#00040python.pyrex
I need to wrap some functions that take C complex arguments and return C complex results. I got this to work using cdef extern from "complex.h": ctypedef struct c_complex "complex": pass cdef double creal(c_complex z) cdef double cimag(c_complex z) cdef extern from "myfile.h": cdef c_complex cplx(double r, double i) cplx is actually the following macro: #define cplx(r,i) ((r)+I*(i)) Then my pyrex code uses creal and cimag to convert a C complex variable to a python complex, and uses cplx to convert the other way. But it would be much cleaner if pyrex did the conversion for me. Is there a way to do this? Thanks, Dan |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Struggling with "Hello World" Extension type: 00040, Bryan O'Sullivan |
|---|---|
| Next by Date: | Pyrex exception type checking broken under Python 2.5 (and earlier): 00040, Stefan Behnel |
| Previous by Thread: | Struggling with "Hello World" Extension typei: 00040, Andrew Chambers |
| Next by Thread: | Pyrex exception type checking broken under Python 2.5 (and earlier): 00040, Stefan Behnel |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |