§
    ¡éUgìd  ã                   ó,  — d dl mZmZmZ d dlZd dlmZ d dlmZm	Z	m
Z
mZmZ d dlmZmZ d dlmZ d dlZddlmZ d	Z	 d dlmZ n# e$ r d
ZY nw xY we Zg d¢Z G d„ de¦  «        Zd„ Zd„ Zd„ Zdd„Z dddd e!¦   «         fd„Z"	 	 dd„Z#d„ Z$	 	 dd„Z%dS )é    )ÚwarnÚcatch_warningsÚsimplefilterN)Úasarray)ÚissparseÚSparseEfficiencyWarningÚ
csc_matrixÚeyeÚdiags)Úis_pydata_spmatrixÚconvert_pydata_sparse_to_scipy)ÚLinAlgErroré   )Ú_superluFT)Ú
use_solverÚspsolveÚspluÚspiluÚ
factorizedÚMatrixRankWarningÚspsolve_triangularc                   ó   — e Zd ZdS )r   N)Ú__name__Ú
__module__Ú__qualname__© ó    úc/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/scipy/sparse/linalg/_dsolve/linsolve.pyr   r      s   € € € € € Ø€Dr   r   c                  ó�   — d| v r| d         t          ¦   «         d<   t          r!d| v rt          j        | d         ¬¦  «         dS dS dS )as	  
    Select default sparse direct solver to be used.

    Parameters
    ----------
    useUmfpack : bool, optional
        Use UMFPACK [1]_, [2]_, [3]_, [4]_. over SuperLU. Has effect only
        if ``scikits.umfpack`` is installed. Default: True
    assumeSortedIndices : bool, optional
        Allow UMFPACK to skip the step of sorting indices for a CSR/CSC matrix.
        Has effect only if useUmfpack is True and ``scikits.umfpack`` is
        installed. Default: False

    Notes
    -----
    The default sparse solver is UMFPACK when available
    (``scikits.umfpack`` is installed). This can be changed by passing
    useUmfpack = False, which then causes the always present SuperLU
    based solver to be used.

    UMFPACK requires a CSR/CSC matrix to have sorted column/row indices. If
    sure that the matrix fulfills this, pass ``assumeSortedIndices=True``
    to gain some speed.

    References
    ----------
    .. [1] T. A. Davis, Algorithm 832:  UMFPACK - an unsymmetric-pattern
           multifrontal method with a column pre-ordering strategy, ACM
           Trans. on Mathematical Software, 30(2), 2004, pp. 196--199.
           https://dl.acm.org/doi/abs/10.1145/992200.992206

    .. [2] T. A. Davis, A column pre-ordering strategy for the
           unsymmetric-pattern multifrontal method, ACM Trans.
           on Mathematical Software, 30(2), 2004, pp. 165--195.
           https://dl.acm.org/doi/abs/10.1145/992200.992205

    .. [3] T. A. Davis and I. S. Duff, A combined unifrontal/multifrontal
           method for unsymmetric sparse matrices, ACM Trans. on
           Mathematical Software, 25(1), 1999, pp. 1--19.
           https://doi.org/10.1145/305658.287640

    .. [4] T. A. Davis and I. S. Duff, An unsymmetric-pattern multifrontal
           method for sparse LU factorization, SIAM J. Matrix Analysis and
           Computations, 18(1), 1997, pp. 140--158.
           https://doi.org/10.1137/S0895479894246905T.

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.sparse.linalg import use_solver, spsolve
    >>> from scipy.sparse import csc_matrix
    >>> R = np.random.randn(5, 5)
    >>> A = csc_matrix(R)
    >>> b = np.random.randn(5)
    >>> use_solver(useUmfpack=False) # enforce superLU over UMFPACK
    >>> x = spsolve(A, b)
    >>> np.allclose(A.dot(x), b)
    True
    >>> use_solver(useUmfpack=True) # reset umfPack usage to default
    Ú
