
ʽXc           @` s  d  Z  d d l m Z m Z m Z d Z d Z d Z d Z d Z	 d Z
 d d	 l Z d d	 l Z d d	 l Z d d	 l Z d d	 l Z d d	 l Z e d
  Z i	 d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6Z i	 d d 6d d 6d d 6d  d 6d! d 6d" d 6d# d 6d$ d 6d d 6Z i d% d 6d& d 6d' d 6d( d 6d) d 6d* d 6d+ d 6d, d 6Z i	 d- d. g d/ 6d0 g d1 6d d g d2 6d g d3 6d d g d4 6d0 d5 g d6 6d g d7 6d g d8 6d d g d9 6Z d:   Z d;   Z e d d f d d f d d f d d f d d f d d f d d f d d f d d f d d f d d f d d f d d f d d f d d f d d f d d f d d f d d f d d f d d f d d f g  Z i d< d 6d< d 6d< d 6d< d 6d< d 6d< d 6d= d 6d= d 6Z d>   Z d?   Z d@   Z dA   Z dB   Z  dC   Z! dD   Z" dE e# f dF     YZ$ dG e$ f dH     YZ% dI e$ f dJ     YZ& dK   Z' dL   Z( dM   Z) dN   Z* dO   Z+ e, dP k re+   n  d	 S(Q   sz	  
generate_ufuncs.py

Generate Ufunc definition source files for scipy.special.  Produces
files '_ufuncs.c' and '_ufuncs_cxx.c' by first producing Cython.

This will generate both calls to PyUFunc_FromFuncAndData and the
required ufunc inner loops.

The syntax in the ufunc signature list is

    <line>:           <ufunc_name> '--' <kernels> '--' <headers>
    <kernels>:        <function> [',' <function>]*
    <function>:       <name> ':' <input> '*' <output>
                        '->' <retval> '*' <ignored_retval>
    <input>:          <typecode>*
    <output>:         <typecode>*
    <retval>:         <typecode>?
    <ignored_retval>: <typecode>?
    <headers>:        <header_name> [',' <header_name>]*

The input parameter types are denoted by single character type
codes, according to

   'f': 'float'
   'd': 'double'
   'g': 'long double'
   'F': 'float complex'
   'D': 'double complex'
   'G': 'long double complex'
   'i': 'int'
   'l': 'long'
   'v': 'void'

If multiple kernel functions are given for a single ufunc, the one
which is used is determined by the standard ufunc mechanism. Kernel
functions that are listed first are also matched first against the
ufunc input types, so functions listed earlier take precedence.

In addition, versions with casted variables, such as d->f,D->F and
i->d are automatically generated.

There should be either a single header that contains all of the kernel
functions listed, or there should be one header for each kernel
function. Cython pxd files are allowed in addition to .h files.

Cython functions may use fused types, but the names in the list
should be the specialized ones, such as 'somefunc[float]'.

Function coming from C++ should have ``++`` appended to the name of
the header.

Floating-point exceptions inside these Ufuncs are converted to
special function errors --- which are separately controlled by the
user, and off by default, as they are usually not especially useful
for the user.


The C++ module
--------------
In addition to ``_ufuncs`` module, a second module ``_ufuncs_cxx`` is
generated. This module only exports function pointers that are to be
used when constructing some of the ufuncs in ``_ufuncs``. The function
pointers are exported via Cython's standard mechanism.

This mainly avoids build issues --- Python distutils has no way to
figure out what to do if you want to link both C++ and Fortran code in
the same shared library.

i    (   t   divisiont   print_functiont   absolute_importsjL  
_sf_error_test_function -- _sf_error_test_function: i->i   -- sf_error.pxd
sph_harm -- sph_harmonic: iidd->D, sph_harmonic_unsafe: dddd->D -- sph_harm.pxd, _legacy.pxd
_lambertw -- lambertw_scalar: Dld->D                       -- lambertw.pxd
wrightomega -- wrightomega : D->D                          -- _wright.h++
_ellip_harm -- ellip_harmonic: ddiiddd->d, ellip_harmonic_unsafe: ddddddd->d --_ellip_harm.pxd, _legacy.pxd
logit -- logitf: f->f, logit: d->d, logitl: g->g           -- _logit.h
expit -- expitf: f->f, expit: d->d, expitl: g->g           -- _logit.h
bdtrc -- bdtrc: iid->d, bdtrc_unsafe: ddd->d               -- cephes.h, _legacy.pxd
bdtr -- bdtr: iid->d, bdtr_unsafe: ddd->d                  -- cephes.h, _legacy.pxd
bdtri -- bdtri: iid->d, bdtri_unsafe: ddd->d               -- cephes.h, _legacy.pxd
binom -- binom: dd->d                                      -- orthogonal_eval.pxd
btdtr -- btdtr: ddd->d                                     -- cephes.h
btdtri -- incbi: ddd->d                                    -- cephes.h
fdtrc -- fdtrc: ddd->d                                     -- cephes.h
fdtr -- fdtr: ddd->d                                       -- cephes.h
fdtri -- fdtri: ddd->d                                     -- cephes.h
gdtrc -- gdtrc: ddd->d                                     -- cephes.h
gdtr -- gdtr: ddd->d                                       -- cephes.h
hyp0f1 -- _hyp0f1_real: dd->d, _hyp0f1_cmplx: dD->D        -- _hyp0f1.pxd
hyp2f1 -- hyp2f1: dddd->d, chyp2f1_wrap: dddD->D           -- cephes.h, specfun_wrappers.h
hyp1f1 -- hyp1f1_wrap: ddd->d, chyp1f1_wrap: ddD->D        -- specfun_wrappers.h
hyperu -- hypU_wrap: ddd->d                                -- specfun_wrappers.h
hyp2f0 -- hyp2f0: dddi*d->d, hyp2f0_unsafe: dddd*d->d      -- cephes.h, _legacy.pxd
hyp1f2 -- onef2: dddd*d->d                                 -- cephes.h
hyp3f0 -- threef0: dddd*d->d                               -- cephes.h
betainc -- incbet: ddd->d                                  -- cephes.h
betaincinv -- incbi: ddd->d                                -- cephes.h
nbdtrc -- nbdtrc: iid->d, nbdtrc_unsafe: ddd->d            -- cephes.h, _legacy.pxd
nbdtr -- nbdtr: iid->d, nbdtr_unsafe: ddd->d               -- cephes.h, _legacy.pxd
nbdtri -- nbdtri: iid->d, nbdtri_unsafe: ddd->d            -- cephes.h, _legacy.pxd
beta -- beta: dd->d                                        -- cephes.h
betaln -- lbeta: dd->d                                     -- cephes.h
cbrt -- cbrt: d->d                                         -- cephes.h
chdtrc -- chdtrc: dd->d                                    -- cephes.h
chdtr -- chdtr: dd->d                                      -- cephes.h
chdtri -- chdtri: dd->d                                    -- cephes.h
ellipeinc -- ellie: dd->d                                  -- cephes.h
ellipkinc -- ellik: dd->d                                  -- cephes.h
ellipe -- ellpe: d->d                                      -- cephes.h
ellipkm1 -- ellpk: d->d                                    -- cephes.h
eval_jacobi --      eval_jacobi[double]: dddd->d,     eval_jacobi[double complex]: dddD->D,     eval_jacobi_l: lddd->d -- orthogonal_eval.pxd
eval_sh_jacobi --   eval_sh_jacobi[double]: dddd->d,  eval_sh_jacobi[double complex]: dddD->D,  eval_sh_jacobi_l: lddd->d -- orthogonal_eval.pxd
eval_gegenbauer --  eval_gegenbauer[double]: ddd->d,  eval_gegenbauer[double complex]: ddD->D,  eval_gegenbauer_l: ldd->d -- orthogonal_eval.pxd
eval_chebyt --      eval_chebyt[double]: dd->d,       eval_chebyt[double complex]: dD->D,       eval_chebyt_l: ld->d -- orthogonal_eval.pxd
eval_chebyu --      eval_chebyu[double]: dd->d,       eval_chebyu[double complex]: dD->D,       eval_chebyu_l: ld->d -- orthogonal_eval.pxd
eval_chebyc --      eval_chebyc[double]: dd->d,       eval_chebyc[double complex]: dD->D,       eval_chebyc_l: ld->d -- orthogonal_eval.pxd
eval_chebys --      eval_chebys[double]: dd->d,       eval_chebys[double complex]: dD->D,       eval_chebys_l: ld->d -- orthogonal_eval.pxd
eval_sh_chebyt --   eval_sh_chebyt[double]: dd->d,    eval_sh_chebyt[double complex]: dD->D,    eval_sh_chebyt_l:ld->d -- orthogonal_eval.pxd
eval_sh_chebyu --   eval_sh_chebyu[double]: dd->d,    eval_sh_chebyu[double complex]: dD->D,    eval_sh_chebyu_l:ld->d -- orthogonal_eval.pxd
eval_legendre --    eval_legendre[double]: dd->d,     eval_legendre[double complex]: dD->D,     eval_legendre_l: ld->d -- orthogonal_eval.pxd
eval_sh_legendre -- eval_sh_legendre[double]: dd->d,  eval_sh_legendre[double complex]: dD->D,  eval_sh_legendre_l:ld->d -- orthogonal_eval.pxd
eval_genlaguerre -- eval_genlaguerre[double]: ddd->d, eval_genlaguerre[double complex]: ddD->D, eval_genlaguerre_l:ldd->d -- orthogonal_eval.pxd
eval_laguerre --    eval_laguerre[double]: dd->d,     eval_laguerre[double complex]: dD->D,     eval_laguerre_l:ld->d -- orthogonal_eval.pxd
eval_hermite  -- eval_hermite: ld->d                       -- orthogonal_eval.pxd
eval_hermitenorm -- eval_hermitenorm: ld->d                -- orthogonal_eval.pxd
exp10 -- exp10: d->d                                       -- cephes.h
exp2 -- exp2: d->d                                         -- cephes.h
gamma -- Gamma: d->d, cgamma: D->D                         -- cephes.h, _loggamma.pxd
_gammaln -- lgam: d->d, clngamma_wrap: D->D                -- cephes.h, specfun_wrappers.h
gammasgn -- gammasgn: d->d                                 -- c_misc/misc.h
i0 -- i0: d->d                                             -- cephes.h
i0e -- i0e: d->d                                           -- cephes.h
i1 -- i1: d->d                                             -- cephes.h
i1e -- i1e: d->d                                           -- cephes.h
gammaincc -- igamc: dd->d                                  -- cephes.h
gammainc -- igam: dd->d                                    -- cephes.h
gammaincinv -- gammaincinv: dd->d                          -- cephes.h
gammainccinv -- igami: dd->d                               -- cephes.h
iv -- iv: dd->d, cbesi_wrap: dD->D                         -- cephes.h, amos_wrappers.h
ive -- cbesi_wrap_e_real: dd->d, cbesi_wrap_e: dD->D       -- amos_wrappers.h
ellipj -- ellpj: dd*dddd->*i                               -- cephes.h
expn -- expn: id->d, expn_unsafe: dd->d                    -- cephes.h, _legacy.pxd
exp1 -- exp1_wrap: d->d, cexp1_wrap: D->D                  -- specfun_wrappers.h
expi -- expi_wrap: d->d, cexpi_wrap: D->D                  -- specfun_wrappers.h
kn -- cbesk_wrap_real_int: id->d, kn_unsafe: dd->d         -- cephes.h, _legacy.pxd
pdtrc -- pdtrc: id->d, pdtrc_unsafe: dd->d                 -- cephes.h, _legacy.pxd
pdtr -- pdtr: id->d, pdtr_unsafe: dd->d                    -- cephes.h, _legacy.pxd
pdtri -- pdtri: id->d, pdtri_unsafe: dd->d                 -- cephes.h, _legacy.pxd
yn -- yn: id->d, yn_unsafe: dd->d                          -- cephes.h, _legacy.pxd
smirnov -- smirnov: id->d, smirnov_unsafe: dd->d           -- cephes.h, _legacy.pxd
smirnovi -- smirnovi: id->d, smirnovi_unsafe: dd->d        -- cephes.h, _legacy.pxd
airy -- airy_wrap: d*dddd->*i, cairy_wrap: D*DDDD->*i      -- amos_wrappers.h
itairy -- itairy_wrap: d*dddd->*i                          -- specfun_wrappers.h
airye -- cairy_wrap_e_real: d*dddd->*i, cairy_wrap_e: D*DDDD->*i -- amos_wrappers.h
fresnel -- fresnl: d*dd->*i, cfresnl_wrap: D*DD->*i        -- cephes.h, specfun_wrappers.h
shichi -- shichi: d*dd->*i, cshichi: D*DD->*i              -- cephes.h, _sici.pxd
sici -- sici: d*dd->*i, csici: D*DD->*i                    -- cephes.h, _sici.pxd
itj0y0 -- it1j0y0_wrap: d*dd->*i                           -- specfun_wrappers.h
it2j0y0 -- it2j0y0_wrap: d*dd->*i                          -- specfun_wrappers.h
iti0k0 -- it1i0k0_wrap: d*dd->*i                           -- specfun_wrappers.h
it2i0k0 -- it2i0k0_wrap: d*dd->*i                          -- specfun_wrappers.h
j0 -- j0: d->d                                             -- cephes.h
y0 -- y0: d->d                                             -- cephes.h
j1 -- j1: d->d                                             -- cephes.h
y1 -- y1: d->d                                             -- cephes.h
jv -- cbesj_wrap_real: dd->d, cbesj_wrap: dD->D            -- amos_wrappers.h
jve -- cbesj_wrap_e_real: dd->d, cbesj_wrap_e: dD->D       -- amos_wrappers.h
yv -- cbesy_wrap_real: dd->d, cbesy_wrap: dD->D            -- amos_wrappers.h
yve -- cbesy_wrap_e_real: dd->d, cbesy_wrap_e: dD->D       -- amos_wrappers.h
k0 -- k0: d->d                                             -- cephes.h
k0e -- k0e: d->d                                           -- cephes.h
k1 -- k1: d->d                                             -- cephes.h
k1e -- k1e: d->d                                           -- cephes.h
kv -- cbesk_wrap_real: dd->d, cbesk_wrap: dD->D            -- amos_wrappers.h
kve -- cbesk_wrap_e_real: dd->d, cbesk_wrap_e: dD->D       -- amos_wrappers.h
hankel1 -- cbesh_wrap1: dD->D                              -- amos_wrappers.h
hankel1e -- cbesh_wrap1_e: dD->D                           -- amos_wrappers.h
hankel2 -- cbesh_wrap2: dD->D                              -- amos_wrappers.h
hankel2e -- cbesh_wrap2_e: dD->D                           -- amos_wrappers.h
ndtr -- ndtr: d->d, faddeeva_ndtr: D->D                    -- cephes.h, _faddeeva.h++
log_ndtr -- log_ndtr: d->d, faddeeva_log_ndtr: D->D        -- cephes.h, _faddeeva.h++
ndtri -- ndtri: d->d                                       -- cephes.h
psi -- digamma: d->d, cdigamma: D->D                       -- _digamma.pxd, _digamma.pxd
rgamma -- rgamma: d->d, crgamma: D->D                      -- cephes.h, _loggamma.pxd
round -- round: d->d                                       -- cephes.h
sindg -- sindg: d->d                                       -- cephes.h
cosdg -- cosdg: d->d                                       -- cephes.h
radian -- radian: ddd->d                                   -- cephes.h
tandg -- tandg: d->d                                       -- cephes.h
cotdg -- cotdg: d->d                                       -- cephes.h
log1p -- log1p: d->d, clog1p: D->D                         -- cephes.h, _cunity.pxd
expm1 -- expm1: d->d, cexpm1: D->D                         -- cephes.h, _cunity.pxd
cosm1 -- cosm1: d->d                                       -- cephes.h
spence -- spence: d->d, cspence: D-> D                     -- cephes.h, _spence.pxd
zetac -- zetac: d->d                                       -- cephes.h
struve -- struve_h: dd->d                                  -- misc.h
modstruve -- struve_l: dd->d                               -- misc.h
_struve_power_series -- struve_power_series:  ddi*d->d     -- misc.h
_struve_asymp_large_z -- struve_asymp_large_z: ddi*d->d    -- misc.h
_struve_bessel_series -- struve_bessel_series: ddi*d->d    -- misc.h
itstruve0 -- itstruve0_wrap: d->d                          -- specfun_wrappers.h
it2struve0 -- it2struve0_wrap: d->d                        -- specfun_wrappers.h
itmodstruve0 -- itmodstruve0_wrap: d->d                    -- specfun_wrappers.h
kelvin -- kelvin_wrap: d*DDDD->*i                          -- specfun_wrappers.h
ber -- ber_wrap: d->d                                      -- specfun_wrappers.h
bei -- bei_wrap: d->d                                      -- specfun_wrappers.h
ker -- ker_wrap: d->d                                      -- specfun_wrappers.h
kei -- kei_wrap: d->d                                      -- specfun_wrappers.h
berp -- berp_wrap: d->d                                    -- specfun_wrappers.h
beip -- beip_wrap: d->d                                    -- specfun_wrappers.h
kerp -- kerp_wrap: d->d                                    -- specfun_wrappers.h
keip -- keip_wrap: d->d                                    -- specfun_wrappers.h
_zeta -- zeta: dd->d                                       -- cephes.h
kolmogorov -- kolmogorov: d->d                             -- cephes.h
kolmogi -- kolmogi: d->d                                   -- cephes.h
besselpoly -- besselpoly: ddd->d                           -- c_misc/misc.h
btdtria -- cdfbet3_wrap: ddd->d                            -- cdf_wrappers.h
btdtrib -- cdfbet4_wrap: ddd->d                            -- cdf_wrappers.h
bdtrik -- cdfbin2_wrap: ddd->d                             -- cdf_wrappers.h
bdtrin -- cdfbin3_wrap: ddd->d                             -- cdf_wrappers.h
chdtriv -- cdfchi3_wrap: dd->d                             -- cdf_wrappers.h
chndtr -- cdfchn1_wrap: ddd->d                             -- cdf_wrappers.h
chndtrix -- cdfchn2_wrap: ddd->d                           -- cdf_wrappers.h
chndtridf -- cdfchn3_wrap: ddd->d                          -- cdf_wrappers.h
chndtrinc -- cdfchn4_wrap: ddd->d                          -- cdf_wrappers.h
fdtridfd -- cdff4_wrap: ddd->d                             -- cdf_wrappers.h
ncfdtr -- cdffnc1_wrap: dddd->d                            -- cdf_wrappers.h
ncfdtri -- cdffnc2_wrap: dddd->d                           -- cdf_wrappers.h
ncfdtridfn -- cdffnc3_wrap: dddd->d                        -- cdf_wrappers.h
ncfdtridfd -- cdffnc4_wrap: dddd->d                        -- cdf_wrappers.h
ncfdtrinc -- cdffnc5_wrap: dddd->d                         -- cdf_wrappers.h
gdtrix -- cdfgam2_wrap: ddd->d                             -- cdf_wrappers.h
gdtrib -- cdfgam3_wrap: ddd->d                             -- cdf_wrappers.h
gdtria -- cdfgam4_wrap: ddd->d                             -- cdf_wrappers.h
nbdtrik -- cdfnbn2_wrap: ddd->d                            -- cdf_wrappers.h
nbdtrin -- cdfnbn3_wrap: ddd->d                            -- cdf_wrappers.h
nrdtrimn -- cdfnor3_wrap: ddd->d                           -- cdf_wrappers.h
nrdtrisd -- cdfnor4_wrap: ddd->d                           -- cdf_wrappers.h
pdtrik -- cdfpoi2_wrap: dd->d                              -- cdf_wrappers.h
stdtr -- cdft1_wrap: dd->d                                 -- cdf_wrappers.h
stdtrit -- cdft2_wrap: dd->d                               -- cdf_wrappers.h
stdtridf -- cdft3_wrap: dd->d                              -- cdf_wrappers.h
nctdtr -- cdftnc1_wrap: ddd->d                             -- cdf_wrappers.h
nctdtrit -- cdftnc2_wrap: ddd->d                           -- cdf_wrappers.h
nctdtridf -- cdftnc3_wrap: ddd->d                          -- cdf_wrappers.h
nctdtrinc -- cdftnc4_wrap: ddd->d                          -- cdf_wrappers.h
tklmbda -- tukeylambdacdf: dd->d                           -- cdf_wrappers.h
mathieu_a -- cem_cva_wrap: dd->d                           -- specfun_wrappers.h
mathieu_b -- sem_cva_wrap: dd->d                           -- specfun_wrappers.h
mathieu_cem -- cem_wrap: ddd*dd->*i                        -- specfun_wrappers.h
mathieu_sem -- sem_wrap: ddd*dd->*i                        -- specfun_wrappers.h
mathieu_modcem1 -- mcm1_wrap: ddd*dd->*i                   -- specfun_wrappers.h
mathieu_modcem2 -- mcm2_wrap: ddd*dd->*i                   -- specfun_wrappers.h
mathieu_modsem1 -- msm1_wrap: ddd*dd->*i                   -- specfun_wrappers.h
mathieu_modsem2 -- msm2_wrap: ddd*dd->*i                   -- specfun_wrappers.h
lpmv -- pmv_wrap: ddd->d                                   -- specfun_wrappers.h
pbwa -- pbwa_wrap: dd*dd->*i                               -- specfun_wrappers.h
pbdv -- pbdv_wrap: dd*dd->*i                               -- specfun_wrappers.h
pbvv -- pbvv_wrap: dd*dd->*i                               -- specfun_wrappers.h
pro_cv -- prolate_segv_wrap: ddd->d                        -- specfun_wrappers.h
obl_cv -- oblate_segv_wrap: ddd->d                         -- specfun_wrappers.h
pro_ang1_cv -- prolate_aswfa_wrap: ddddd*dd->*i            -- specfun_wrappers.h
pro_rad1_cv -- prolate_radial1_wrap: ddddd*dd->*i          -- specfun_wrappers.h
pro_rad2_cv -- prolate_radial2_wrap: ddddd*dd->*i          -- specfun_wrappers.h
obl_ang1_cv -- oblate_aswfa_wrap: ddddd*dd->*i             -- specfun_wrappers.h
obl_rad1_cv -- oblate_radial1_wrap: ddddd*dd->*i           -- specfun_wrappers.h
obl_rad2_cv -- oblate_radial2_wrap: ddddd*dd->*i           -- specfun_wrappers.h
pro_ang1 -- prolate_aswfa_nocv_wrap: dddd*d->d             -- specfun_wrappers.h
pro_rad1 -- prolate_radial1_nocv_wrap: dddd*d->d           -- specfun_wrappers.h
pro_rad2 -- prolate_radial2_nocv_wrap: dddd*d->d           -- specfun_wrappers.h
obl_ang1 -- oblate_aswfa_nocv_wrap: dddd*d->d              -- specfun_wrappers.h
obl_rad1 -- oblate_radial1_nocv_wrap: dddd*d->d            -- specfun_wrappers.h
obl_rad2 -- oblate_radial2_nocv_wrap: dddd*d->d            -- specfun_wrappers.h
modfresnelp -- modified_fresnel_plus_wrap: d*DD->*i        -- specfun_wrappers.h
modfresnelm -- modified_fresnel_minus_wrap: d*DD->*i       -- specfun_wrappers.h
wofz -- faddeeva_w: D->D                                   -- _faddeeva.h++
erfc -- erfc: d->d, faddeeva_erfc: D->D                    -- cephes.h, _faddeeva.h++
erf -- erf: d->d, faddeeva_erf: D->D                       -- cephes.h, _faddeeva.h++
dawsn -- faddeeva_dawsn: d->d, faddeeva_dawsn_complex: D->D -- _faddeeva.h++
erfcx -- faddeeva_erfcx: d->d, faddeeva_erfcx_complex: D->D -- _faddeeva.h++
erfi -- faddeeva_erfi: d->d, faddeeva_erfi_complex: D->D   -- _faddeeva.h++
xlogy -- xlogy[double]: dd->d, xlogy[double_complex]: DD->D -- _xlogy.pxd
xlog1py -- xlog1py[double]: dd->d, xlog1py[double_complex]: DD->D   -- _xlogy.pxd
poch -- poch: dd->d                                        -- c_misc/misc.h
boxcox -- boxcox: dd->d                                    -- _boxcox.pxd
boxcox1p -- boxcox1p: dd->d                                -- _boxcox.pxd
inv_boxcox -- inv_boxcox: dd->d                            -- _boxcox.pxd
inv_boxcox1p -- inv_boxcox1p: dd->d                        -- _boxcox.pxd
entr -- entr: d->d                                         -- _convex_analysis.pxd
kl_div -- kl_div: dd->d                                    -- _convex_analysis.pxd
rel_entr -- rel_entr: dd->d                                -- _convex_analysis.pxd
huber -- huber: dd->d                                      -- _convex_analysis.pxd
pseudo_huber -- pseudo_huber: dd->d                        -- _convex_analysis.pxd
exprel -- exprel: d->d                                     -- _exprel.pxd
_spherical_yn -- spherical_yn_real: ld->d, spherical_yn_complex: lD->D -- _spherical_bessel.pxd
_spherical_jn -- spherical_jn_real: ld->d, spherical_jn_complex: lD->D -- _spherical_bessel.pxd
_spherical_in -- spherical_in_real: ld->d, spherical_in_complex: lD->D -- _spherical_bessel.pxd
_spherical_kn -- spherical_kn_real: ld->d, spherical_kn_complex: lD->D -- _spherical_bessel.pxd
_spherical_yn_d -- spherical_yn_d_real: ld->d, spherical_yn_d_complex: lD->D -- _spherical_bessel.pxd
_spherical_jn_d -- spherical_jn_d_real: ld->d, spherical_jn_d_complex: lD->D -- _spherical_bessel.pxd
_spherical_in_d -- spherical_in_d_real: ld->d, spherical_in_d_complex: lD->D -- _spherical_bessel.pxd
_spherical_kn_d -- spherical_kn_d_real: ld->d, spherical_kn_d_complex: lD->D -- _spherical_bessel.pxd
loggamma -- loggamma: D->D                                 -- _loggamma.pxd
_sinpi -- dsinpi: d->d, csinpi: D->D                       -- _trig.pxd
_cospi -- dcospi: d->d, ccospi: D->D                       -- _trig.pxd
_lgam1p -- lgam1p: d->d                                    -- cephes.h
_lanczos_sum_expg_scaled -- lanczos_sum_expg_scaled: d->d  -- cephes.h
_log1pmx -- log1pmx: d->d                                  -- cephes.h
_igam_fac -- igam_fac: dd->d                               -- cephes.h
s~   # This file is automatically generated by generate_ufuncs.py.
# Do not edit manually!
include "_ufuncs_extra_code_common.pxi"
s!   include "_ufuncs_extra_code.pxi"
s   #
# Aliases
#
jn = jv
sV   # This file is automatically generated by generate_ufuncs.py.
# Do not edit manually!
s6  # This file is automatically generated by generate_ufuncs.py.
# Do not edit manually!
"""
.. highlight:: cython

================================
Cython API for Special Functions
================================

Scalar, typed versions of many of the functions in ``scipy.special``
can be accessed directly from Cython; the complete list is given
below. Functions are overloaded using Cython fused types so their
names match their ufunc counterpart. The module follows the following
conventions:

- If a function's ufunc counterpart returns multiple values, then the
  function returns its outputs via pointers in the final arguments
- If a function's ufunc counterpart returns a single value, then the
  function's output is returned directly.

The module is usable from Cython via::

    cimport scipy.special.cython_special

Error Handling
==============

Functions can indicate an error by returning ``nan``; however they
cannot emit warnings like their counterparts in ``scipy.special``.

Available Functions
===================

FUNCLIST
"""
include "_cython_special.pxi"
Nt   add_newdocst   floatt   ft   doublet   ds   long doublet   gs   float complext   Fs   double complext   Ds   long double complext   Gt   intt   it   longt   lt   voidt   vt	   npy_floatt
   npy_doublet   npy_longdoublet
   npy_cfloatt   npy_cdoublet   npy_clongdoublet   npy_intt   npy_longt	   NPY_FLOATt
   NPY_DOUBLEt   NPY_LONGDOUBLEt
   NPY_CFLOATt   NPY_CDOUBLEt   NPY_CLONGDOUBLEt   NPY_INTt   NPY_LONGs   d*dddds   D*DDDDt   airyt   ddt   betat   erft   exprelt   gammat   dDt   jvt   loggammat   logitt   psic         C` s   |  j  d d  S(   Nt    t   _(   t   replace(   t   arg(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt
   underscore  s    c         C` s    g  |  D] } d j  |  ^ q S(   Nt   ilfdgFDG(   t   index(   t   ct   x(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt
   cast_order  s    t   NPY_NANt
   0xbad0bad0c      
   C` s  t  |   t  |  k r' t d   n  t  |  t  |  k rw | d k od t  |  d t  |  k rw t d   n  d | |  | | | f } d | } | d 7} | d 7} | d	 7} x. t t  |   D] } | d
 | | f 7} q Wx8 t t  |   D]$ } | d | | t  |  f 7} q Wg  } g  }	 g  }
 xY t t  |    D]E } | j t |  |  |	 j d t |  | t | | | f  qIWt  |  d t  |  k rd } |
 j |  | d t | f 7} n d } xm t |  D]_ \ } } | d t | | | f 7} | j d t |  |	 j d | |  |
 j |  qW| d 7} t  |  d t  |  k r~d } n d } d | t | d j |  d j |	  f } g  } xu t t  |    D]a } | | |  | f t k rd t |  | t | | | t | | | f } | j |  qqW| r| d d j |  7} | d | 7} | d 7} | d 7} xF t |
  D]+ \ } } | d | t | t | f 7} qzWn
 | | 7} x t t	 | |
   D] \ } \ } } | | f t k rj| d | t | | f 7} | d t | | t | | f 7} | d 7} | d  7} | d! t | | t | t | f 7} q| d" t | | t | | f 7} qWx. t t  |   D] } | d# | | f 7} qWx8 t t  |   D]$ } | d$ | | t  |  f 7} qW| d% 7} | | f S(&   s  
    Generate a UFunc loop function that calls a function given as its
    data parameter with the specified input and output arguments and
    return value.

    This function can be passed to PyUFunc_FromFuncAndData.

    Parameters
    ----------
    func_inputs, func_outputs, func_retval : str
        Signature of the function to call, given as type codes of the
        input, output and return value arguments. These 1-character
        codes are given according to the CY_TYPES and TYPE_NAMES
        lists above.

        The corresponding C function signature to be called is:

            retval func(intype1 iv1, intype2 iv2, ..., outtype1 *ov1, ...);

        If len(ufunc_outputs) == len(func_outputs)+1, the return value
        is treated as the first output argument. Otherwise, the return
        value is ignored.

    ufunc_inputs, ufunc_outputs : str
        Ufunc input and output signature.

        This does not have to exactly match the function signature,
        as long as the type casts work out on the C level.

    Returns
    -------
    loop_name
        Name of the generated loop function.
    loop_body
        Generated C code for the loop.

    s2   Function and ufunc have different number of inputsR   i   s-   Function retval and ufunc outputs don't matchs   loop_%s_%s_%s_As_%s_%ssT   cdef void %s(char **args, np.npy_intp *dims, np.npy_intp *steps, void *data) nogil:
