
    bi                     h    d dl Zd dlmZ d dlmZ ddlmZ ddlm	Z
mZmZ d Zd Zd	 Zd
 Z	d Zd Zy)    N)LinAlgError)dgesv   )_monomial_powers_impl)_build_system_build_evaluation_coefficients_polynomial_matrixc           	      $    t        | ||||||      S N)&_pythran_build_evaluation_coefficients)xykernelepsilonpowersshiftscalexps           Z/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/scipy/interpolate/_rbfinterp_np.pyr   r      s      2	1fgvue     c                     t        | |      S r   )_pythran_polynomial_matrix)r   r   r   s      r   polynomial_matrixr      s    %a00r   c                     t        | |      }t        j                  |t        j                        }t	        |      dk(  r|j                  d|       }|S )N)dtyper   )r   npasarrayint64lenreshape)ndimdegreer   outs       r   _monomial_powersr$      sB    
f
-C
**S
)C
3x1}kk!T"Jr   c                 "    t        | |||||      S r   )_pythran_build_system)r   d	smoothingr   r   r   r   s          r   r   r   !   s     Ay&'6JJr   c           	      V   t        | ||||||      \  }}}	}
t        ||dd      \  }}}}|dk  rt        d|  d      |dkD  rad}|j                  d   }|dkD  r@t	        | |	z
  |
z  ||      }t
        j                  j                  |      }||k  r	d| d| d	}t        |      |	|
|fS )
a   Build and solve the RBF interpolation system of equations.

    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
    -------
    coeffs : (P + R, S) float ndarray
        Coefficients for each RBF and monomial.
    shift : (N,) float ndarray
        Domain shift used to create the polynomial matrix.
    scale : (N,) float ndarray
        Domain scaling used to create the polynomial matrix.

    T)overwrite_aoverwrite_br   zThe z"-th argument had an illegal value.zSingular matrix.zqSingular matrix. The matrix of monomials evaluated at the data point coordinates does not have full column rank (/z).)	r   r   
ValueErrorshaper   r   linalgmatrix_rankr   )r   r'   r(   r   r   r   r   lhsrhsr   r   _coeffsinfomsgnmonospmatranks                     r   _build_and_solve_systemr:   %   s    8 +	1i&"
CeU sCTtLAq&$ax4w&HIJJ	 aA:$a%i%6CD99((.Df}!F!F82/  #%r   c	           
      0    t        | |||||||      }	|	|z  S r   )r   )
r   r   r   r   r   r   r   r4   r   vecs
             r   compute_interpolationr=   X   s)    
(	1fgvueRC <r   )numpyr   numpy.linalgr   scipy.linalg.lapackr   _rbfinterp_commonr   _rbfinterp_pythranr   r&   r   r   r	   r   r   r$   r:   r=    r   r   <module>rD      s;     $ % 4 1K1 fr   