User guide

NumPy User Guide, Release 1.9.0
npy_intp
*
steps, void
*
data)
{
npy_intp i;
npy_intp n = dimensions[0];
char
*
in = args[0],
*
out = args[1];
npy_intp in_step = steps[0], out_step = steps[1];
double tmp;
for (i = 0; i < n; i++) {
/
*
BEGIN main ufunc computation
*
/
tmp =
*
(double
*
)in;
tmp /= 1-tmp;
*
((double
*
)out) = log(tmp);
/
*
END main ufunc computation
*
/
in += in_step;
out += out_step;
}
}
static void float_logit(char
**
args, npy_intp
*
dimensions,
npy_intp
*
steps, void
*
data)
{
npy_intp i;
npy_intp n = dimensions[0];
char
*
in=args[0],
*
out = args[1];
npy_intp in_step = steps[0], out_step = steps[1];
float tmp;
for (i = 0; i < n; i++) {
/
*
BEGIN main ufunc computation
*
/
tmp =
*
(float
*
)in;
tmp /= 1-tmp;
*
((float
*
)out) = logf(tmp);
/
*
END main ufunc computation
*
/
in += in_step;
out += out_step;
}
}
static void half_float_logit(char
**
args, npy_intp
*
dimensions,
npy_intp
*
steps, void
*
data)
{
npy_intp i;
npy_intp n = dimensions[0];
char
*
in = args[0],
*
out = args[1];
npy_intp in_step = steps[0], out_step = steps[1];
float tmp;
for (i = 0; i < n; i++) {
/
*
BEGIN main ufunc computation
*
/
tmp =
*
(npy_half
*
)in;
88 Chapter 5. Using Numpy C-API