ó
    ‚(phä  ã                   óT   • S r SSKrSSKrSSKrSSKJrJr  / r	SS jr
 " S S\5      rg)	z$Newton-CG trust-region optimization.é    Né   )Ú_minimize_trust_regionÚBaseQuadraticSubproblemc           	      ój   • Uc  [        S5      eUc  Uc  [        S5      e[        X4X#UU[        S.UD6$ )aö  
Minimization of scalar function of one or more variables using
the Newton conjugate gradient trust-region algorithm.

Options
-------
initial_trust_radius : float
    Initial trust-region radius.
max_trust_radius : float
    Maximum value of the trust-region radius. No steps that are longer
    than this value will be proposed.
eta : float
    Trust region related acceptance stringency for proposed steps.
gtol : float
    Gradient norm must be less than `gtol` before successful
    termination.

z<Jacobian is required for Newton-CG trust-region minimizationzdEither the Hessian or the Hessian-vector product is required for Newton-CG trust-region minimization)ÚargsÚjacÚhessÚhesspÚ
subproblem)Ú
ValueErrorr   ÚCGSteihaugSubproblem)ÚfunÚx0r   r   r	   r
   Útrust_region_optionss          ÚR/var/www/html/venv/lib/python3.13/site-packages/scipy/optimize/_trustregion_ncg.pyÚ_minimize_trust_ncgr      s_   € ð( {Üð (ó )ð 	)à|˜™Üð Oó Pð 	Pä! #ð :°ÀDØ(-Ô:Nñ:à$8ñ:ð :ó    c                   ó   • \ rS rSrSrS rSrg)r   é*   z:Quadratic subproblem solved by a conjugate gradient methodc                 óJ  • [         R                  " U R                  5      n[        S[        R
                  " U R                  5      5      U R                  -  nU R                  U:  a  SnX$4$ UnU R                  nU* n U R                  U5      n[         R                  " Xx5      n	U	S::  a>  U R                  XWU5      u  p«XZU-  -   nX[U-  -   nU " U5      U " U5      :  a  UnOUnSnXä4$ [         R                  " Xf5      nXù-  nUUU-  -   n[        R                  R                  U5      U:¼  a   U R                  XWU5      u  p«X[U-  -   nSnXä4$ UUU-  -   n[         R                  " UU5      n[        R
                  " U5      U:  a  SnUU4$ UU-  nU* UU-  -   nUnUnUnGM&  )a$  
Solve the subproblem using a conjugate gradient method.

Parameters
----------
trust_radius : float
    We are allowed to wander only this far away from the origin.

Returns
-------
p : ndarray
    The proposed step.
hits_boundary : bool
    True if the proposed step is on the boundary of the trust region.

Notes
-----
This is algorithm (7.2) of Nocedal and Wright 2nd edition.
Only the function that computes the Hessian-vector product is required.
The Hessian itself is not required, and the Hessian does
not need to be positive semidefinite.
g      à?FTr   )ÚnpÚ
zeros_liker   ÚminÚmathÚsqrtÚjac_magr
   ÚdotÚget_boundaries_intersectionsÚscipyÚlinalgÚnorm)ÚselfÚtrust_radiusÚp_originÚ	toleranceÚhits_boundaryÚzÚrÚdÚBdÚdBdÚtaÚtbÚpaÚpbÚ
p_boundaryÚ	r_squaredÚalphaÚz_nextÚr_nextÚr_next_squaredÚ	beta_nextÚd_nexts                         r   ÚsolveÚCGSteihaugSubproblem.solve,   s¿  € ô2 —=’= §¡Ó*ˆô ˜œTŸYšY t§|¡|Ó4Ó5¸¿¹ÑDˆ	ð <‰<˜)Ó#Ø!ˆMØÐ*Ð*ð ˆØH‰HˆØˆBˆð ð —‘˜A“ˆBÜ—&’&˜“-ˆCØa‹xð
 ×:Ñ:¸1ÀÓN‘Ø˜a™‘ZØ˜a™‘ZÙ˜“8™d 2›hÓ&Ø!#‘Jà!#JØ $Ø!Ð0Ð0ÜŸš˜q›ˆIØ‘OˆEØ˜ ™‘]ˆFÜ|‰|× Ñ  Ó(¨LÓ8ð ×:Ñ:¸1ÀÓN‘Ø a¡™Z
Ø $Ø!Ð0Ð0Ø˜ ™‘^ˆFÜŸVšV F¨FÓ3ˆNÜyŠy˜Ó(¨9Ó4Ø %Ø˜}Ð,Ð,Ø&¨Ñ2ˆIØW˜y¨1™}Ñ,ˆFð ˆAØˆAØˆAòQ r   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r8   Ú__static_attributes__r:   r   r   r   r   *   s   † ÙDõRr   r   )r:   NNN)r?   r   Únumpyr   Úscipy.linalgr   Ú_trustregionr   r   Ú__all__r   r   r:   r   r   Ú<module>rE      s-   ðÙ *Û ã Û ß Kà
€ô:ô>TÐ2õ Tr   