a
    CCCfr                     @   s2  d Z g dZddlZddlmZmZ ddlmZ ddl	m
Z
 ddlmZmZ ddlZddl	ZddlmZ dd	lmZ d
dlmZmZ dZdd Zdd Zdd Zd2ddZG dd deZG dd deZd3ddZd4ddZ G d d! d!Z!d"d# Z"d$d% Z#d5d&d'Z$d(d) Z%d*d+ Z&d,d- Z'd.d/ Z(d0d1 Z)dS )6z
Sparse matrix functions
)expminvmatrix_power    N)solvesolve_triangular)issparse)spsolve)is_pydata_spmatrix	isintlike)LinearOperator)eye   )_ident_like_exact_1_normZupper_triangularc                 C   s2   t j| st| stdt| }t| |}|S )a  
    Compute the inverse of a sparse matrix

    Parameters
    ----------
    A : (M, M) sparse matrix
        square matrix to be inverted

    Returns
    -------
    Ainv : (M, M) sparse matrix
        inverse of `A`

    Notes
    -----
    This computes the sparse inverse of `A`. If the inverse of `A` is expected
    to be non-sparse, it will likely be faster to convert `A` to dense and use
    `scipy.linalg.inv`.

    Examples
    --------
    >>> from scipy.sparse import csc_matrix
    >>> from scipy.sparse.linalg import inv
    >>> A = csc_matrix([[1., 0.], [1., 2.]])
    >>> Ainv = inv(A)
    >>> Ainv
    <2x2 sparse matrix of type '<class 'numpy.float64'>'
        with 3 stored elements in Compressed Sparse Column format>
    >>> A.dot(Ainv)
    <2x2 sparse matrix of type '<class 'numpy.float64'>'
        with 2 stored elements in Compressed Sparse Column format>
    >>> A.dot(Ainv).toarray()
    array([[ 1.,  0.],
           [ 0.,  1.]])

    .. versionadded:: 0.12.0

    zInput must be a sparse matrix)scipysparser   r	   	TypeErrorr   r   )AIZAinv r   Y/var/www/html/django/DPS/env/lib/python3.9/site-packages/scipy/sparse/linalg/_matfuncs.pyr      s
    (
r   c                 C   s   t ||ks|dk rtdt |}t| jdksF| jd | jd krNtdtj| jd dftd}| j}t|D ]}|	|}qtt
|S )a  
    Compute the 1-norm of a non-negative integer power of a non-negative matrix.

    Parameters
    ----------
    A : a square ndarray or matrix or sparse matrix
        Input matrix with non-negative entries.
    p : non-negative integer
        The power to which the matrix is to be raised.

    Returns
    -------
    out : float
        The 1-norm of the matrix power p of A.

    r   zexpected non-negative integer p   r   %expected A to be like a square matrixdtype)int
ValueErrorlenshapenpZonesfloatTrangedotmax)r   pvMir   r   r   _onenorm_matrix_power_nnmP   s    "r)   c                 C   sh   t | r,tj| d}|jdkp*| dkS t| rRdd l}|| d}|jdkS t| d  S d S )Nr   )	r   r   r   ZtrilZnnzZcount_nonzeror	   r   any)r   Z
lower_partr   r   r   r   _is_upper_triangularq   s    
r,   c                 C   s   t | jdkrtdt |jdkr,tdd}|tkrlt| slt|slt| slt|sltjd| |f\}|dur|du rd}||| |}n"|du r| 	|}n|| 	| }|S )a  
    A matrix product that knows about sparse and structured matrices.

    Parameters
    ----------
    A : 2d ndarray
        First matrix.
    B : 2d ndarray
        Second matrix.
    alpha : float
        The matrix product will be scaled by this constant.
    structure : str, optional
        A string describing the structure of both matrices `A` and `B`.
        Only `upper_triangular` is currently supported.

    Returns
    -------
    M : 2d ndarray
        Matrix product of A and B.

    r   z%expected A to be a rectangular matrixz%expected B to be a rectangular matrixN)Ztrmm      ?)
