+
    /i4                         R t ^ RIHtHtHtHt ^ RIHt ^ RIt	^ RIt	 ^ RI
HtHt Rt^ RIt^ RIHtHt RR	.tR
 tR tR tR tR tRR ltR#   ] d
    ^ RItRt L5i ; i)z1Basic linear factorizations needed by the solver.)block_array	csc_array	eye_arrayissparse)LinearOperatorN)cholesky_AAtCholmodTypeConversionWarningTF)warncatch_warningsorthogonalityprojectionsc                   \         P                  P                  V4      p\        V 4      '       d-   \        P
                  P                  P                  V RR7      pM!\         P                  P                  V RR7      pV^ 8X  g   V^ 8X  d   ^ # \         P                  P                  V P                  V4      4      pWCV,          ,          pV# )a_  Measure orthogonality between a vector and the null space of a matrix.

Compute a measure of orthogonality between the null space
of the (possibly sparse) matrix ``A`` and a given vector ``g``.

The formula is a simplified (and cheaper) version of formula (3.13)
from [1]_.
``orth =  norm(A g, ord=2)/(norm(A, ord='fro')*norm(g, ord=2))``.

References
----------
.. [1] Gould, Nicholas IM, Mary E. Hribar, and Jorge Nocedal.
       "On the solution of equality constrained quadratic
        programming problems arising in optimization."
        SIAM Journal on Scientific Computing 23.4 (2001): 1376-1395.
fro)ord)nplinalgnormr   scipysparsedot)Agnorm_gnorm_Anorm_A_gorths   &&    l/var/www/html/photoedit/myenv/lib/python3.14/site-packages/scipy/optimize/_trustregion_constr/projections.pyr   r      s    $ YY^^AF{{$$))!)7u- {fkyy~~aeeAh'Hf}%DK    c                   a aaa	 \        R\        R7      ;_uu_ 4        \        S 4      o	RRR4       V V	VV3R lpV V	3R lpV V	3R lpWgV3#   + '       g   i     L+; i)zLReturn linear operators for matrix A using ``NormalEquation`` approach.
    ignore)actioncategoryNc                 <  < S! SP                  V 4      4      pV SP                  P                  V4      ,
          p^ p\        SV4      S8  dO   VS8  d    V# S! SP                  V4      4      pVSP                  P                  V4      ,
          pV^,          pK_  V# )    r   Tr   )xvzkr   factor	max_refinorth_tols   &   r   
null_space/normal_equation_projections.<locals>.null_spaceD   s    1558
N Aq!H,I~ 	 quuQx AACCGGAJAFAr   c                 2   < S! SP                  V 4      4      # Nr   r&   r   r*   s   &r   least_squares2normal_equation_projections.<locals>.least_squaresV   s    aeeAhr   c                 F   < SP                   P                  S! V 4      4      # r0   r%   r   r2   s   &r   	row_space.normal_equation_projections.<locals>.row_spaceZ   s    sswwvay!!r   )r
   r   r   )
r   mnr,   r+   tolr-   r3   r7   r*   s
   f&&ff&   @r   normal_equation_projectionsr<   9   sM     
x2N	O	Oa 
P $ " i//; 
P	Os   AA	c           	     f  a aaaaa	a
 \        \        S4      S P                  .S R..RR7      o	 \        P                  P
                  P                  S	4      o
T T	TTTTT
3R lpTTT
3R lpTT
3R lpYgT3#   \         d/    \        R^R7       \        S P                  4       SSSST4      u # i ; i)	z;Return linear operators for matrix A - ``AugmentedSystem``.Ncsc)formatzVSingular Jacobian matrix. Using dense SVD decomposition to perform the factorizations.
stacklevelc                 $  < \         P                  ! V \         P                  ! S	4      .4      pS! V4      pVR S p^ p\        SV4      S8  dC   VS
8  d    V# VSP	                  V4      ,
          pS! V4      pW&,          pVR S pV^,          pKS  V# r0   )r   hstackzerosr   r   )r&   r'   lu_solr(   r)   new_v	lu_updater   Kr9   r+   r:   r,   solves   &      r   r-   0augmented_system_projections.<locals>.null_spacev   s     IIq"((1+&' q2AJ Aq!H,I~  f%E eI Fr
