+
    LV-j P  ã                   óR  € R t ^ RIHt ^ RIt^ RIHt ^ RIHtH	t	H
t
 ^ RIHtHt ^ RIHt ]P                   ! ]4      P$                  tR tR!R ltR	 tR
 tR"R ltR#R ltR$R ltR tR tR%R ltR%R ltR tR t R t!R t"R t#R t$R t%R$R lt&R t'R t(R t)R&R lt*R&R lt+R t,R  t-R# )'z+Functions used by least-squares algorithms.)ÚcopysignN)Únorm)Ú
cho_factorÚ	cho_solveÚLinAlgError)ÚLinearOperatorÚaslinearoperator)Úissparsec                óš  € \         P                  ! W4      pV^ 8X  d   \        R4      h\         P                  ! W4      p\         P                  ! W 4      V^,          ,
          pV^ 8”  d   \        R4      h\         P                  ! WD,          W5,          ,
          4      pV\	        Wd4      ,           ) pWs,          pWW,          p	W‰8  d   W‰3# W˜3# )aE  Find the intersection of a line with the boundary of a trust region.

This function solves the quadratic equation with respect to t
||(x + s*t)||**2 = Delta**2.

Returns
-------
t_neg, t_pos : tuple of float
    Negative and positive roots.

Raises
------
ValueError
    If `s` is zero or `x` is not within the trust region.
z`s` is zero.z#`x` is not within the trust region.)ÚnpÚdotÚ
ValueErrorÚsqrtr   )
ÚxÚsÚDeltaÚaÚbÚcÚdÚqÚt1Út2s
   &&&       Úk/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/scipy/optimize/_lsq/common.pyÚintersect_trust_regionr      s£   € ô  	�Šˆq‹€AØˆA„vÜ˜Ó(Ð(ä
�Šˆq‹€Aä
�Šˆq‹�u˜a•xÕ€AØˆ1„uÜÐ>Ó?Ð?ä
�Š�•�a•c•	Ó€Að Œh�q‹nÕ
Ð€AØ	
�€BØ	
�€Bà	„wØˆvˆàˆvˆó    c	                ó²  € R p	W2,          p
W8¼  d)   \         V,          V^ ,          ,          pVR,          V8„  pMRpV'       d.   VP                  W#,          4      ) p\        V4      V8:  d   VR^ 3# \        V
4      V,          pV'       d   V	! RW£V4      w  ppV) V,          pMRpVe   V'       g*   V^ 8X  d#   \        RV,          VV,          R,          4      pMTp\	        V4       F¤  pVV8  g   VV8”  d"   \        RV,          VV,          R,          4      pV	! VW£V4      w  ppV^ 8  d   TpVV,          p\        VVV,
          4      pVWõ,           V,          V,          ,          p\
        P                  ! V4      Wu,          8  g   K¤   M	  VP                  W£^,          V,           ,          4      ) pWÕ\        V4      ,          ,          pVVX^,           3# )a  Solve a trust-region problem arising in least-squares minimization.

This function implements a method described by J. J. More [1]_ and used
in MINPACK, but it relies on a single SVD of Jacobian instead of series
of Cholesky decompositions. Before running this function, compute:
``U, s, VT = svd(J, full_matrices=False)``.

Parameters
----------
n : int
    Number of variables.
m : int
    Number of residuals.
uf : ndarray
    Computed as U.T.dot(f).
s : ndarray
    Singular values of J.
V : ndarray
    Transpose of VT.
Delta : float
    Radius of a trust region.
initial_alpha : float, optional
    Initial guess for alpha, which might be available from a previous
    iteration. If None, determined automatically.
rtol : float, optional
    Stopping tolerance for the root-finding procedure. Namely, the
    solution ``p`` will satisfy ``abs(norm(p) - Delta) < rtol * Delta``.
max_iter : int, optional
    Maximum allowed number of iterations for the root-finding procedure.

Returns
-------
p : ndarray, shape (n,)
    Found solution of a trust-region problem.
alpha : float
    Positive value such that (J.T*J + alpha*I)*p = -J.T*f.
    Sometimes called Levenberg-Marquardt parameter.
n_iter : int
    Number of iterations made by root-finding procedure. Zero means
    that Gauss-Newton step was selected as the solution.

References
----------
.. [1] More, J. J., "The Levenberg-Marquardt Algorithm: Implementation
       and Theory," Numerical Analysis, ed. G. A. Watson, Lecture Notes
       in Mathematics 630, Springer Verlag, pp. 105-116, 1977.
