numpy  2.0.0
src/umath/scalarmath.c.src File Reference
#include "Python.h"
#include "npy_config.h"
#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"
#include "numpy/arrayscalars.h"
#include "npy_pycompat.h"
#include "numpy/halffloat.h"
#include "templ_common.h"

Defines

#define _UMATHMODULE
#define NPY_NO_DEPRECATED_API   NPY_API_VERSION
#define PY_ARRAY_UNIQUE_SYMBOL   _npy_umathmodule_ARRAY_API
#define NO_IMPORT_ARRAY
#define NPY_SIZEOF_BYTE   1
#define name   @_ctype_floor_divide @name@_ctype_divide
#define name
#define name   @_ctype_@oper@(arg1, arg2, out) *(out) = (arg1) @op@ (arg2)
#define name   @_ctype_add(a, b, outp) *(outp) = (a) + (b)
#define name   @_ctype_subtract(a, b, outp) *(outp) = (a) - (b)
#define name   @_ctype_multiply(a, b, outp) *(outp) = (a) * (b)
#define name   @_ctype_divide(a, b, outp) *(outp) = (a) / (b)
#define name   @_ctype_true_divide @name@_ctype_divide
#define half_ctype_add(a, b, outp)
#define half_ctype_subtract(a, b, outp)
#define half_ctype_multiply(a, b, outp)
#define half_ctype_divide(a, b, outp)
#define half_ctype_true_divide   half_ctype_divide
#define name
#define name
#define name
#define name
#define name   @_ctype_true_divide @name@_ctype_divide
#define name
#define name
#define name   @_ctype_absolute @name@_ctype_positive
#define name   @_ctype_invert(a, out) *(out) = ~a;
#define _IS_ZERO(x)   (x == 0)
#define name   @_@oper@ NULL
#define name   @_@oper@ NULL
#define name   @_invert NULL
#define NONZERO_NAME(prefix)   prefix##nonzero
#define _IS_NONZERO(x)   (x != 0)
#define def_cmp_   @oper@(arg1, arg2) (arg1 @op@ arg2)
#define cmplx_cmp_
#define def_half_cmp_   @oper@(arg1, arg2) @halfop@(arg1, arg2)

Functions

static void name _ctype_add (@type @a,@type @b,@type @*out)
static void name _ctype_subtract (@type @a,@type @b,@type @*out)
static void name _ctype_multiply (@type @a,@type @b,@type @*out)
static void name _ctype_divide (@type @a,@type @b,@type @*out)
static void name _ctype_remainder (@type @a,@type @b,@type @*out)
static void name _ctype_power (@type @a,@type @b,@type @*out)
static void name _ctype_floor_divide (@type @a,@type @b,@type @*out)
static void name _ctype_divmod (@type @a,@type @b,@type @*out1,@type @*out2)
static void half_ctype_floor_divide (npy_half a, npy_half b, npy_half *out)
static void half_ctype_remainder (npy_half a, npy_half b, npy_half *out)
static void half_ctype_divmod (npy_half a, npy_half b, npy_half *out1, npy_half *out2)
static void half_ctype_power (npy_half a, npy_half b, npy_half *out)
static void name _ctype_negative (@type @a,@type @*out)
static void half_ctype_negative (npy_half a, npy_half *out)
static void name _ctype_positive (@type @a,@type @*out)
static void name _ctype_absolute (@type @a,@type @*out)
static void half_ctype_absolute (npy_half a, npy_half *out)
static void name _ctype_absolute (@type @a,@rtype @*out)
static int _ name _convert_to_ctype (PyObject *a,@type @*arg1)
static int _ name _convert2_to_ctypes (PyObject *a,@type @*arg1, PyObject *b,@type @*arg2)
static PyObject *nameoper (PyObject *a, PyObject *b)
static PyObject *name _power (PyObject *a, PyObject *b, PyObject *NPY_UNUSED(c))
static PyObject *nameoper (PyObject *a)
static int NONZERO_NAME (@name @_)(PyObject *a)
static int emit_complexwarning (void)
static PyObject *name _int (PyObject *obj)
static NPY_INLINE PyObject *namewhich (PyObject *obj)
static PyObject *name _richcompare (PyObject *self, PyObject *other, int cmp_op)
NPY_NO_EXPORT void add_scalarmath (void)
static int get_functions (PyObject *mm)
NPY_NO_EXPORT int initscalarmath (PyObject *m)

Variables

static type(* _basic_ )(@type @)
static npy_half(* _basic_half_sqrt )(npy_half)
static npy_half(* _basic_half_fmod )(npy_half, npy_half)
static PyNumberMethods name _as_number

Define Documentation

#define _IS_NONZERO (   x)    (x != 0)
#define _IS_ZERO (   x)    (x == 0)
end repeat*
#define _UMATHMODULE
The purpose of this module is to add faster math for array scalars

that does not go through the ufunc machinery

but still supports error-modes.

#define cmplx_cmp_
Value:
@oper@(arg1, arg2) ((arg1.real == arg2.real) ?        \
                                      arg1.imag @op@ arg2.imag :        \
                                      arg1.real @op@ arg2.real)
#define def_cmp_   @oper@(arg1, arg2) (arg1 @op@ arg2)
end repeat*
begin repeat

oper = le, ge, lt, gt, eq, ne# #op = <=, >=, <, >, ==, !=# #halfop = npy_half_le, npy_half_ge, npy_half_lt,

System Message: ERROR/3 (<string>, line 5) Unexpected indentation.

<blockquote class="last"> npy_half_gt, npy_half_eq, npy_half_ne#</blockquote>

#define def_half_cmp_   @oper@(arg1, arg2) @halfop@(arg1, arg2)
#define half_ctype_add (   a,
  b,
  outp 
)
#define half_ctype_divide (   a,
  b,
  outp 
)
#define half_ctype_multiply (   a,
  b,
  outp 
)
#define half_ctype_subtract (   a,
  b,
  outp 
)
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>

Referenced by datetimetype_repr(), form(), and timedeltatype_repr().

