a
    BCCf#                     @   s@   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dZ
dS )    )zerosasarrayeyepoly1dhstackr_)linalgpadeNc                 C   sz  t | } |du r0t| d | }|dk r0td|dk r@td|| }|t| d kr`td| d|d  } t|d |d | jd}t|d |f| jd}td|d D ](}| d| ddd  ||d|f< qt|d |d D ],}| || | ddd  ||ddf< qt||f}t	|| }|d|d  }	t
d	||d d f }
t|	ddd t|
ddd fS )
a  
    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)-1-m``.

    Returns
    -------
    p, q : Polynomial class
        The Pade approximation of the polynomial defined by `an` is
        ``p(x)/q(x)``.

    Examples
    --------
    >>> import numpy as np
    >>> 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

    N   r   z.Order of q <m> must be smaller than len(an)-1.z&Order of p <n> must be greater than 0.z0Order of q+p <m+n> must be smaller than len(an).)dtypeg      ?)r   len
ValueErrorr   r   r   ranger   r   Zsolver   r   )anmnNZAkjZBkjrowCZpqpq r   S/var/www/html/django/DPS/env/lib/python3.9/site-packages/scipy/interpolate/_pade.pyr	      s,    '&*)N)numpyr   r   r   r   r   r   Zscipyr   __all__r	   r   r   r   r   <module>   s    