complex_usecases.py 1.48 KB
Newer Older
dugupeiwen's avatar
dugupeiwen committed
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
import cmath


def div_usecase(x, y):
    return x / y


def real_usecase(x):
    return x.real

def imag_usecase(x):
    return x.imag

def conjugate_usecase(x):
    return x.conjugate()


def acos_usecase(x):
    return cmath.acos(x)

def cos_usecase(x):
    return cmath.cos(x)

def asin_usecase(x):
    return cmath.asin(x)

def sin_usecase(x):
    return cmath.sin(x)

def atan_usecase(x):
    return cmath.atan(x)

def tan_usecase(x):
    return cmath.tan(x)

def acosh_usecase(x):
    return cmath.acosh(x)

def cosh_usecase(x):
    return cmath.cosh(x)

def asinh_usecase(x):
    return cmath.asinh(x)

def sinh_usecase(x):
    return cmath.sinh(x)

def atanh_usecase(x):
    return cmath.atanh(x)

def tanh_usecase(x):
    return cmath.tanh(x)

def exp_usecase(x):
    return cmath.exp(x)

def isfinite_usecase(x):
    return cmath.isfinite(x)

def isinf_usecase(x):
    return cmath.isinf(x)

def isnan_usecase(x):
    return cmath.isnan(x)

def log_usecase(x):
    return cmath.log(x)

def log_base_usecase(x, base):
    return cmath.log(x, base)

def log10_usecase(x):
    return cmath.log10(x)

def phase_usecase(x):
    return cmath.phase(x)

def polar_usecase(x):
    return cmath.polar(x)

_two = 2.0

def polar_as_complex_usecase(x):
    # HACK: clear errno by invoking float.__pow__
    # (workaround for http://bugs.python.org/issue24489)
    _two ** _two
    return complex(*cmath.polar(x))

def rect_usecase(r, phi):
    return cmath.rect(r, phi)

def sqrt_usecase(x):
    return cmath.sqrt(x)