useUmfpackÚassumeSortedIndices)r!   N)Úglobalsr    ÚumfpackÚ	configure)Úkwargss    r   r   r      si   € ðz �vÐÐØ"(¨Ô"6�‰	Œ	�,ÑÝð MÐ+¨vÐ5Ð5ÝÔ¨fÐ5JÔ.KÐLÑLÔLÐLÐLÐLðMð MÐ5Ð5r   c                 ó¨  — t           j        t           j        fdt           j        t           j        fdt           j        t           j        fdt           j        t           j        fdi}t          t           | j        j        ¦  «        }t          t           | j        j        j        ¦  «        }	 |||f         }n+# t          $ r}d|› d|› d�}t          |¦  «        |‚d}~ww xY w|d	         d
z   }t          j        | ¦  «        }t          j        | j        t           j        ¬¦  «        |_        t          j        | j        t           j        ¬¦  «        |_        ||fS )z8Get umfpack family string given the sparse matrix dtype.ÚdiÚziÚdlÚzlz]only float64 or complex128 matrices with int32 or int64 indices are supported! (got: matrix: z, indices: ú)Nr   Úl©Údtype)ÚnpÚfloat64Úint32Ú
complex128Úint64Úgetattrr.   ÚnameÚindicesÚKeyErrorÚ
ValueErrorÚcopyr   Úindptr)ÚAÚ	_familiesÚf_typeÚi_typeÚfamilyÚeÚmsgÚA_news           r   Ú_get_umf_familyrC   _   s9  € õ 
Œ•R”XÐ Ý	Œ�œÐ! 4Ý	Œ•R”XÐ Ý	Œ�œÐ! 4ð	€Iõ •R˜œœÑ&Ô&€Fõ •R˜œœÔ-Ñ.Ô.€Fð%Ø˜F FÐ+Ô,ˆˆøåð %ð %ð %ðTØ7=ðTð TØJPðTð Tð Tˆå˜‰oŒo 1Ð$øøøøð%øøøð �AŒY˜‰_€FÝŒI�a‰LŒL€EÝ”:˜aœh­b¬hÐ7Ñ7Ô7€E„LÝ”J˜qœyµ´Ð9Ñ9Ô9€E„Mà�5ˆ=Ðs   Â'
B2 Â2
CÂ<CÃCc                 ó¤  — t          j        t           j        ¦  «        j        }| j        d         |k    rt          d¦  «        ‚t          | j        Ž |k    r,t          j        | j        |k    ¦  «        rt          d¦  «        ‚| j         	                    t           j        d¬¦  «        }| j         	                    t           j        d¬¦  «        }||fS )Néÿÿÿÿz#indptr values too large for SuperLUz$indices values too large for SuperLUF©r9   )
r/   ÚiinfoÚintcÚmaxr:   r8   ÚshapeÚanyr6   Úastype)r;   Ú	max_valuer6   r:   s       r   Ú_safe_downcast_indicesrN   �   s¯   € å”�œÑ!Ô!Ô%€Ià„x�„|�iÒÐÝÐ>Ñ?Ô?Ð?å
ˆAŒG€}�yÒ Ð ÝŒ6�!”)˜iÒ'Ñ(Ô(ð 	EÝÐCÑDÔDÐDàŒi×Ò�rœw¨UÐÑ3Ô3€GØŒX�_Š_�RœW¨5ˆ_Ñ1Ô1€FØ�Fˆ?Ðr   c           
      óh
  — t          |¦  «        }|r|j        nd}t          | ¦  «        } t          |¦  «        }t          | ¦  «        r	| j        dv s&t          | ¦  «        } t          dt          d¬¦  «         t          |¦  «        }|st          |¦  «        }|j	        dk    p|j	        dk    o|j
        d         dk    }|                      ¦   «          |                      ¦   «         } t          j        | j        |j        ¦  «        }| j        |k    r|                      |¦  «        } |j        |k    r|                     |¦  «        }| j
        \  }	}
|	|
k    rt#          d|	|
f› d�¦  «        ‚|	|j
        d	         k    r&t#          d
| j
        › d|j
        d	         › d�¦  «        ‚|ot$          }|rÁ|r¿|r|                     ¦   «         }n|}t          || j        ¬¦  «                             ¦   «         }t*          rt-          d¦  «        ‚| j        j        dvrt#          d¦  «        ‚t1          | ¦  «        \  }} t3          j        |¦  «        }|                     t2          j        | |d¬¦  «        }�nÅ|r|r|                     ¦   «         }d}|sé| j        dk    rd}nd	}| j                             t          j        d¬¦  «        }| j                             t          j        d¬¦  «        }tA          |¬¦  «        }tC          j"        |