#define name
Value:
@_ctype_true_divide(a, b, out)     \
    *(out) = ((@otyp@) (a)) / ((@otyp@) (b));
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name   @_ctype_@oper@(arg1, arg2, out) *(out) = (arg1) @op@ (arg2)
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name   @_ctype_add(a, b, outp) *(outp) = (a) + (b)
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name   @_ctype_subtract(a, b, outp) *(outp) = (a) - (b)
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name   @_ctype_multiply(a, b, outp) *(outp) = (a) * (b)
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name   @_ctype_divide(a, b, outp) *(outp) = (a) / (b)
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name   @_ctype_true_divide @name@_ctype_divide
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name
Value:
@_ctype_add(a, b, outp) do{        \
    (outp)->real = (a).real + (b).real;         \
    (outp)->imag = (a).imag + (b).imag;         \
    } while(0)
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name
Value:
@_ctype_subtract(a, b, outp) do{   \
    (outp)->real = (a).real - (b).real;         \
    (outp)->imag = (a).imag - (b).imag;         \
    } while(0)
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name
Value:
@_ctype_multiply(a, b, outp) do{                   \
    (outp)->real = (a).real * (b).real - (a).imag * (b).imag;   \
    (outp)->imag = (a).real * (b).imag + (a).imag * (b).real;   \
    } while(0)
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name
Value:
@_ctype_divide(a, b, outp) do{                         \
    @rtype@ in1r = (a).real;                                        \
    @rtype@ in1i = (a).imag;                                        \
    @rtype@ in2r = (b).real;                                        \
    @rtype@ in2i = (b).imag;                                        \
    @rtype@ in2r_abs = npy_fabs@c@(in2r);                           \
    @rtype@ in2i_abs = npy_fabs@c@(in2i);                           \
    if (in2r_abs >= in2i_abs) {                                     \
        if (in2r_abs == 0 && in2i_abs == 0) {                       \  \
            (outp)->real = in1r/in2r_abs;                           \
            (outp)->imag = in1i/in2i_abs;                           \
        }                                                           \
        else {                                                      \
            @rtype@ rat = in2i/in2r;                                \
            @rtype@ scl = 1.0@c@/(in2r + in2i*rat);                 \
            (outp)->real = (in1r + in1i*rat)*scl;                   \
            (outp)->imag = (in1i - in1r*rat)*scl;                   \
        }                                                           \
    }                                                               \
    else {                                                          \
        @rtype@ rat = in2r/in2i;                                    \
        @rtype@ scl = 1.0@c@/(in2i + in2r*rat);                     \
        (outp)->real = (in1r*rat + in1i)*scl;                       \
        (outp)->imag = (in1i*rat - in1r)*scl;                       \
    }                                                               \
    } while(0)
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name   @_ctype_true_divide @name@_ctype_divide
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name
Value:
@_ctype_floor_divide(a, b, outp) do {      \
    @rname@_ctype_floor_divide(                         \
        ((a).real*(b).real + (a).imag*(b).imag),        \
        ((b).real*(b).real + (b).imag*(b).imag),        \
        &((outp)->real));                               \
    (outp)->imag = 0;                                   \
    } while(0)
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name
Value:
@_ctype_divmod(a, b, out, out2) {  \
    @name@_ctype_floor_divide(a, b, out);       \
    @name@_ctype_remainder(a, b, out2);         \
    }
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name   @_ctype_invert(a, out) *(out) = ~a;
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name   @_@oper@ NULL
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name   @_@oper@ NULL
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define name   @_invert NULL
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
System Message: WARNING/2 (<string>, line 5) Definition list ends without a blank line; unexpected unindent.
#otyp = npy_float*4, npy_double*6# </blockquote>
end repeat*
QUESTION: Should we check for overflow / underflow in (l,r)shift?
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
begin repeat1

oper = and, xor, or, lshift, rshift# #op = &, ^, |, <<, >>#

System Message: WARNING/2 (<string>, line 2); backlink Inline substitution_reference start-string without end-string.
begin repeat
name = cfloat, cdouble, clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble# c = f,,l#
Algorithm identical to that in loops.c.src, for consistency
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long, ulong,
longlong, ulonglong, cfloat, cdouble, clongdouble#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong#
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint, long,
ulong, longlong, ulonglong#
end repeat*
begin repeat <blockquote> name = cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = divmod, remainder#</blockquote>
end repeat1*
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
begin repeat1 <blockquote> oper = lshift, rshift, and, or, xor#</blockquote>
end repeat*
begin repeat <blockquote> name = half, float, double, longdouble, cfloat, cdouble, clongdouble#</blockquote>
#define NO_IMPORT_ARRAY
#define NONZERO_NAME (   prefix)    prefix##nonzero
end repeat*
#define NPY_NO_DEPRECATED_API   NPY_API_VERSION
#define NPY_SIZEOF_BYTE   1
end repeat*
#define PY_ARRAY_UNIQUE_SYMBOL   _npy_umathmodule_ARRAY_API

Function Documentation

static int _ name _convert2_to_ctypes ( PyObject *  a,
@type @*  arg1,
PyObject *  b,
@type @*  arg2 
) [static]
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong, half, float, double, cfloat, cdouble#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong, npy_half, npy_float, npy_double, npy_cfloat, npy_cdouble#
end repeat*
begin repeat
name = longdouble, clongdouble# #type = npy_longdouble, npy_clongdouble#
static int _ name _convert_to_ctype ( PyObject *  a,
@type @*  arg1 
) [static]
end repeat*
  • END OF BASIC CODE *
The general strategy for commutative binary operators is to

  1. Convert the types to the common type if both are scalars (0 return)
  2. If both are not scalars use ufunc machinery (-2 return)