AFA r   c                    < \         P                  ! V \         P                  ! S4      .4      pS! V4      pVSSS,            # r0   r   rC   rD   )r&   r'   rE   r9   r:   rI   s   &  r   r3   3augmented_system_projections.<locals>.least_squares   s;     IIq"((1+&' qa!}r   c                 v   < \         P                  ! \         P                  ! S4      V .4      pS! V4      pVR S # r0   rL   )r&   r'   rE   r:   rI   s   &  r   r7   /augmented_system_projections.<locals>.row_space   s7     IIrxx{A&' qbqzr   )r   r   r%   r   r   r   
factorizedRuntimeErrorr	   svd_factorization_projectionstoarray)r   r9   r:   r,   r+   r;   r-   r3   r7   rH   rI   s   fffff&   @@r   augmented_system_projectionsrT   `   s     	ilACC(1d)4UCA
=##..q1 D i//M  = +	 -QYY[-.8-6= 	=	=s   )A7 76B0/B0c                `  a aaaa	a
a \         P                  P                  S P                  RRR7      w  o
oo	\        P                  P                  SR,          \        P                  4      V8  d   \        R	^R7       \        S SVSSV4      # V V	V
VVVV3R lpV	V
VV3R lpV	V
V3R lpWgV3# )
zMReturn linear operators for matrix A using ``QRFactorization`` approach.
    Teconomic)pivotingmoder@   c                   < SP                   P                  V 4      p\        P                  P	                  S	VR R7      p\
        P                  ! S
4      pW#S&   V SP                   P                  V4      ,
          p^ p\        SV4      S8  dy   VS8  d    V# SP                   P                  V4      p\        P                  P	                  S	VR R7      pW#S&   VSP                   P                  V4      ,
          pV^,          pK  V# F)lower)r%   r   r   r   solve_triangularr   rD   r   )r&   aux1aux2r'   r(   r)   r   PQRr9   r+   r,   s   &     r   r-   0qr_factorization_projections.<locals>.null_space   s    sswwqz||,,QE,BHHQK!
N Aq!H,I~  33771:D<<00D0FDaDACCGGAJAFAr   c                    < SP                   P                  V 4      p\        P                  P	                  SVR R7      p\
        P                  ! S4      pW#S&   V# rZ   )r%   r   r   r   r\   r   rD   )r&   r]   r^   r(   r_   r`   ra   r9   s   &   r   r3   3qr_factorization_projections.<locals>.least_squares   sH    sswwqz||,,QE,BHHQK!r   c                    < V S,          p\         P                  P                  SVR RR7      pSP                  V4      pV# )Fr%   )r[   trans)r   r   r\   r   )r&   r]   r^   r(   r_   r`   ra   s   &   r   r7   /qr_factorization_projections.<locals>.row_space   sC    t||,,Q3836 - 8 EE$Kr   )NNNzPSingular Jacobian matrix. Using SVD decomposition to perform the factorizations.)	r   r   qrr%   r   r   infr	   rR   )r   r9   r:   r,   r+   r;   r-   r3   r7   r_   r`   ra   s   ff&ff&   @@@r   qr_factorization_projectionsrl      s     llooaccDzoBGAq!	yy~~ah'#- +	 -Q1-5-6-02 	2 2  i//r   c                   a aaa	a
a \         P                  P                  S RR7      w  o	oo
S	RSV8  3,          o	S
SV8  R3,          o
SSV8  ,          oV V	V
VVV3R lpV	V
V3R lpV	V
V3R lpWgV3# )zNReturn linear operators for matrix A using ``SVDFactorization`` approach.
    F)full_matricesri   c                   < SP                  V 4      p^S,          V,          pSP                  V4      pV SP                  P                  V4      ,
          p^ p\        SV4      S
8  dj   VS	8  d    V# SP                  V4      p^S,          V,          pSP                  V4      pVSP                  P                  V4      ,
          pV^,          pKz  V#    r$   )r&   r]   r^   r'   r(   r)   r   UVtr+   r,   ss   &     r   r-   1svd_factorization_projections.<locals>.null_space   s    vvays4xEE$K
N Aq!H,I~  66!9DQ3t8DdAACCGGAJAFAr   c                 l   < SP                  V 4      p^S,          V,          pSP                  V4      pV# rp   r1   r&   r]   r^   r(   rr   rs   rt   s   &   r   r3   4svd_factorization_projections.<locals>.least_squares  s/    vvays4xEE$Kr   c                    < SP                   P                  V 4      p^S,          V,          pSP                   P                  V4      pV# rp   r6   rw   s   &   r   r7   0svd_factorization_projections.<locals>.row_space  s7    sswwqzs4xDDHHTNr   )r   r   svd)r   r9   r:   r,   r+   r;   r-   r3   r7   rr   rs   rt   s   f&&ff&   @@@r   rR   rR      sv     ||7HAq" 	
!QW*A	AGQJB	!c'
A 0 i//r   c                ^   \         P                  ! V 4      w  rVWV,          ^ 8X  d   \        V 4      p \        V 4      '       dL   Vf   RpVR	9  d   \	        R4      hVR8X  d,   \
        '       g    \        P                  ! R\        ^R7       RpMVf   RpVR