s$       cdef np.npy_intp i, n = dims[0]
s(       cdef void *func = (<void**>data)[0]
s4       cdef char *func_name = <char*>(<void**>data)[1]
s       cdef char *ip%d = args[%d]
s       cdef char *op%d = args[%d]
s   <%s>(<%s*>ip%d)[0]s       cdef %s ov0
i    s       cdef %s ov%d
s   %s *s   &ov%ds       for i in range(n):
s   ov0 = t    s&           %s(<%s(*)(%s) nogil>func)(%s)
s   , s$   <%s>(<%s*>ip%d)[0] == (<%s*>ip%d)[0]s           if %s:
s    and s       s           else:
sQ               sf_error.error(func_name, sf_error.DOMAIN, "invalid input argument")
s               ov%d = <%s>%s
s           if ov%d == <%s>ov%d:
s'               (<%s *>op%d)[0] = <%s>ov%d
sI               sf_error.error(func_name, sf_error.DOMAIN, "invalid output")
s%               (<%s *>op%d)[0] = <%s>%s
s#           (<%s *>op%d)[0] = <%s>ov%d
s           ip%d += steps[%d]
s           op%d += steps[%d]
s"       sf_error.check_fpe(func_name)
(
   t   lent
   ValueErrort   ranget   appendt   CY_TYPESt	   enumeratet   joint   DANGEROUS_DOWNCASTt	   NAN_VALUEt   zip(   t   func_inputst   func_outputst   func_retvalt   ufunc_inputst   ufunc_outputst   namet   bodyt   jt   ftypest   fvarst   outtypecodest	   func_jofft   outtypet   rvt   funcallt   input_checkst   chkt   fouttype(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   generate_loop  s    ')



"	
	)

 
(

# "
c         C` sh   t  d   |   } |  d } d | d g } x | D] } | j d |  q4 Wd j |  } | | f S(   s   
    Generate name of and cython code for a fused type.

    Parameters
    ----------
    typecodes : str
        Valid inputs to CY_TYPES (i.e. f, d, g, ...).

    c         S` s   t  |  S(   N(   R>   (   R5   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   <lambda>r  s    t	   _number_ts   ctypedef fused t   :s       s   
(   t   mapR=   R@   (   t   codest   cytypesRI   t   declarationt   cytype(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   generate_fused_typeh  s    

c         C` s2  d } g  g  g  } } } | j  d  } t |  d k rR | d } | d } n | d } d } g  g  }	 }
 xS t |  D]E \ } } d j |  } |	 j |  |
 j d j t | |   q| Wd	 j d
 j |
   } | j |  | j | d  g  } xf t |  D]X \ } } d j |  } | j d j |   d j t | |  } | j | |  qW| j | d  | j d | d  d j |  | d  } d j |  | d  } d j | |  } d j | | |  } | j | d |  d
 j |	   } | j | |  d
 j |	 |   } | | f S(   NR-   i   t   *i   i    R9   s   x{}s   {} {}s   def {{}}(int N, {}):s   , s
   cdef int ns   y{}s   &{}s
   cdef {} {}s   for n in range(N):i   s   {}({})s   _bench_{}_{}_{}t   pyt   cys   
s   _ufuncs.s       (   t   splitR:   R?   t   formatR=   R>   R@   (   RI   R[   t   tabt   topt   middlet   endt   tmpt   incodest   outcodest   inargst   inargs_and_typest   nt   codeR0   t   linet   outargst   pyfunct   cyfunct
   pytemplatet
   cytemplatet   pybencht   cybench(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   generate_bench{  s>    

!""c         C` s  d } d j  |   g } x | D] } | j d  \ } } | j d  } t t d   | d   } t |  d k r t d	   | d  } | j |  n  t | }	 d
 j  |	 |  d j |   }
 | j d | |
  q Wd j  | d  | d <d j |  } | S(   NR-   i   s!   - :py:func:`~scipy.special.{}`::
s   ->R`   c         S` s   t  |  S(   N(   R>   (   R5   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyRW     s    i    i   c         S` s   d j  t |   S(   Ns   {} *(   Rd   R>   (   R5   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyRW     s    s	   {} {}({})s   , i   s   {}
is   
s       (	   Rd   Rc   t   listRZ   R:   t   extendR>   R@   R=   (   RI   t   specsRe   t   doct   specRj   Rk   t   intypest   typesRP   Rp   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   generate_doc  s    
c         C` s   d j  |   } | S(   s0   Cast a cython double complex to a numpy cdouble.s1   _complexstuff.npy_cdouble_from_double_complex({})(   Rd   (   t   vart   res(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   npy_cdouble_from_double_complex  s    c         C` s   d j  |   } | S(   s0   Cast a numpy cdouble to a cython double complex.s1   _complexstuff.double_complex_from_npy_cdouble({})(   Rd   (   R   R   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   double_complex_from_npy_cdouble  s    c   	      c` s   d g } d |  k p d |  k sU | g  | D]  \ } } | d | d f ^ q+ } n  xo | D]g \ } } |  } | } xA t  | |  D]0 \ } } | j | |  } | j | |  } q W| | f Vq\ Wd S(   s.  
    Generate variants of UFunc signatures, by changing variable types,
    within the limitation that the corresponding C types casts still
    work out.

    This does not generate all possibilities, just the ones required
    for the ufunc to work properly with the most common data types.

    Parameters
    ----------
    inputs, outputs : str
        UFunc input and output signature strings

    Yields
    ------
    new_input, new_output : str
        Modified input and output strings.
        Also the original input/output pair is yielded.

    R   R   R(   t   fFN(   R   R   (   RC   R/   (	   t   inputst   outputst   mapst   at   bt   srct   dstt
   new_inputst   new_outputs(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   iter_variants  s    	4t   Funcc           B` sV   e  Z d  Z d   Z d   Z d   Z e d  Z e d e d  Z	 e
 d    Z RS(   s.   
    Base class for Ufunc and FusedFunc.

    c         C` s+   | |  _  |  j | |  |  _ i  |  _ d  S(   N(   RI   t   _parse_signaturest
   signaturest   function_name_overrides(   t   selfRI   R   t   headers(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   __init__  s    	c         C` s   g  | j  d  D] } | j   r | j   ^ q } g  | j  d  D] } | j   rD | j   ^ qD } t |  d k r | t |  } n  t |  t |  k r t d |  j | | f   n  g  t | |  D]" \ } } |  j |  | f ^ q S(   Nt   ,i   s<   %s: Number of headers and signatures doesn't match: %r -- %r(   Rc   t   stripR:   R;   RI   RC   t   _parse_signature(   R   t   sigs_strt   headers_strR5   t   sigsR   t   h(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyR     s    44c         C` s   t  j d |  } | r g  | j   D] } | j   ^ q% \ } } } } | j d  d k rz t d |  j | f   n  | | | | f St  j d |  } | r g  | j   D] } | j   ^ q \ } } } | | d | f St d |  j | f   d  S(   NsG   \s*(.*):\s*([fdgFDGil]*)\s*\*\s*([fdgFDGil]*)\s*->\s*([*fdgFDGil]*)\s*$R`   i   s   %s: Invalid signature: %rs1   \s*(.*):\s*([fdgFDGil]*)\s*->\s*([fdgFDGil]?)\s*$R9   (   t   ret   matcht   groupsR   t   countR;   RI   (   R   t   sigt   mR5   t   funct   inargt   outargt   ret(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyR     s    1.c         C` s,  g  } x|  j  D]\ } } } } } | j d d  } g  | D] } t | ^ q> g  | D] } t | d ^ qX }	 g  | D] } t | ^ qz g  | D] } t | d ^ q }
 d t | d j |	  f } | j d  r | r | d } n d t | d j |
  f } | j | | | | f  q W| S(	   NR`   R9   s    *s
   %s (*)(%s)s   , R   t   nogils   %s (*)(%s) nogil(   R   R/   t   C_TYPESR>   R@   t   endswithR=   (   R   t   nptypes_for_ht
   prototypest	   func_nameR   R   R   t   headerR5   t   c_argst   cy_argst   c_protot   cy_proto(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   get_prototypes  s    ""t   _func_c         C` s   | r+ | |  j  k r+ |  j  | } d } n  t j d |  } | rX | j   \ } } n | d } } | r d | | | j d d  f Sd | | f Sd  S(   NR9   s   ^(.*?)(\[.*\])$s   %s%s%sR-   R.   s   %s%s(   R   R   R   R   R/   (   R   t   c_namet   specializedt   prefixt   overrideR   t   c_base_namet
   fused_part(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   cython_func_name  s    	c         C` s   g  } | j    } | j   x | D]} } | j   } | sA q# n  t j d |  } | sl t d |   n  | j |  | j d  | j d  | j d    q# W| S(   Ns$   ^([a-z0-9_]+)\s*--\s*(.*?)\s*--(.*)$s   Unparseable line %ri   i   i   (   t
   splitlinest   sortR   R   R   R;   R=   t   group(   t   clst	   ufunc_strt   ufuncst   linesRp   R   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt	   parse_all1  s    
8(   t   __name__t
   __module__t   __doc__R   R   R   t   FalseR   t   TrueR   t   classmethodR   (    (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyR     s   		
	t   Ufuncc           B` s)   e  Z d  Z d   Z d   Z d   Z RS(   s  
    Ufunc signature, restricted format suitable for special functions.

    Parameters
    ----------
    name
        Name of the ufunc to create
    signature
        String of form 'func: fff*ff->f, func2: ddd->*i' describing
        the C-level functions and types of their input arguments
        and return values.

        The syntax is 'function_name: inputparams*outputparams->output_retval*ignored_retval'

    Attributes
    ----------
    name : str
        Python name for the Ufunc
    signatures : list of (func_name, inarg_spec, outarg_spec, ret_spec, header_name)
        List of parsed signatures
    doc : str
        Docstring, obtained from add_newdocs
    function_name_overrides : dict of str->str
        Overrides for the function names in signatures

    c         C` ss   t  t |   j | | |  t j d |  |  _ |  j d  k rT t d |   n  t j	 |  j  j
   |  _ d  S(   Ns   scipy.special.s   No docstring for ufunc %r(   t   superR   R   R   t   getR|   t   NoneR;   t   textwrapt   dedentR   (   R   RI   R   R   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyR   ^  s
    c   
   	   ` s  d   d   t    g          f d   } x  j D] \ } } } } } t j d d |  | } | j d d  }  d  k r t |   t |   n  t t | |   d \ }	 } | | | | | |	 |  qC Wx  j D]y \ } } } } } t j d d |  | } | j d d  } x6 t | |  D]% \ }	 } | | | | | |	 |  q@Wq W j	 d d       f S(   Nc   	      ` s   |  k r d  S j  |  |  | | f } d | k rT t d  j | f   n  t |   k sx t |   k r t d  j |   f   n  t | | | | |  \ } } |   | < j |  | | | f  d  S(   NR   s   %s: void signature %rs6   %s: signature %r does not have %d/%d input/output args(   t   addR;   RI   R:   RV   R=   (	   R   R   R   R   t   inpt   outpR   t	   loop_namet   loop(   t	   all_loopst	   inarg_numt
   outarg_numt   seenR   t   variants(    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   add_variantl  s    $	
s   \*.*R9   R`   i    t   keyc         S` s   t  |  d  S(   Ni   (   R6   (   R   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyRW     s    (
   R   t   setR   R   t   subR/   R:   Ry   R   R   (
   R   R   R   R   R   R   R   R   R   R   (    (   R   R   R   R   R   R   s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   _get_signatures_and_loopse  s(    	!c      	   C` s  d } |  j  |  \ } } } g  } g  } g  } xx | D]p \ }	 }
 } } x | D] } | j t |  qP Wx | D] } | j t |  qr W| j |
  | j |	  q7 W| d |  j t |  f 7} | d |  j d t |  f 7} | d |  j t |  f 7} | d |  j t |  f 7} | d |  j |  j j d d	  j d
 d  j d d  f 7} x4 t |  D]& \ } } | d |  j | | f 7} qnWx4 t |  D]& \ } } | d |  j | | f 7} qWx` t |  D]R \ } } | d |  j | |  j | d t	 f 7} | d |  j | |  j f 7} qWx: t |  D], \ } } | d |  j | |  j | f 7} q?W| d t |  | | | | f j d |  j  7} | S(   NR9   s2   cdef np.PyUFuncGenericFunction ufunc_%s_loops[%d]
s   cdef void *ufunc_%s_ptr[%d]
i   s   cdef void *ufunc_%s_data[%d]
s   cdef char ufunc_%s_types[%d]
s&   cdef char *ufunc_%s_doc = (
    "%s")
s   \s   \\t   "s   \"s   
s	   \n"
    "s3   ufunc_%s_loops[%d] = <np.PyUFuncGenericFunction>%s
s   ufunc_%s_types[%d] = <char>%s
s   ufunc_%s_ptr[2*%d] = <void*>%s
R   s,   ufunc_%s_ptr[2*%d+1] = <void*>(<char*>"%s")
s(   ufunc_%s_data[%d] = &ufunc_%s_ptr[2*%d]
so   @ = np.PyUFunc_FromFuncAndData(ufunc_@_loops, ufunc_@_data, ufunc_@_types, %d, %d, %d, 0, "@", ufunc_@_doc, 0)
t   @(
   R   R=   t
   TYPE_NAMESRI   R:   R|   R/   R?   R   R   (   R   R   t   toplevelR   R   R   t   loopst   funcsR   R   R   R   R   R5   RK   t   functiont   typeR   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   generate  sH    !2(   R   R   R   R   R   R   (    (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyR   C  s   		1t	   FusedFuncc           B` s   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z RS(   s_   
    Generate code for a fused-type special function that can be
    cimported in cython.

    c         C` s   t  t |   j | | |  d |  j |  _ |  j   \ |  _ |  _ t   |  _	 |  j
 |  j  \ |  _ } |  j	 j |  |  j
 |  j  \ |  _ } |  j	 j |  |  j   \ |  _ |  _ d  S(   Ns(   See the documentation for scipy.special.(   R   R   R   RI   R|   t
   _get_codesRj   Rk   R   t   fused_typest
   _get_typesR~   t   updatet   outtypest	   _get_varst   invarst   outvars(   R   RI   R   R   t   infused_typest   outfused_types(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyR     s    c         ` s  d \ } } g  g  } } x |  j D] \ } } } } } t j d d |  | }	 | d  k rx t |  } t |	  } n  t t | |	   d \ }
 }	 | j |
  | j |	  q# Wg  } xR t |  D]D   t	 t
   f d   |   } | j   | j d j |   q Wg  } xR t |  D]D   t	 t
   f d   |   } | j   | j d j |   q#Wt |  t |  f S(   Ns   \*.*R9   i    c         ` s   |    S(   N(    (   R5   (   Rn   (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyRW     s    c         ` s   |    S(   N(    (   R5   (   Rn   (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyRW     s    (   NN(   R   R   R   R   R:   Ry   R   R=   R<   t   uniqueRZ   R   R@   t   tuple(   R   R   R   t   all_inpt   all_outpR.   R   R   R   R   R   Rj   R[   Rk   (    (   Rn   s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyR     s*    