| j#        | j$        |||||¬¦  «        \  }}|d	k    r6t          dtJ          d¬¦  «         | &                    t          j'        ¦  «         |r|                     ¦   «         }�nÀtQ          | ¦  «        }|j        dk    s5t          |¦  «        s&t          dt          d¬¦  «         t          |¦  «        }g }g }g }tS          |j
        d         ¦  «        D ]×}|dd…|gf                              ¦   «                              ¦   «         } ||¦  «        }t          j*        |¦  «        }|j
        d	         }| +                    |¦  «         | +                    t          j,        ||tZ          ¬¦  «        ¦  «         | +                    t          j        ||         | j        ¬¦  «        ¦  «         ŒØt          j.        |¦  «        }t          j.        |¦  «        }t          j.        |¦  «        }|                      |||ff|j
        | j        ¬¦  «        }|r| /                    |¦  «        }|S )aì  Solve the sparse linear system Ax=b, where b may be a vector or a matrix.

    Parameters
    ----------
    A : ndarray or sparse matrix
        The square matrix A will be converted into CSC or CSR form
    b : ndarray or sparse matrix
        The matrix or vector representing the right hand side of the equation.
        If a vector, b.shape must be (n,) or (n, 1).
    permc_spec : str, optional
        How to permute the columns of the matrix for sparsity preservation.
        (default: 'COLAMD')

        - ``NATURAL``: natural ordering.
        - ``MMD_ATA``: minimum degree ordering on the structure of A^T A.
        - ``MMD_AT_PLUS_A``: minimum degree ordering on the structure of A^T+A.
        - ``COLAMD``: approximate minimum degree column ordering [1]_, [2]_.

    use_umfpack : bool, optional
        if True (default) then use UMFPACK for the solution [3]_, [4]_, [5]_,
        [6]_ . This is only referenced if b is a vector and
        ``scikits.umfpack`` is installed.

    Returns
    -------
    x : ndarray or sparse matrix
        the solution of the sparse linear equation.
        If b is a vector, then x is a vector of size A.shape[1]
        If b is a matrix, then x is a matrix of size (A.shape[1], b.shape[1])

    Notes
    -----
    For solving the matrix expression AX = B, this solver assumes the resulting
    matrix X is sparse, as is often the case for very sparse inputs.  If the
    resulting X is dense, the construction of this sparse result will be
    relatively expensive.  In that case, consider converting A to a dense
    matrix and using scipy.linalg.solve or its variants.

    References
    ----------
    .. [1] T. A. Davis, J. R. Gilbert, S. Larimore, E. Ng, Algorithm 836:
           COLAMD, an approximate column minimum degree ordering algorithm,
           ACM Trans. on Mathematical Software, 30(3), 2004, pp. 377--380.
           :doi:`10.1145/1024074.1024080`

    .. [2] T. A. Davis, J. R. Gilbert, S. Larimore, E. Ng, A column approximate
           minimum degree ordering algorithm, ACM Trans. on Mathematical
           Software, 30(3), 2004, pp. 353--376. :doi:`10.1145/1024074.1024079`

    .. [3] T. A. Davis, Algorithm 832:  UMFPACK - an unsymmetric-pattern
           multifrontal method with a column pre-ordering strategy, ACM
           Trans. on Mathematical Software, 30(2), 2004, pp. 196--199.
           https://dl.acm.org/doi/abs/10.1145/992200.992206

    .. [4] T. A. Davis, A column pre-ordering strategy for the
           unsymmetric-pattern multifrontal method, ACM Trans.
           on Mathematical Software, 30(2), 2004, pp. 165--195.
           https://dl.acm.org/doi/abs/10.1145/992200.992205

    .. [5] T. A. Davis and I. S. Duff, A combined unifrontal/multifrontal
           method for unsymmetric sparse matrices, ACM Trans. on
           Mathematical Software, 25(1), 1999, pp. 1--19.
           https://doi.org/10.1145/305658.287640

    .. [6] T. A. Davis and I. S. Duff, An unsymmetric-pattern multifrontal
           method for sparse LU factorization, SIAM J. Matrix Analysis and
           Computations, 18(1), 1997, pp. 140--158.
           https://doi.org/10.1137/S0895479894246905T.


    Examples
    --------
    >>> import numpy as np
    >>> from scipy.sparse import csc_matrix
    >>> from scipy.sparse.linalg import spsolve
    >>> A = csc_matrix([[3, 2, 0], [1, -1, 0], [0, 5, 1]], dtype=float)
    >>> B = csc_matrix([[2, 0], [-1, 0], [2, 0]], dtype=float)
    >>> x = spsolve(A, B)
    >>> np.allclose(A.dot(x).toarray(), B.toarray())
    True
    N)ÚcscÚcsrz.spsolve requires A be CSC or CSR matrix formaté   ©Ú