c                óÀ   € V^,          V ,           p\        W,          4      pWS,
          p\        P                  ! V^,          V^,          ,          4      ) V,          pWg3# )zˆFunction of which to find zero.

It is defined as "norm of regularized (by alpha) least-squares
solution minus `Delta`". Refer to [1]_.
)r   r   Úsum)ÚalphaÚsufr   r   ÚdenomÚp_normÚphiÚ	phi_primes   &&&&    r   Úphi_and_derivativeÚ2solve_lsq_trust_region.<locals>.phi_and_derivativej   sO   € ð �1•�u•ˆÜ�c•kÓ"ˆØ�nˆÜ—V’V˜C 1�H u¨a¥xÕ/Ó0Ð0°6Õ9ˆ	Øˆ~Ðr   Fg        gü©ñÒMbP?ç      à?éÿÿÿÿ)ÚEPSr   r   ÚmaxÚranger   Úabs)ÚnÚmÚufr   ÚVr   Úinitial_alphaÚrtolÚmax_iterr%   r    Ú	thresholdÚ	full_rankÚpÚalpha_upperr#   r$   Úalpha_lowerr   ÚitÚratios   &&&&&&&&&            r   Úsolve_lsq_trust_regionr;   9   s¦  € òb
ð �&€Cð 	„vÜ˜!•G˜a �d•Nˆ	Ø�b•E˜IÑ%‰	àˆ	çØ�U‰U�2•6‹]ˆNˆÜ�‹7�eÔØ�c˜1�9Ðä�s“)˜eÕ#€KçÙ+¨C°¸Ó?‰ˆˆYØ�d˜YÕ&‰àˆàÒ§I°-À1Ô2DÜ�E˜KÕ'¨+¸Õ*CÀcÕ)IÓJ‰àˆä�HŽoˆØ�;Ô %¨+Ô"5Ü˜ Õ+¨k¸KÕ.GÈ#Õ-MÓNˆEá+¨E°3¸5ÓA‰ˆˆYà�Œ7ØˆKà�i•ˆÜ˜+ u¨u¥}Ó5ˆØ�#•+ Õ&¨Õ.Õ.ˆä�6Š6�#‹;˜�Ö%Ùñ ð  
�‰ˆs˜•d˜U•lÕ#Ó	$Ð$€Að
 ”�a“�Õ€Aàˆe�R˜!•VÐÐr   c                ó`  €  \        V 4      w  r4\        W43V4      ) p\        P                  ! WU4      V^,          8:  d   VR3#  V R,          V^,          ,          pV R,          V^,          ,          pV R,          V^,          ,          pV^ ,          V,          p	V^,          V,          p
\        P
                  ! V) V	,           ^Wh,
          V
,           ,          ^V,          ^V) V,           V
,           ,          V) V	,
          .4      p\        P                  ! V4      p\        P                  ! V\        P                  ! V4      ,          4      pV\        P                  ! ^V,          ^V^,          ,           ,          ^V^,          ,
          ^V^,          ,           ,          34      ,          pR\        P                  ! WPP                  V4      ,          ^ R7      ,          \        P                  ! W4      ,           p\        P                  ! V4      pVRV3,          pVR3#   \         d     ELèi ; i)	a2  Solve a general trust-region problem in 2 dimensions.

The problem is reformulated as a 4th order algebraic equation,
the solution of which is found by numpy.roots.

Parameters
----------
B : ndarray, shape (2, 2)
    Symmetric matrix, defines a quadratic term of the function.
g : ndarray, shape (2,)
    Defines a linear term of the function.
Delta : float
    Radius of a trust region.

Returns
-------
p : ndarray, shape (2,)
    Found solution.
newton_step : bool
    Whether the returned solution is the Newton step which lies within
    the trust region.
Tr'   ©ÚaxisºNNNF)é    r@   )r@   é   )rA   rA   )r   r   r   r   r   ÚarrayÚrootsÚrealÚisrealÚvstackr   Úargmin)ÚBÚgr   ÚRÚlowerr6   r   r   r   r   ÚfÚcoeffsÚtÚvalueÚis   &&&            r   Úsolve_trust_region_2drQ   «   s§  € ð.Ü˜a“=‰ˆÜ˜�z 1Ó%Ð%ˆÜ�6Š6�!‹<˜5 !�8Ô#Ø�d�7ˆNð $ð
 	
ˆ$��%˜•(Õ€AØ	ˆ$��%˜•(Õ€AØ	ˆ$��%˜•(Õ€Aà	ˆ!�ˆu�€AØ	ˆ!�ˆu�€Aä�XŠXØ
ˆˆa���a•e˜a•i• ! a¥%¨¨q¨b°1­f°q­jÕ)9¸A¸2À½6ÐBóD€Fä
�Š�Ó€AÜ
�Š�”"—)’)˜A“,•Ó €Aà”—	’	˜1˜q�5 A¨¨1­¥HÕ-°°A°qµDµ¸QÀÀAÅ½XÕ/FÐGÓHÕH€AØ”"—&’&˜ŸU™U 1›X�¨AÔ.Õ.´·²¸³Õ=€EÜ
�	Š	�%Ó€AØ	ˆ!ˆQˆ$�€Aàˆeˆ8€Oøô) ô Úðús   ‚A H ÈH-È,H-c                óª   € V^ 8”  d
   W,          pMY!u;8X  d   ^ 8X  d   M M^pM^ pVR8  d   RV,          p W3# VR8”  d   V'       d
   V R,          p W3# )z±Update the radius of a trust region based on the cost reduction.

Returns
-------
Delta : float
    New radius.
ratio : float
    Ratio between actual and predicted reductions.
ç      Ð?g      è?g       @© )r   Úactual_reductionÚpredicted_reductionÚ	step_normÚ	bound_hitr:   s   &&&&& r   Úupdate_tr_radiusrY   Þ   s`   € ð ˜QÔØ Õ6‰Ø	Ö	5°A×	5Ø‰àˆàˆt„|Ø�yÕ ˆð ˆ<Ðð 
�ŒŸ)Ø��ˆàˆ<Ðr   c                óf  € V P                  V4      p\        P                   ! WU4      pVe%   V\        P                   ! W#,          V4      ,          pVR,          p\        P                   ! W4      pVe¾   V P                  V4      pV\        P                   ! W…4      ,          pR\        P                   ! Wˆ4      ,          \        P                   ! W4      ,           p	VeP   V\        P                   ! WC,          V4      ,          pV	R\        P                   ! WC,          V4      ,          ,          p	WgV	3# Wg3# )aH  Parameterize a multivariate quadratic function along a line.

