+
    /i                         R t ^ RIt^ RIHt ^ RIHtHt ^ RIH	t	 ^ RI
Ht ^RIHt ^RIHtHtHtHtHtHtHtHtHtHtHtHtHtHtHt RR ltR	 tR
 tRR/R lt R# )zWThe adaptation of Trust Region Reflective algorithm for a linear
least-squares problem.N)norm)qrsolve_triangular)lsmr)OptimizeResult)givens_elimination)EPSstep_size_to_boundfind_active_constraints	in_boundsmake_strictly_feasiblebuild_quadratic_1devaluate_quadraticminimize_quadratic_1dCL_scaling_vectorreflective_transformationprint_header_linearprint_iteration_linearcompute_gradregularized_lsq_operatorright_multiplied_operatorc                   V'       d   VP                  4       pVP                  4       p\        W'WT,          4       \        P                  ! \        P                  ! V4      4      p\
        \        W4      ,          \        P                  ! V4      ,          p	\        P                  ! W8  4      w  p
V\        P                  ! W4      ,          pWz,          p\        P                  ! V4      p\        W'4      WV
,          &   V# )a^  Solve regularized least squares using information from QR-decomposition.

The initial problem is to solve the following system in a least-squares
sense::

    A x = b
    D x = 0

where D is diagonal matrix. The method is based on QR decomposition
of the form A P = Q R, where P is a column permutation matrix, Q is an
orthogonal matrix and R is an upper triangular matrix.

Parameters
----------
m, n : int
    Initial shape of A.
R : ndarray, shape (n, n)
    Upper triangular matrix from QR decomposition of A.
QTb : ndarray, shape (n,)
    First n components of Q^T b.
perm : ndarray, shape (n,)
    Array defining column permutation of A, such that ith column of
    P is perm[i]-th column of identity matrix.
diag : ndarray, shape (n,)
    Array containing diagonal elements of D.

Returns
-------
x : ndarray, shape (n,)
    Found least-squares solution.
)copyr   npabsdiagr   maxnonzeroix_zerosr   )mnRQTbpermr   copy_Rv
abs_diag_R	thresholdnnsxs   &&&&&&&     \/var/www/html/photoedit/myenv/lib/python3.14/site-packages/scipy/optimize/_lsq/trf_linear.pyregularized_lsq_with_qrr,      s    @ FFH
AqTZ(
#Jc!i"&&"44I::j,-DC	"&&
A	A
A#A)A3iLH    c                   ^p \        W(V,          ,           Wg4      w  rW,
          p\        WV4      ) pVRV,          V,          8  d   MVR,          pKR  \        WV4      p\        P                  ! V^ 8g  4      '       dF   \        W$V,          V,          ,           Wg4      w  r\        WV^ R7      p	W,
          p\        WV4      ) pW+V3# )z=Find an appropriate step size using backtracking line search.      ?rstepg)r   r   r
   r   anyr   )Agr*   pthetap_dot_glbubalphax_new_stepcost_changeactives   &&&&&&&&      r+   backtrackingr@   E   s    E
,Q]BCy)!55//$U3F	vvfk,Q1B-BBK&u"A>y)!55Kr-   c
                    \        W,           Wx4      '       d   V# \        WWx4      w  r\        P                  ! V4      pWP	                  \
        4      ;;,          R,          uu&   Wl,          pWJ,          pWZ,          pW,           p\        WWx4      w  pp^V	,
          V,          pW,          pV^ 8  d>   \        WWVR7      w  ppp\        VVVVVR7      w  ppW\V,          ,           pWl,          pM\        P                  pWY,          pWI,          p\        WWSR7      pV) pVV,          p\        V VWx4      w  ppVV	,          p\        WVVR7      w  pp\        VV^ V4      w  ppVV,          pVV8  d
   VV8  d   V# VV8  d
   VV8  d   V# V# )zDSelect the best step according to Trust Region Reflective algorithm.)s0r   )c)r   )
