+
    LV-jÀ  ã                   ó‚   € R t ^ RIt^ RIt^ RIHt ^ RIHt ^RIH	t	H
t
  ! R R]4      tRR ltRR ltRR	 ltR
 tR tR# )z,
Spectral Algorithm for Nonlinear Equations
N)ÚOptimizeResult)Ú_check_unknown_options)Ú_nonmonotone_line_search_cruzÚ_nonmonotone_line_search_chengc                   ó   € ] tR t^tRtR# )Ú_NoConvergence© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    Úi/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/scipy/optimize/_spectral.pyr   r      s   † Ûr   r   c           
     ó\  a*a+a,€ \        V4       VR9  d   \        RV: R24      h^o,V
f   V*3R lp
Vf   V+V,3R lpV,3R lp^ .p\        WVVWR4      w  pppo+pp^ pS+o*TpV! V4      p\        P                  ! S+.V	4      pRpS*pR	pR
p V! V4      pV'       d   \        RV RVR RVR 24       Ve
   V! VV4       VVV,          V,           8  d   RpRpEM\        V4      ^V,          8”  d&   ^V,          \        P                  ! V4      ,          pM\        V4      V8  d   TpV) V,          pV
! VVV4      p  VR8X  d   \        VVVVV R7      w  p!p"p#p$M VR8X  d   \        VVVS+VVV R7      w  p!p"p#p$ppX"V,
          p%X$V,
          p&\        P                  ! V%V%4      \        P                  ! V%V&4      ,          pT"pT$pX#o+VR8X  d   VP                  V#4       V^,          pEK^  \        VVVR7      p'\        VV4      p(\        V'VVV(V^ ,          VRR7      p)V)#   \         d     KC  i ; i)aó  
Solve nonlinear equation with the DF-SANE method

Options
-------
ftol : float, optional
    Relative norm tolerance.
fatol : float, optional
    Absolute norm tolerance.
    Algorithm terminates when ``||func(x)|| < fatol + ftol ||func(x_0)||``.
fnorm : callable, optional
    Norm to use in the convergence check. If None, 2-norm is used.
maxfev : int, optional
    Maximum number of function evaluations.
disp : bool, optional
    Whether to print convergence process to stdout.
eta_strategy : callable, optional
    Choice of the ``eta_k`` parameter, which gives slack for growth
    of ``||F||**2``.  Called as ``eta_k = eta_strategy(k, x, F)`` with
    `k` the iteration number, `x` the current iterate and `F` the current
    residual. Should satisfy ``eta_k > 0`` and ``sum(eta, k=0..inf) < inf``.
    Default: ``||F||**2 / (1 + k)**2``.
sigma_eps : float, optional
    The spectral coefficient is constrained to ``sigma_eps < sigma < 1/sigma_eps``.
    Default: 1e-10
sigma_0 : float, optional
    Initial spectral coefficient.
    Default: 1.0
M : int, optional
    Number of iterates to include in the nonmonotonic line search.
    Default: 10
line_search : {'cruz', 'cheng'}
    Type of line search to employ. 'cruz' is the original one defined in
    [Martinez & Raydan. Math. Comp. 75, 1429 (2006)], 'cheng' is
    a modified search defined in [Cheng & Li. IMA J. Numer. Anal. 29, 814 (2009)].
    Default: 'cruz'

References
----------
.. [1] "Spectral residual method without gradient information for solving
       large-scale nonlinear systems of equations." W. La Cruz,
       J.M. Martinez, M. Raydan. Math. Comp. **75**, 1429 (2006).
.. [2] W. La Cruz, Opt. Meth. Software, 29, 24 (2014).
.. [3] W. Cheng, D.-H. Li. IMA J. Numer. Anal. **29**, 814 (2009).