stacklevelr   z!matrix must be square (has shape r+   r   z!matrix - rhs dimension mismatch (z - r-   úScikits.umfpack not installed.ÚdDúZconvert matrix data to double, please, using .astype(), or set linsolve.useUmfpack = FalseT©ÚautoTransposeFrP   rF   )ÚColPerm)ÚoptionszMatrix is exactly singularzCspsolve is more efficient when sparse b is in the CSC matrix format)rJ   r.   )0r   Ú	__class__r   r   Úformatr	   r   r   r   ÚndimrJ   Úsum_duplicatesÚ	_asfptyper/   Úpromote_typesr.   rL   r8   r    ÚtoarrayÚravelÚnoScikitÚRuntimeErrorÚcharrC   r#   ÚUmfpackContextÚlinsolveÚ	UMFPACK_Ar6   rH   r:   Údictr   ÚgssvÚnnzÚdatar   ÚfillÚnanr   ÚrangeÚflatnonzeroÚappendÚfullÚintÚconcatenateÚfrom_scipy_sparse) r;   ÚbÚ
permc_specÚuse_umfpackÚis_pydata_sparseÚpydata_sparse_clsÚb_is_sparseÚb_is_vectorÚresult_dtypeÚMÚNÚb_vecÚ
umf_familyÚumfÚxÚflagr6   r:   r[   ÚinfoÚ
AfactsolveÚ	data_segsÚrow_segsÚcol_segsÚjÚbjÚxjÚwÚsegment_lengthÚsparse_dataÚ
sparse_rowÚ
sparse_cols                                    r   r   r   �   sA  € õd *¨!Ñ,Ô,ÐØ'7ÐA˜œ˜¸TÐÝ& qÑ)Ô)€AÝ& qÑ)Ô)€Aå�Q‰KŒKð 4˜AœH¨Ð6Ð6Ý�q‰MŒMˆÝÐ=Ý$°ð	4ñ 	4ô 	4ð 	4õ ˜1‘+”+€KØð Ý�A‰JŒJˆØ”F˜a’KÐE Q¤V¨q¢[Ð%D°Q´W¸Q´ZÀ1²_€Kð ×ÒÑÔÐØ	�Š‰Œ€AÝÔ# A¤G¨Q¬WÑ5Ô5€LØ„w�,ÒÐØ�HŠH�\Ñ"Ô"ˆØ„w�,ÒÐØ�HŠH�\Ñ"Ô"ˆð Œ7�D€A€qØ	ˆQŠˆÝÐF¸aÀ¸VÐFÐFÐFÑGÔGÐGàˆAŒG�AŒJ‚€ÝÐV¸Q¼WÐVÐVÈÌÐQRÌÐVÐVÐVÑWÔWÐWàÐ,¥*€Kàð I;�{ð I;Øð 	Ø—I’I‘K”KˆEˆEàˆEÝ˜ Q¤WÐ-Ñ-Ô-×3Ò3Ñ5Ô5ˆåð 	AÝÐ?Ñ@Ô@Ð@àŒ7Œ<˜tÐ#Ð#Ýð Cñ Dô Dð Dõ (¨Ñ*Ô*‰ˆ
�AÝÔ$ ZÑ0Ô0ˆØ�LŠL�Ô*¨A¨uØ'+ð ñ -ô -ˆ‰ð ð 	 ˜;ð 	 Ø—	’	‘”ˆAØˆKàð 2	;ØŒx˜5Ò Ð Ø��à�à”i×&Ò&¥r¤w°UÐ&Ñ;Ô;ˆGØ”X—_’_¥R¤W°5�_Ñ9Ô9ˆFÝ :Ð.Ñ.Ô.ˆGÝ”m A q¤u¨a¬f°g¸vØ$% t°Wð>ñ >ô >‰GˆAˆtà�qŠyˆyÝÐ1Õ3DÐQRÐSÑSÔSÐSØ—’•r”v‘”�Øð Ø—G’G‘I”I�ùõ $ A™œˆJà”H Ò%Ð%Õ);¸AÑ)>Ô)>Ð%Ýð 3å,¸ð<ñ <ô <ð <õ ˜q‘M”M�ð ˆIØˆHØˆHÝ˜1œ7 1œ:Ñ&Ô&ð Cð C�ð
 �q�q�q˜1˜#�v”Y×&Ò&Ñ(Ô(×.Ò.Ñ0Ô0�Ø�Z ‘^”^�Ý”N 2Ñ&Ô&�Ø!"¤¨¤�Ø—’ Ñ"Ô"Ð"Ø—’¥¤¨¸ÅÐ EÑ EÔ EÑFÔFÐFØ× Ò ¥¤¨B¨q¬E¸¼Ð!AÑ!AÔ!AÑBÔBÐBÐBÝœ.¨Ñ3Ô3ˆKÝœ¨Ñ1Ô1ˆJÝœ¨Ñ1Ô1ˆJØ—’˜[¨:°zÐ*BÐCØ!"¤°´ð ñ 9ô 9ˆAð  ð ;Ø%×7Ò7¸Ñ:Ô:�à€Hr   c           
      ó–  — t          | ¦  «        r:t          | ¦  «        dœd„}|                      ¦   «                              ¦   «         } nt          }t          | ¦  «        r| j        dk    s&t	          | ¦  «        } t          dt          d¬¦  «         |  	                    ¦   «          |  
                    ¦   «         } | j        \  }}||k    rt          d¦  «        ‚t          | ¦  «        \  }	}
t          ||||¬¦  «        }|�|                     |¦  «         |d
         dk    rd|d<   t!          j        || j        | j        |	|
