+
    /i                         R t ^ RIHt ^RIHt R tR tR tR tR t	R t
R	 tR
 tR tR tR]R]R]	R]
R]R]R]R]/tR tR tR tR tR tR# )aj  
'Generic' Array API backend for RBF interpolation.

The general logic is this: `_rbfinterp.py` implements the user API and calls
into either `_rbfinterp_np` (the "numpy backend"), or `_rbfinterp_xp` (the
"generic backend".

The numpy backend offloads performance-critical computations to the
pythran-compiled `_rbfinterp_pythran` extension. This way, the call chain is

    _rbfinterp.py <-- _rbfinterp_np.py <-- _rbfinterp_pythran.py

The "generic" backend here is a drop-in replacement of the API of
`_rbfinterp_np.py` for use in `_rbfinterp.py` with non-numpy arrays.

The implementation closely follows `_rbfinterp_np + _rbfinterp_pythran`, with
the following differences:

  -  We used vectorized code not explicit loops in `_build_system` and
     `_build_evaluation_coefficients`; this is more torch/jax friendly;
  - RBF kernels are also "vectorized" and not scalar: they receive an
    array of norms not a single norm;
  - RBF kernels accept an extra xp= argument;

In general, we would prefer less code duplication. The main blocker ATM is
that pythran cannot compile functions with an xp= argument where xp is numpy.
)LinAlgError)_monomial_powers_implc                     \        W4      pVP                  V4      pVP                  ^ ,          ^ 8X  d   VP                  V^ V 34      pV#     )r   asarrayshapereshape)ndimdegreexpouts   &&& ]/var/www/html/photoedit/myenv/lib/python3.14/site-packages/scipy/interpolate/_rbfinterp_xp.py_monomial_powersr       sB    

-C
**S/C
yy|qjjq$i(J    c           	     X   \        WW#WEV4      w  rxr VP                  P                  Wx4      pYT3#   \         dm    RpTP                  ^ ,          pT^ 8  dE   \        Y	,
          T
,          YVR7      pTP                  P                  T4      pY8  d
   RT RT R2p\        T4      hi ; i)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.

zSingular matrix)r   zqSingular matrix. The matrix of monomials evaluated at the data point coordinates does not have full column rank (/z).)_build_systemlinalgsolve	Exceptionr   polynomial_matrixmatrix_rankr   )yd	smoothingkernelepsilonpowersr   lhsrhsshiftscalecoeffsmsgnmonospmatranks   &&&&&&&         r   _build_and_solve_systemr(   (   s    8 +	i"
Ce*& %  
  aA:$ai%6FD99((.D}!F!F82/ 
 #!s
   2 A7B)c                     V ) # N rr   s   &&r   linearr.   ^   s	    2Ir   c                 h    VP                  V ^ 8H  ^ V ^,          VP                  V 4      ,          4      # r   )wherelogr,   s   &&r   thin_plate_spliner2   b   s*    88AFAq!tbffQi/00r   c                     V ^,          # )   r+   r,   s   &&r   cubicr5   g   s    a4Kr   c                     V ^,          ) # )   r+   r,   s   &&r   quinticr8   k   s    qD5Lr   c                 B    VP                  V ^,          ^,           4      ) #    sqrtr,   s   &&r   multiquadricr>   o   s    GGAqD1Hr   c                 N    R VP                  V ^,          R ,           4      ,          #       ?r<   r,   s   &&r   inverse_multiquadricrB   s   s    A$$$r   c                 0    R V ^,          R ,           ,          # r@   r+   r,   s   &&r   inverse_quadraticrD   w   s    !Q$*r   c                 4    VP                  V ^,          ) 4      # r:   )expr,   s   &&r   gaussianrG   {   s    661a4%=r   r.   r2   r5   r8   r>   rB   rD   rG   c                t    V! VP                   P                  V R,          V R,          ,
          RR7      V4      # )z+Evaluate RBFs, with centers at `x`, at `x`.axisNNNNrL   rL   NrL   )r   vector_norm)xkernel_funcr   s   &&&r   kernel_matrixrR      s5    
		a
ma
m;"Er r   c                D    VP                  V R,          V,          RR7      # )z9Evaluate monomials, with exponents from `powers`, at `x`.rI   rM   rN   )prod)rP   r   r   s   &&&r   r   r      s    771Z=F*744r   c           
        VP                   ^,          pVP                   ^ ,          p\        V,          p	VP                  V ^ R7      p
VP                  V ^ R7      pW,           ^,          pW,
          ^,          pVP	                  VR8H  RV4      pW,          pW,
          V,          p\        WV4      p\        WV4      pVP                  VP                  VV3^R7      VP                  VP                  VP                  W34      3^R7      .^ R7      VP                  VP                  W&P                  V4      .4      4      ,           pVP                  WP                  W34      .^ R7      pVVW3# )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.

rI   g        rA   )r   NAME_TO_FUNCminmaxr0   rR   r   concatTzerosdiag)r   r   r   r   r   r   r   sr-   rQ   minsmaxsr!   r"   yepsyhatout_kernelsout_polyr   r    s   &&&&&&&             r   r   r      sS   < 	

AQAv&K 66!!6D66!!6D[!OE[!OE HHUc\3.E9DIuD B7K r2H
))	K*	3	HJJ! 01	:	
   
 		9hhqk":;<=C ))Q!())
2CU!!r   c           	     4   \         V,          pW,          p	W,          p
W,
          V,          pVP                  V! VP                  P                  V
R,          V	R,          ,
          RR7      V4      VP	                  VR,          V,          RR7      .RR7      pV# )a-  Construct the coefficients needed to evaluate
the RBF.

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.

Returns
-------
(Q, P + R) float ndarray

rI   rM   rK   rN   )rV   rY   r   rO   rT   )rP   r   r   r   r   r!   r"   r   rQ   r`   xepsxhatvecs   &&&&&&&&     r   _build_evaluation_coefficientsrh      s    8 v&K9D9DIuD ))		%%$tJ'77b & 
 GGD$.RG8	
   	C Jr   c	           
      .    \        WW#WEWh4      p	W,          # r*   )rh   )
rP   r   r   r   r   r!   r"   r#   r   rg   s
   &&&&&&&&& r   compute_interpolationrj     s    
(	fveC <r   N)__doc__numpy.linalgr   _rbfinterp_commonr   r   r(   r.   r2   r5   r8   r>   rB   rD   rG   rV   rR   r   r   rh   rj   r+   r   r   <module>rn      s   6 % 43 l1
%
 V)
Eg</)x	5
;"|.br   