§
    fŠtjp(  ã                   óØ   — d gZ ddlZddlmZ ddlmZ ddlmZ ej	        ej
        ej        ej        dœZej        ej        ej        ej        dœZdddœZ G d	„ d
¦  «        Z	 	 	 	 dd„ZdS )Ú_svdpé    N)Úaslinearoperator)ÚLinAlgErroré   )Ú_propack)ÚfÚdÚFÚD)ÚLMÚSMc                   óJ   — e Zd ZdZd„ Zd„ Zed„ ¦   «         Zed„ ¦   «         ZdS )Ú_AProdzŒ
    Wrapper class for linear operator

    The call signature of the __call__ method matches the callback of
    the PROPACK routines.
    c                 óž   — 	 t          |¦  «        | _        d S # t          $ r* t          t          j        |¦  «        ¦  «        | _        Y d S w xY w©N)r   ÚAÚ	TypeErrorÚnpÚasarray)Úselfr   s     úW/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/scipy/sparse/linalg/_svdp.pyÚ__init__z_AProd.__init__(   sR   € ð	5Ý% aÑ(Ô(ˆDŒFˆFˆFøÝð 	5ð 	5ð 	5Ý%¥b¤j°¡m¤mÑ4Ô4ˆDŒFˆFˆFˆFð	5øøøs   ‚ ˜0AÁAc                 ó’   — |dk    r!| j                              |¦  «        |d d …<   d S | j                              |¦  «        |d d …<   d S )Nr   )r   ÚmatvecÚrmatvec)r   ÚtransaÚmÚnÚxÚys         r   Ú__call__z_AProd.__call__.   sI   € Ø�QŠ;ˆ;Ø”6—=’= Ñ#Ô#ˆAˆaˆaˆa‰DˆDˆDà”6—>’> !Ñ$Ô$ˆAˆaˆaˆa‰DˆDˆDó    c                 ó   — | j         j        S r   )r   Úshape©r   s    r   r$   z_AProd.shape4   s   € àŒvŒ|Ðr"   c                 ó¾   — 	 | j         j        S # t          $ rD | j                              t	          j        | j         j        d         ¦  «        ¦  «        j        cY S w xY w)Nr   )r   ÚdtypeÚAttributeErrorr   r   Úzerosr$   r%   s    r   r'   z_AProd.dtype8   s`   € ð	BØ”6”<ÐøÝð 	Bð 	Bð 	BØ”6—=’=¥¤¨$¬&¬,°q¬/Ñ!:Ô!:Ñ;Ô;ÔAÐAÐAÐAð	Bøøøs   ‚ ŽAAÁAN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r!   Úpropertyr$   r'   © r"   r   r   r   !   sw   € € € € € ðð ð5ð 5ð 5ð%ð %ð %ð ðð ñ „Xðð ðBð Bñ „XðBð Bð Br"   r   r   TFçü©ñÒMb`?c                 ó  — |€t          d¦  «        ‚|                     ¦   «         }|dvrt          d¦  «        ‚|s|dk    rt          d¦  «        ‚t          | ¦  «        }|j        j        }	 t
          |         }t          |         }nW# t          $ rJ t          j	        t          j
        d|¬¦  «        ¦  «        rd	}nd
}t
          |         }t          |         }Y nw xY w|j        \  }}|dk     s|t          ||¦  «        k    rt          d¦  «        ‚|€d|z  }|€d}t          |dz   |dz   |¦  «        }||k     rt          d|› d|› d�¦  «        ‚|rdnd}|rdnd}t          j        ||dz   fd|¬¦  «        }t          j        ||fd|¬¦  «        }t          j        |d|                     ¦   «         ¬¦  «        }t          j        |d|                     ¦   «         ¬¦  «        }|€q|                     |¬¦  «        |dd…df<   t          j	        t          j
        d|¬¦  «        ¦  «        r+|dd…dfxx         d|                     |¬¦  «        z  z  cc<   n+	 ||dd…df<   n # t           $ r t          d|› �¦  «        ‚w xY w|
€+t          j        t          j        |¦  «        j        ¦  «        }
|€t          j        |¦  «        j        dz  }|rpt          j        |
|||f|                     ¦   «         ¬¦  «        }|€||z
  }|t          ||z
  ||¦  «        k    rt          d¦  «        ‚|dk     rt          d¦  «        ‚n+t          j        |