|d|¬¦  «        S )a×  
    Compute the LU decomposition of a sparse, square matrix.

    Parameters
    ----------
    A : sparse matrix
        Sparse matrix to factorize. Most efficient when provided in CSC
        format. Other formats will be converted to CSC before factorization.
    permc_spec : str, optional
        How to permute the columns of the matrix for sparsity preservation.
        (default: 'COLAMD')

        - ``NATURAL``: natural ordering.
        - ``MMD_ATA``: minimum degree ordering on the structure of A^T A.
        - ``MMD_AT_PLUS_A``: minimum degree ordering on the structure of A^T+A.
        - ``COLAMD``: approximate minimum degree column ordering

    diag_pivot_thresh : float, optional
        Threshold used for a diagonal entry to be an acceptable pivot.
        See SuperLU user's guide for details [1]_
    relax : int, optional
        Expert option for customizing the degree of relaxing supernodes.
        See SuperLU user's guide for details [1]_
    panel_size : int, optional
        Expert option for customizing the panel size.
        See SuperLU user's guide for details [1]_
    options : dict, optional
        Dictionary containing additional expert options to SuperLU.
        See SuperLU user guide [1]_ (section 2.4 on the 'Options' argument)
        for more details. For example, you can specify
        ``options=dict(Equil=False, IterRefine='SINGLE'))``
        to turn equilibration off and perform a single iterative refinement.

    Returns
    -------
    invA : scipy.sparse.linalg.SuperLU
        Object, which has a ``solve`` method.

    See also
    --------
    spilu : incomplete LU decomposition

    Notes
    -----
    This function uses the SuperLU library.

    References
    ----------
    .. [1] SuperLU https://portal.nersc.gov/project/sparse/superlu/

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.sparse import csc_matrix
    >>> from scipy.sparse.linalg import splu
    >>> A = csc_matrix([[1., 0., 0.], [5., 0., 2.], [0., -1., 0.]], dtype=float)
    >>> B = splu(A)
    >>> x = np.array([1., 2., 3.], dtype=float)
    >>> B.solve(x)
    array([ 1. , -3. , -1.5])
    >>> A.dot(B.solve(x))
    array([ 1.,  2.,  3.])
    >>> B.solve(A.dot(x))
    array([ 1.,  2.,  3.])
    ©Úclsc                 ó:   — |                       t          |Ž ¦  «        S ©N©rv   r	   ©r•   Úas     r   Úcsc_construct_funcz splu.<locals>.csc_construct_func˜  ó   € Ø×(Ò(­°Q¨Ñ8Ô8Ð8r   rP   ú&splu converted its input to CSC formatrR   rS   úcan only factor square matrices)ÚDiagPivotThreshrZ   Ú	PanelSizeÚRelaxNrZ   ÚNATURALTÚSymmetricModeF©r›   Úilur[   ©r   ÚtypeÚto_scipy_sparseÚtocscr	   r   r]   r   r   r_   r`   rJ   r8   rN   rj   Úupdater   Úgstrfrl   rm   )r;   rx   Údiag_pivot_threshÚrelaxÚ
panel_sizer[   r›   r   r€   r6   r:   Ú_optionss               r   r   r   S  sv  € õH ˜!ÑÔð (Ý'+¨A¡w¤wð 	9ð 	9ð 	9ð 	9ð 	9à×ÒÑÔ×%Ò%Ñ'Ô'ˆˆå'Ðå�Q‰KŒKð 4˜AœH¨Ò-Ð-Ý�q‰MŒMˆÝÐ5Ý$°ð	4ñ 	4ô 	4ð 	4ð ×ÒÑÔÐØ	�Š‰Œ€AàŒ7�D€A€qØ	ˆQŠˆÝÐ:Ñ;Ô;Ð;å,¨QÑ/Ô/�O€GˆVåÐ$5¸zØ(°ð7ñ 7ô 7€HàÐØ�Š˜Ñ Ô Ð ð 	�Ô˜yÒ(Ð(Ø$(ˆ�Ñ!åŒ>˜!˜QœU A¤F¨G°VØ-?Ø#¨Xð7ñ 7ô 7ð 7r   c	           
      óœ  — t          | ¦  «        r:t          | ¦  «        dœd„}	|                      ¦   «                              ¦   «         } nt          }	t          | ¦  «        r| j        dk    s&t	          | ¦  «        } t          dt          d¬¦  «         |  	                    ¦   «          |  
                    ¦   «         } | j        \  }
}|
|k    rt          d¦  «        ‚t          | ¦  «        \  }}t          |||||||¬¦  «        }|�|                     |¦  «         |d
         dk    rd|d<   t!          j        || j        | j        |||	d|¬¦  «        S )aÏ  
    Compute an incomplete LU decomposition for a sparse, square matrix.

    The resulting object is an approximation to the inverse of `A`.

    Parameters
    ----------
    A : (N, N) array_like
        Sparse matrix to factorize. Most efficient when provided in CSC format.
        Other formats will be converted to CSC before factorization.
    drop_tol : float, optional
        Drop tolerance (0 <= tol <= 1) for an incomplete LU decomposition.
        (default: 1e-4)
    fill_factor : float, optional
        Specifies the fill ratio upper bound (>= 1.0) for ILU. (default: 10)
    drop_rule : str, optional
        Comma-separated string of drop rules to use.
        Available rules: ``basic``, ``prows``, ``column``, ``area``,
        ``secondary``, ``dynamic``, ``interp``. (Default: ``basic,area``)

        See SuperLU documentation for details.

    Remaining other options
        Same as for `splu`

    Returns
    -------
    invA_approx : scipy.sparse.linalg.SuperLU
        Object, which has a ``solve`` method.

    See also
    --------
    splu : complete LU decomposition

    Notes
    -----
    To improve the better approximation to the inverse, you may need to
    increase `fill_factor` AND decrease `drop_tol`.

    This function uses the SuperLU library.

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.sparse import csc_matrix
    >>> from scipy.sparse.linalg import spilu
    >>> A = csc_matrix([[1., 0., 0.], [5., 0., 2.], [0., -1., 0.]], dtype=float)
    >>> B = spilu(A)
    >>> x = np.array([1., 2., 3.], dtype=float)
    >>> B.solve(x)
    array([ 1. , -3. , -1.5])
    >>> A.dot(B.solve(x))
    array([ 1.,  2.,  3.])
    >>> B.solve(A.dot(x))
    array([ 1.,  2.,  3.])
    r”   c                 ó:   — |                       t          |Ž ¦  «        S r—   r˜   r™   s     r   r›   z!spilu.<locals>.csc_construct_func÷  rœ   r   rP   z'spilu converted its input to CSC formatrR   rS   rž   )ÚILU_DropRuleÚILU_DropTolÚILU_FillFactorrŸ   rZ   r    r¡   NrZ   r¢   Tr£   r¤   r¦   )r;   Údrop_tolÚfill_factorÚ	drop_rulerx   r¬   r­   r®   r[   r›   r   r€   r6   r:   r¯   s                  r   r   r   »  s  € õv ˜!ÑÔð (Ý'+¨A¡w¤wð 	9ð 	9ð 	9ð 	9ð 	9à×ÒÑÔ×%Ò%Ñ'Ô'ˆˆå'Ðå�Q‰KŒKð 4˜AœH¨Ò-Ð-Ý�q‰MŒMˆÝÐ6Ý$°ð	4ñ 	4ô 	4ð 	4ð ×ÒÑÔÐØ	�Š‰Œ€AàŒ7�D€A€qØ	ˆQŠˆÝÐ:Ñ;Ô;Ð;å,¨QÑ/Ô/�O€GˆVå ¸Ø#.Ø$5¸zØ(°ð7ñ 7ô 7€Hð ÐØ�Š˜Ñ Ô Ð ð 	�Ô˜yÒ(Ð(Ø$(ˆ�Ñ!åŒ>˜!˜QœU A¤F¨G°VØ-?Ø"¨Hð6ñ 6ô 6ð 6r   c                 ó:  ‡ ‡— t          ‰ ¦  «        r&‰                      ¦   «                              ¦   «         Š t          rÊt          rt          d¦  «        ‚t          ‰ ¦  «        r‰ j        dk    s&t          ‰ ¦  «        Š t          dt          d¬¦  «         ‰                      ¦   «         Š ‰ j        j        dvrt          d¦  «        ‚t          ‰ ¦  «        \  }Š t!          j        |¦  «        Š‰                     ‰ ¦  «         ˆ ˆfd„}|S t'          ‰ ¦  «        j        S )	aƒ  
    Return a function for solving a sparse linear system, with A pre-factorized.

    Parameters
    ----------
    A : (N, N) array_like
        Input. A in CSC format is most efficient. A CSR format matrix will
        be converted to CSC before factorization.

    Returns
    -------
    solve : callable
        To solve the linear system of equations given in `A`, the `solve`
        callable should be passed an ndarray of shape (N,).

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.sparse.linalg import factorized
    >>> from scipy.sparse import csc_matrix
    >>> A = np.array([[ 3. ,  2. , -1. ],
    ...               [ 2. , -2. ,  4. ],
    ...               [-1. ,  0.5, -1. ]])
    >>> solve = factorized(csc_matrix(A)) # Makes LU decomposition.
    >>> rhs1 = np.array([1, -2, 0])
    >>> solve(rhs1) # Uses the LU factors.
    array([ 1., -2., -2.])

    rU   rP   r�   rR   rS   rV   rW   c                 óª   •— t          j        dd¬¦  «        5  ‰                     t          j        ‰| d¬¦  «        }d d d ¦  «         n# 1 swxY w Y   |S )NÚignore)ÚdivideÚinvalidTrX   )r/   ÚerrstateÚsolver#   ri   )rw   Úresultr;   rƒ   s     €€r   r¾   zfactorized.<locals>.solveR  s¡   ø€ Ý” H°hÐ?Ñ?Ô?ð Pð PàŸš¥7Ô#4°a¸È$˜ÑOÔO�ðPð Pð Pñ Pô Pð Pð Pð Pð Pð Pð Pøøøð Pð Pð Pð Pð ˆMs   ˜$AÁAÁA)r   r¨   r©   r    rd   re   r   r]   r	   r   r   r`   r.   rf   r8   rC   r#   rg   Únumericr   r¾   )r;   r‚   r¾   rƒ   s   `  @r   r   r     s7  øø€ õ< ˜!ÑÔð (Ø×ÒÑÔ×%Ò%Ñ'Ô'ˆåð Ýð 	AÝÐ?Ñ@Ô@Ð@å˜‘”ð 	8 ¤¨EÒ 1Ð 1Ý˜1‘”ˆAÝÐ9Ý(°Qð8ñ 8ô 8ð 8ð �KŠK‰MŒMˆàŒ7Œ<˜tÐ#Ð#Ýð Cñ Dô Dð Dõ (¨Ñ*Ô*‰ˆ
�AÝÔ$ ZÑ0Ô0ˆð 	�Š�A‰Œˆð	ð 	ð 	ð 	ð 	ð 	ð ˆå�A‰wŒwŒ}Ðr   c                 óü  — t          | ¦  «        r&|                      ¦   «                              ¦   «         } d}t          | ¦  «        r| j        dk    r| j        } d}| }t          | ¦  «        r| j        dk    s't          dt          d¬¦  «         t          | ¦  «        } n|s|  	                    ¦   «         } | j
        \  }}||k    rt          d| j
        › d	�¦  «        ‚|rQt          ¦   «         5  t          d
