a
    þd  ã                   @   s   d d„ Z dd„ ZdS )c                 C   s’   d| ||  d||    d|  }|d| d|   d|   d|  d|  }||d	|   d
|   d|  d|  }|| }	| }
|
|	|||gS )a‚  Fit coefficients for 4th order polynomial interpolation.

    Args:
        y0: function value at the start of the interval.
        y1: function value at the end of the interval.
        y_mid: function value at the mid-point of the interval.
        f0: derivative value at the start of the interval.
        f1: derivative value at the end of the interval.
        dt: width of the interval.

    Returns:
        List of coefficients `[a, b, c, d, e]` for interpolating with the polynomial
        `p = a * x ** 4 + b * x ** 3 + c * x ** 2 + d * x + e` for values of `x`
        between 0 (start of interval) and 1 (end of interval).
    é   é   é   é   é   é   é   é    é   é   © )Zy0Úy1Zy_midZf0Úf1ÚdtÚaÚbÚcÚdÚer   r   úa/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/torchdiffeq/_impl/interp.pyÚ_interp_fit   s    $,(r   c                 C   s„   ||k||k@ s"J d  |||¡ƒ‚|| ||  }| | d j¡}| d || d   }|}| dd… D ]}|| }|||  }qf|S )a·  Evaluate polynomial interpolation at the given time point.

    Args:
        coefficients: list of Tensor coefficients as created by `interp_fit`.
        t0: scalar float64 Tensor giving the start of the interval.
        t1: scalar float64 Tensor giving the end of the interval.
        t: scalar float64 Tensor giving the desired interpolation point.

    Returns:
        Polynomial interpolation of the coefficients at time `t`.
    z8invalid interpolation, fails `t0 <= t <= t1`: {}, {}, {}é    é   r   N)ÚformatÚtoZdtype)ZcoefficientsÚt0Út1ÚtÚxÚtotalZx_powerZcoefficientr   r   r   Ú_interp_evaluate   s    "r   N)r   r   r   r   r   r   Ú<module>   s   