[Numpy-discussion] Mathematical functions in Numpy

Julian Taylor jtaylor.debian at googlemail.com
Tue Mar 17 16:01:18 EDT 2015


currently the math functions are wrapped via the generic PyUfunc_*
functions in numpy/core/src/umath/loops.c.src which just apply some
arbitrary function to a scalar from arbitrarily strided inputs.
When adding variants one likely needs to add some special purpose loops
to deal with the various special requirements of the vector math api's.
This involves adding some special cases to the ufunc generation in
numpy/core/code_generators/generate_umath.py and then implementing the
new kernel functions.
See e.g. this oldish PR, which changes the sqrt function from a
PyUfunc_d_d function to a special loop to take advantage of the
vectorized machine instructions:
https://github.com/numpy/numpy/pull/3341

some things have changed a bit since then but it does show many of the
files you probably need to look for this project.

On 17.03.2015 19:51, Robert Kern wrote:
> On Tue, Mar 17, 2015 at 6:29 PM, Matthieu Brucher
> <matthieu.brucher at gmail.com <mailto:matthieu.brucher at gmail.com>> wrote:
>>
>> Hi,
>>
>> These functions are defined in the C standard library!
> 
> I think he's asking how to define numpy ufuncs.
> 
>> 2015-03-17 18:00 GMT+00:00 Shubhankar Mohapatra
> <mshubhankar at yahoo.co.in <mailto:mshubhankar at yahoo.co.in>>:
>> > Hello all,
>> > I am a undergraduate and i am trying to do a project this time on
> numppy in
>> > gsoc. This project is about integrating vector math library classes
> of sleef
>> > and yeppp into numpy to make the mathematical functions faster. I have
>> > already studied the new library classes but i am unable to find the
> sin ,
>> > cos function definitions in the numpy souce code.Can someone please
> help me
>> > find the functions in the source code so that i can implement the new
>> > library class into numpy.
>> > Thanking you,
>> > Shubhankar Mohapatra
>> >
>> >
>> > _______________________________________________
>> > NumPy-Discussion mailing list
>> > NumPy-Discussion at scipy.org <mailto:NumPy-Discussion at scipy.org>
>> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
>> >
>>
>>
>>
>> --
>> Information System Engineer, Ph.D.
>> Blog: http://matt.eifelle.com
>> LinkedIn: http://www.linkedin.com/in/matthieubrucher
>> Music band: http://liliejay.com/
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion at scipy.org <mailto:NumPy-Discussion at scipy.org>
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> 
> 
> 
> 
> --
> Robert Kern
> 
> 
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> 




More information about the NumPy-Discussion mailing list