c         C` s   g  } t    } xl | D]d } t |  d k rH | j t | | f  q t |  \ } } | j |  | j | | f  q W| | f S(   Ni   (   R   R:   R=   R>   R_   R   (   R   R[   t	   all_typesR   Ro   t
   fused_typet   dec(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyR     s    	c         C` s   g  } x3 t  t |  j   D] } | j d j |   q Wg  } x3 t  t |  j   D] } | j d j |   qX W| | f S(   Ns   x{}s   y{}(   R<   R:   R~   R=   Rd   R   (   R   R   Rn   R   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyR     s    c   
      C` s   g  } t    } xz t | |  D]i \ \ } } } t |  d k rI q n  | | k r | j d j | t t |    | j |  q q W| r | d k r d j | d j |   }	 n! | r | d k r d }	 n d }	 |	 S(   s_   Generate an if/elif/else clause that selects a specialization of
        fused types.

        i   s   {} is {}t   elses   {} {}:s    and s   else:N(
   R   RC   R:   R=   Rd   R1   R>   R   R@   R   (
   R   R   R[   t   adverbt   clausesR   t   typt   typcodeRo   Rp   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   _get_conditional  s    	"#	c         C` sb   g  } xU t  |  D]G \ } } |  j | } | rM | d k rM t |  } n  | j |  q W| S(   sw   Generate pure input variables to a specialization,
        i.e. variables that aren't used to return a value.

        s   double complex(   R?   R   R   R=   (   R   R~   R4   t
   incallvarsRn   t   intypeR   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   _get_incallvars  s    c         C` s   g  g  g  } } } t  |  j  t  |  } |  j | } x t t | |   D] \ } \ }	 }
 | r |
 d k r d j |  } | j |  | j d j |   t |  } | j d j |	 |   qP | j d j |	   qP W| | | f S(   sn   Generate output variables to a specialization,
        i.e. pointers that are used to return values.

        s   double complexs   tmp{}s   &{}s
   {}[0] = {}s   {}(   R:   R   R?   RC   Rd   R=   R   (   R   R   R4   t   outcallvarst   tmpvarst   castst   startR   Rn   R   RP   Ri   t   tmpcast(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   _get_outcallvars*  s    (c         ` s  d   g    d g } } t    } x t |  j |  j |  j  D] \ } } } t |  d k r d j | t |  } | j d   |  q? | } | \ }	 }
 |	 | k r? | j |  | j	 |	  q? q? W| s | Sg  } x' | D] } | \ }
 } | j |  q Wt
 |  } t t d   |   } t j |  d } x@t t j |    D])\ } } g  g  } } x t |  D] \ } } | | } | j t t |   xV t |  j  D]E \ } } |  j | | k rd j | t |  } | j |  qqWqzW| d k rd	 } n | | k r.d
 } n d } |  j | | |  } | j d   |  | j t   f d   |   qTW| S(   sn   Set all variables to nan for specializations of fused types for
        which don't have signatures.

        R-   i   s   else:i   s
   {}[0] = {}i   c         S` s
   t  |   S(   N(   R:   (   R5   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyRW   \  s    i    t   ifR   t   elifc         ` s   d   |  S(   Ni   (    (   R5   (   Re   (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyRW   o  s    s       (   R   RC   R   R   Rk   R:   Rd   RB   R=   R   R   Ry   RZ   t   numpyt   productR?   t	   itertoolsR1   R>   R   Rz   (   R   R   R   R   t   outvarRP   Ro   Rp   R   RI   R.   t	   all_codesR[   t   codelenst   lastR   t   fused_codest   decsRn   R   t   cond(    (   Re   s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   _get_nan_decs?  sN    	+"
		#c         C` sW   d } t  |  } | j   g  } x. | D]& } d j |  } | j | |  q) W| S(   sQ   Generate the declarations of any necessary temporary
        variables.

        R-   i   s   cdef npy_cdouble {}s       (   Ry   R   Rd   R=   (   R   t   all_tmpvarsRe   R  t   tmpdecst   tmpvarRp   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   _get_tmp_decsr  s    
c         C` sd  d } g  g  } } xB t  |  j |  j  D]+ \ \ } } } | j d j | |   q) Wd j |  j d j |   } | j |  xL t  |  j |  j  D]5 \ \ } } }	 d j | |	  } | j | |  q Wt	 d   |  j  }
 d j |  j d j |  j  d j |
   } | j | |  d	 j d j |  j   } | j | |  d
 j |  } | S(   sa   Generate a python wrapper for functions which pass their
        arguments as pointers.

        R-   i   s   {} {}s   def _{}_pywrap({}):s   , s
   cdef {} {}c         S` s   d j  |   S(   Ns   &{}(   Rd   (   R5   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyRW     s    s
   {}({}, {})s	   return {}s   
s       (
   RC   R~   R   R=   Rd   RI   R@   R   R   RZ   (   R   Re   RJ   t   callvarsR  R.   t   invarRp   RP   R  t   addr_outvars(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   _get_python_wrap  s"    ((c      
   C` s  d } | \ } } } } } | j  d d  } | j  d d  } | j  d d  } | j d  ri t }	 n t }	 | j d  r t }
 n t }
 t t d   |   } t t d   |   } t j d	 d
 |  } | s d } n  t | } |
 r%d j	 |  } d j	 | d j
 | |  |  } n |  j | d t } | d k rOd } n d } |  j |  j | |  } | r| | g } d | } n g  } | } | | | | | | | |	 | | f
 S(   s4   Generate code common to all the _generate_* methods.R-   i   R   R   R   s   ++c         S` s   t  |  S(   N(   R>   (   R5   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyRW     s    c         S` s   t  |  S(   N(   R>   (   R5   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyRW     s    s   \*.*R9   R   s$   scipy.special._ufuncs_cxx._export_{}s   (<{}(*)({}) nogil>{})s   , R   i    R	  R
  i   s       (   R/   R   R   R   Ry   RZ   R   R   R>   Rd   R@   R   R   R~   (   R   t   signumR   Re   R   Rj   Rk   t   retcodeR   R4   t   cppR~   R   t   rettypeR   R  R   t   sp(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   _get_common  sB    			
	c         C` s  d } g  g  } } x t  |  j  D] \ } } |  j | |  \
 } } } }	 }
 } } } } } | j |  |  j |
 |  } d j | d j |   } | r | d k r t |  } n  | d j |  } | j |  d j | |	  } | j |  q# Wt	 |  d k r%| j | d	  |  j
 d
 \ } } t	 |  d } t	 |  d k rd j t |  } | j d | |  q%x t  |  D] \ } } | d
 k rd } n | | k rd } n d } |  j |  j
 | |  } | j d | |  d j t |  } | j d | |  qWn  g  g  } } xC t  |  j  D]2 \ } \ } } | j d j | |  j |   qBW|  j
 d
 \ } } d j | |  j d j |   } | j | d  | j | d j |  j   d j | |  } | | | f S(   NR-   i   s   {}({})s   , s   double complexs	   return {}s   {}->{}i   s   else:i    i   R	  R   R
  i   s   {} {}s   cpdef {} {}({}) nogilRY   s   """{}"""s   
s       (   R?   R   R#  Rz   R  Rd   R@   R   R=   R:   R   RB   R   R~   R   RI   R|   (   R   Re   R{   RJ   R  R   R   Rj   Rk   R  R~   R   R!  R4   R   R"  R  t   callRp   RP   R  Rn   Ro   R   R  t   headR  R.   R   R   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt$   _generate_from_return_and_no_outargs  sN    0		"$!c         ` s  d } t    } g  g  } } x?t |  j  D].\ } } |  j | |  \
 } } }	 }
 } } } } }   | j |  |  j | |  } |  j | |  \ } } } | j |  | j |  d j | d j	 |   } | j
   |  | j t   f d   |   t |	  d k r;d j | |	  } | j
 |  q, d j | |	  } | j
 |  q, Wt |  d k r|  j   } | j |  n  t |  j  d k rd	 j |  j d
  } | j
 | |  n  g  g  } } xB t |  j |  j  D]+ \ } \ } } | j
 d j | |   qWt |  j  d k rzxE t |  j |  j  D]+ \ } \ } } | j
 d j | |   qHWn  t |  j  d k r|  j d
 \ } } d j | |  j d j	 |   } n d j |  j d j	 |   } | j
 | d  | j
 | d j |  j   t |  j  d k rm|  j d
 } |  j d
 \ } } d j | |  } | j
 | |  n  | j |  j |   d j	 | |  } | | | f S(   NR-   i   s   {}({})s   , c         ` s     |  S(   N(    (   R5   (   R"  (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyRW     s    i   s   {}->{}s   {}*{}->vs   return {}[0]i    s   {} {}s   {} *{}s   cpdef {} {}({}) nogils   cdef void {}({}) nogilRY   s   """{}"""s
   cdef {} {}s   
s       (   R   R?   R   R#  Rz   R  R  R   Rd   R@   R=   RZ   R:   R  R   RC   R   R~   R   RI   R|   R  (   R   Re   R  R{   RJ   R  R   R   Rj   Rk   R  R~   R   R!  R4   R   R  R  R  R  R$  Rp   R%  R  R  R.   R  RP   R   R   (    (   R"  s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt$   _generate_from_outargs_and_no_return  sX    	0(( $c         ` s  d } t    } g  g  } } xIt |  j  D]8\ } } |  j | |  \
 } } }	 }
 } } } } }   | j |  |  j | |  } |  j | |  \ } } } | j |  | j |  d j | d j	 |   } | r | d k r t
 |  } n  d j |  j d |  } | j   |  | j t   f d   |   d	 j | |	 |
  } | j |  q, Wt |  d
 k r|  j   } | j |  n  g  g  } } xB t |  j |  j  D]+ \ } \ } } | j d j | |   qWxB t |  j |  j  D]+ \ } \ } } | j d j | |   qWd j |  j d j	 |   } | j | d  | j | d j |  j   | j |  j |   d j	 | |  } | | | f S(   NR-   i   s   {}({})s   , s   double complexs
   {}[0] = {}i    c         ` s     |  S(   N(    (   R5   (   R"  (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyRW   G  s    s   {}*{}->vi   s   {} {}s   {} *{}s   cdef void {}({}) nogilRY   s   """{}"""s   
s       (   R   R?   R   R#  Rz   R  R  R   Rd   R@   R   R   R=   RZ   R:   R  RC   R   R~   R   RI   R|   R  (   R   Re   R  R{   RJ   R  R   R   Rj   Rk   R  R~   R   R!  R4   R   R  R  R  R  R$  R%  R  R  R.   R  RP   R   R   (    (   R"  s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt!   _generate_from_outargs_and_return4  s@    	0((c         C` s.  |  j  d \ } } } } } t j d d |  } | s@ d } n  t |  d k rv | d k rv |  j   \ } } } nx t |  d k r | d k r |  j   \ } } } nB t |  d k r | d k r |  j   \ } } } n t d   t |  j  d k r|  j	   } n d  } | | | |  j | f S(   Ni    s   \*.*R9   R   s   Invalid signaturei   (   R   R   R   R:   R&  R'  R(  R;   R   R  R   R   (   R   R.   Rk   R  R   R   R{   t   wrap(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyR   ]  s    	(   R   R   R   R   R   R   R   R   R  R  R  R  R  R#  R&  R'  R(  R   (    (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyR     s    									3			1	3	9	)c         C` sP  g  } g  } | j  d d  j  d d  j  d d  } | j d  r | j d | d  |  j | d d	 |  j |  f  d
 | }	 | j d | j  d |	   | j d |	 |	 |  j | d t f  nu d |  j |  | f }
 | j d |  | j d | j  d |
   | j d |  | j d | j  d |   | | | f S(   s   
    Construct a Cython declaration of a function coming either from a
    pxd or a header file. Do sufficient tricks to enable compile-time
    type checking against the signature expected by the ufunc.
    t   [R.   t   ]R-   s   .pxds   from %s cimport %s as %siR   R9   s   _proto_%s_ts   ctypedef %ss   (*)s   cdef %s *%s_var = &%sR   s   %s "%s"s   cdef extern from "%s":s       cdef %ss   #include "%s"s   %s;(   R/   R   R=   R   R   (   t   ufuncR   R   R   R   t   proto_h_filenamet   defst   defs_ht   var_namet
   proto_namet   new_name(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   get_declarationt  s"    *	
	#c         C` sc  |  d } |  d } | d } | d } | d } d } g  }	 g  }
 i  } g  } d d g } g  } | j  d d    x=| D]5} | j   } x| D] \ } } } } | j d	  rR| d
  } t | | | | | |  \ } } } | j |  | j |  | j d | | j | d t d t f  | j d | f  d | | j	 | <q t | | | | | |  \ } } } |	 j |  |
 j |  q W| j
 |  } | | d 7} q| Wd j t | j    |	 | g  } t | d  H } | j t  | j t  | j d  | j |  | j t  Wd  QXt |
  }
 t | d  7 } | j d  | j d j |
   | j d  Wd  QXt |  } t | d  7 } | j d  | j d j |   | j d  Wd  QXt | d  D } | j t  | j d  | j d j |   | j d  Wd  QXt | d   } | j d j |   Wd  QXd  S(   Ns   .pyxs   _defs.hs   .pxdR9   s   cimport sf_errorsF   cdef void _set_action(sf_error.sf_error_t, sf_error.sf_action_t) nogilR   c         S` s   |  j  S(   N(   RI   (   t   u(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyRW     s    s   ++is!   cdef void *_export_%s = <void*>%sR   R   s   cdef void *_export_%ss"   scipy.special._ufuncs_cxx._export_s   
t   ws0   #ifndef UFUNCS_PROTO_H
#define UFUNCS_PROTO_H 1
s   
#endif
s   
# distutils: language = c++
(   R   R   R   R3  Rz   R=   R   R   R   R   R   R@   t   sortedt   valuest   opent   writet   UFUNCS_EXTRA_CODE_COMMONt   UFUNCS_EXTRA_CODEt   UFUNCS_EXTRA_CODE_BOTTOMR   (   t	   fn_prefixt   cxx_fn_prefixR   t   filenameR-  t   cxx_proto_h_filenamet   cxx_pyx_filenamet   cxx_pxd_filenameR   R.  R/  R   t   cxx_defst   cxx_pxd_defst
   cxx_defs_hR,  t   cfuncsR   R   R   R   t	   item_defst   item_defs_hR0  R.   t   tR   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   generate_ufuncs  sr    




	
	#&c      	   C` s  t  j j t  } t  j j | |  d  } t  j j | |  d  } t  j j | | d  } g  } g  } g  }	 t   }
 g  } g  } xa| D]Y} | j j d  r q n  | j   \ } } } } } | j	 |  | j	 |  | r | j	 |  n  |
 j
 |  | j d t  } x` | D]X \ } } } } | j d  rAqn  t | | | | | |  \ } } } | j |  qW| j	 t | j |   | j t k r xC t | j D]1 } t | j |  \ } } |	 j | | g  qWq q Wt |
  }
 |
 j   t | d  Z } | j t  | j d  | j d	 j |
   | j d	  | j d j |   Wd  QXt | d   } t } | j d
 d j |   } | j |  | j d  | j d j |   | j d	  | j d	 j |   | j d	  | j d	 j |	   Wd  QXd  S(   Ns   .pxds   .pyxs   _defs.hR.   R   s   ++R5  s   
s   

t   FUNCLIST(   t   ost   patht   dirnamet   __file__R@   R   RI   t
   startswithR   R=   R   R   R   R   R3  Rz   R   t   CYTHON_SPECIAL_BENCHFUNCSRx   Ry   R   R8  R9  t   CYTHON_SPECIAL_PXDt   CYTHON_SPECIAL_PYXR/   (   t   modnamet   ufunc_fn_prefixt   fused_funcst   pwdt   pxdfilet   pyxfileR-  t   sourcest   declarationst	   bench_auxR   R|   R.  R   R   R   R{   t   func_fused_typesR)  RF  R   R   R   R   RG  R.   R[   Rv   Rw   R   (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   generate_fused_funcs  sd    	
c         C` sP   t    } g  } x: |  D]2 } | | k r. q n  | j |  | j |  q W| S(   sb   
    Return a list without repeated entries (first occurrence is kept),
    preserving order.
    (   R   R   R=   (   t   lstR   t   new_lstt   item(    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyR   4  s    	c          C` s   t  j d t j    }  |  j   \ } } t |  d k rL |  j d  n  t j t	  } t
 d d |  t j t	  } t d d |  d  S(   Nt   usagei    s   invalid number of argumentst   _ufuncst   _ufuncs_cxxt   cython_special(   t   optparset   OptionParserR   R   t
   parse_argsR:   t   errorR   R   t   FUNCSRJ  R   R^  (   t   pt   optionst   argsR   RV  (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   mainC  s    t   __main__(-   R   t
   __future__R    R   R   Rj  R:  R;  R<  RR  RS  RL  Rf  R   R   R  R  t
   __import__R   R>   R   R   RQ  R1   R6   R   RA   RB   RV   R_   Rx   R   R   R   R   t   objectR   R   R   R3  RJ  R^  R   Rn  R   (    (    (    s<   /tmp/pip-build-7oUkmx/scipy/scipy/special/generate_ufuncs.pyt   <module>G   s   
'






		---
			'				.U 	"	W	G		