1#cython: cdivison=True
2cdef extern from "numpy/npy_math.h":
3    double NPY_INFINITY
4
5from libc.math cimport expm1, fabs, log
6
7cdef inline double exprel(double x) nogil:
8    if fabs(x) < 1e-16:
9        return 1.0
10    elif x > 717:  # near log(DBL_MAX)
11        return NPY_INFINITY
12    else:
13        return expm1(x) / x
14
15