On May 14, 2009, at 6:06 AM, Dag Sverre Seljebotn wrote:
> Robert Bradshaw wrote:
>> On May 14, 2009, at 2:06 AM, Stefan Behnel wrote:
>>
>>> Robert Bradshaw wrote:
>>>> I just pushed a series of patches to http://hg.cython.org/cython-
>>>> devel/ for complex number support. See
>>>>
>>>> http://hg.cython.org/cython-devel/file/5c014b865386/tests/run/
>>>> complex_numbers_T305.pyx .
>>>>
>>>> Despite being a rather large change, and shortly before a
>>>> release, it
>>>> belongs in -devel because this is one of the motivations to do a
>>>> release so soon.
>>> Does it (potentially) break any existing stuff or is it a plain new
>>> feature?
>>
>> It's a plain new feature, though I did have to touch a lot of code.
>>
>>> The latter would make it easy to say: "Sure, let's release it; if
>>> the
>>> feature is broken in some way, there will be a fix release."
>
> OK I've looked at it and it looks sweet! Buffer support added, it
> was a
> three line change :-) [1]
Just saw it, that was fast. Does this still work with the complex.h
header turned on as well (I don't see you using the __Pyx_REAL_PART
macros).
> I haven't been giving it thorough testing, but as good as it looks I
> suggest that we just release it with an "experimental" note (and
> obviously check whether it breaks existing code in any way).
>
> One thing I miss is the ability to extract real and imaginary parts. I
> assume we want to follow Python here?
>
> cdef double complex r = 1 + 1j
> print r.real, r.imag
>
> Tell me if you start on that because it's now on my TODO-list
> (though I
> might very well not get time before the release).
Oh, yeah, I meant to do this.
> [1]
>
> I'm making the assumption that C99 complex will be exchangeable with
>
> struct { T real, imag}
>
> both when it comes to alignment and ordering.
I believe so:
http://c0x.coding-guidelines.com/6.2.5.html
http://home.datacomm.ch/t_wolf/tw/c/c9x_changes.html
The implementation of the complex types is defined by the standard
(6.2.5(13)) to use cartesian coordinates (real and imaginary part),
i.e. forbids an implementation using polar coordinates (distance from
[0,0] and an angle). Furthermore, the same paragraph also specifies
that a complex type has the same alignment requirements as an array
of two elements of the corresponding floating types, the first must
be the real part and the second the imaginary part.
> Perhaps a runtime check
> for those assumptions should be added at some point.
Yeah, that would make things a log messier...
> Without C99 support those assumptions obviously holds anyway.
Yep.
- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev