[Numpy-discussion] Core math library in numpy

David Cournapeau cournape@gmail....
Thu Feb 19 10:05:03 CST 2009

On Fri, Feb 20, 2009 at 12:28 AM, Pauli Virtanen <pav@iki.fi> wrote:
> Fri, 20 Feb 2009 00:16:42 +0900, David Cournapeau wrote:
> [clip]
>> Ok, I have started this in the coremath branch - it solves the warning
>> issues we got since the merge of formatting stuff. I tested it on Linux,
>> windows (both mingw and VS - still need to test on Win64), so I think it
>> is good to go in the trunk. The functions exported are in a separate
>> header:
>> http://projects.scipy.org/scipy/numpy/browser/branches/coremath/numpy/
> core/include/numpy/npy_math.h
> One question: doesn't this add one extra function call to all umath
> functions? Could we do '#define npy_XXX XXX' in the npy_math.h header
> when the appropriate platform-specified functions are available?

I think it does add a cost. I thought about it, but I don't know
whether this is significant or not. The problem of #define npy_XXX XXX
is that the header needs to know whether the corresponding function is
available - and we can't import HAVE_XXX symbols in npy_math.h.

Another argument against the define is that in the future, we could
load the actual implementation at runtime (SSE, etc...). If we use
define, that's not possible.

I don't know how to evaluate the cost of function call on those
functions: I tried some naive benchmark, but with cache effects and
all, I am not convinced I was measuring anything meaningful.

> I think they should be. Then we could easily use C99 complex math
> functions on plaforms on which they are available (and so get the
> "correct" corner-case semantics for free on these platforms).

maybe we could change the names, then ? nc is not very clear IMHO (and
since they were static up to now, we are free to change them I



More information about the Numpy-discussion mailing list