Download Python Scientific lecture notes Release 2012.3 (EuroScipy - e

Transcript
Python Scientific lecture notes, Release 2012.3 (EuroScipy 2012)
cdef PyUFuncGenericFunction loop_func[1]
cdef char input_output_types[3]
cdef void *elementwise_funcs[1]
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
Reminder: some pre-made Ufunc loops:
================
‘‘PyUfunc_f_f‘‘
‘‘PyUfunc_ff_f‘‘
‘‘PyUfunc_d_d‘‘
‘‘PyUfunc_dd_d‘‘
‘‘PyUfunc_D_D‘‘
‘‘PyUfunc_DD_D‘‘
================
=======================================================
‘‘float elementwise_func(float input_1)‘‘
‘‘float elementwise_func(float input_1, float input_2)‘‘
‘‘double elementwise_func(double input_1)‘‘
‘‘double elementwise_func(double input_1, double input_2)‘‘
‘‘elementwise_func(complex_double *input, complex_double* complex_double)‘‘
‘‘elementwise_func(complex_double *in1, complex_double *in2, complex_double* o
=======================================================
The full list is above.
Type codes:
NPY_BOOL, NPY_BYTE, NPY_UBYTE, NPY_SHORT, NPY_USHORT, NPY_INT, NPY_UINT,
NPY_LONG, NPY_ULONG, NPY_LONGLONG, NPY_ULONGLONG, NPY_FLOAT, NPY_DOUBLE,
NPY_LONGDOUBLE, NPY_CFLOAT, NPY_CDOUBLE, NPY_CLONGDOUBLE, NPY_DATETIME,
NPY_TIMEDELTA, NPY_OBJECT, NPY_STRING, NPY_UNICODE, NPY_VOID
loop_func[0] = ... TODO: suitable PyUFunc_* ...
input_output_types[0] = ... TODO ...
... TODO: fill in rest of input_output_types ...
# This thing is passed as the ‘‘data‘‘ parameter for the generic
# PyUFunc_* loop, to let it know which function it should call.
elementwise_funcs[0] = <void*>mandel_single_point
# Construct the ufunc:
mandel = PyUFunc_FromFuncAndData(
loop_func,
elementwise_funcs,
input_output_types,
1, # number of supported input types
TODO, # number of input args
TODO, # number of output args
0, # ‘identity‘ element, never mind this
"mandel", # function name
"mandel(z, c) -> computes z*z + c", # docstring
0 # unused
)
Reminder: some pre-made Ufunc loops:
PyUfunc_f_f float elementwise_func(float input_1)
PyUfunc_ff_ffloat elementwise_func(float input_1, float input_2)
PyUfunc_d_d double elementwise_func(double input_1)
PyUfunc_dd_ddouble elementwise_func(double input_1, double input_2)
PyUfunc_D_D elementwise_func(complex_double *input, complex_double*
output)
PyUfunc_DD_Delementwise_func(complex_double *in1, complex_double *in2,
complex_double* out)
Type codes:
8.2. Universal functions
176