summaryrefslogtreecommitdiff
path: root/tests/run/cpp_stl_cmath_cpp17.pyx
blob: d6e2cc33baf1a0f1efb41fb56c7a1565b76a939b (plain)
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
# mode: run
# tag: cpp, werror, cpp17

from libcpp.cmath cimport beta, legendre, hypot

def test_beta(double x, double y):
    """
    Test C++17 std::beta function
    >>> test_beta(1.0, 1.0)
    1.0
    >>> test_beta(1.0, 2.0)
    0.5
    """
    return beta(x, y)

def test_legendre(int x, double y):
    """
    Test C++17 std::legendre function
    >>> test_legendre(1, 0.5)
    0.5
    >>> test_legendre(2, 0.5)
    -0.125
    """
    return legendre(x, y)

def test_hypot(double x, double y, double z):
    """
    Test C++17 std::hypot function
    >>> test_hypot(1.0, 2.0, 2.0)
    3.0
    >>> test_hypot(3.0, 4.0, 0.0)
    5.0
    """
    return hypot(x, y, z)