r   r   r   UPPER_TRIANGULARr   r	   r   linalgZget_blas_funcsr#   )r   Balpha	structurefoutr   r   r   _smart_matrix_product   s(    r5   c                   @   s:   e Zd ZdddZdd Zdd Zdd	 Zed
d ZdS )MatrixPowerOperatorNc                 C   sd   |j dks|jd |jd kr&td|dk r6td|| _|| _|| _|j| _|j | _ |j| _d S )Nr   r   r   r   z'expected p to be a non-negative integer)ndimr   r   _A_p
_structurer   )selfr   r%   r2   r   r   r   __init__   s    zMatrixPowerOperator.__init__c                 C   s    t | jD ]}| j|}q
|S N)r"   r9   r8   r#   )r;   xr(   r   r   r   _matvec   s    zMatrixPowerOperator._matvecc                 C   s.   | j j}| }t| jD ]}||}q|S r=   )r8   r!   ravelr"   r9   r#   )r;   r>   ZA_Tr(   r   r   r   _rmatvec   s
    zMatrixPowerOperator._rmatvecc                 C   s&   t | jD ]}t| j|| jd}q
|S Nr2   )r"   r9   r5   r8   r:   )r;   Xr(   r   r   r   _matmat   s    zMatrixPowerOperator._matmatc                 C   s   t | jj| jS r=   )r6   r8   r!   r9   r;   r   r   r   r!      s    zMatrixPowerOperator.T)N)	__name__
__module____qualname__r<   r?   rA   rE   propertyr!   r   r   r   r   r6      s   
r6   c                   @   s<   e Zd ZdZdd Zdd Zdd Zdd	 Zed
d Z	dS )ProductOperatorzK
    For now, this is limited to products of multiple square matrices.
    c                 O   s   | dd | _|D ].}t|jdks8|jd |jd krtdq|r|d jd }|D ] }|jD ]}||krbtdqbqX||f| _t| j| _tjdd |D  | _|| _	d S )	Nr2   r   r   r   zbFor now, the ProductOperator implementation is limited to the product of multiple square matrices.zHThe square matrices of the ProductOperator must all have the same shape.c                 S   s   g | ]
}|j qS r   r   ).0r>   r   r   r   
<listcomp>       z,ProductOperator.__init__.<locals>.<listcomp>)
getr:   r   r   r   r7   r   Zresult_typer   _operator_sequence)r;   argskwargsr   ndr   r   r   r<      s$    "

zProductOperator.__init__c                 C   s   t | jD ]}||}q
|S r=   )reversedrP   r#   r;   r>   r   r   r   r   r?      s    zProductOperator._matvecc                 C   s$   |  }| jD ]}|j|}q|S r=   )r@   rP   r!   r#   rV   r   r   r   rA      s    
zProductOperator._rmatvecc                 C   s$   t | jD ]}t||| jd}q
|S rB   )rU   rP   r5   r:   )r;   rD   r   r   r   r   rE      s    zProductOperator._matmatc                 C   s   dd t | jD }t| S )Nc                 S   s   g | ]
}|j qS r   )r!   )rL   r   r   r   r   rM      rN   z%ProductOperator.T.<locals>.<listcomp>)rU   rP   rK   )r;   ZT_argsr   r   r   r!      s    zProductOperator.TN)
rG   rH   rI   __doc__r<   r?   rA   rE   rJ   r!   r   r   r   r   rK      s   rK   r      Fc                 C   s   t jjt| ||dS )a  
    Efficiently estimate the 1-norm of A^p.

    Parameters
    ----------
    A : ndarray
        Matrix whose 1-norm of a power is to be computed.
    p : int
        Non-negative integer power.
    t : int, optional
        A positive parameter controlling the tradeoff between
        accuracy versus time and memory usage.
        Larger values take longer and use more memory
        but give more accurate output.
    itmax : int, optional
        Use at most this many iterations.
    compute_v : bool, optional
        Request a norm-maximizing linear operator input vector if True.
    compute_w : bool, optional
        Request a norm-maximizing linear operator output vector if True.

    Returns
    -------
    est : float
        An underestimate of the 1-norm of the sparse matrix.
    v : ndarray, optional
        The vector such that ||Av||_1 == est*||v||_1.
        It can be thought of as an input to the linear operator
        that gives an output with particularly large norm.
    w : ndarray, optional
        The vector Av which has relatively large 1-norm.
        It can be thought of as an output of the linear operator
        that is relatively large in norm compared to the input.

    rC   )r   r   r/   