System Message: WARNING/2 (<string>, line 5) Enumerated list ends without a blank line; unexpected unindent.
3) If both are scalars but cannot be cast to the right type return NotImplmented (-1 return)

  1. Perform the function on the C-type.
System Message: WARNING/2 (<string>, line 9) Enumerated list ends without a blank line; unexpected unindent.
5) If an error condition occurred, check to see what the current error-handling is and handle the error.

  1. Construct and return the output scalar.
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong, half, float, longdouble, cfloat, cdouble, clongdouble#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong, npy_half, npy_float, npy_longdouble, npy_cfloat, npy_cdouble, npy_clongdouble#
#Name = Byte, UByte, Short, UShort, Int, UInt,
Long, ULong, LongLong, ULongLong, Half, Float, LongDouble, CFloat, CDouble, CLongDouble#
TYPE = NPY_BYTE, NPY_UBYTE, NPY_SHORT, NPY_USHORT, NPY_INT, NPY_UINT,
NPY_LONG, NPY_ULONG, NPY_LONGLONG, NPY_ULONGLONG, NPY_HALF, NPY_FLOAT, NPY_LONGDOUBLE, NPY_CFLOAT, NPY_CDOUBLE, NPY_CLONGDOUBLE#
end repeat*
Same as above but added exact checks against known python types for speed
begin repeat
name = double# #type = npy_double# #Name = Double# TYPE = NPY_DOUBLE# #PYCHECKEXACT = PyFloat_CheckExact# #PYEXTRACTCTYPE = PyFloat_AS_DOUBLE#
static void name _ctype_absolute ( @type @  a,
@type @*  out 
) [static]
end repeat*
begin repeat
name = byte, short, int, long, longlong# #type = npy_byte, npy_short, npy_int, npy_long, npy_longlong#
end repeat*
begin repeat
name = float, double, longdouble# #type = npy_float, npy_double, npy_longdouble# c = f,,l#
static void name _ctype_absolute ( @type @  a,
@rtype @*  out 
) [static]
begin repeat
name = cfloat, cdouble, clongdouble# #type = npy_cfloat, npy_cdouble, npy_clongdouble# #rname = float, double, longdouble# #rtype = npy_float, npy_double, npy_longdouble#
static void name _ctype_add ( @type @  a,
@type @  b,
@type @*  out 
) [static]
Basic operations: <blockquote> BINARY:</blockquote>
add, subtract, multiply, divide, remainder, divmod, power, floor_divide, true_divide
lshift, rshift, and, or, xor (integers only)
UNARY:
negative, positive, absolute, nonzero, invert, int, long, float, oct, hex
begin repeat
name = byte, short, int, long, longlong# #type = npy_byte, npy_short, npy_int, npy_long, npy_longlong#
end repeat*
begin repeat
name = ubyte, ushort, uint, ulong, ulonglong# #type = npy_ubyte, npy_ushort, npy_uint, npy_ulong, npy_ulonglong#
static void name _ctype_divide ( @type @  a,
@type @  b,
@type @*  out 
) [static]
end repeat*
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
System Message: WARNING/2 (<string>, line 7) Definition list ends without a blank line; unexpected unindent.
#neg = (1,0)*5# </blockquote>
static void name _ctype_divmod ( @type @  a,
@type @  b,
@type @*  out1,
@type @*  out2 
) [static]
static void name _ctype_floor_divide ( @type @  a,
@type @  b,
@type @*  out 
) [static]
static void name _ctype_multiply ( @type @  a,
@type @  b,
@type @*  out 
) [static]
begin repeat <blockquote>

name = byte, ubyte, short, ushort,
int, uint, long, ulong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort,
npy_int, npy_uint, npy_long, npy_ulong#
#big = npy_int, npy_uint, npy_int, npy_uint,
npy_longlong, npy_ulonglong, npy_longlong, npy_ulonglong#
#NAME = BYTE, UBYTE, SHORT, USHORT,
INT, UINT, LONG, ULONG#
System Message: WARNING/2 (<string>, line 11) Definition list ends without a blank line; unexpected unindent.
#SIZENAME = BYTE*2, SHORT*2, INT*2, LONG*2# #SIZE = INT*4,LONGLONG*4# #neg = (1,0)*4# </blockquote>
end repeat*
begin repeat <blockquote>

