+
    Z°³jÊ  ã                   ó&   € R t ^ RIt^ RItR tR tR# )z4Helpers for producing efficient wrappers of ufuncs.
Nc                ó¸   € V P                  R4      ^ ,          p\        P                  ! RV4      p\        ;QJ d    . R V 4       F  NK  	  5# ! R V 4       4      # )z>Return tuple of num core dims per input from gufunc signature.z->z	\((.*?)\)c              3   ó€   "  € T F4  qP                  4       '       g   ^ MVP                  R4      ^,           x € K6  	  R# 5i)é    Ú,N)ÚstripÚcount)Ú.0Úgs   & Ú[/home/luca/screen-checking/.venv/lib/python3.14/site-packages/scipy/special/_ufunc_tools.pyÚ	<genexpr>Ú$_parse_core_ndims.<locals>.<genexpr>   s*   é € ÐJÁ6¸aŸ'™'Ÿ)š)‘¨¯©°«¸Õ)9Ô9Ã6ùs   ‚<>)ÚsplitÚreÚfindallÚtuple)Ú	signatureÚ	input_sigÚgroupss   &  r
   Ú_parse_core_ndimsr      sG   € à—‘ Ó% aÕ(€IÜ�ZŠZ˜ iÓ0€FßŒ5ÑJÁ6ÓJ�5ÐJˆ5ÑJÁ6ÓJÓJÐJó    c                óü   aaa
€ SP                   e   \        SP                   4      MRSP                  ,          o
VV
V3R lpRP                  V4      pRV  RV RV R2pRV/p\	        Wx4       W€,          p	W)n        V	# )	a{	  Helper to ensure optimal iteration order for ufuncs that use caching.

This concerns internal caches which are only live over the course of one
call to a ufunc to avoid repeated computations during the course of the
loops. See the notes below for more information.

Parameters
----------
name : str
arg_names : list[str]
    The function name and arg names are passed in so that the wrapper
    can be generated with the create name and argument names, improving
    documentation and autocomplete.
docstring : str
ufunc : numpy.ufunc
cache_arg_indices : list[int]
   Arguments to ufunc which are used in the kernel to compute an output
   which is being cached for reuse when iterating over other arguments.

Returns
-------
callable
    A wrapper for ufunc which transposes the axes of the inputs to ensure
    iteration precedes in such a way to allow the cache within the ufunc
    kernel to eliminate redundant computation.

Notes
-----
There is a common pattern in ufunc kernels exemplified by the situation
where some of the arguments are used to compute coeffients of an expansion
that is taken over one or more of the other arguments. A classic example is
Mathieu functions, which compute coefficients corresponding to the shape
parameter q and order m which in principle could be reused for varying
values of the parameter x.

It had long been the case that the expensive computation of coefficients is
repeated unnecessarily across values of x. It is possible to add a cache to
the ufunc kernel which stores the expansion coefficients and only updates
if the pointers into the q and m arrays advance during the course of the
ufunc loops. Such a cache is instantiated each time a ufunc is called and
only lives during the course of the loops that are carried out for that
particular call.

Whether such a cache actually helps depends on the order in which iteration
occurs. Ideally, one would want q and m to advance most slowly and for the
iterations over x for fixed q and m to be pushed to the inner most loops.
This helper replaces each input array (and a pre-allocated output array)
with a view where the axes which should vary most slowly are transposed to
the ends and forces computation in C order. This ensures iteration proceeds
in the optimal order.

Note that because the pre-allocated output array used internally is C
contiguous, the output will be C contiguous regardless of contiguity of
the inputs.

c                  óÊ  <a aa€ S  Uu. uF  p\         P                  ! V4      NK  	  upo \        ;QJ d     V V3R  lS 4       F  '       d   K   RM	  RM! V V3R  lS 4       4      '       d   S! S !  # \        S 4       UUu. uF6  w  r!SV,          ^ 8”  d   VP                  RSV,          )  MVP                  NK8  	  ppp\         P
                  ! V!  p\        V4      p\        S 4       UUu. uF[  w  r!SV,          ^ 8”  d3   \         P                  ! WVP                  SV,          ) R ,           4      M\         P                  ! W4      NK]  	  uppo. p. p\        V4       Fk  o\        ;QJ d     VV3R lS 4       F  '       d   K   RM	  RM! VV3R lS 4       4      pV'       d   VP                  S4       KZ  VP                  S4       Km  	  Wg,           p	. p