ÚchengÚcruzzInvalid value z for 'line_search'c                 ó2   <€ S^V ,           ^,          ,          # )é   r   )ÚkÚxÚFÚf_0s   &&&€r   Úeta_strategyÚ#_root_df_sane.<locals>.eta_strategyJ   s   ø€ à˜!˜a�% !�Õ#Ð#r   c                 ó$   <€ SR S,          ,          # )ç      ð?r   )r   Úf_kÚnexps   &€€r   ÚfnormÚ_root_df_sane.<locals>.fnormO   s   ø€ à˜˜T�•?Ð"r   c                 óP   <€ \         P                  P                  V 4      S,          # ©N)ÚnpÚlinalgÚnorm)r   r   s   &€r   ÚfmeritÚ_root_df_sane.<locals>.fmeritS   s   ø€ Ü�y‰y�~‰~˜aÓ  $Õ&Ð&r   r   Fz&too many function evaluations requiredTziter z
: ||F|| = Úgz
, sigma = zsuccessful convergence)Úeta)Úshapezdf-sane)r   ÚsuccessÚmessageÚfunÚnfevÚnitÚmethod)r   r   )r   Ú
ValueErrorÚ
_wrap_funcÚcollectionsÚdequeÚprintÚabsr#   Úsignr   r   r   ÚvdotÚappendÚ_wrap_resultr   )-ÚfuncÚx0ÚargsÚftolÚfatolÚmaxfevr   ÚcallbackÚdispÚMr   Ú	sigma_epsÚsigma_0Úline_searchÚunknown_optionsr&   r.   ÚfÚx_kÚx_shapeÚF_kÚ
is_complexr   Úsigma_kÚF_0_normÚprev_fsÚQÚCÚ	convergedr,   ÚF_k_normÚdr)   ÚalphaÚxpÚfpÚFpÚs_kÚy_kr   r   Úresultr   r   r   s-   &&&&&&&&&&&&&&,                           @@@r   Ú_root_df_saner\      s†  ú€ ôb ˜?Ô+àÐ+Ô+Ü˜>¨+©Ð8JÐKÓLÐLà€DàÒõ	$ð ‚}ö	#õ'ð ˆ3€DÜ,6°tÀØ7;¸Vó-KÑ)€A€sˆG�S˜#˜zð 	
€AØ
€CØ€Gá�S‹z€Hô ×Ò   qÓ)€Gð 	€AØ€Aà€IØ6€Gà
Ù˜“:ˆçÜ�E˜!˜˜J x° l°*¸WÀQ¸KÐHÔIàÒÙ�S˜#Ôà�d˜X•o¨Õ-Ô-à.ˆGØˆIÙô ˆw‹<˜!˜I�+Ô%Ø˜	•k¤B§G¢G¨GÓ$4Õ4‰GÜ�‹\˜IÔ%ØˆGð ˆH�s�Nˆñ ˜1˜c 3Ó'ˆð	Ø˜fÔ$Ü$AÀ!ÀSÈ!ÈWØFIô%KÑ!��r˜2™rà Ô'Ü*HÈÈCÐQRÐTWØIJÈAÐSVô+XÑ'��r˜2˜r 1 að �3�hˆØ�3�hˆÜ—'’'˜#˜sÓ#¤b§g¢g¨c°3Ó&7Õ7ˆð ˆØˆØˆð ˜&Ô Ø�N‰N˜2Ôà	ˆQ�‹ä�S˜*¨GÔ4€AÜ�S˜*Ó%€Aä˜a¨Ø$+Ø !¨¨Q­°Q¸yôJ€Fð €Møô5 ô 	Úð	ús   Ä;H Å H ÈH+È*H+c                ó¾  a aaaaa	€ \         P                  ! V4      pVP                  o	\         P                  ! S ! V.SO5!  4      P                  4       p\         P                  ! V4      ;'       g    \         P                  ! V4      pVP                  4       p^S^ &   V'       d#   VVV VVV	3R lp\        V4      p\        V4      pMVVV VVV	3R lpW�S	S! V4      Wg3# )a   
Wrap a function and an initial value so that (i) complex values
are wrapped to reals, and (ii) value for a merit function
fmerit(x, f) is computed at the same time, (iii) iteration count
is maintained and an exception is raised if it is exceeded.

Parameters
----------
func : callable
    Function to wrap
x0 : ndarray
    Initial value
fmerit : callable
    Merit function fmerit(f) for computing merit value from residual.
nfev_list : list
    List to store number of evaluations in. Should be [0] in the beginning.
maxfev : int
    Maximum number of evaluations before _NoConvergence is raised.
args : tuple
    Extra arguments to func