name = int, uint, long, ulong,
longlong, ulonglong#
#type = npy_int, npy_uint, npy_long, npy_ulong,
npy_longlong, npy_ulonglong#
System Message: WARNING/2 (<string>, line 7) Definition list ends without a blank line; unexpected unindent.
#SIZE = INT*2, LONG*2, LONGLONG*2# </blockquote>
static void name _ctype_negative ( @type @  a,
@type @*  out 
) [static]
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong, float, double, longdouble#
#type = 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#
System Message: WARNING/2 (<string>, line 8) Definition list ends without a blank line; unexpected unindent.

#uns = (0,1)*5,0*3#

begin repeat
name = cfloat, cdouble, clongdouble# #type = npy_cfloat, npy_cdouble, npy_clongdouble#

References NPY_PRIORITY, PyArray_CanCastSafely(), PyArray_CastScalarDirect(), PyArray_DescrFromTypeObject(), PyArray_GetPriority(), PyArray_IsScalar, PyArray_ScalarFromObject(), PyArrayScalar_VAL, TYPE, and _PyArray_Descr::type_num.

static void name _ctype_positive ( @type @  a,
@type @*  out 
) [static]
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong, half, float, double, longdouble#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong, npy_half, npy_float, npy_double, npy_longdouble#
end repeat*
Get the nc_powf, nc_pow, and nc_powl functions from the data area of the power ufunc in umathmodule.
begin repeat
name = cfloat, cdouble, clongdouble# #type = npy_cfloat, npy_cdouble, npy_clongdouble#
static void name _ctype_power ( @type @  a,
@type @  b,
@type @*  out 
) [static]
end repeat*
b will always be positive in this call
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong#
#upc = BYTE, UBYTE, SHORT, USHORT, INT, UINT,
LONG, ULONG, LONGLONG, ULONGLONG#

</blockquote>

References c, and npy_divmod().

static void name _ctype_remainder ( @type @  a,
@type @  b,
@type @*  out 
) [static]
static void name _ctype_subtract ( @type @  a,
@type @  b,
@type @*  out 
) [static]
static PyObject* name _int ( PyObject *  obj) [static]
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int,
uint, long, ulong, longlong, ulonglong, half, float, double, longdouble, cfloat, cdouble, clongdouble#
#Name = Byte, UByte, Short, UShort, Int,
UInt, Long, ULong, LongLong, ULongLong, Half, Float, Double, LongDouble, CFloat, CDouble, CLongDouble#
#cmplx = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1# #sign = (signed, unsigned)*5, , , , , , , # #unsigntyp = 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0*7# #ctype = long*8, PY_LONG_LONG*2, double*7# #to_ctype = , , , , , , , , , , npy_half_to_double, , , , , , # #realtyp = 0*10, 1*7# #func = (PyLong_FromLong, PyLong_FromUnsignedLong)*4,

System Message: ERROR/3 (<string>, line 20) Unexpected indentation.

<blockquote> PyLong_FromLongLong, PyLong_FromUnsignedLongLong, PyLong_FromDouble*7#</blockquote> </blockquote>

