from cupy import core from cupy._math import ufunc exp = ufunc.create_math_ufunc( 'exp', 1, 'cupy_exp', '''Elementwise exponential function. .. seealso:: :data:`numpy.exp` ''') expm1 = ufunc.create_math_ufunc( 'expm1', 1, 'cupy_expm1', '''Computes ``exp(x) - 1`` elementwise. .. seealso:: :data:`numpy.expm1` ''') exp2 = core.create_ufunc('cupy_exp2', ('e->e', 'f->f', 'd->d', 'F->F', 'D->D'), 'out0 = pow(in0_type(2), in0)', doc='''Elementwise exponentiation with base 2. .. seealso:: :data:`numpy.exp2` ''') log = ufunc.create_math_ufunc( 'log', 1, 'cupy_log', '''Elementwise natural logarithm function. .. seealso:: :data:`numpy.log` ''')
import numpy import cupy from cupy import core from cupy._math import sumprod from cupy._math import ufunc sin = ufunc.create_math_ufunc( 'sin', 1, 'cupy_sin', '''Elementwise sine function. .. seealso:: :data:`numpy.sin` ''') cos = ufunc.create_math_ufunc( 'cos', 1, 'cupy_cos', '''Elementwise cosine function. .. seealso:: :data:`numpy.cos` ''') tan = ufunc.create_math_ufunc( 'tan', 1, 'cupy_tan', '''Elementwise tangent function. .. seealso:: :data:`numpy.tan`
from cupy._math import ufunc from cupy.cuda import runtime signbit = core.create_ufunc( 'cupy_signbit', ('e->?', 'f->?', 'd->?'), 'out0 = signbit(in0)', doc='''Tests elementwise if the sign bit is set (i.e. less than zero). .. seealso:: :data:`numpy.signbit` ''') copysign = ufunc.create_math_ufunc( 'copysign', 2, 'cupy_copysign', '''Returns the first argument with the sign bit of the second elementwise. .. seealso:: :data:`numpy.copysign` ''') ldexp = core.create_ufunc( 'cupy_ldexp', ('ei->e', 'fi->f', 'el->e', 'fl->f', 'di->d', 'dq->d'), 'out0 = ldexp(in0, in1)', doc='''Computes ``x1 * 2 ** x2`` elementwise. .. seealso:: :data:`numpy.ldexp` ''') # HIP supports frexpf but not frexp ... frexp = core.create_ufunc(
""" if fusion._is_fusing(): return fusion._call_ufunc(core.core._round_ufunc, a, decimals, out=out) a = core.array(a, copy=False) return a.round(decimals, out=out) def round_(a, decimals=0, out=None): return around(a, decimals, out=out) rint = ufunc.create_math_ufunc( 'rint', 1, 'cupy_rint', '''Rounds each element of an array to the nearest integer. .. seealso:: :data:`numpy.rint` ''') floor = ufunc.create_math_ufunc( 'floor', 1, 'cupy_floor', '''Rounds each element of an array to its floor integer. .. seealso:: :data:`numpy.floor` ''', support_complex=False)
from cupy import core from cupy._math import ufunc i0 = ufunc.create_math_ufunc( 'cyl_bessel_i0', 1, 'cupy_i0', '''Modified Bessel function of the first kind, order 0. .. seealso:: :func:`numpy.i0` ''') sinc = core.create_ufunc( 'cupy_sinc', ('e->e', 'f->f', 'd->d', ('F->F', 'in0_type pi_in0 = (in0_type) M_PI * in0;' 'out0 = abs(in0) > 1e-9 ? sin(pi_in0) / (pi_in0) : 1'), ('D->D', 'in0_type pi_in0 = (in0_type) M_PI * in0;' 'out0 = abs(in0) > 1e-9 ? sin(pi_in0) / (pi_in0) : 1')), 'out0 = abs(in0) > 1e-9 ? sinpi(in0) / (M_PI * in0) : 1', doc='''Elementwise sinc function. .. seealso:: :func:`numpy.sinc` ''')
from cupy._math import ufunc sinh = ufunc.create_math_ufunc( 'sinh', 1, 'cupy_sinh', '''Elementwise hyperbolic sine function. .. seealso:: :data:`numpy.sinh` ''') cosh = ufunc.create_math_ufunc( 'cosh', 1, 'cupy_cosh', '''Elementwise hyperbolic cosine function. .. seealso:: :data:`numpy.cosh` ''') tanh = ufunc.create_math_ufunc( 'tanh', 1, 'cupy_tanh', '''Elementwise hyperbolic tangent function. .. seealso:: :data:`numpy.tanh` ''') arcsinh = ufunc.create_math_ufunc( 'asinh', 1, 'cupy_arcsinh', '''Elementwise inverse of hyperbolic sine function. .. seealso:: :data:`numpy.arcsinh` ''')