||f|                     ¦   «         ¬¦  «        }t          j        t)          t+          |¦  «        ¦  «        t)          t+          |¦  «        ¦  «        fd¬¦  «        } d}!|s|rP||z   d|dz  z  z   d|z  z   dz   }"|"t-          d |dz  z  d|z  z   dz   |!t-          ||¦  «        z  ¦  «        z  }"d!|z  }#n9||z   d|z  z   d|dz  z  z   dz   t-          ||z   d|z  dz   ¦  «        z   }"d|z  dz   }#t          j
        |"|                     ¦   «         ¬¦  «        }$t          j
        |#t          j        ¬¦  «        }%t          j
        d|                     ¦   «         ¬¦  «        }&t          j
        dt          j        ¬¦  «        }'|                     ¦   «         r"t          j
        ||z   |z   |¬¦  «        }(|$|(|%f})n|$|%f})|                     dt          j        t          j        ¦  «        j        dt          j        ¬"¦  «        }*|r, |t:          |         ||||||||	|||||g|)¢|‘| ‘|&‘|'‘|*‘R Ž }+n ||||||||	|||||g|)¢|‘| ‘|&‘|'‘|*‘R Ž }+|+dk    rt=          d#|+› d$�¦  «        ‚|+dk     rt=          d%|› d&|› d'�¦  «        ‚|dd…d|…f         ||dd…d|…f                              ¦   «         j         |fS )(ax  
    Compute the singular value decomposition of a linear operator using PROPACK

    Parameters
    ----------
    A : array_like, sparse matrix, or LinearOperator
        Operator for which SVD will be computed.  If `A` is a LinearOperator
        object, it must define both ``matvec`` and ``rmatvec`` methods.
    k : int
        Number of singular values/vectors to compute
    which : {"LM", "SM"}
        Which singular triplets to compute:
        - 'LM': compute triplets corresponding to the `k` largest singular
                values
        - 'SM': compute triplets corresponding to the `k` smallest singular
                values
        `which='SM'` requires `irl_mode=True`.  Computes largest singular
        values by default.
    irl_mode : bool, optional
        If `True`, then compute SVD using IRL (implicitly restarted Lanczos)
        mode.  Default is `True`.
    kmax : int, optional
        Maximal number of iterations / maximal dimension of the Krylov
        subspace. Default is ``10 * k``.
    compute_u : bool, optional
        If `True` (default) then compute left singular vectors, `u`.
    compute_v : bool, optional
        If `True` (default) then compute right singular vectors, `v`.
    tol : float, optional
        The desired relative accuracy for computed singular values.
        If not specified, it will be set based on machine precision.
    v0 : array_like, optional
        Starting vector for iterations: must be of length ``A.shape[0]``.
        If not specified, PROPACK will generate a starting vector.
    full_output : bool, optional
        If `True`, then return sigma_bound.  Default is `False`.
    delta : float, optional
        Level of orthogonality to maintain between Lanczos vectors.
        Default is set based on machine precision.
    eta : float, optional
        Orthogonality cutoff.  During reorthogonalization, vectors with
        component larger than `eta` along the Lanczos vector will be purged.
        Default is set based on machine precision.
    anorm : float, optional
        Estimate of ``||A||``.  Default is ``0``.
    cgs : bool, optional
        If `True`, reorthogonalization is done using classical Gram-Schmidt.
        If `False` (default), it is done using modified Gram-Schmidt.
    elr : bool, optional
        If `True` (default), then extended local orthogonality is enforced
        when obtaining singular vectors.
    min_relgap : float, optional
        The smallest relative gap allowed between any shift in IRL mode.
        Default is ``0.001``.  Accessed only if ``irl_mode=True``.
    shifts : int, optional
        Number of shifts per restart in IRL mode.  Default is determined
        to satisfy ``k <= min(kmax-shifts, m, n)``.  Must be
        >= 0, but choosing 0 might lead to performance degradation.
        Accessed only if ``irl_mode=True``.
    maxiter : int, optional
        Maximum number of restarts in IRL mode.  Default is ``1000``.
        Accessed only if ``irl_mode=True``.
    rng : `numpy.random.Generator`, optional
        Pseudorandom number generator state. When `rng` is None, a new
        `numpy.random.Generator` is created using entropy from the
        operating system. Types other than `numpy.random.Generator` are
        passed to `numpy.random.default_rng` to instantiate a ``Generator``.

    Returns
    -------
    u : ndarray
        The `k` largest (``which="LM"``) or smallest (``which="SM"``) left
        singular vectors, ``shape == (A.shape[0], 3)``, returned only if
        ``compute_u=True``.
    sigma : ndarray
        The top `k` singular values, ``shape == (k,)``
    vt : ndarray
        The `k` largest (``which="LM"``) or smallest (``which="SM"``) right
        singular vectors, ``shape == (3, A.shape[1])``, returned only if
        ``compute_v=True``.
    sigma_bound : ndarray
        the error bounds on the singular values sigma, returned only if
        ``full_output=True``.

    Nz:`rng` must be a normalized numpy.random.Generator instance>   r   r   z#`which` must be either 'LM' or 'SM'r   z#`which`='SM' requires irl_mode=Truer   )r'   r   r	   r   z.k must be positive and not greater than m or né
   iè  z3kmax must be greater than or equal to k, but kmax (z) < k (ú)r
   )Úorderr'   )Úsizey              ð?zv0 must be of length g      è?z0shifts must satisfy k <= min(kmax-shifts, m, n)!zshifts must be >= 0!Úié    é   é   é	   é   é   é   )ÚlowÚhighr5   r'   z#An invariant subspace of dimension z was found.zk=z0 singular triplets did not converge within kmax=z iterations)!Ú