onenormestr6   )r   r%   titmax	compute_v	compute_wr2   r   r   r   _onenormest_matrix_power   s    %r^   c                 C   s   t jjt| d|iS )a^  
    Efficiently estimate the 1-norm of the matrix product of the args.

    Parameters
    ----------
    operator_seq : linear operator sequence
        Matrices whose 1-norm of product is to be computed.
    t : int, optional
        A positive parameter controlling the tradeoff between
        accuracy versus time and memory usage.
        Larger values take longer and use more memory
        but give more accurate output.
    itmax : int, optional
        Use at most this many iterations.
    compute_v : bool, optional
        Request a norm-maximizing linear operator input vector if True.
    compute_w : bool, optional
        Request a norm-maximizing linear operator output vector if True.
    structure : str, optional
        A string describing the structure of all operators.
        Only `upper_triangular` is currently supported.

    Returns
    -------
    est : float
        An underestimate of the 1-norm of the sparse matrix.
    v : ndarray, optional
        The vector such that ||Av||_1 == est*||v||_1.
        It can be thought of as an input to the linear operator
        that gives an output with particularly large norm.
    w : ndarray, optional
        The vector Av which has relatively large 1-norm.
        It can be thought of as an output of the linear operator
        that is relatively large in norm compared to the input.

    r2   )r   r   r/   rY   rK   )Zoperator_seqrZ   r[   r\   r]   r2   r   r   r   _onenormest_product'  s    &r_   c                   @   s   e Zd ZdZd*ddZedd Zedd	 Zed
d Zedd Z	edd Z
edd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) ZdS )+_ExpmPadeHelperz
    Help lazily evaluate a matrix exponential.

    The idea is to not do more work than we need for high expm precision,
    so we lazily compute matrix powers and store or precompute
    other properties of the matrix.

    NFc                 C   sn   || _ d| _d| _d| _d| _d| _d| _d| _d| _d| _	d| _
d| _d| _d| _t|| _|| _|| _dS )a>  
        Initialize the object.

        Parameters
        ----------
        A : a dense or sparse square numpy matrix or ndarray
            The matrix to be exponentiated.
        structure : str, optional
            A string describing the structure of matrix `A`.
            Only `upper_triangular` is currently supported.
        use_exact_onenorm : bool, optional
            If True then only the exact one-norm of matrix powers and products
            will be used. Otherwise, the one-norm of powers and products
            may initially be estimated.
        N)r   _A2_A4_A6_A8_A10	_d4_exact	_d6_exact	_d8_exact
_d10_exact
_d4_approx
_d6_approx
_d8_approx_d10_approxr   identr2   use_exact_onenorm)r;   r   r2   ro   r   r   r   r<   [  s"    
z_ExpmPadeHelper.__init__c                 C   s&   | j d u r t| j| j| jd| _ | j S rB   )ra   r5   r   r2   rF   r   r   r   A2}  s
    
z_ExpmPadeHelper.A2c                 C   s&   | j d u r t| j| j| jd| _ | j S rB   )rb   r5   rp   r2   rF   r   r   r   A4  s
    
z_ExpmPadeHelper.A4c                 C   s&   | j d u r t| j| j| jd| _ | j S rB   )rc   r5   rq   rp   r2   rF   r   r   r   A6  s
    
z_ExpmPadeHelper.A6c                 C   s&   | j d u r t| j| j| jd| _ | j S rB   )rd   r5   rr   rp   r2   rF   r   r   r   A8  s
    
z_ExpmPadeHelper.A8c                 C   s&   | j d u r t| j| j| jd| _ | j S rB   )re   r5   rq   rr   r2   rF   r   r   r   A10  s
    
z_ExpmPadeHelper.A10c                 C   s    | j d u rt| jd | _ | j S )N      ?)rf   _onenormrq   rF   r   r   r   d4_tight  s    
z_ExpmPadeHelper.d4_tightc                 C   s    | j d u rt| jd | _ | j S )NUUUUUU?)rg   rv   rr   rF   r   r   r   d6_tight  s    
z_ExpmPadeHelper.d6_tightc                 C   s    | j d u rt| jd | _ | j S )N      ?)rh   rv   rs   rF   r   r   r   d8_tight  s    
z_ExpmPadeHelper.d8_tightc                 C   s    | j d u rt| jd | _ | j S )N皙?)ri   rv   rt   rF   r   r   r   	d10_tight  s    
z_ExpmPadeHelper.d10_tightc                 C   sH   | j r| jS | jd ur| jS | jd u r>t| jd| jdd | _| jS d S )Nr   rC   ru   )ro   rw   rf   rj   r^   rp   r2   rF   r   r   r   d4_loose  s    

