File size: 2,013 Bytes
3662621
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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`

    ''')


log10 = ufunc.create_math_ufunc(
    'log10', 1, 'cupy_log10',
    '''Elementwise common logarithm function.

    .. seealso:: :data:`numpy.log10`

    ''')


log2 = ufunc.create_math_ufunc(
    'log2', 1, 'cupy_log2',
    '''Elementwise binary logarithm function.

    .. seealso:: :data:`numpy.log2`

    ''')


log1p = ufunc.create_math_ufunc(
    'log1p', 1, 'cupy_log1p',
    '''Computes ``log(1 + x)`` elementwise.

    .. seealso:: :data:`numpy.log1p`

    ''')


logaddexp = _core.create_ufunc(
    'cupy_logaddexp',
    ('ee->e', 'ff->f', 'dd->d'),
    '''
    if (in0 == in1) {
        /* Handles infinities of the same sign */
        out0 = in0 + log(2.0);
    } else {
        out0 = fmax(in0, in1) + log1p(exp(-fabs(in0 - in1)));
    }
    ''',
    doc='''Computes ``log(exp(x1) + exp(x2))`` elementwise.

    .. seealso:: :data:`numpy.logaddexp`

    ''')


logaddexp2 = _core.create_ufunc(
    'cupy_logaddexp2',
    ('ee->e', 'ff->f', 'dd->d'),
    '''
    if (in0 == in1) {
        /* Handles infinities of the same sign */
        out0 = in0 + 1.0;
    } else {
        out0 = fmax(in0, in1) + log2(1 + exp2(-fabs(in0 - in1)));
    }
    ''',
    doc='''Computes ``log2(exp2(x1) + exp2(x2))`` elementwise.

    .. seealso:: :data:`numpy.logaddexp2`

    ''')