+
    LV-jæ  ã                   ó    € 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   &&& Úp/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/scipy/interpolate/_rbfinterp_xp.pyÚ_monomial_powersr       sB   € Ü
 Ó
-€CØ
�*‰*�S‹/€CØ
‡y�y�…|�qÔØ�j‰j˜˜q $˜iÓ(ˆØ€Jó    c           	     óX  € \        WW#WEV4      w  rxrš VP                  P                  Wx4      pYšT3#   \         dm    RpTP                  ^ ,          pT^ 8”  dE   \        Y	,
          T
,          YVR7      pTP                  P                  T4      pYý8  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 °"ó
Ñ€CˆeðØ—‘—‘ Ó*ˆð& ˜ÐÐøô% ô ð
  ˆØ—‘˜a•ˆØ�AŒ:Ü$ a¥i°Õ%6¸ÔFˆDØ—9‘9×(Ñ(¨Ó.ˆDØŒ}ðà!˜F ! F 8¨2ð/ð ô
 ˜#ÓÐð!ús
   “2 ²A7B)c                 ó   € V ) # ©N© ©Úrr   s   &&r   Úlinearr.   ^   s	   € Øˆ2€Ir   c                 óh   € VP                  V ^ 8H  ^ V ^,          VP                  V 4      ,          4      # r   )ÚwhereÚlogr,   s   &&r   Úthin_plate_spliner2   b   s*   € à�8‰8�A˜‘F˜A˜q !�t b§f¡f¨Q£iÕ/Ó0Ð0r   c                 ó   € V ^,          # )é   r+   r,   s   &&r   Úcubicr5   g   s   € Øˆa�4€Kr   c                 ó   € V ^,          ) # )é   r+   r,   s   &&r   Úquinticr8   k   s   € Øˆq�Dˆ5€Lr   c                 óB   € VP                  V ^,          ^,           4      ) # ©é   ©Úsqrtr,   s   &&r   Úmultiquadricr>   o   s   € Ø�G‰G�A�q•D˜1•HÓÐÐ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   € Ø�6‰6�1�a•4�%‹=Ð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©NºNNNrL   ©rL   NrL   éÿÿÿÿ)r   Úvector_norm)ÚxÚkernel_funcr   s   &&&r   Úkernel_matrixrR   ‹   s5   € áØ
�	‰	×Ñ˜a 
�m¨a°
­mÕ;À"ÐÓEÀróð 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   € à�7‰7�1�Z•= 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\        WéV4      p\        WõV4      pVP                  VP                  VV3^R7      VP                  VP                  VP                  Wˆ34      3^R7      .^ R7      VP                  VP                  W&P                  V4      .4      4      ,           pVP                  WP                  W‡34      .^ R7      pVVWÍ3# )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ð �6‰6�!˜!ˆ6Ó€DØ�6‰6�!˜!ˆ6Ó€DØ�[˜!�O€EØ�[˜!�O€Eð �H‰H�U˜c‘\ 3¨Ó.€Eà�9€DØ�I�uÕ€Dä  °BÓ7€KÜ  ¨rÓ2€Hà
�)‰)à	�‰�K Ð*°ˆÓ	3Ø	�‰�H—J‘J §¡¨!¨Ó 0Ð1¸ˆÓ	:ð	
ð ð ó ð
 —‘˜Ÿ	™	 9¯h©h°q«kÐ":Ó;Ó<õ=€Cð �)‰)�QŸ™ ! Ó(Ð)°ˆ)Ó
2€Cà��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à�9€DØ�9€DØ�I�uÕ€Dð �)‰)áØ—	‘	×%Ñ%Ø˜Õ$ t¨JÕ'7Õ7¸bð &ó àóð
 �G‰G�D˜Õ$¨Õ.°RˆGÓ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   € Ü
(Ø	ˆf˜v¨eó€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   