z_ExpmPadeHelper.d4_loosec                 C   sH   | j r| jS | jd ur| jS | jd u r>t| jd| jdd | _| jS d S )N   rC   rx   )ro   ry   rg   rk   r^   rp   r2   rF   r   r   r   d6_loose  s    

z_ExpmPadeHelper.d6_loosec                 C   sH   | j r| jS | jd ur| jS | jd u r>t| jd| jdd | _| jS d S )Nr   rC   rz   )ro   r{   rh   rl   r^   rq   r2   rF   r   r   r   d8_loose  s    

z_ExpmPadeHelper.d8_loosec                 C   sL   | j r| jS | jd ur| jS | jd u rBt| j| jf| jdd | _| jS d S )NrC   r|   )ro   r}   ri   rm   r_   rq   rr   r2   rF   r   r   r   	d10_loose  s    

z_ExpmPadeHelper.d10_loosec                 C   sR   d}t | j|d | j |d | j  | jd}|d | j |d | j  }||fS )N)g      ^@g      N@g      (@r-   r   r   rC   r   r   )r5   r   rp   rn   r2   r;   bUVr   r   r   pade3  s    z_ExpmPadeHelper.pade3c                 C   sn   d}t | j|d | j |d | j  |d | j  | jd}|d | j |d | j  |d | j  }||fS )	N)g     @g     @g     @@g     @z@g      >@r-   rX   r   r   rC      r   r   )r5   r   rq   rp   rn   r2   r   r   r   r   pade5  s    (*z_ExpmPadeHelper.pade5c                 C   s   d}t | j|d | j |d | j  |d | j  |d | j  | jd}|d | j |d | j  |d	 | j  |d
 | j  }||fS )N)g    ~pAg    ~`Ag    @t>Ag    @Ag     @g     @g      L@r-      rX   r   r   rC      r   r   r   )r5   r   rr   rq   rp   rn   r2   r   r   r   r   pade7  s    68z_ExpmPadeHelper.pade7c                 C   s   d}t | j|d | j |d | j  |d | j  |d | j  |d | j  | jd}|d | j |d	 | j  |d
 | j  |d | j  |d | j  }||fS )N)
g   ynBg   yn Bg    Ag   @
Ag    2|Ag    ~@Ag     @g     @g     V@r-   	   r   rX   r   r   rC      r   r   r   r   )r5   r   rs   rr   rq   rp   rn   r2   r   r   r   r   pade9   s    ((z_ExpmPadeHelper.pade9c                 C   s*  d}| j d|   }| jdd|   }| jdd|   }| jdd|   }t||d | |d |  |d |  | jd	}t|||d
 |  |d |  |d |  |d | j  | jd	}t||d | |d |  |d |  | jd	}	|	|d |  |d |  |d |  |d | j  }
||
fS )N)g D`lCg D`\Cg `=Hb;Cg 	eCg JXBg  "5Bg  /cBg   \L8Bg   pķAg    syAg    S-Ag     @g     f@r-   r   i      r   rC   r   rX   r   r      
   r   r   r   r   )r   rp   rq   rr   r5   r2   rn   )r;   sr   r0   ZB2ZB4ZB6ZU2r   ZV2r   r   r   r   pade13_scaled  s.    "
"6z_ExpmPadeHelper.pade13_scaled)NF)rG   rH   rI   rW   r<   rJ   rp   rq   rr   rs   rt   rw   ry   r{   r}   r~   r   r   r   r   r   r   r   r   r   r   r   r   r`   Q  sB   	
"