9  d   \	        R4      hVR8X  d   \        WWbW44      w  rxp	MGVR8X  d   \        WWbW44      w  rxp	M/VR8X  d   \        WWbW44      w  rxp	MVR8X  d   \        WWbW44      w  rxp	\        Wf3X4      p
\        WV3X4      p\        We3X	4      pWV3# )a	  Return three linear operators related with a given matrix A.

Parameters
----------
A : sparse array (or ndarray), shape (m, n)
    Matrix ``A`` used in the projection.
method : string, optional
    Method used for compute the given linear
    operators. Should be one of:

        - 'NormalEquation': The operators
           will be computed using the
           so-called normal equation approach
           explained in [1]_. In order to do
           so the Cholesky factorization of
           ``(A A.T)`` is computed. Exclusive
           for sparse matrices.
        - 'AugmentedSystem': The operators
           will be computed using the
           so-called augmented system approach
           explained in [1]_. Exclusive
           for sparse matrices.
        - 'QRFactorization': Compute projections
           using QR factorization. Exclusive for
           dense matrices.
        - 'SVDFactorization': Compute projections
           using SVD factorization. Exclusive for
           dense matrices.

orth_tol : float, optional
    Tolerance for iterative refinements.
max_refin : int, optional
    Maximum number of iterative refinements.
tol : float, optional
    Tolerance for singular values.

Returns
-------
Z : LinearOperator, shape (n, n)
    Null-space operator. For a given vector ``x``,
    the null space operator is equivalent to apply
    a projection matrix ``P = I - A.T inv(A A.T) A``
    to the vector. It can be shown that this is
    equivalent to project ``x`` into the null space
    of A.
LS : LinearOperator, shape (m, n)
    Least-squares operator. For a given vector ``x``,
    the least-squares operator is equivalent to apply a
    pseudoinverse matrix ``pinv(A.T) = inv(A A.T) A``
    to the vector. It can be shown that this vector
    ``pinv(A.T) x`` is the least_square solution to
    ``A.T y = x``.
Y : LinearOperator, shape (n, m)
    Row-space operator. For a given vector ``x``,
    the row-space operator is equivalent to apply a
    projection matrix ``Q = A.T inv(A A.T)``
    to the vector.  It can be shown that this
    vector ``y = Q x``  the minimum norm solution
    of ``A y = x``.

Notes
-----
Uses iterative refinements described in [1]
during the computation of ``Z`` in order to
cope with the possibility of large roundoff errors.

References
----------
.. [1] Gould, Nicholas IM, Mary E. Hribar, and Jorge Nocedal.
    "On the solution of equality constrained quadratic
    programming problems arising in optimization."
    SIAM Journal on Scientific Computing 23.4 (2001): 1376-1395.
AugmentedSystemNormalEquationz$Method not allowed for sparse array.zmOnly accepts 'NormalEquation' option when scikit-sparse is available. Using 'AugmentedSystem' option instead.r@   QRFactorizationSVDFactorizationz#Method not allowed for dense array.)r~   r}   )r   r   )r   shaper   r   
ValueErrorsksparse_availablewarningsr	   ImportWarningr<   rT   rl   rR   r   )r   methodr,   r+   r;   r9   r:   r-   r3   r7   ZLSYs   &&&&&        r   r   r   '  sM   T 88A;DA 	saxaL {{>&F>>CDD%%.@.@MM > (A7 'F>&F@@BCC!!)!YL 	-
9	$	$*1iM 	-
9	$	$*1iM 	-
9	%	%+A!yN 	-
9 	vz*A		.Bvy)A!8Or   )Ng-q=   gV瞯<)__doc__scipy.sparser   r   r   r   scipy.sparse.linalgr   scipy.linalgr   sksparse.cholmodr   r   r   ImportErrorr   numpyr   r	   r
   __all__r   r<   rT   rl   rR   r    r   r   <module>r      s|    7 D D .  K  )  F$0NP0f;0|30lt{  s   
A AA