o
    ÒtBhb  ã                	   @   s¢   d dl Zdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Z	eeeeeeee	dœZ
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ ZdS )#é    Nc                 C   s   |  S )N© ©Úrr   r   ú{/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/scipy/interpolate/_rbfinterp_pythran.pyÚlinear   s   r   c                 C   s   | dkrdS | d t  | ¡ S )Nr   ç        é   )ÚnpÚlogr   r   r   r   Úthin_plate_spline   s   r   c                 C   s   | d S )Né   r   r   r   r   r   Úcubic   s   r   c                 C   s
   | d  S )Né   r   r   r   r   r   Úquintic   s   
r   c                 C   s   t  | d d ¡ S )Nr   é   ©r	   Úsqrtr   r   r   r   Úmultiquadric   s   r   c                 C   s   dt  | d d ¡ S ©Nr   r   r   r   r   r   r   Úinverse_multiquadric   s   r   c                 C   s   d| d d  S r   r   r   r   r   r   Úinverse_quadratic   ó   r   c                 C   s   t  | d  ¡S )Nr   )r	   Úexpr   r   r   r   Úgaussian#   r   r   )r   r   r   r   r   r   r   r   c                 C   s4   t |jd ƒD ]}|tj | ||  ¡ƒ||< qdS )z5Evaluate RBFs, with centers at `y`, at the point `x`.r   N©ÚrangeÚshaper	   ÚlinalgÚnorm)ÚxÚyÚkernel_funcÚoutÚir   r   r   Úkernel_vector3   s   ÿr$   c                 C   s.   t |jd ƒD ]}t | ||  ¡||< qdS )zCEvaluate monomials, with exponents from `powers`, at the point `x`.r   N©r   r   r	   Úprod)r   Úpowersr"   r#   r   r   r   Úpolynomial_vector9   s   ÿr(   c                 C   sb   t | jd ƒD ]'}t |d ƒD ]}|tj | | | |  ¡ƒ|||f< |||f |||f< qqdS )z+Evaluate RBFs, with centers at `x`, at `x`.r   r   Nr   )r   r!   r"   r#   Újr   r   r   Úkernel_matrix?   s   $þÿr*   c                 C   sJ   t | jd ƒD ]}t |jd ƒD ]}t | | ||  ¡|||f< qqdS )z9Evaluate monomials, with exponents from `powers`, at `x`.r   Nr%   )r   r'   r"   r#   r)   r   r   r   Úpolynomial_matrixG   s
    ÿÿr+   c                 C   s6   t j| jd | jd ftd}t| }t| ||ƒ |S )z3Return RBFs, with centers at `x`, evaluated at `x`.r   ©Údtype)r	   Úemptyr   ÚfloatÚNAME_TO_FUNCr*   )r   Úkernelr"   r!   r   r   r   Ú_kernel_matrixO   s   r2   c                 C   s.   t j| jd |jd ftd}t| ||ƒ |S )zAReturn monomials, with exponents from `powers`, evaluated at `x`.r   r,   )r	   r.   r   r/   r+   )r   r'   r"   r   r   r   Ú_polynomial_matrixX   s   r3   c                 C   sj  |j d }|j d }|j d }t| }	tj| dd}
tj| dd}||
 d }||
 d }d||dk< | | }| | | }tj|| || ftdj}t||	|d|…d|…f ƒ t	|||d|…|d…f ƒ |d|…|d…f j||d…d|…f< d||d…|d…f< t
|ƒD ]}|||f  || 7  < qˆtj||| ftdj}||d|…< d||d…< ||||fS )	a=  Build the system used to solve for the RBF interpolant coefficients.

    Parameters
    ----------
    y : (P, N) float ndarray
        Data point coordinates.
    d : (P, S) float ndarray
        Data values at `y`.
    smoothing : (P,) float ndarray
        Smoothing parameter for each data point.
    kernel : str
        Name of the RBF.
    epsilon : float
        Shape parameter.
    powers : (R, N) int ndarray
        The exponents for each monomial in the polynomial.

    Returns
    -------
    lhs : (P + R, P + R) float ndarray
        Left-hand side matrix.
    rhs : (P + R, S) float ndarray
        Right-hand side matrix.
    shift : (N,) float ndarray
        Domain shift used to create the polynomial matrix.
    scale : (N,) float ndarray
        Domain scaling used to create the polynomial matrix.

    r   r   )Úaxisr   g      ð?r   r,   N)r   r0   r	   ÚminÚmaxr.   r/   ÚTr*   r+   r   )r    ÚdÚ	smoothingr1   Úepsilonr'   ÚpÚsr   r!   ÚminsÚmaxsÚshiftÚscaleÚyepsÚyhatÚlhsr#   Úrhsr   r   r   Ú_build_systeme   s,   


&rE   c              	   C   sú   | j d }|j d }	|j d }
|j d }t| }|| }| | }| | | }tj||ftd}tj|	|
 ftd}t|ƒD ]=}t|| |||d|	… ƒ t|| |||	d… ƒ t|ƒD ]}t|	|
 ƒD ]}|||f  |||f ||  7  < qdq\q=|S )a½  Evaluate the RBF interpolant at `x`.

    Parameters
    ----------
    x : (Q, N) float ndarray
        Evaluation point coordinates.
    y : (P, N) float ndarray
        Data point coordinates.
    kernel : str
        Name of the RBF.
    epsilon : float
        Shape parameter.
    powers : (R, N) int ndarray
        The exponents for each monomial in the polynomial.
    shift : (N,) float ndarray
        Shifts the polynomial domain for numerical stability.
    scale : (N,) float ndarray
        Scales the polynomial domain for numerical stability.
    coeffs : (P + R, S) float ndarray
        Coefficients for each RBF and monomial.

    Returns
    -------
    (Q, S) float ndarray

    r   r   r,   N)	r   r0   r	   Úzerosr/   r.   r   r$   r(   )r   r    r1   r:   r'   r?   r@   ÚcoeffsÚqr;   r   r<   r!   rA   ÚxepsÚxhatr"   Úvecr#   r)   Úkr   r   r   Ú	_evaluate¯   s&   



&ÿÿrM   )Únumpyr	   r   r   r   r   r   r   r   r   r0   r$   r(   r*   r+   r2   r3   rE   rM   r   r   r   r   Ú<module>   s4    ø	J