r`   c                 C   s   t | ddS )a  
    Compute the matrix exponential using Pade approximation.

    Parameters
    ----------
    A : (M,M) array_like or sparse matrix
        2D Array or Matrix (sparse or dense) to be exponentiated

    Returns
    -------
    expA : (M,M) ndarray
        Matrix exponential of `A`

    Notes
    -----
    This is algorithm (6.1) which is a simplification of algorithm (5.1).

    .. versionadded:: 0.12.0

    References
    ----------
    .. [1] Awad H. Al-Mohy and Nicholas J. Higham (2009)
           "A New Scaling and Squaring Algorithm for the Matrix Exponential."
           SIAM Journal on Matrix Analysis and Applications.
           31 (3). pp. 970-989. ISSN 1095-7162

    Examples
    --------
    >>> from scipy.sparse import csc_matrix
    >>> from scipy.sparse.linalg import expm
    >>> A = csc_matrix([[1, 0, 0], [0, 2, 0], [0, 0, 3]])
    >>> A.toarray()
    array([[1, 0, 0],
           [0, 2, 0],
           [0, 0, 3]], dtype=int64)
    >>> Aexp = expm(A)
    >>> Aexp
    <3x3 sparse matrix of type '<class 'numpy.float64'>'
        with 3 stored elements in Compressed Sparse Column format>
    >>> Aexp.toarray()
    array([[  2.71828183,   0.        ,   0.        ],
           [  0.        ,   7.3890561 ,   0.        ],
           [  0.        ,   0.        ,  20.08553692]])
    auto)ro   )_expm)r   r   r   r   r   "  s    -r   c                 C   s  t | tttjfrt| } t| jdks>| jd | jd krFtd| jdkrtj	ddg| j
d}t| stt| r~| |S |S | jdkrt| d gg}t| st| r| |S t|S t | tjst| st| rt| j
tjs| t} t| rtnd }|dkr"| jd d	k }t| ||d
}t|j|j}|dk rtt|jddkrt| \}}t|||dS t|j|j}|dk rt|jddkr|  \}}t|||dS t|j!|j"}	|	dk rt|jddkr|# \}}t|||dS |	dk r2t|jddkr2|$ \}}t|||dS t|j"|j%}
t&|	|
}d}|dkr^d}ntt't(t)|| d}|td|  |j d }|*|\}}t|||d}|tkrt+||j|}nt,|D ]}|-|}q|S )Nr   r   r   zexpected a square matrix)r   r   r   )r   r   r      )r2   ro   g ,?r   rC   g|zی@?rX   gQi?r   gd @r   g      @r   ).
isinstancelisttupler   matrixZasarrayr   r   r   Zzerosr   r   r	   	__class__exparrayZndarrayZ
issubdtypeZinexactZastyper    r,   r.   r`   r$   r~   r   _ellr   r   
_solve_P_Qrw   r   ry   r   r   r   r   minr   ceillog2r   _fragment_2_1r"   r#   )r   ro   r4   r2   hZeta_1r   r   Zeta_2Zeta_3Zeta_4Zeta_5Ztheta_13r   rD   r(   r   r   r   r   R  sj    
"









r   c                 C   sd   | | }|  | }t | s"t| r,t||S |du r>t||S |tkrPt||S tdt| dS )a  
    A helper function for expm_2009.

    Parameters
    ----------
    U : ndarray
        Pade numerator.
    V : ndarray
        Pade denominator.
    structure : str, optional
        A string describing the structure of both matrices `U` and `V`.
        Only `upper_triangular` is currently supported.

    Notes
    -----
    The `structure` argument is inspired by similar args
    for theano and cvxopt functions.

    Nzunsupported matrix structure: )r   r	   r   r   r.   r   r   str)r   r   r2   PQr   r   r   r     s    



r   c                 C   sj   t |dk rB|| }t| d|d d|d d|d       S t| | t| |  d|  S dS )a  
    Stably evaluate exp(a)*sinh(x)/x

    Notes
    -----
    The strategy of falling back to a sixth order Taylor expansion
    was suggested by the Spallation Neutron Source docs
    which was found on the internet by google search.
    http://www.ornl.gov/~t6p/resources/xal/javadoc/gov/sns/tools/math/ElementaryFunction.html
    The details of the cutoff point and the Horner-like evaluation
    was picked without reference to anything in particular.

    Note that sinch is not currently implemented in scipy.special,
    whereas the "engineer's" definition of sinc is implemented.
    The implementation of sinc involves a scaling factor of pi
    that distinguishes it from the "mathematician's" version of sinc.

    gS㥋?r   g      @g      4@g      E@r   N)absr   r   )ar>   Zx2r   r   r   
_exp_sinch  s    .r   c                 C   s&   d| |  }d| |  }|t || S )a  
    Equation (10.42) of Functions of Matrices: Theory and Computation.

    Notes
    -----
    This is a helper function for _fragment_2_1 of expm_2009.
    Equation (10.42) is on page 251 in the section on Schur algorithms.
    In particular, section 10.4.3 explains the Schur-Parlett algorithm.
    expm([[lam_1, t_12], [0, lam_1])
    =
    [[exp(lam_1), t_12*exp((lam_1 + lam_2)/2)*sinch((lam_1 - lam_2)/2)],
    [0, exp(lam_2)]
    g      ?)r   )lam_1lam_2t_12r   r   r   r   r   	_eq_10_42  s    r   c                 C   s
  | j d }t|  }d|  }t|| }t|D ]}|| | ||f< q<t|d ddD ]}| | } d|  }t|| }t|D ]}|| | ||f< qt|d D ]P}|||  }	|||d   }
