File: cpp_stl_cmath_cpp17.pyx

package info (click to toggle)
cython 3.0.11%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 19,092 kB
  • sloc: python: 83,539; ansic: 18,831; cpp: 1,402; xml: 1,031; javascript: 511; makefile: 403; sh: 204; sed: 11
file content (34 lines) | stat: -rw-r--r-- 670 bytes parent folder | download
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)