r   r	   r   r   astypeboolr   r   infr   )r*   A_hg_hc_hr5   p_hdr8   r9   r6   p_stridehitsr_hr
x_on_bound
r_stride_ur<   
r_stride_labrC   r_strider_valuep_valueag_hagag_stride_u	ag_strideag_values   &&&&&&&&&&                   r+   select_stepr^   Z   s   'b5NH
''#,CDb 	A MAOCJ 'zb=MJ e)z)JJA~$SsE1a1q*jA/'(N"G&& LCJA 39G4D	
TB'2r6NK5Kc37DAq/1aEIx)OBWx/	7	w1	r-   lsmr_maxiterc
                N   V P                   w  r\        W#V4      w  r\        WVR R7      pVR8X  d{   \        V RRR7      w  pppVP                  pW8  d5   \
        P                  ! V\
        P                  ! W,
          V34      34      p\
        P                  ! V4      p\        W4      pM<VR8X  d6   \
        P                  ! W,           4      pRpVf   R	V,          pM	VR
8X  d   RpV P                  V4      V,
          p\        V V4      pR\
        P                  ! VV4      ,          pTpRpRpRpVf   ^dpV	^8X  d   \        4        \        V4       EF!  p\        VVW44      w  ppVV,          p \        V \
        P                  R7      p!V!V8  d   ^pV	^8X  d   \!        VVVVV!4       Ve    EMVV,          p"V"R,          p#VR,          p$V$V,          p%\#        V V$4      p&VR8X  d6   XP                  V4      XRX% \%        WXV$X,          ,          VVV#RR7      ) p'MkVR8X  de   \'        V&V#4      p(VXRV% X'       d5   R	\        RV!4      ,          p)\)        \*        \        R V)V!,          4      4      p\-        V(VV
WwR7      ^ ,          ) p'V$X',          p*\
        P                  ! V*V4      p+V+^ 8  d   Rp^\        RV!4      ,
          p,\/        VV&V%V"V*V'V$W4V,4
      p-\1        V VV-4      ) pV^ 8  d   \3        V VVV*V,V+W44      w  pp-pM\        VV-,           W4^ R7      p\        V-4      pV P                  V4      V,
          p\        V V4      pVVV,          8  d   ^pR\
        P                  ! VV4      ,          pEK$  	  Vf   ^ p\5        WWER7      p.\7        VVVX!V.X^,           VVR7      # )g?r0   exacteconomicT)modepivotingr   FNg{Gz?autor/   )ord)r%   )maxiteratolbtolg{Gzt?)rtol)r*   funcost
optimalityactive_masknitstatusinitial_costrD   )shaper   r   r   Tr   vstackr   mindotr   r   ranger   r   rG   r   r   r,   r   r   r   r   r^   r   r@   r
   r   )/r3   rU   x_lsqr8   r9   tol
lsq_solverlsmr_tolmax_iterverboser_   r    r!   r*   r<   QTr"   r$   QTrkr_augauto_lsmr_tolrP   r4   rl   rq   termination_status	step_normr>   	iterationr&   dvg_scaledg_normdiag_hdiag_root_hrL   rI   rH   rK   lsmr_opetar5   r7   r6   r=   rn   s/   &&&&&&&&&&$                                    r+   
trf_linearr      s   77DA$U3DAqb4AWd;AtTT5		1bhhqz234AhhqkI	v	czH M	a1AQA1DLIK!|8_	!!Q/2q5hBFF+C<!"a<"9dK#,f6 )RmH!e'1- ffQiCG*1QtWc4+6uF FC6!.sK@GE"1ISf--sCS6\$:;%6679 9C G&&A,Q;!#Cv&&1c3325I)!Q55
 ?#/1aE7B$4 At[ 'q4xqAAJ	EE!HqLAt#!"RVVAq\!w %z !)!>K
&kM"4!# #r-   )T)!__doc__numpyr   numpy.linalgr   scipy.linalgr   r   scipy.sparse.linalgr   scipy.optimizer   r   commonr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r,   r@   r^   r    r-   r+   <module>r      sU      - $ ) 29 9 9 9 90f *1hk#26k#r-   