||||d f  }t|	|
|}|| ||d f< qqb| S )a  
    A helper function for expm_2009.

    Notes
    -----
    The argument X is modified in-place, but this modification is not the same
    as the returned value of the function.
    This function also takes pains to do things in ways that are compatible
    with sparse matrices, for example by avoiding fancy indexing
    and by using methods of the matrices whenever possible instead of
    using functions of the numpy or scipy libraries themselves.

    r   r   r   r*   )	r   r   r@   Zdiagonalcopyr   r"   r#   r   )rD   r!   r   rS   Zdiag_TscaleZexp_diagkr(   r   r   r   valuer   r   r   r     s&    



r   c           	      C   s   t | jdks"| jd | jd kr*tdddddd	d
}|| }d}tt| d| d }|sddS |t| |  }t|| }tt	|d|  }t
|dS )a!  
    A helper function for expm_2009.

    Parameters
    ----------
    A : linear operator
        A linear operator whose norm of power we care about.
    m : int
        The power of the linear operator

    Returns
    -------
    value : int
        A value related to a bound.

    r   r   r   r   g     @g   `Bg //Cgu;	tDg5G)r   rX   r   r   r   g      <)r   r   r   r)   r   rv   r   r   r   r   r$   )	r   mZc_iZabs_c_recipuZA_abs_onenormr1   Zlog2_alpha_div_ur   r   r   r   r   4  s"    "r   c                 C   s   | j \}}||krtdt|rt|}|dk r:td|dkrPt|| jdS |dkr`|  S t| |d }|d r| | | S || S ntddS )	a  
    Raise a square matrix to the integer power, `power`.

    For non-negative integers, ``A**power`` is computed using repeated
    matrix multiplications. Negative integers are not supported. 

    Parameters
    ----------
    A : (M, M) square sparse array or matrix
        sparse array that will be raised to power `power`
    power : int
        Exponent used to raise sparse array `A`

    Returns
    -------
    A**power : (M, M) sparse array or matrix
        The output matrix will be the same shape as A, and will preserve
        the class of A, but the format of the output may be changed.
    
    Notes
    -----
    This uses a recursive implementation of the matrix power. For computing
    the matrix power using a reasonably large `power`, this may be less efficient
    than computing the product directly, using A @ A @ ... @ A.
    This is contingent upon the number of nonzero entries in the matrix. 

    .. versionadded:: 1.12.0

    Examples
    --------
    >>> from scipy import sparse
    >>> A = sparse.csc_array([[0,1,0],[1,0,1],[0,1,0]])
    >>> A.todense()
    array([[0, 1, 0],
           [1, 0, 1],
           [0, 1, 0]])
    >>> (A @ A).todense()
    array([[1, 0, 1],
           [0, 2, 0],
           [1, 0, 1]])
    >>> A2 = sparse.linalg.matrix_power(A, 2)
    >>> A2.todense()
    array([[1, 0, 1],
           [0, 2, 0],
           [1, 0, 1]])
    >>> A4 = sparse.linalg.matrix_power(A, 4)
    >>> A4.todense()
    array([[2, 0, 2],
           [0, 4, 0],
           [2, 0, 2]])

    zsparse matrix is not squarer   zexponent must be >= 0r   r   r   zexponent must be an integerN)	r   r   r
   r   r   r   r   r   r   )r   powerr'   Ntmpr   r   r   r   b  s     5

r   )NN)r   rX   FFN)r   rX   FFN)N)*rW   __all__numpyr   Zscipy.linalg._basicr   r   Zscipy.sparse._baser   Zscipy.sparse.linalgr   Zscipy.sparse._sputilsr	   r
   Zscipy.sparser   Zscipy.sparse.linalg._interfacer   Zscipy.sparse._constructr   Z_expm_multiplyr   r   rv   r.   r   r)   r,   r5   r6   rK   r^   r_   r`   r   r   r   r   r   r   r   r   r   r   r   r   <module>   s@   
1!
+$0 
* 
* R0Z
 1.