File: _legacy.pxd

package info (click to toggle)
python-scipy 0.18.1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 75,464 kB
  • ctags: 79,406
  • sloc: python: 143,495; cpp: 89,357; fortran: 81,650; ansic: 79,778; makefile: 364; sh: 265
file content (97 lines) | stat: -rw-r--r-- 4,016 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
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
# -*- cython -*-
"""
Many Scipy special functions originally cast silently double input
arguments to integers.

Here, we define such unsafe wrappers manually.

"""

cimport sf_error

from _ellip_harm cimport ellip_harmonic

from sph_harm cimport sph_harmonic

cdef extern from "cephes.h":
    double bdtrc(int k, int n, double p) nogil
    double bdtr(int k, int n, double p) nogil 
    double bdtri(int k, int n, double y) nogil
    double expn(int n, double x) nogil
    double hyp2f0(double a, double b, double x, int type, double *err) nogil
    double nbdtrc(int k, int n, double p) nogil
    double nbdtr(int k, int n, double p) nogil 
    double nbdtri(int k, int n, double p) nogil
    double pdtrc(int k, double m) nogil
    double pdtr(int k, double m) nogil
    double pdtri(int k, double y) nogil
    double kn(int n, double x) nogil
    double yn(int n, double x) nogil
    double smirnov(int n, double e) nogil
    double smirnovi(int n, double p) nogil

cdef extern from "amos_wrappers.h":
    double cbesk_wrap_real_int(int n, double z) nogil

cdef extern from "Python.h":
    # Purposefully ignore the raised PyError --- assume the ufunc will collect it
    int PyErr_WarnEx_noerr "PyErr_WarnEx" (object, char *, int)

cdef inline void _legacy_cast_check(char *func_name, double x, double y) nogil:
    if <int>x != x or <int>y != y:
        with gil:
            PyErr_WarnEx_noerr(RuntimeWarning,
                               "floating point number truncated to an integer",
                               1)

cdef inline double complex sph_harmonic_unsafe(double m, double n, double theta, double phi) nogil:
    _legacy_cast_check("sph_harm", m, n)
    return sph_harmonic(<int>m, <int> n, theta, phi)
cdef inline double ellip_harmonic_unsafe(double h2, double k2, double n, double p, double l, double signm, double signn) nogil:
    _legacy_cast_check("_ellip_harm", n, p)
    return ellip_harmonic(h2, k2, <int>n, <int>p, l, signm, signn)
cdef inline double bdtrc_unsafe(double k, double n, double p) nogil:
    _legacy_cast_check("bdtrc", k, n)
    return bdtrc(<int>k, <int>n, p)
cdef inline double bdtr_unsafe(double k, double n, double p) nogil:
    _legacy_cast_check("bdtr", k, n)
    return bdtr(<int>k, <int>n, p)
cdef inline double bdtri_unsafe(double k, double n, double y) nogil:
    _legacy_cast_check("bdtri", k, n)
    return bdtri(<int>k, <int>n, y)
cdef inline double expn_unsafe(double n, double x) nogil:
    _legacy_cast_check("expn", n, 0)
    return expn(<int>n, x)
cdef inline double hyp2f0_unsafe(double a, double b, double x, double type, double *err) nogil:
    _legacy_cast_check("hyp2f0", type, 0)
    return hyp2f0(a, b, x, <int>type, err)
cdef inline double nbdtrc_unsafe(double k, double n, double p) nogil:
    _legacy_cast_check("nbdtrc", k, n)
    return nbdtrc(<int>k, <int>n, p)
cdef inline double nbdtr_unsafe(double k, double n, double p)  nogil:
    _legacy_cast_check("nbdtr", k, n)
    return nbdtr(<int>k, <int>n, p)
cdef inline double nbdtri_unsafe(double k, double n, double p) nogil:
    _legacy_cast_check("nbdtri", k, n)
    return nbdtri(<int>k, <int>n, p)
cdef inline double pdtrc_unsafe(double k, double m) nogil:
    _legacy_cast_check("pdtrc", k, 0)
    return pdtrc(<int>k, m)
cdef inline double pdtr_unsafe(double k, double m) nogil: 
    _legacy_cast_check("pdtr", k, 0)
    return pdtr(<int>k, m)
cdef inline double pdtri_unsafe(double k, double y) nogil:
    _legacy_cast_check("pdtri", k, 0)
    return pdtri(<int>k, y)
cdef inline double kn_unsafe(double n, double x) nogil:
    _legacy_cast_check("kn", n, 0)
    return cbesk_wrap_real_int(<int>n, x)
cdef inline double yn_unsafe(double n, double x) nogil:
    _legacy_cast_check("yn", n, 0)
    return yn(<int>n, x)
cdef inline double smirnov_unsafe(double n, double e) nogil:
    _legacy_cast_check("smirnov", n, 0)
    return smirnov(<int>n, e)
cdef inline double smirnovi_unsafe(double n, double p) nogil:
    _legacy_cast_check("smirnovi", n, 0)
    return smirnovi(<int>n, p)