ó
Ê½÷Xc           @` s¾   d  Z  d d l m Z m Z m Z d d l Z d d l m Z y d d l Z	 Wn e
 k
 ra n Xd „  Z d „  Z d „  Z d „  Z d	 „  Z d
 Z d Z d „  Z e d k rº e ƒ  n  d S(   së   
Precompute coefficients of Temme's asymptotic expansion for gammainc.

This takes about 8 hours to run on a 2.3 GHz Macbook Pro with 4GB ram.

Sources:
[1] NIST, "Digital Library of Mathematical Functions",
    http://dlmf.nist.gov/

i    (   t   divisiont   print_functiont   absolute_importN(   t   lagrange_inversionc         C` sµ   t  j d ƒ d g } x˜ t d |  ƒ D]‡ } | d | } x< t d t | ƒ ƒ D]% } | | | | | | d 8} qP W| | d d t  j d ƒ | d } | j | ƒ q& W| S(   s   a_k from DLMF 5.11.6i   i   iÿÿÿÿi    (   t   mpt   sqrtt   ranget   lent   mpft   append(   t   nt   at   kt   akt   j(    (    sE   /tmp/pip-build-7oUkmx/scipy/scipy/special/_precompute/gammainc_asy.pyt	   compute_a   s    #'c         C` sc   t  d |  ƒ } g  } xF t |  ƒ D]8 } | j t j d ƒ t j d | ƒ | d | ƒ q# W| S(   s   g_k from DLMF 5.11.3/5.11.5i   g      à?(   R   R   R	   R   R   t   rf(   R
   R   t   gR   (    (    sE   /tmp/pip-build-7oUkmx/scipy/scipy/special/_precompute/gammainc_asy.pyt	   compute_g"   s
    6c         C` se   |  d k r. t  j d |  t  j |  d ƒ ƒ S|  d k  r] t  j d |  t  j |  d ƒ ƒ Sd Sd S(   s6   Function from DLMF 8.12.1 shifted to be centered at 0.i    i   i   N(   R   R   t   log(   t   lam(    (    sE   /tmp/pip-build-7oUkmx/scipy/scipy/special/_precompute/gammainc_asy.pyt   eta+   s
    "#c         C` s#   t  j t d |  d ƒ } t | ƒ S(   s   alpha_n from DLMF 8.12.13i    i   (   R   t   taylorR   R   (   R
   t   coeffs(    (    sE   /tmp/pip-build-7oUkmx/scipy/scipy/special/_precompute/gammainc_asy.pyt   compute_alpha5   s    c   
      C` s;  | d |  } t  j d ƒ d g } t | d ƒ } x4 t d | ƒ D]# } | j | d | | d ƒ qE W| g } t |  ƒ } xŠ t d |  ƒ D]y } g  }	 x] t | d | ƒ D]G } |	 j d | | | | d | | d | | d | d ƒ q² W| j |	 ƒ q‘ Wx& t |  ƒ D] } | | |  | | <qW| S(   s   d_{k, n} from DLMF 8.12.12i   i   i   iÿÿÿÿi    (   R   R   R   R   R	   R   (
   t   Kt   Nt   Mt   d0t   alphaR
   t   dR   R   t   dk(    (    sE   /tmp/pip-build-7oUkmx/scipy/scipy/special/_precompute/gammainc_asy.pyt	   compute_d;   s    !	Es°   /* This file was automatically generated by _precomp/gammainc.py.
 * Do not edit it manually!
 */

#ifndef IGAM_H
#define IGAM_H

#define K {}
#define N {}

double d[K][N] =
{{s   
#endif
c       	   C` s;  t  t ƒ d }  d } t j d ƒ  t |  | ƒ } Wd  QXt j j t j j t	 ƒ d d d ƒ } t
 | d d ƒ ¬ } | j t j |  | ƒ ƒ x| t | ƒ D]n \ } } t d „  | ƒ } | j d	 ƒ | j d
 j | ƒ ƒ | |  d k  rÿ | j d ƒ qž | j d ƒ qž W| j t ƒ Wd  QXt j | d | ƒ d  S(   Ni   i2   s   ..t   cephess   igam.hs   .newt   wc         S` s   t  j |  d d d d d ƒS(   Ni   t	   min_fixedi    t	   max_fixed(   R   t   nstr(   t   x(    (    sE   /tmp/pip-build-7oUkmx/scipy/scipy/special/_precompute/gammainc_asy.pyt   <lambda>k   s    t   {s   , i   s   },
s   }};
(   t   printt   __doc__R   t   workdpsR    t   ost   patht   joint   dirnamet   __file__t   opent   writet   headert   formatt	   enumeratet   mapt   footert   rename(   R   R   R   t   fnt   fR   t   row(    (    sE   /tmp/pip-build-7oUkmx/scipy/scipy/special/_precompute/gammainc_asy.pyt   maina   s"    
't   __main__(   R*   t
   __future__R    R   R   R,   t   scipy.special._precompute.utilsR   t   mpmathR   t   ImportErrorR   R   R   R   R    R3   R7   R<   t   __name__(    (    (    sE   /tmp/pip-build-7oUkmx/scipy/scipy/special/_precompute/gammainc_asy.pyt   <module>
   s"   				
			