[Numpy-discussion] NumPy, buffers (PEP 3118), complex floats, and Cython

Dag Sverre Seljebotn dagss@student.matnat.uio...
Sun Jul 6 10:24:49 CDT 2008

Travis E. Oliphant wrote:
> Dag Sverre Seljebotn wrote:
>> I'd like some advice for what way people feel would be the best for 
>> supporting complex datatypes in NumPy in Cython; as well as ask in what 
>> way it is likely that NumPy will make use of PEP 3118.
>> It seems like NumPy defines its complex data to be a struct of two 
>> doubles, for instance:
>> typedef struct { double real, imag; } npy_cdouble;
>> According to PEP 3118 [1], it would be natural to export this as "dd" 
>> (record of two doubles) rather than "Zd" (complex double), when 
>> exporting ndarrays through a buffer interface. Right?
> No, it is more natural to use Zd because then you know you are dealing 
> with complex numbers and not just two separate floats.

I guess my confusion comes from assuming the wrong thing about what 
"complex double" refers to in the PEP; since that's the only reference I 
  found to the concept in the PEP I assumed it corresponded to the C99 

Can I assume then that Zd means that the data always has the form of 
npy_cdouble and friends? (I guess this might seem "obvious", but as you 
see I've already had one wrong guess, and I can't seem to find it 
defined anywhere...)

Dag Sverre

More information about the Numpy-discussion mailing list