ó
î&]\c           @` ss   d  d l  m Z m Z m Z d  d l m Z m Z m Z m Z m	 Z	 m
 Z
 d  d l m Z d g Z d d „ Z d S(   i    (   t   divisiont   print_functiont   absolute_import(   t   zerost   asarrayt   eyet   poly1dt   hstackt   r_(   t   linalgt   padec         C` sã  t  |  ƒ }  | d k rJ t |  ƒ d | } | d k  rJ t d ƒ ‚ qJ n  | d k  re t d ƒ ‚ n  | | } | t |  ƒ d k r” t d ƒ ‚ n  |  | d  }  t | d | d ƒ } t | d | f d ƒ } xC t d | d ƒ D]. } |  |  d d d … | | d | … f <qæ WxN t | d | d ƒ D]5 } |  | | | !d d d … | | d d … f <q0Wt | | f ƒ } t j	 | |  ƒ } | | d  }	 t
 d	 | | d f }
 t |	 d d d … ƒ t |
 d d d … ƒ f S(
   s‘  
    Return Pade approximation to a polynomial as the ratio of two polynomials.

    Parameters
    ----------
    an : (N,) array_like
        Taylor series coefficients.
    m : int
        The order of the returned approximating polynomial `q`.
    n : int, optional
        The order of the returned approximating polynomial `p`. By default, 
        the order is ``len(an)-m``.
    
    Returns
    -------
    p, q : Polynomial class
        The Pade approximation of the polynomial defined by `an` is
        ``p(x)/q(x)``.

    Examples
    --------
    >>> from scipy.interpolate import pade
    >>> e_exp = [1.0, 1.0, 1.0/2.0, 1.0/6.0, 1.0/24.0, 1.0/120.0]
    >>> p, q = pade(e_exp, 2)

    >>> e_exp.reverse()
    >>> e_poly = np.poly1d(e_exp)

    Compare ``e_poly(x)`` and the Pade approximation ``p(x)/q(x)``

    >>> e_poly(1)
    2.7166666666666668

    >>> p(1)/q(1)
    2.7179487179487181

    i   i    s.   Order of q <m> must be smaller than len(an)-1.s&   Order of p <n> must be greater than 0.s0   Order of q+p <m+n> must be smaller than len(an).t   dNiÿÿÿÿg      ð?(   R   t   Nonet   lent
   ValueErrorR   R   t   rangeR   R	   t   solveR   R   (   t   ant   mt   nt   Nt   Akjt   Bkjt   rowt   Ct   pqt   pt   q(    (    s6   lib/python2.7/site-packages/scipy/interpolate/_pade.pyR
      s,    &
,3N(   t
   __future__R    R   R   t   numpyR   R   R   R   R   R   t   scipyR	   t   __all__R   R
   (    (    (    s6   lib/python2.7/site-packages/scipy/interpolate/_pade.pyt   <module>   s   .	