numpy  2.0.0
src/private/templ_common.h.src File Reference
#include "numpy/npy_common.h"

Defines

#define __NPY_TYPED_COMMON_INC

Functions

static NPY_INLINE int
npy_mul_with_overflow_ 
name (@type @*r,@type @a,@type @b)

Define Documentation


Function Documentation

static NPY_INLINE int npy_mul_with_overflow_ name ( @type @*  r,
@type @  a,
@type @  b 
) [static]
utility functions that profit from templates
begin repeat
name = int, uint, long, ulong,
longlong, ulonglong, intp#
#type = npy_int, npy_uint, npy_long, npy_ulong,
npy_longlong, npy_ulonglong, npy_intp#
MAX = NPY_MAX_INT, NPY_MAX_UINT, NPY_MAX_LONG, NPY_MAX_ULONG,
NPY_MAX_LONGLONG, NPY_MAX_ULONGLONG, NPY_MAX_INTP#
writes result of a * b into r returns 1 if a * b overflowed else returns 0
These functions are not designed to work if either a or b is negative, but that is not checked. Could use absolute values and adjust the sign if that functionality was desired.
avoid expensive division on common no overflow case