t          ¦  «         |                      d¦  «         ddd¦  «         n# 1 swxY w Y   nu|                      ¦   «         }	t!          j        |	dk    ¦  «        rt%          d¦  «        ‚d|	z  }
|dk    r| t'          |
¦  «        z  } n| j        t'          |
¦  «        z  j        } |                      ¦   «          t!          j        |¦  «        }|j        dvrt          d|j
        › d	�¦  «        ‚||j
        d         k    r t          d| j
        › d|j
        › d	�¦  «        ‚t!          j        t!          j        | j        t           j        ¦  «        |j        ¦  «        }| j        |k    r|                      |¦  «        } |j        |k    r|                     |¦  «        }n|s| 	                    ¦   «         }|r| }t          ||f|¬¦  «        }n)t7          ||d¬¦  «        }| }|                     d¦  «         t9          j        |||j        |j        |j         |j!        ||j        |j        |j         |j!        |¦  «        \  }}|rt%          d¦  «        ‚|s, |
j"        dgdgtG          |j
        ¦  «        dz
  z  ¢R Ž }
||
z  }|S )aŽ  
    Solve the equation ``A x = b`` for `x`, assuming A is a triangular matrix.

    Parameters
    ----------
    A : (M, M) sparse matrix
        A sparse square triangular matrix. Should be in CSR or CSC format.
    b : (M,) or (M, N) array_like
        Right-hand side matrix in ``A x = b``
    lower : bool, optional
        Whether `A` is a lower or upper triangular matrix.
        Default is lower triangular matrix.
    overwrite_A : bool, optional
        Allow changing `A`.
        Enabling gives a performance gain. Default is False.
    overwrite_b : bool, optional
        Allow overwriting data in `b`.
        Enabling gives a performance gain. Default is False.
        If `overwrite_b` is True, it should be ensured that
        `b` has an appropriate dtype to be able to store the result.
    unit_diagonal : bool, optional
        If True, diagonal elements of `a` are assumed to be 1.

        .. versionadded:: 1.4.0

    Returns
    -------
    x : (M,) or (M, N) ndarray
        Solution to the system ``A x = b``. Shape of return matches shape
        of `b`.

    Raises
    ------
    LinAlgError
        If `A` is singular or not triangular.
    ValueError
        If shape of `A` or shape of `b` do not match the requirements.

    Notes
    -----
    .. versionadded:: 0.19.0

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.sparse import csc_array
    >>> from scipy.sparse.linalg import spsolve_triangular
    >>> A = csc_array([[3, 0, 0], [1, -1, 0], [2, 0, 1]], dtype=float)
    >>> B = np.array([[2, 0], [-1, 0], [2, 0]], dtype=float)
    >>> x = spsolve_triangular(A, B)
    >>> np.allclose(A.dot(x), B)
    True
    r€   rQ   ÚTrP   z?CSC or CSR matrix format is required. Converting to CSC matrix.rR   rS   z+A must be a square matrix but its shape is ú.rº   r   Nr   z&A is singular: zero entry on diagonal.)r   rR   z)b must have 1 or 2 dims but its shape is zlThe size of the dimensions of A must be equal to the size of the first dimension of b but the shape of A is z and the shape of b is r-   )r.   r]   zA is singular.rE   )$r   r¨   r©   r   r]   rÂ   r   r   r	   r9   rJ   r8   r   r   ÚsetdiagÚdiagonalr/   rK   r   r   r_   Ú