Returns
-------
wrap_func : callable
    Wrapped function, to be called as
    ``F, fp = wrap_func(x0)``
x0_wrap : ndarray of float
    Wrapped initial value; raveled to 1-D and complex
    values mapped to reals.
x0_shape : tuple
    Shape of the initial value array
f : float
    Merit function at F
F : ndarray of float
    Residual at x0_wrap
is_complex : bool
    Whether complex values were mapped to reals

c                 ó  <€ S	^ ,          S8¼  d   \        4       hS	^ ;;,          ^,          uu&   \        V 4      P                  S
4      p\        P                  ! S! V.SO5!  4      P                  4       p\        V4      pS! V4      pWC3# ©é    )r   Ú_real2complexÚreshaper#   ÚasarrayÚravelÚ_complex2real)r   ÚzÚvr   rH   r=   r&   r;   r@   Ú	nfev_listÚx0_shapes   &    €€€€€€r   Ú	wrap_funcÚ_wrap_func.<locals>.wrap_funcÙ   st   ø€ Ø˜�|˜vÔ%Ü$Ó&Ð&Ø�a�L˜AÕ‹LÜ˜aÓ ×(Ñ(¨Ó2ˆAÜ—
’
™4 ˜> D›>Ó*×0Ñ0Ó2ˆAÜ˜aÓ ˆAÙ�q“	ˆAØ�4ˆKr   c                 óî   <€ S^ ,          S8¼  d   \        4       hS^ ;;,          ^,          uu&   V P                  S4      p \        P                  ! S! V .SO5!  4      P	                  4       pS! V4      pW!3# r_   )r   rb   r#   rc   rd   )	r   r   rH   r=   r&   r;   r@   rh   ri   s	   &  €€€€€€r   rj   rk   æ   sc   ø€ Ø˜�|˜vÔ%Ü$Ó&Ð&Ø�a�L˜AÕ‹LØ—	‘	˜(Ó#ˆAÜ—
’
™4 ˜> D›>Ó*×0Ñ0Ó2ˆAÙ�q“	ˆAØ�4ˆKr   )r#   rc   r*   rd   Úiscomplexobjre   )
r;   r<   r&   rh   r@   r=   r   rL   rj   ri   s
   f&ffff   @r   r2   r2   ¨   s°   ý€ ôP 
�Š�B‹€BØ�x‰x€HÜ
�
Š
‘4˜�?˜T“?Ó#×)Ñ)Ó+€AÜ—’ Ó$×:Ð:¬¯ª¸Ó(:€JØ	�‰‹€Bà€Iˆa�Lç÷	ò 	ô ˜2ÓˆÜ˜!Ó‰÷	ò 	ð ˜(¡F¨1£I¨qÐ<Ð<r   c                ó\   € V'       d   \        V 4      pMT pVe   VP                  V4      pV# )z9
Convert from real to complex and reshape result arrays.
)ra   rb   )r[   rL   r*   rf   s   &&& r   r:   r:   ò   s/   € ÷ Ü˜&Ó!‰àˆØÒØ�I‰I�eÓˆØ€Hr   c                 ót   € \         P                  ! V \        R 7      P                  \         P                  4      # ©)Údtype)r#   ÚascontiguousarrayÚfloatÚviewÚ
complex128)r   s   &r   ra   ra   ÿ   s$   € Ü×Ò ¬Ô/×4Ñ4´R·]±]ÓCÐCr   c                 ót   € \         P                  ! V \        R 7      P                  \         P                  4      # rp   )r#   rr   Úcomplexrt   Úfloat64)rf   s   &r   re   re     s$   € Ü×Ò ¬Ô1×6Ñ6´r·z±zÓBÐBr   )r   g:Œ0âŽyE>gYóøÂn¥iè  NNFé
   Ng»½×Ùß|Û=r   r   )r   r"   )Ú__doc__r3   Únumpyr#   Úscipy.optimizer   Úscipy.optimize._optimizer   Ú_linesearchr   r   Ú	Exceptionr   r\   r2   r:   ra   re   r   r   r   Ú<module>r€      sF   ðñó ã Ý )Ý ;ß Vô	�Yô 	ôVôrG=ôT
òDôCr   