Beispiel #1
0
from cupy.math import ufunc


sinh = ufunc.create_math_ufunc(
    'sinh', 1, 'cupy_sinh',
    '''Elementwise hypoerbolic sine function.

    .. seealso:: :data:`numpy.sinh`

    ''')


cosh = ufunc.create_math_ufunc(
    'cosh', 1, 'cupy_cosh',
    '''Elementwise hypoerbolic 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(
Beispiel #2
0
import cupy.core.fusion
from cupy.math import ufunc

try:
    import scipy.special
    _scipy_available = True
except ImportError:
    _scipy_available = False

_j0 = ufunc.create_math_ufunc(
    'j0', 1, 'cupyx_scipy_j0', '''Bessel function of the first kind of order 0.

    .. seealso:: :meth:`scipy.special.j0`

    ''')

_j1 = ufunc.create_math_ufunc(
    'j1', 1, 'cupyx_scipy_j1', '''Bessel function of the first kind of order 1.

    .. seealso:: :meth:`scipy.special.j1`

    ''')

_y0 = ufunc.create_math_ufunc(
    'y0', 1, 'cupyx_scipy_y0',
    '''Bessel function of the second kind of order 0.

    .. seealso:: :meth:`scipy.special.y0`

    ''')
Beispiel #3
0
from cupy.math import ufunc

sinh = ufunc.create_math_ufunc(
    'sinh', 1, 'cupy_sinh', '''Elementwise hypoerbolic sine function.

    .. seealso:: :data:`numpy.sinh`

    ''')

cosh = ufunc.create_math_ufunc(
    'cosh', 1, 'cupy_cosh', '''Elementwise hypoerbolic 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`

    ''')
Beispiel #4
0
from cupy.math import ufunc


def around(a, decimals=0, out=None):
    # TODO(beam2d): Implement it
    raise NotImplementedError


# TODO(beam2d): Implement it
# round_ = around


rint = ufunc.create_math_ufunc(
    'rint', 1, 'cupy_rint',
    '''Rounds eacy element of an array to the nearest integer.

    .. seealso:: :data:`numpy.rint`

    ''')


def fix(x, y=None):
    # TODO(beam2d): Implement it
    raise NotImplementedError


floor = ufunc.create_math_ufunc(
    'floor', 1, 'cupy_floor',
    '''Rounds each element of an array to its floow integer.

    .. seealso:: :data:`numpy.floor`
Beispiel #5
0
from cupy import core
from cupy.math import ufunc

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', 'dl->d'),
    'out0 = ldexp(in0, in1)',
    doc='''Computes ``x1 * 2 ** x2`` elementwise.

    .. seealso:: :data:`numpy.ldexp`

    ''')

frexp = core.create_ufunc(
    'cupy_frexp', ('e->ei', 'f->fi', 'd->di'),
Beispiel #6
0
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`
Beispiel #7
0
from cupy import core
from cupy.math import ufunc

# TODO(okuta): Implement around


# TODO(beam2d): Implement it
# round_ = around


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`

    ''')


ceil = ufunc.create_math_ufunc(
    'ceil', 1, 'cupy_ceil',
    '''Rounds each element of an array to its ceiling integer.
Beispiel #8
0
from cupy import elementwise
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 = elementwise.create_ufunc('cupy_exp2', ('e->e', 'f->f',
                                              ('d->d', 'out0 = pow(2., in0)')),
                                'out0 = powf(2.f, 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`
Beispiel #9
0
from cupy import elementwise
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`

    ''')

Beispiel #10
0
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 arugment 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', 'dl->d'),
    'out0 = ldexp(in0, in1)',
    doc='''Computes ``x1 * 2 ** x2`` elementwise.

    .. seealso:: :data:`numpy.ldexp`

    ''')
Beispiel #11
0
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'),
    'out0 = abs(in0) > 1e-9 ? sinpi(in0) / (M_PI * in0) : 1',
    doc='''Elementwise sinc function.

    .. seealso:: :func:`numpy.sinc`

    ''')
Beispiel #12
0
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', 'out0 = pow(2., in0)')),
    'out0 = powf(2.f, in0)',
    doc='''Elementwise exponentiation with base 2.

    .. seealso:: :data:`numpy.exp2`

    ''')
Beispiel #13
0

def around(a, decimals=0, out=None):
    # TODO(beam2d): Implement it
    raise NotImplementedError


# TODO(beam2d): Implement it
# round_ = around


rint = ufunc.create_math_ufunc(
    "rint",
    1,
    "cupy_rint",
    """Rounds eacy element of an array to the nearest integer.

    .. seealso:: :data:`numpy.rint`

    """,
)


def fix(x, y=None):
    # TODO(beam2d): Implement it
    raise NotImplementedError


floor = ufunc.create_math_ufunc(
    "floor",
    1,
    "cupy_floor",