The resulting univariate quadratic function is given as follows::

    f(t) = 0.5 * (s0 + s*t).T * (J.T*J + diag) * (s0 + s*t) +
           g.T * (s0 + s*t)

Parameters
----------
J : ndarray, sparse array or LinearOperator shape (m, n)
    Jacobian matrix, affects the quadratic term.
g : ndarray, shape (n,)
    Gradient, defines the linear term.
s : ndarray, shape (n,)
    Direction vector of a line.
diag : None or ndarray with shape (n,), optional
    Addition diagonal part, affects the quadratic term.
    If None, assumed to be 0.
s0 : None or ndarray with shape (n,), optional
    Initial point. If None, assumed to be 0.

Returns
-------
a : float
    Coefficient for t**2.
b : float
    Coefficient for t.
c : float
    Free term. Returned only if `s0` is provided.
r'   )r   r   )
ÚJrI   r   ÚdiagÚs0Úvr   r   Úur   s
   &&&&&     r   Úbuild_quadratic_1dr`   û   sÝ   € ð> 	
�‰ˆa‹€AÜ
�Šˆq‹€AØÒØ	ŒR�VŠV�A•H˜aÓ Õ ˆØˆ…H€Aä
�Šˆq‹€Aà	‚~Ø�E‰E�"‹IˆØ	ŒR�VŠV�A‹\ÕˆØ”"—&’&˜“,Õ¤§¢¨£Õ.ˆØÒØ”—’˜�	 1Ó%Õ%ˆAØ�”r—v’v˜b�i¨Ó,Õ,Õ,ˆAØ�Qˆwˆàˆtˆr   c                ó,  € W#.pV ^ 8w  d3   RV,          V ,          pY&u;8  d   V8  d   M MVP                  V4       \        P                  ! V4      pWPV,          V,           ,          V,           p\        P                  ! V4      pWX,          Wx,          3# )z»Minimize a 1-D quadratic function subject to bounds.

The free term `c` is 0 by default. Bounds must be finite.

Returns
-------
t : float
    Minimum point.
y : float
    Minimum value.
g      à¿)Úappendr   ÚasarrayrG   )	r   r   ÚlbÚubr   rN   ÚextremumÚyÚ	min_indexs	   &&&&&    r   Úminimize_quadratic_1dri   .  ss   € ð 
ˆ€AØˆA„vØ˜!•8˜a•<ˆØÖ˜2×Ø�H‰H�XÔÜ
�
Š
�1‹€AØ	��U�Q�Y�˜!Õ€AÜ—	’	˜!“€IØ�<˜�Ð%Ð%r   c                óä  € VP                   ^8X  dQ   V P                  V4      p\        P                  ! WD4      pVe%   V\        P                  ! W#,          V4      ,          pMjV P                  VP                  4      p\        P                  ! V^,          ^ R7      pVe-   V\        P                  ! W2^,          ,          ^R7      ,          p\        P                  ! W!4      pRV,          V,           # )a£  Compute values of a quadratic function arising in least squares.

The function is 0.5 * s.T * (J.T * J + diag) * s + g.T * s.

Parameters
----------
J : ndarray, sparse array or LinearOperator, shape (m, n)
    Jacobian matrix, affects the quadratic term.
g : ndarray, shape (n,)
    Gradient, defines the linear term.
s : ndarray, shape (k, n) or (n,)
    Array containing steps as rows.
diag : ndarray, shape (n,), optional
    Addition diagonal part, affects the quadratic term.
    If None, assumed to be 0.

Returns
-------
values : ndarray with shape (k,) or float
    Values of the function. If `s` was 2-D, then ndarray is
    returned, otherwise, float is returned.
r=   r'   )Úndimr   r   ÚTr   )r[   rI   r   r\   ÚJsr   Úls   &&&&   r   Úevaluate_quadraticro   E  s¨   € ð. 	‡v�v�„{Ø�U‰U�1‹XˆÜ�FŠF�2‹NˆØÒØ”—’˜� !Ó$Õ$ˆAøà�U‰U�1—3‘3‹ZˆÜ�FŠF�2�q•5˜qÔ!ˆØÒØ”—’˜ !�t�¨!Ô,Õ,ˆAä
�Šˆq‹€Aà��7�Q�;Ðr   c                óD   € \         P                  ! W8¬  W8*  ,          4      # )z$Check if a point lies within bounds.)r   Úall)r   rd   re   s   &&&r   Ú	in_boundsrr   o  s   € ä�6Š6�1‘7˜q™wÕ'Ó(Ð(r   c                óX  € \         P                  ! V4      pW,          p\         P                  ! V 4      pVP                  \         P                  4       \         P
                  ! RR7      ;_uu_ 4        \         P                  ! W ,
          V,          V,          W0,
          V,          V,          4      Wd&   RRR4       \         P                  ! V4      pV\         P                  ! Wg4      \         P                  ! V4      P                  \        4      ,          3#   + '       g   i     Ll; i)a¼  Compute a min_step size required to reach a bound.

The function computes a positive scalar t, such that x + s * t is on
the bound.

Returns
-------
step : float
    Computed step. Non-negative value.
hits : ndarray of int with shape of x
    Each element indicates whether a corresponding variable reaches the
    bound:

         *  0 - the bound was not hit.
         * -1 - the lower bound was hit.
         *  1 - the upper bound was hit.
Úignore)ÚoverN)r   ÚnonzeroÚ
empty_likeÚfillÚinfÚerrstateÚmaximumÚminÚequalÚsignÚastypeÚint)r   r   rd   re   Únon_zeroÚ
s_non_zeroÚstepsÚmin_steps   &&&&    r   Ústep_size_to_boundr…   t  s¼   € ô$ �zŠz˜!‹}€HØ•€JÜ�MŠM˜!Ó€EØ	‡J�JŒr�v‰vÔÜ	�Š˜(×	#Ö	#ÜŸ*š* b¥f¨hÕ%7¸*Õ%DØ&(¥f¨hÕ%7¸*Õ%DóFˆ‰÷ 
$ô �vŠv�e‹}€HØ”R—X’X˜eÓ.´·²¸³×1BÑ1BÄ3Ó1GÕGÐGÐG÷	 
$×	#ús   Á3ADÄD)	c                ó4  € \         P                  ! V \        R7      pV^ 8X  d   RW@V8*  &   ^W@V8¬  &   V# W,
          pW ,
          pV\         P                  ! ^\         P                  ! V4      4      ,          pV\         P                  ! ^\         P                  ! V4      4      ,          p\         P
                  ! V4      V\         P                  ! Wg4      8*  ,          p	RWI&   \         P
                  ! V4      V\         P                  ! WX4      8*  ,          p
^WJ&   V# )a�  Determine which constraints are active in a given point.

The threshold is computed using `rtol` and the absolute value of the
closest bound.

Returns
-------
active : ndarray of int with shape of x
    Each component shows whether the corresponding constraint is active:

         *  0 - a constraint is not active.
         * -1 - a lower bound is active.
         *  1 - a upper bound is active.
©Údtyper(   )r   Ú
zeros_liker€   r{   r,   ÚisfiniteÚminimum)r   rd   re   r2   ÚactiveÚ
lower_distÚ
upper_distÚlower_thresholdÚupper_thresholdÚlower_activeÚupper_actives   &&&&       r   Úfind_active_constraintsr“   ‘  sÛ   € ô �]Š]˜1¤CÔ(€Fàˆq„yØˆ�B‰w‰Øˆ�B‰w‰Øˆà•€JØ•€JàœRŸZšZ¨¬2¯6ª6°"«:Ó6Õ6€OØœRŸZšZ¨¬2¯6ª6°"«:Ó6Õ6€Oä—K’K “OØ¤2§:¢:¨jÓ#JÑJõL€Là€FÑä—K’K “OØ¤2§:¢:¨jÓ#JÑJõL€Là€FÑà€Mr   c           	     ó°  € V P                  4       p\        WW#4      p\        P                  ! VR4      p\        P                  ! V^4      pV^ 8X  dL   \        P                  ! W,          W&,          4      WF&   \        P                  ! W',          W,          4      WG&   MŽW,          V\        P
                  ! ^\        P                  ! W,          4      4      ,          ,           WF&   W',          V\        P
                  ! ^\        P                  ! W',          4      4      ,          ,
          WG&   WA8  WB8„  ,          pRW,          W(,          ,           ,          WH&   V# )zÈShift a point to the interior of a feasible region.

Each element of the returned vector is at least at a relative distance
`rstep` from the closest bound. If ``rstep=0`` then `np.nextafter` is used.
r'   r(   )Úcopyr“   r   r}   Ú	nextafterr{   r,   )	r   rd   re   ÚrstepÚx_newrŒ   Ú
lower_maskÚ
upper_maskÚtight_boundss	   &&&&     r   Úmake_strictly_feasiblerœ   ¸  sù   € ð �F‰F‹H€Eä$ Q¨BÓ6€FÜ—’˜& "Ó%€JÜ—’˜& !Ó$€Jà�„zÜŸLšL¨­¸½ÓHˆÑÜŸLšL¨­¸½ÓHˆÒà�^Ø"¤R§Z¢Z°´2·6²6¸"½.Ó3IÓ%JÕJõKˆÑà�^Ø"¤R§Z¢Z°´2·6²6¸"½.Ó3IÓ%JÕJõKˆÑð ‘J 5¡:Õ.€LØ Õ!1°BÕ4DÕ!DÕE€EÑà€Lr   c                óL  € \         P                  ! V 4      p\         P                  ! V 4      pV^ 8  \         P                  ! V4      ,          pW6,          W,          ,
          WF&   RWV&   V^ 8„  \         P                  ! V4      ,          pW,          W&,          ,
          WF&   ^WV&   WE3# )aØ  Compute Coleman-Li scaling vector and its derivatives.

Components of a vector v are defined as follows::

           | ub[i] - x[i], if g[i] < 0 and ub[i] < np.inf
    v[i] = | x[i] - lb[i], if g[i] > 0 and lb[i] > -np.inf
           | 1,           otherwise

According to this definition v[i] >= 0 for all i. It differs from the
definition in paper [1]_ (eq. (2.2)), where the absolute value of v is
used. Both definitions are equivalent down the line.
Derivatives of v with respect to x take value 1, -1 or 0 depending on a
case.

Returns
-------
v : ndarray with shape of x
    Scaling vector.
dv : ndarray with shape of x
    Derivatives of v[i] with respect to x[i], diagonal elements of v's
    Jacobian.

References
----------
.. [1] M.A. Branch, T.F. Coleman, and Y. Li, "A Subspace, Interior,
       and Conjugate Gradient Method for Large-Scale Bound-Constrained
       Minimization Problems," SIAM Journal on Scientific Computing,
       Vol. 21, Number 1, pp 1-23, 1999.
r(   )r   Ú	ones_liker‰   rŠ   )r   rI   rd   re   r^   ÚdvÚmasks   &&&&   r   ÚCL_scaling_vectorr¡   Ó  s€   € ô< 	�Š�Q‹€AÜ	�Š�qÓ	€Bà�‰E”R—[’[ “_Õ$€DØ�h˜�Õ €A�GØ€B�Hà�‰E”R—[’[ “_Õ$€DØ�g˜�Õ €A�GØ€B�Hàˆ5€Lr   c                ó²  € \        WV4      '       d   V \        P                  ! V 4      3# \        P                  ! V4      p\        P                  ! V4      pV P	                  4       p\        P
                  ! V \        R7      pW4( ,          p\        P                  ! W,          ^W,          ,          W,          ,
          4      WW&   W,          W,          8  Wg&   V( V,          p\        P                  ! W,          ^W',          ,          W,          ,
          4      WW&   W,          W',          8„  Wg&   W4,          pW!,
          p\        P                  ! W,          W,          ,
          ^W‡,          ,          4      p	W,          \        P                  ! V	^W‡,          ,          V	,
          4      ,           WW&   W˜V,          8„  Wg&   \        P                  ! V 4      p
RW¦&   WZ3# )z3Compute reflective transformation and its gradient.r‡   r(   )
rr   r   rž   rŠ   r•   r‰   Úboolr{   r‹   Ú	remainder)rg   rd   re   Ú	lb_finiteÚ	ub_finiter   Ú
g_negativer    r   rN   rI   s   &&&        r   Úreflective_transformationr¨   ÿ  sK  € ä�˜×ÒØ”"—,’,˜q“/Ð!Ð!ä—’˜B“€IÜ—’˜B“€Ià	�‰‹€AÜ—’˜q¬Ô-€Jà�zÕ!€DÜ�jŠj˜� ! b¥h¥,°µÕ"8Ó9€A�GØ•w ¥Ñ)€JÑàˆ:˜	Õ!€DÜ�jŠj˜� ! b¥h¥,°µÕ"8Ó9€A�GØ•w ¥Ñ)€JÑàÕ €DØ
�€AÜ
�Š�Q•W˜r�xÕ'¨¨Q­W­Ó5€AØ�hœŸš A q¨1­7¥{°Q¥Ó7Õ7€A�GØ˜T�7‘{€JÑä
�Š�Q‹€AØ€A�Màˆ4€Kr   c            
      óD   € \        R P                  RRRRRR4      4       R# )z${:^15}{:^15}{:^15}{:^15}{:^15}{:^15}Ú	Iterationz
Total nfevÚCostúCost reductionú	Step normÚ
OptimalityN©ÚprintÚformatrT   r   r   Úprint_header_nonlinearr²   !  s%   € Ü	Ð
0ß‰6�+˜|¨VÐ5EØ˜|ó-ö.r   c           	      óh   € Vf   RpMVR pVf   RpMVR p\        V R VR VR V V VR 24       R # ©Nz^15.2ez^15z^15.4ez               ©r°   )Ú	iterationÚnfevÚcostÚcost_reductionrW   Ú
optimalitys   &&&&&&r   Úprint_iteration_nonlinearr»   '  sX   € àÒØ!‰à*¨6Ð2ˆàÒØ‰	à  Ð(ˆ	ä	ˆY�sˆO˜D ˜: d¨6 ]°>Ð2BÀ9À+ÈjÐY_ÐM`Ð
aÖbr   c            	      óB   € \        R P                  RRRRR4      4       R# )z{:^15}{:^15}{:^15}{:^15}{:^15}rª   r«   r¬   r­   r®   Nr¯   rT   r   r   Úprint_header_linearr½   6  s#   € Ü	Ð
*ß‰6�+˜vÐ'7¸Øó ö!r   c                 ób   € Vf   RpMVR pVf   RpMVR p\        V R VR V V VR 24       R # r´   rµ   )r¶   r¸   r¹   rW   rº   s   &&&&&r   Úprint_iteration_linearr¿   <  sQ   € àÒØ!‰à*¨6Ð2ˆàÒØ‰	à  Ð(ˆ	ä	ˆY�sˆO˜D ˜=¨Ð(8¸¸ÀJÈvÐCVÐ
WÖXr   c                ó†   € \        V \        4      '       d   V P                  V4      # V P                  P	                  V4      # )z4Compute gradient of the least-squares cost function.)Ú
isinstancer   Úrmatvecrl   r   )r[   rL   s   &&r   Úcompute_gradrÃ   N  s/   € ä�!”^×$Ò$Ø�y‰y˜‹|Ðà�s‰s�w‰w�q‹zÐr   c                ó`  € \        V 4      '       dL   \        P                  ! V P                  ^4      P	                  ^ R7      4      P                  4       R,          pM&\        P                  ! V ^,          ^ R7      R,          pVf	   ^W"^ 8H  &   M\        P                  ! W!4      p^V,          V3# )z5Compute variables scale based on the Jacobian matrix.r=   r'   )r	   r   rc   Úpowerr   Úravelr{   )r[   Úscale_inv_oldÚ	scale_invs   && r   Úcompute_jac_scalerÉ   V  s‚   € ä�‡{‚{Ü—J’J˜qŸw™w q›zŸ~™~°1˜~Ó5Ó6×<Ñ<Ó>ÀÕC‰	ä—F’F˜1˜a�4 aÔ(¨#Õ-ˆ	àÒØ$%ˆ	˜q‘.Ò!ä—J’J˜yÓ8ˆ	àˆy�=˜)Ð#Ð#r   c                óv   a a€ \        S 4      o V V3R lpV V3R lpV V3R lp\        S P                  W#VR7      # )z#Return diag(d) J as LinearOperator.c                 ó4   <€ SSP                  V 4      ,          # ©N)Úmatvec©r   r[   r   s   &€€r   rÍ   Ú(left_multiplied_operator.<locals>.matveci  s   ø€ Ø�1—8‘8˜A“;�Ðr   c                 ób   <€ SR \         P                  3,          SP                  V 4      ,          # ©r?   )r   ÚnewaxisÚmatmat©ÚXr[   r   s   &€€r   rÓ   Ú(left_multiplied_operator.<locals>.matmatl  s#   ø€ Ø�”B—J‘J�Õ !§(¡(¨1£+Õ-Ð-r   c                 óP   <€ SP                  V P                  4       S,          4      # rÌ   )rÂ   rÆ   rÎ   s   &€€r   rÂ   Ú)left_multiplied_operator.<locals>.rmatveco  s   ø€ Ø�y‰y˜Ÿ™› Q�Ó'Ð'r   ©rÍ   rÓ   rÂ   ©r   r   Úshape©r[   r   rÍ   rÓ   rÂ   s   ff   r   Úleft_multiplied_operatorrÝ   e  s6   ù€ ä˜Ó€Aöö.ö(ô ˜!Ÿ'™'¨&Ø")ô+ð +r   c                óv   a a€ \        S 4      o V V3R lpV V3R lpV V3R lp\        S P                  W#VR7      # )z#Return J diag(d) as LinearOperator.c                 ó\   <€ SP                  \        P                  ! V 4      S,          4      # rÌ   )rÍ   r   rÆ   rÎ   s   &€€r   rÍ   Ú)right_multiplied_operator.<locals>.matvecz  s   ø€ Ø�x‰xœŸš › a�Ó(Ð(r   c                 ób   <€ SP                  V SR \        P                  3,          ,          4      # rÑ   )rÓ   r   rÒ   rÔ   s   &€€r   rÓ   Ú)right_multiplied_operator.<locals>.matmat}  s$   ø€ Ø�x‰x˜˜A˜a¤§¡˜mÕ,Õ,Ó-Ð-r   c                 ó4   <€ SSP                  V 4      ,          # rÌ   ©rÂ   rÎ   s   &€€r   rÂ   Ú*right_multiplied_operator.<locals>.rmatvec€  s   ø€ Ø�1—9‘9˜Q“<ÕÐr   rÙ   rÚ   rÜ   s   ff   r   Úright_multiplied_operatorræ   v  s6   ù€ ä˜Ó€Aö)ö.ö ô ˜!Ÿ'™'¨&Ø")ô+ð +r   c                ó†   a aa€ \        S 4      o S P                  w  opV V3R lpV VV3R lp\        SV,           V3W4R7      # )z¡Return a matrix arising in regularized least squares as LinearOperator.

The matrix is
    [ J ]
    [ D ]
where D is diagonal matrix with elements from `diag`.
c                 ó`   <€ \         P                  ! SP                  V 4      SV ,          34      # rÌ   )r   ÚhstackrÍ   )r   r[   r\   s   &€€r   rÍ   Ú(regularized_lsq_operator.<locals>.matvec’  s#   ø€ Ü�yŠy˜!Ÿ(™( 1›+ t¨a¥xÐ0Ó1Ð1r   c                 óV   <€ V R S pV SR  pSP                  V4      SV,          ,           # rÌ   rä   )r   Úx1Úx2r[   r\   r.   s   &  €€€r   rÂ   Ú)regularized_lsq_operator.<locals>.rmatvec•  s0   ø€ Øˆr�ˆUˆØˆqˆrˆUˆØ�y‰y˜‹}˜t b�yÕ(Ð(r   )rÍ   rÂ   )r   rÛ   r   )r[   r\   r-   rÍ   rÂ   r.   s   ff   @r   Úregularized_lsq_operatorrï   ‡  s=   ú€ ô 	˜Ó€AØ�7‰7�D€A€qö2÷)ô
 ˜1˜q�5 !˜*¨VÔEÐEr   c                óF  € V'       d'   \        V \        4      '       g   V P                  4       p \        V 4      '       d7   V ;P                  VP                  V P                  RR7      ,          un        V # \        V \        4      '       d   \        W4      p V # W,          p V # )z`Compute J diag(d).

If `copy` is False, `J` is modified in place (unless being LinearOperator).
Úclip)Úmode)rÁ   r   r•   r	   ÚdataÚtakeÚindicesræ   ©r[   r   r•   s   &&&r   Úright_multiplyr÷   �  s{   € ÷
 ”J˜q¤.×1Ò1Ø�F‰F‹Hˆä�‡{‚{Ø	�Š�!—&‘&˜Ÿ™¨�&Ó0Õ0�ð €Hô 
�A”~×	&Ò	&Ü% aÓ+ˆð €Hð 	
�ˆà€Hr   c                ó¤  € V'       d'   \        V \        4      '       g   V P                  4       p \        V 4      '       dO   V ;P                  \
        P                  ! V\
        P                  ! V P                  4      4      ,          un        V # \        V \        4      '       d   \        W4      p V # WR\
        P                  3,          ,          p V # )z`Compute diag(d) J.

If `copy` is False, `J` is modified in place (unless being LinearOperator).
r?   )rÁ   r   r•   r	   ró   r   ÚrepeatÚdiffÚindptrrÝ   rÒ   rö   s   &&&r   Úleft_multiplyrü   ¯  s�   € ÷
 ”J˜q¤.×1Ò1Ø�F‰F‹Hˆä�‡{‚{Ø	�Š”"—)’)˜AœrŸwšw q§x¡xÓ0Ó1Õ1�ð €Hô 
�A”~×	&Ò	&Ü$ QÓ*ˆð €Hð 	
ˆq”"—*‘*ˆ}ÕÕˆà€Hr   c                ó¤   € WV,          8  ;'       d    VR8„  pW&Wc,           ,          8  pV'       d   V'       d   ^# V'       d   ^# V'       d   ^# R# )z8Check termination condition for nonlinear least squares.rS   NrT   )	ÚdFÚFÚdx_normÚx_normr:   ÚftolÚxtolÚftol_satisfiedÚxtol_satisfieds	   &&&&&&&  r   Úcheck_terminationr  Á  s?   € à �(‘]×3Ð3 u¨t¡|€NØ t¥}Õ5Ñ5€NçŸ.Ùß	Ùß	Ùár   c                óÔ   € V^,          ^V^,          ,          V^,          ,          ,           p\         W3\         8  &   VR,          pW^,          V,          ,          p\        WRR7      V3# )zXScale Jacobian and residuals for a robust loss function.

Arrays are modified in place.
r'   F)r•   )r)   rü   )r[   rL   ÚrhoÚJ_scales   &&& r   Úscale_for_robust_loss_functionr
  Ð  s[   € ð
 �!�f�q˜3˜q�6•z A q¥DÕ(Õ(€GÜ €G”c‰MÑØ�…O€GàˆQ��'Õ	Õ€Aä˜¨%Ô0°!Ð3Ð3r   )Ng{®Gáz„?é
   )NN)r@   rÌ   )g»½×Ùß|Û=)T).Ú__doc__Úmathr   Únumpyr   Únumpy.linalgr   Úscipy.linalgr   r   r   Úscipy.sparse.linalgr   r   Úscipy._lib._sparser	   ÚfinfoÚfloatÚepsr)   r   r;   rQ   rY   r`   ri   ro   rr   r…   r“   rœ   r¡   r¨   r²   r»   r½   r¿   rÃ   rÉ   rÝ   ræ   rï   r÷   rü   r  r
  rT   r   r   Ú<module>r     sÁ   ðÙ 1Ý ã Ý ç ;Ñ ;ß @Ý 'ð 	‡h‚hˆuƒo×Ñ€ò$ôNoòd0òfô:0ôf&ô.$òT)ò
Hô:$ôNò6)òXòD.òcò!òYò$ô$ò+ò"+ò"Fô,ô$ò$ô4r   