static PyObject* name _power ( PyObject *  a,
PyObject *  b,
PyObject *  NPY_UNUSED
) [static]
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong, half, float, double, longdouble, cfloat, cdouble, clongdouble#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
npy_long, npy_ulong, npy_longlong, npy_ulonglong, npy_half, npy_float, npy_double, npy_longdouble, npy_cfloat, npy_cdouble, npy_clongdouble#
#Name = Byte, UByte, Short, UShort, Int, UInt,
Long, ULong, LongLong, ULongLong, Half, Float, Double, LongDouble, CFloat, CDouble, CLongDouble#
#oname = float*4, double*6, half, float, double, longdouble,
cfloat, cdouble, clongdouble#
#otype = npy_float*4, npy_double*6, npy_half, npy_float,
npy_double, npy_longdouble, npy_cfloat, npy_cdouble, npy_clongdouble#
#OName = Float*4, Double*6, Half, Float,
Double, LongDouble, CFloat, CDouble, CLongDouble#
#isint = (1,0)*5,0*7# #cmplx = 0*14,1*3# #iszero = _IS_ZERO*10, npy_half_iszero, _IS_ZERO*6# #zero = 0*10, NPY_HALF_ZERO, 0*6# #one = 1*10, NPY_HALF_ONE, 1*6# </blockquote>
can't cast both safely mixed-types?
use default handling
special case for longdouble and clongdouble because they have a recursive getitem in their dtype
here we do the actual calculation with arg1 and arg2 as a function call.
Check status flag. If it is set, then look up what to do
static PyObject* name _richcompare ( PyObject *  self,
PyObject *  other,
int  cmp_op 
) [static]
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong, half, float, double, longdouble, cfloat, cdouble, clongdouble#
System Message: WARNING/2 (<string>, line 6) Definition list ends without a blank line; unexpected unindent.

#simp = def*10, def_half, def*3, cmplx*3#

can't cast both safely use different add function
use ufunc
special case for longdouble and clongdouble because they have a recursive getitem in their dtype
here we do the actual calculation with arg1 and arg2
NPY_NO_EXPORT void add_scalarmath ( void  )
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong, half, float, double, longdouble, cfloat, cdouble, clongdouble#
#NAME = Byte, UByte, Short, UShort, Int, UInt,
Long, ULong, LongLong, ULongLong, Half, Float, Double, LongDouble, CFloat, CDouble, CLongDouble#
end repeat*
static int emit_complexwarning ( void  ) [static]
end repeat*
static int get_functions ( PyObject *  mm) [static]
Get the nc_pow functions
Get the pow functions
Get the sqrt functions
sqrt ufunc is specialized for double and float loops in generate_umath.py, the first to go into FLOAT/DOUBLE_sqrt they have the same signature as the scalar variants so we need to skip over them also skip float16 copy placed before
Get the fmod functions
static void half_ctype_absolute ( npy_half  a,
npy_half out 
) [static]
end repeat*
static void half_ctype_divmod ( npy_half  a,
npy_half  b,
npy_half out1,
npy_half out2 
) [static]
static void half_ctype_floor_divide ( npy_half  a,
npy_half  b,
npy_half out 
) [static]
static void half_ctype_negative ( npy_half  a,
npy_half out 
) [static]
end repeat*
static void half_ctype_power ( npy_half  a,
npy_half  b,
npy_half out 
) [static]
end repeat*

References _basic_, and _sqrt().

static void half_ctype_remainder ( npy_half  a,
npy_half  b,
npy_half out 
) [static]
NPY_NO_EXPORT int initscalarmath ( PyObject *  )

* INCLUDE GENERATED CODE **

static int NONZERO_NAME ( @name _) [static]
begin repeat <blockquote>

name = byte, ubyte, short, ushort, int,
uint, long, ulong, longlong, ulonglong, half, float, double, longdouble, cfloat, cdouble, clongdouble#
#type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int,
npy_uint, npy_long, npy_ulong, npy_longlong, npy_ulonglong, npy_half, npy_float, npy_double, npy_longdouble, npy_cfloat, npy_cdouble, npy_clongdouble#
System Message: WARNING/2 (<string>, line 11) Definition list ends without a blank line; unexpected unindent.
#simp = 1*14, 0*3# #nonzero = _IS_NONZERO*10, !npy_half_iszero, _IS_NONZERO*6# </blockquote>
here we do the actual calculation with arg1 and arg2 make it a function call.
static PyObject* name _ oper ( PyObject *  a,
PyObject *  b 
) [static]
end repeat*
begin repeat <blockquote>