ValueErrorÚupperr   r'   ÚcharÚ_lansvd_irl_dictÚ_lansvd_dictÚKeyErrorr   ÚiscomplexobjÚemptyr$   Úminr)   ÚlowerÚuniformÚsqrtÚfinfoÚepsÚarrayÚintÚboolÚmaxÚint32ÚisupperÚintegersÚiinfoÚint64Úuint64Ú_which_converterr   ÚconjÚT),r   ÚkÚwhichÚirl_modeÚkmaxÚ	compute_uÚ	compute_vÚv0Úfull_outputÚtolÚdeltaÚetaÚanormÚcgsÚelrÚ
min_relgapÚshiftsÚmaxiterÚrngÚaprodÚtypÚ
lansvd_irlÚlansvdr   r   ÚjobuÚjobvÚuÚvÚsigmaÚbndÚdoptionÚioptionÚNBÚlworkÚliworkÚworkÚiworkÚdparmÚiparmÚzworkÚworksÚ	rng_stateÚinfos,                                               r   r   r   @   sA  € ðr €{ÝÐUÑVÔVÐVà�KŠK‰MŒM€EØ�LÐ Ð ÝÐ>Ñ?Ô?Ð?Øð @˜ š˜ÝÐ>Ñ?Ô?Ð?å�1‰IŒI€EØ
Œ+Ô
€Cð
#Ý% cÔ*ˆ
Ý˜cÔ"ˆˆøÝð #ð #ð #åŒ?�2œ8 A¨SÐ1Ñ1Ô1Ñ2Ô2ð 	ØˆCˆCàˆCÝ% cÔ*ˆ
Ý˜cÔ"ˆˆˆð#øøøð Œ;�D€A€qØ	ˆAŠˆ�1•s˜1˜a‘y”y’=�=ÝÐIÑJÔJÐJà€|Ø�!‰tˆØ€Øˆõ ˆq�1‰u�a˜!‘e˜TÑ"Ô"€DØˆa‚x€xÝð+Øð+ð +Ø&'ð+ð +ð +ñ,ô ,ð 	,ð
 Ð ˆ1ˆ1˜q€DØÐ ˆ1ˆ1˜q€Dõ 	Œ�!�T˜A‘X� c°Ð5Ñ5Ô5€AÝ
Œ�!�T� #¨SÐ1Ñ1Ô1€AÝŒH�Q˜c¨¯ª©¬Ð5Ñ5Ô5€EÝ
Œ(�1˜C s§y¢y¡{¤{Ð
3Ñ
3Ô
3€Cð
 
€zØ—+’+ 1�+Ñ%Ô%ˆˆ!ˆ!ˆ!ˆQˆ$‰ÝŒ?�2œ8 A¨SÐ1Ñ1Ô1Ñ2Ô2ð 	0Øˆaˆaˆa�ˆdˆGˆGŒG�r˜CŸKšK¨Q˜KÑ/Ô/Ñ/Ñ/ˆGˆG‰Gøð	:ØˆAˆaˆaˆa�ˆd‰GˆGøÝð 	:ð 	:ð 	:ÝÐ8°QÐ8Ð8Ñ9Ô9Ð9ð	:øøøð €}Ý”�œ ™œÔ)Ñ*Ô*ˆØ
€{ÝŒh�s‰mŒmÔ 4Ñ'ˆàð CÝ”(˜E 3¨¨zÐ:À#Ç)Â)Á+Ä+ÐNÑNÔNˆð ˆ>Ø˜A‘XˆFØ�s�4˜&‘= ! QÑ'Ô'Ò'Ð'Ýð <ñ =ô =ð =à�aŠZˆZÝÐ3Ñ4Ô4Ð4ð õ ”(˜E 3¨Ð.°c·i²i±k´kÐBÑBÔBˆåŒh��D ™IœI™œ­­D°©I¬I©¬Ð7¸sÐCÑCÔC€Gð 
€Bð ð �Ið Ø�A‘˜˜$ ™'™	Ñ! A d¡FÑ*¨QÑ.ˆØ•�Q�t˜Q‘w‘Y  4¡Ñ'¨!Ñ+¨Rµ°A°q±	´	©\Ñ:Ô:Ñ:ˆØ�4‘ˆˆà�A‘˜˜$™‘  4¨¡7¡Ñ*¨QÑ.µ°Q¸±U¸A¸d¹FÀQ¹JÑ1GÔ1GÑGˆØ�4‘˜!‘ˆÝŒ8�E §¢¡¤Ð-Ñ-Ô-€DÝŒH�V¥2¤8Ð,Ñ,Ô,€Eõ ŒH�Q˜cŸiši™kœkÐ*Ñ*Ô*€EÝŒH�Q�bœhÐ'Ñ'Ô'€Eà
‡{‚{�}„}ð Ý”˜˜Q™ ™¨SÐ1Ñ1Ô1ˆØ�e˜UÐ"ˆˆà�e�ˆð —’ ­¬µ"´(Ñ);Ô);Ô)?Ø"#­2¬9ð ñ 6ô 6€Ið ð IØˆzÕ*¨5Ô1°4Ø  1 f¨a°¸#Ø  E¨3°ð<à49ð<à;Bð<ð "ð<ð $)ð<ð +0ð<ð 2;ð<ð <ð <ˆˆð
 ˆv�d˜D ! Q¨¨4°°e¸QÀÀsÈAð IØðIØ%ðIØ'.ðIØ05ðIØ7<ðIØ>GðIð Ið Iˆð ˆa‚x€xÝØC°$ÐCÐCÐCñEô Eð 	Eà	�ŠˆÝð&�ð &ð &Øð&ð &ð &ñ'ô 'ð 	'ð ˆQˆQˆQ���ˆUŒ8�U˜A˜a˜a˜a  ! ˜eœHŸMšM™OœOÔ-¨sÐ2Ð2s   Á,B ÂACÃCÉ	I  É I=)r   TNTTNFr   NNr   FTr0   NNN)Ú__all__Únumpyr   Úscipy.sparse.linalgr   Úscipy.linalgr   Ú r   ÚslansvdÚdlansvdÚclansvdÚzlansvdrD   Úslansvd_irlÚdlansvd_irlÚclansvd_irlÚzlansvd_irlrC   rX   r   r   r/   r"   r   ú<module>r‘      s  ðØˆ)€à Ð Ð Ð à 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø $Ð $Ð $Ð $Ð $Ð $à Ð Ð Ð Ð Ð ð 
Ô	Ø	Ô	Ø	Ô	Ø	Ô	ð	ð €ð 
Ô	Ø	Ô	Ø	Ô	Ø	Ô	ð	ð Ð ð Ø
ðð Ð ðBð Bð Bð Bð Bñ Bô Bð Bð> 15ØJKØ8<Ø;?ðc3ð c3ð c3ð c3ð c3ð c3r"   