[Numpy-discussion] [RFC] complex functions in npymath

David Cournapeau david@ar.media.kyoto-u.ac...
Fri Oct 30 04:34:07 CDT 2009

Hi Pauli,

Pauli Virtanen wrote:
> Hi (esp. David),
> If there are no objections, I'd like to move Numpy's complex-valued
> C99-like functions to npymath:
> 	http://github.com/pv/numpy-work/tree/npymath-complex
> This'll come useful if we want to start eg. writing Ufuncs in Cython.

Actually, I am in the process of cleaning my numpy branches for review,
and intend to push them into svn as fast as possible. Complex is pretty
high on the list.

The missing piece in complex support in npymath is mostly tests: I have
tests for all the special cases (all special cases specified in C99
standard are tested), but no test for the actual 'normal' values. If you
(or someone else) could add a couple of tests, that would be great.

> I'm working around possible compiler-incompatibilities of struct
> return values by having only pointer versions of the functions in
> libnpymath.a, and the non-pointer versions as inlined static
> functions.

Is this a problem if we guarantee that our complex type is bit
compatible with C99 complex (e.g. casting a complex to a double[2]
should alway work) ?

That's how the complex math is implemented ATM.

> Also, perhaps we should add a header file
> 	npy_math_c99compat.h
> that would detect if the compiler supports C99, and if not,
> substitute the C99 functions with our npy_math implementations.
> This'd be great for scipy.special.

I am not sure I understand this: currently, if a given complex function
is detected on the platform, npy_foo is just an alias to foo, so we use
the platform implementation whenever possible.



More information about the NumPy-Discussion mailing list