Exemplo n.º 1
0
def test11_hyp():
    for i in range(-5, 5):
        for j in range(-5, 5):
            a = ek.sinh(C(i, j))
            b = C(cmath.sinh(complex(i, j)))
            assert ek.allclose(a, b)

            a = ek.cosh(C(i, j))
            b = C(cmath.cosh(complex(i, j)))
            assert ek.allclose(a, b)

            sa, ca = ek.sincosh(C(i, j))
            sb = C(cmath.sinh(complex(i, j)))
            cb = C(cmath.cosh(complex(i, j)))
            assert ek.allclose(sa, sb)
            assert ek.allclose(ca, cb)

            # Python appears to handle the branch cuts
            # differently from Enoki, C, and Mathematica..
            a = ek.asinh(C(i + 0.1, j))
            b = C(cmath.asinh(complex(i + 0.1, j)))
            assert ek.allclose(a, b)

            a = ek.acosh(C(i, j))
            b = C(cmath.acosh(complex(i, j)))
            assert ek.allclose(a, b, atol=1e-7)

            if abs(i) != 1 or j != 0:
                a = ek.atanh(C(i, j))
                b = C(cmath.atanh(complex(i, j)))
                assert ek.allclose(a, b, atol=1e-7)
Exemplo n.º 2
0
def sincosh_(a0):
    if not a0.IsFloat:
        raise Exception("sincosh(): requires floating point operands!")
    ar0, sr0 = _check1(a0)
    ar1 = a0.empty_(sr0 if a0.Size == Dynamic else 0)
    if not a0.IsSpecial:
        for i in range(sr0):
            result = _ek.sincosh(a0[i])
            ar0[i] = result[0]
            ar1[i] = result[1]
    elif a0.IsComplex:
        s, c = _ek.sincos(a0.imag)
        sh, ch = _ek.sincosh(a0.real)
        ar0.real = sh * c
        ar0.imag = ch * s
        ar1.real = ch * c
        ar1.imag = sh * s
    else:
        raise Exception("sincosh(): unsupported array type!")
    return ar0, ar1
Exemplo n.º 3
0
def cosh_(a0):
    if not a0.IsFloat:
        raise Exception("cosh(): requires floating point operands!")
    ar, sr = _check1(a0)
    if not a0.IsSpecial:
        for i in range(sr):
            ar[i] = _ek.cosh(a0[i])
    elif a0.IsComplex:
        s, c = _ek.sincos(a0.imag)
        sh, ch = _ek.sincosh(a0.real)
        ar.real = ch * c
        ar.imag = sh * s
    else:
        raise Exception("cosh(): unsupported array type!")
    return ar