\        S4       FT  w  r+V	\        \        WUSV,          ,           4      4      ,           pV
P                  \         P                  ! W¼R7      4       KV  	  \        ;QJ d    . R V
 4       F  NK  	  5M! R V
 4       4      RSP                  ,          ,           pSP                  V4      R,          p\         P                  ! WNRR7      p\         P                  ! WùR7      pS! V
R	VR
R/  V# u upi u uppi u uppi )c              3   ó^   <"  € T F"  pSV,          P                   SV,          8H  x € K$  	  R # 5i©N)Úndim)r   ÚiÚargsÚ
core_ndimss   & €€r
   r   Ú=_with_cache_optimization.<locals>._wrapper.<locals>.<genexpr>]   s$   øé € ÐHÑ6G°ˆt�A�w�|‰|˜z¨!�}Ö,Ó6Gùó   ƒ*-FTNc              3   ó^   <"  € T F"  pSV,          P                   S,          ^ 8H  x € K$  	  R# 5i)r   N)Ústrides)r   r   Úargs_bÚaxs   & €€r
   r   r   x   s)   øé € ð Ù4E¨q��q•	×!Ñ! "Õ%¨Ö*Ó4Eùr   )Úaxesc              3   ó8   "  € T F  qP                   x € K  	  R # 5ir   )Údtype)r   Úargs   & r
   r   r   ‹   s   é € Ð9±&¨3ŸYžY³&ùs   ‚ÚC)r&   ÚorderÚoutr)   r   éÿÿÿÿ)ÚnpÚasarrayÚallÚ	enumerateÚshapeÚbroadcast_shapesÚlenÚbroadcast_toÚrangeÚappendÚlistÚ	transposer   ÚnoutÚresolve_dtypesÚempty)r   r'   r   Úbatch_shapesÚbatch_shapeÚ
batch_ndimÚvarying_axesÚconstant_axesÚis_constantÚsorted_batch_axesÚargs_tÚarg_br$   Úinput_dtypesÚ	out_dtypeÚ	out_finalÚout_tr"   r#   Úcache_arg_indicesr   Úufuncs   j                @@€€€r
   Ú_wrapperÚ*_with_cache_optimization.<locals>._wrapperX   sl  û€ Ù+/Ó0©4 C”—
’
˜3–©4Ñ0ˆ÷ ‹3ÕHÑ6GÓH�3�3Š3ÕHÑ6GÓH×HÒHÙ˜$‘<Ðô $ Dœ/ô
á)‘�ð +5°Q­-¸!Ô*;ˆC�I‰I�o˜
 1��~Ñ&ÀÇÁÒJÙ)ð 	ñ 
ô ×)Ò)¨<Ñ8ˆÜ˜Ó%ˆ
ô $ Dœ/ô
ñ *‘�ð ˜!�}˜qÔ ô �OŠO˜C¨s¯y©y¸*ÀQ½-¸¸Ð/IÕ!IÔJÜ&(§o¢o°cÓ&GòHá)ò
ˆð ˆØˆä˜
Ö#ˆBß›#õ Ù4EóŸ#Ÿ#š#õ Ù4Eóó ˆK÷ Ø×$Ñ$ RÖ(à×#Ñ# BÖ'ñ $ð )Õ8Ðð ˆÜ! &Ö)‰HˆAØ$¤tÜ�j¨z¸!­}Õ"<Ó=ó(õ ˆDð �M‰Mœ"Ÿ,š, uÔ8Ö9ñ	 *÷ ”uÑ9±&Ó9—u‘uÑ9±&Ó9Ó9¸GÀEÇJÁJÕ<NÕNˆØ×(Ñ(¨Ó6°rÕ:ˆ	Ü—H’H˜[ÀÔEˆ	ä—’˜YÔ?ˆñ 	ˆvÐ,˜5Ð,¨Ò,ØÐùòw 1ùó
ùó
s   ‰KÂ<KÃ-A!Kz, zdef Ú(z):
            return _wrapper(z
)
        rJ   )r   )r   r   ÚninÚjoinÚexecÚ__doc__)ÚnameÚ	arg_namesÚ	docstringrI   rH   rJ   Úarg_strÚcodeÚ	namespaceÚwrapperr   s   $$$dd     @r
   Ú_with_cache_optimizationrX      s�   ú€ ðJ �?‰?Ò&ô 	˜%Ÿ/™/Ô*à�%—)‘)�^ð ÷<ð@ �i‰i˜	Ó"€Gà���a˜�yð !Ø$˜Ið &	ð	ð 	ð
 ˜XÐ&€IÜˆÔØ�o€GØ„OØ€Nr   )rP   r   Únumpyr,   r   rX   © r   r
   Ú<module>r[      s   ðñó 
Û òKôSr   