asanyarrayr^   ra   r.   Úfloat32rL   r
   r   Úgstrsrl   rm   r6   r:   ÚreshapeÚlen)r;   rw   ÚlowerÚoverwrite_AÚoverwrite_bÚunit_diagonalÚtransr   r€   ÚdiagÚinvdiagr~   ÚLÚUr„   r†   s                   r   r   r   ^  sú  € õp ˜!ÑÔð (Ø×ÒÑÔ×%Ò%Ñ'Ô'ˆà€EÝ��{„{ð �q”x 5Ò(Ð(ØŒCˆØˆØ�	ˆå�Q‰KŒKð ˜AœH¨Ò-Ð-ÝÐNÝ$°ð	4ñ 	4ô 	4ð 	4å�q‰MŒMˆˆØð Ø�FŠF‰HŒHˆð Œ7�D€A€qØˆA‚v€vÝØD¸!¼'ÐDÐDÐDñFô Fð 	Fð ð )ÝÑÔð 	ð 	Ý˜Õ#:Ñ;Ô;Ð;Ø�IŠI�a‰LŒLˆLð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	øð �zŠz‰|Œ|ˆÝŒ6�$˜!’)ÑÔð 	:ÝØ8ñ:ô :ð :à�D‘&ˆØ�CŠ<ˆ<Ø•E˜'‘N”NÑ"ˆAˆAà”•u˜W‘~”~Ñ%Ô(ˆAð ×ÒÑÔÐå
Œ�aÑÔ€Aà„v�VÐÐÝØB¸¼ÐBÐBÐBñDô Dð 	DàˆAŒG�AŒJ‚€Ýð:àŒwð:ð :à/0¬wð:ð :ð :ñ
ô 
ð 	
õ Ô#¥BÔ$4°Q´W½b¼jÑ$IÔ$IÈ1Ì7ÑSÔS€LØ„w�,ÒÐØ�HŠH�\Ñ"Ô"ˆØ„w�,ÒÐØ�HŠH�\Ñ"Ô"ˆˆØð Ø�FŠF‰HŒHˆàð ØˆÝ˜˜1�v \Ð2Ñ2Ô2ˆˆå�˜¨eÐ4Ñ4Ô4ˆØˆØ	�	Š	�!‰ŒˆåŒn˜UØ ¤ q¤v¨q¬y¸!¼(Ø ¤ q¤v¨q¬y¸!¼(Øñ ô  �G€A€tð ð ,ÝÐ*Ñ+Ô+Ð+àð Ø!�'”/ "ÐB¨¨­s°1´7©|¬|¸aÑ/?Ñ(@ÐBÐBÐBˆØ�‰Kˆà€Hs   Ã-+D$Ä$D(Ä+D()NT)NNNNNNNN)TFFF)&Úwarningsr   r   r   Únumpyr/   r   Úscipy.sparser   r   r	   r
   r   Úscipy.sparse._sputilsr   r   Úscipy.linalgr   r9   Ú r   rd   Úscikits.umfpackr#   ÚImportErrorr    Ú__all__ÚUserWarningr   r   rC   rN   r   rj   r   r   r   r   r   r   r   ú<module>rÞ      s=  ðØ 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7à Ð Ð Ð Ø Ð Ð Ð Ð Ð ðKð Kð Kð Kð Kð Kð Kð Kð Kð Kð Kð Kð Kð Kà TÐ TÐ TÐ TÐ TÐ TÐ TÐ TØ $Ð $Ð $Ð $Ð $Ð $Ø €€€à Ð Ð Ð Ð Ð à€ðØ%Ð%Ð%Ð%Ð%Ð%Ð%øØð ð ð Ø€H€H€Hðøøøð ˆ\€
ð6ð 6ð 6€ð	ð 	ð 	ð 	ð 	˜ñ 	ô 	ð 	ð@Mð @Mð @MðD ð  ð  ðDð ð ð@ð @ð @ð @ðF ¨tØ ¨d¨d©f¬fðe7ð e7ð e7ð e7ðP JNØGKð^6ð ^6ð ^6ð ^6ðB?ð ?ð ?ðD INØ%*ðGð Gð Gð Gð Gð Gs   ¾A ÁAÁA