name = (byte, ubyte, short, ushort, int, uint,

<blockquote class="first"> long, ulong, longlong, ulonglong)*13,</blockquote>

System Message: WARNING/2 (<string>, line 5) Block quote ends without a blank line; unexpected unindent.
(half, float, double, longdouble,
cfloat, cdouble, clongdouble)*6,
System Message: WARNING/2 (<string>, line 7) Definition list ends without a blank line; unexpected unindent.

(half, float, double, longdouble)*2#

#Name = (Byte, UByte, Short, UShort, Int, UInt,

<blockquote class="first"> Long, ULong,LongLong,ULongLong)*13,</blockquote>

System Message: WARNING/2 (<string>, line 10) Block quote ends without a blank line; unexpected unindent.
(Half, Float, Double, LongDouble,
CFloat, CDouble, CLongDouble)*6,
System Message: WARNING/2 (<string>, line 12) Definition list ends without a blank line; unexpected unindent.

(Half, Float, Double, LongDouble)*2#

#type = (npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,

<blockquote class="first"> npy_long, npy_ulong, npy_longlong, npy_ulonglong)*13,</blockquote>

System Message: WARNING/2 (<string>, line 15) Block quote ends without a blank line; unexpected unindent.
(npy_half, npy_float, npy_double, npy_longdouble,
npy_cfloat, npy_cdouble, npy_clongdouble)*6,
System Message: WARNING/2 (<string>, line 17) Definition list ends without a blank line; unexpected unindent.

(npy_half, npy_float, npy_double, npy_longdouble)*2#

oper = add*10, subtract*10, multiply*10, divide*10, remainder*10,
divmod*10, floor_divide*10, lshift*10, rshift*10, and*10, or*10, xor*10, true_divide*10, add*7, subtract*7, multiply*7, divide*7, floor_divide*7, true_divide*7, divmod*4, remainder*4#
#fperr = 1*70,0*50,1*10,
1*42, 1*8#
#twoout = 0*50,1*10,0*70,
0*42, 1*4,0*4#
#otype = (npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,

<blockquote class="first"> npy_long, npy_ulong, npy_longlong, npy_ulonglong)*12,</blockquote>

System Message: WARNING/2 (<string>, line 33) Block quote ends without a blank line; unexpected unindent.

npy_float*4, npy_double*6, (npy_half, npy_float, npy_double, npy_longdouble,

System Message: ERROR/3 (<string>, line 35) Unexpected indentation.

<blockquote> npy_cfloat, npy_cdouble, npy_clongdouble)*6,</blockquote>

System Message: WARNING/2 (<string>, line 36) Block quote ends without a blank line; unexpected unindent.

(npy_half, npy_float, npy_double, npy_longdouble)*2#

#OName = (Byte, UByte, Short, UShort, Int, UInt,

<blockquote class="first"> Long, ULong, LongLong, ULongLong)*12,</blockquote>

System Message: WARNING/2 (<string>, line 39) Block quote ends without a blank line; unexpected unindent.

Float*4, Double*6, (Half, Float, Double, LongDouble,

System Message: ERROR/3 (<string>, line 41) Unexpected indentation.

<blockquote> CFloat, CDouble, CLongDouble)*6,</blockquote>

System Message: WARNING/2 (<string>, line 42) Block quote ends without a blank line; unexpected unindent.

(Half, Float, Double, LongDouble)*2#

</blockquote>

NOTE: In gcc >= 4.1, the compiler will reorder floating point
operations and floating point error state checks. In particular, the arithmetic operations were being reordered so that the errors weren't caught. Declaring this output variable volatile was the minimal fix for the issue. (Ticket #1671)
one of them can't be cast safely must be mixed-types
use default handling
special case for longdouble and clongdouble because they have a recursive getitem in their dtype
here we do the actual calculation with arg1 and arg2 as a function call.
static PyObject *name _ oper ( PyObject *  obj) [static]
end repeat1*
end repeat*
begin repeat
name = (byte, ubyte, short, ushort, int, uint,

<blockquote class="first"> long, ulong, longlong, ulonglong, half, float, double, longdouble, cfloat, cdouble, clongdouble)*3,</blockquote>

byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong#

#type = (npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,

<blockquote class="first"> npy_long, npy_ulong, npy_longlong, npy_ulonglong, npy_half, npy_float, npy_double, npy_longdouble, npy_cfloat, npy_cdouble, npy_clongdouble)*3,</blockquote>

npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint, npy_long, npy_ulong, npy_longlong, npy_ulonglong#

#otype = (npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,

<blockquote class="first"> npy_long, npy_ulong, npy_longlong, npy_ulonglong, npy_half, npy_float, npy_double, npy_longdouble, npy_cfloat, npy_cdouble, npy_clongdouble)*2,</blockquote>

System Message: WARNING/2 (<string>, line 22) Block quote ends without a blank line; unexpected unindent.

npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint, npy_long, npy_ulong, npy_longlong, npy_ulonglong, npy_half, npy_float, npy_double, npy_longdouble, npy_float, npy_double, npy_longdouble,

npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint, npy_long, npy_ulong, npy_longlong, npy_ulonglong#

#OName = (Byte, UByte, Short, UShort, Int, UInt,

<blockquote class="first"> Long, ULong, LongLong, ULongLong, Half, Float, Double, LongDouble, CFloat, CDouble, CLongDouble)*2,</blockquote>

System Message: WARNING/2 (<string>, line 34) Block quote ends without a blank line; unexpected unindent.

Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Half, Float, Double, LongDouble, Float, Double, LongDouble,

Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong#

oper = negative*17, positive*17, absolute*17, invert*10#

end repeat*
begin repeat <blockquote>

name = (byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong, half, float, double, longdouble, cfloat, cdouble, clongdouble)*2#
System Message: WARNING/2 (<string>, line 7) Definition list ends without a blank line; unexpected unindent.
oper = oct*17, hex*17# kind = (int*5, long*5, int*2, long*2, int, long*2)*2# #cap = (Int*5, Long*5, Int*2, Long*2, Int, Long*2)*2# </blockquote>
can't cast both safely use different add function
use default handling
here we do the actual calculation with arg1 and arg2 make it a function call.
static NPY_INLINE PyObject* name _ which ( PyObject *  obj) [static]
end repeat*
begin repeat <blockquote>

name = (byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong, half, float, double, longdouble, cfloat, cdouble, clongdouble)*2#
#Name = (Byte, UByte, Short, UShort, Int, UInt,
Long, ULong, LongLong, ULongLong, Half, Float, Double, LongDouble, CFloat, CDouble, CLongDouble)*2#
System Message: WARNING/2 (<string>, line 11) Definition list ends without a blank line; unexpected unindent.
#cmplx = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1)*2# #to_ctype = (, , , , , , , , , , npy_half_to_double, , , , , , )*2# which = long*17, float*17# #func = (PyLong_FromLongLong, PyLong_FromUnsignedLongLong)*5,

System Message: ERROR/3 (<string>, line 15) Unexpected indentation.

<blockquote> PyLong_FromDouble*7, PyFloat_FromDouble*17#</blockquote> </blockquote>


Variable Documentation

PyNumberMethods name _as_number [static]
end repeat*
begin repeat
name = byte, ubyte, short, ushort, int, uint,
long, ulong, longlong, ulonglong, half, float, double, longdouble, cfloat, cdouble, clongdouble#
static void(* _basic_)(@type @*,@type @*,@type @*) [static]
end repeat1*
end repeat*
begin repeat
name = float, double, longdouble# #type = npy_float, npy_double, npy_longdouble# c = f, , l#
end repeat*
begin repeat
name = float, double, longdouble# #type = npy_float, npy_double, npy_longdouble#

Referenced by half_ctype_power().

end repeat*