U
    z»|eÛn  ã                   @   sü   d Z ddlZddlZddlmZmZmZmZm	Z	 ddl
mZmZmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZmZ ddddddgZdd„ Zdd„ ZeZ dd„ Z!dd„ Z"d dd„Z#d!dd„Z$d"dd„Z%d#dd„Z&dS )$zMatrix equation solver routinesé    N)ÚinvÚLinAlgErrorÚnormÚcondÚsvdé   )ÚsolveÚsolve_triangularÚmatrix_balance)Úget_lapack_funcs)Úschur)Úlu)Úqr)Úordqz)Ú_asarray_validated)ÚkronÚ
block_diagÚsolve_sylvesterÚsolve_continuous_lyapunovÚsolve_discrete_lyapunovÚsolve_lyapunovÚsolve_continuous_areÚsolve_discrete_arec                 C   s¸   t | dd�\}}t | ¡  ¡ dd�\}}t t | ¡  ¡ |¡|¡}td|||fƒ\}|dkrftdƒ‚||||dd�\}	}
}|
|	 }	|dk rœtd	| f ƒ‚t t ||	¡| ¡  ¡ ¡S )
aŽ  
    Computes a solution (X) to the Sylvester equation :math:`AX + XB = Q`.

    Parameters
    ----------
    a : (M, M) array_like
        Leading matrix of the Sylvester equation
    b : (N, N) array_like
        Trailing matrix of the Sylvester equation
    q : (M, N) array_like
        Right-hand side

    Returns
    -------
    x : (M, N) ndarray
        The solution to the Sylvester equation.

    Raises
    ------
    LinAlgError
        If solution was not found

    Notes
    -----
    Computes a solution to the Sylvester matrix equation via the Bartels-
    Stewart algorithm. The A and B matrices first undergo Schur
    decompositions. The resulting matrices are used to construct an
    alternative Sylvester equation (``RY + YS^T = F``) where the R and S
    matrices are in quasi-triangular form (or, when R, S or F are complex,
    triangular form). The simplified equation is then solved using
    ``*TRSYL`` from LAPACK directly.

    .. versionadded:: 0.11.0

    Examples
    --------
    Given `a`, `b`, and `q` solve for `x`:

    >>> import numpy as np
    >>> from scipy import linalg
    >>> a = np.array([[-3, -2, 0], [-1, -1, 3], [3, -5, -1]])
    >>> b = np.array([[1]])
    >>> q = np.array([[1],[2],[3]])
    >>> x = linalg.solve_sylvester(a, b, q)
    >>> x
    array([[ 0.0625],
           [-0.5625],
           [ 0.6875]])
    >>> np.allclose(a.dot(x) + x.dot(b), q)
    True

    Úreal©Úoutput)ÚtrsylNzQLAPACK implementation does not contain a proper Sylvester equation solver (TRSYL)ÚC©Ztranbr   z(Illegal value encountered in the %d term)r   ÚconjÚ	transposeÚnpÚdotr   ÚRuntimeErrorr   )ÚaÚbÚqÚrÚuÚsÚvÚfr   ÚyÚscaleÚinfo© r/   úR/var/www/website-v5/atlas_env/lib/python3.8/site-packages/scipy/linalg/_solvers.pyr      s    7ÿc                 C   s&  t  t| dd�¡} t  t|dd�¡}t}t| |fƒD ]4\}}t  |¡rJt}t j|jŽ s4t	d 
d| ¡ƒ‚q4| j|jkr~t	dƒ‚t| dd�\}}| ¡ j | |¡¡}td||fƒ}|tkr¾d	nd
}	|||||	d�\}
}}|dk ròt	d 
| ¡ƒ‚n|dk�rt dt¡ |
|9 }
| |
¡ | ¡ j¡S )aÍ  
    Solves the continuous Lyapunov equation :math:`AX + XA^H = Q`.

    Uses the Bartels-Stewart algorithm to find :math:`X`.

    Parameters
    ----------
    a : array_like
        A square matrix

    q : array_like
        Right-hand side square matrix

    Returns
    -------
    x : ndarray
        Solution to the continuous Lyapunov equation

    See Also
    --------
    solve_discrete_lyapunov : computes the solution to the discrete-time
        Lyapunov equation
    solve_sylvester : computes the solution to the Sylvester equation

    Notes
    -----
    The continuous Lyapunov equation is a special form of the Sylvester
    equation, hence this solver relies on LAPACK routine ?TRSYL.

    .. versionadded:: 0.11.0

    Examples
    --------
    Given `a` and `q` solve for `x`:

    >>> import numpy as np
    >>> from scipy import linalg
    >>> a = np.array([[-3, -2, 0], [-1, -1, 0], [0, -5, -1]])
    >>> b = np.array([2, 4, -1])
    >>> q = np.eye(3)
    >>> x = linalg.solve_continuous_lyapunov(a, q)
    >>> x
    array([[ -0.75  ,   0.875 ,  -3.75  ],
           [  0.875 ,  -1.375 ,   5.3125],
           [ -3.75  ,   5.3125, -27.0625]])
    >>> np.allclose(a.dot(x) + x.dot(a.T), q)
    True
    T©Úcheck_finiteúMatrix {} should be square.Zaqú*Matrix a and q should have the same shape.r   r   r   ÚTr   r   r   z‚?TRSYL exited with the internal error "illegal value in argument number {}.". See LAPACK documentation for the ?TRSYL error codes.r   z†Input "a" has an eigenvalue pair whose sum is very close to or exactly zero. The solution is obtained via perturbing the coefficients.)r!   Ú
atleast_2dr   ÚfloatÚ	enumerateÚiscomplexobjÚcomplexÚequalÚshapeÚ
ValueErrorÚformatr   r   r5   r"   r   ÚwarningsÚwarnÚRuntimeWarning)r$   r&   Úr_or_cÚindÚ_r'   r(   r+   r   Zdtype_stringr,   r-   r.   r/   r/   r0   r   m   s2    2
ý
ýc                 C   s>   t | |  ¡ ƒ}t |jd ¡| }t|| ¡ ƒ}t ||j¡S )zÄ
    Solves the discrete Lyapunov equation directly.

    This function is called by the `solve_discrete_lyapunov` function with
    `method=direct`. It is not supposed to be called directly.
    r   )r   r   r!   Úeyer<   r   ÚflattenÚreshape)r$   r&   ÚlhsÚxr/   r/   r0   Ú_solve_discrete_lyapunov_directÎ   s    rJ   c                 C   sl   t  | jd ¡}|  ¡  ¡ }t|| ƒ}t  || |¡}dt  t  t| | ƒ|¡|¡ }t| ¡  ¡ | ƒS )zÝ
    Solves the discrete Lyapunov equation using a bilinear transformation.

    This function is called by the `solve_discrete_lyapunov` function with
    `method=bilinear`. It is not supposed to be called directly.
    r   é   )r!   rE   r<   r   r    r   r"   r   )r$   r&   rE   ZaHZaHI_invr%   Úcr/   r/   r0   Ú!_solve_discrete_lyapunov_bilinearÝ   s     rM   c                 C   st   t  | ¡} t  |¡}|dkr4| jd dkr0d}nd}| ¡ }|dkrPt| |ƒ}n |dkrdt| |ƒ}ntd| ƒ‚|S )aE	  
    Solves the discrete Lyapunov equation :math:`AXA^H - X + Q = 0`.

    Parameters
    ----------
    a, q : (M, M) array_like
        Square matrices corresponding to A and Q in the equation
        above respectively. Must have the same shape.

    method : {'direct', 'bilinear'}, optional
        Type of solver.

        If not given, chosen to be ``direct`` if ``M`` is less than 10 and
        ``bilinear`` otherwise.

    Returns
    -------
    x : ndarray
        Solution to the discrete Lyapunov equation

    See Also
    --------
    solve_continuous_lyapunov : computes the solution to the continuous-time
        Lyapunov equation

    Notes
    -----
    This section describes the available solvers that can be selected by the
    'method' parameter. The default method is *direct* if ``M`` is less than 10
    and ``bilinear`` otherwise.

    Method *direct* uses a direct analytical solution to the discrete Lyapunov
    equation. The algorithm is given in, for example, [1]_. However, it requires
    the linear solution of a system with dimension :math:`M^2` so that
    performance degrades rapidly for even moderately sized matrices.

    Method *bilinear* uses a bilinear transformation to convert the discrete
    Lyapunov equation to a continuous Lyapunov equation :math:`(BX+XB'=-C)`
    where :math:`B=(A-I)(A+I)^{-1}` and
    :math:`C=2(A' + I)^{-1} Q (A + I)^{-1}`. The continuous equation can be
    efficiently solved since it is a special case of a Sylvester equation.
    The transformation algorithm is from Popov (1964) as described in [2]_.

    .. versionadded:: 0.11.0

    References
    ----------
    .. [1] Hamilton, James D. Time Series Analysis, Princeton: Princeton
       University Press, 1994.  265.  Print.
       http://doc1.lbfl.li/aca/FLMF037168.pdf
    .. [2] Gajic, Z., and M.T.J. Qureshi. 2008.
       Lyapunov Matrix Equation in System Stability and Control.
       Dover Books on Engineering Series. Dover Publications.

    Examples
    --------
    Given `a` and `q` solve for `x`:

    >>> import numpy as np
    >>> from scipy import linalg
    >>> a = np.array([[0.2, 0.5],[0.7, -0.9]])
    >>> q = np.eye(2)
    >>> x = linalg.solve_discrete_lyapunov(a, q)
    >>> x
    array([[ 0.70872893,  1.43518822],
           [ 1.43518822, -2.4266315 ]])
    >>> np.allclose(a.dot(x).dot(a.T)-x, -q)
    True

    Nr   é
   ZbilinearÚdirectzUnknown solver %s)r!   Úasarrayr<   ÚlowerrJ   rM   r=   )r$   r&   ÚmethodÚmethrI   r/   r/   r0   r   ì   s    G

Tc              
   C   s¤  t | |||||dƒ\
} }}}}}}}}	}
tjd| | d| | f|	d�}| |d|…d|…f< d|d|…|d| …f< ||d|…d| d…f< | ||d| …d|…f< |  ¡ j ||d| …|d| …f< |dkrØdn| ||d| …d| d…f< |dk�rdn| ¡ j|d| d…d|…f< | ¡ j|d| d…|d| …f< ||d| d…d| d…f< |
�rŽ|dk	�rŽt|| ¡ jtj||	d�ƒ}ntt d| ¡tj||	d�ƒ}|�rzt |¡t |¡ }d|t 	|¡< t
|ddd�\}\}}t |t |¡¡�szt |¡}t ||d| … |d|…  d ¡}dtj|| |d| d… f  }|dd…df t |¡ }||9 }||9 }t|dd…| d…f ƒ\}}|dd…|d…f  ¡ j |dd…dd| …f ¡}|dd| …|d…f  ¡ j |dd| …dd| …f ¡}|	tk�rd	nd
}t||dddd|d�\}}}}}}|dk	�r‚tt | |d|…d|…f ¡||d…d|…f f¡ƒ\}}|d|…d|…f }||d…d|…f }t|ƒ\}}}dt|ƒ t d¡k �rØtdƒ‚t| ¡ jt| ¡ j| ¡ jdd�dd� ¡ j | ¡ j¡}|�r:||d|…df |d|…  9 }| ¡ j |¡}t|dƒ}|| ¡ j }t t d¡d| g¡}t|dƒ|k�r’tdƒ‚|| ¡ j d S )a  
    Solves the continuous-time algebraic Riccati equation (CARE).

    The CARE is defined as

    .. math::

          X A + A^H X - X B R^{-1} B^H X + Q = 0

    The limitations for a solution to exist are :

        * All eigenvalues of :math:`A` on the right half plane, should be
          controllable.

        * The associated hamiltonian pencil (See Notes), should have
          eigenvalues sufficiently away from the imaginary axis.

    Moreover, if ``e`` or ``s`` is not precisely ``None``, then the
    generalized version of CARE

    .. math::

          E^HXA + A^HXE - (E^HXB + S) R^{-1} (B^HXE + S^H) + Q = 0

    is solved. When omitted, ``e`` is assumed to be the identity and ``s``
    is assumed to be the zero matrix with sizes compatible with ``a`` and
    ``b``, respectively.

    Parameters
    ----------
    a : (M, M) array_like
        Square matrix
    b : (M, N) array_like
        Input
    q : (M, M) array_like
        Input
    r : (N, N) array_like
        Nonsingular square matrix
    e : (M, M) array_like, optional
        Nonsingular square matrix
    s : (M, N) array_like, optional
        Input
    balanced : bool, optional
        The boolean that indicates whether a balancing step is performed
        on the data. The default is set to True.

    Returns
    -------
    x : (M, M) ndarray
        Solution to the continuous-time algebraic Riccati equation.

    Raises
    ------
    LinAlgError
        For cases where the stable subspace of the pencil could not be
        isolated. See Notes section and the references for details.

    See Also
    --------
    solve_discrete_are : Solves the discrete-time algebraic Riccati equation

    Notes
    -----
    The equation is solved by forming the extended hamiltonian matrix pencil,
    as described in [1]_, :math:`H - \lambda J` given by the block matrices ::

        [ A    0    B ]             [ E   0    0 ]
        [-Q  -A^H  -S ] - \lambda * [ 0  E^H   0 ]
        [ S^H B^H   R ]             [ 0   0    0 ]

    and using a QZ decomposition method.

    In this algorithm, the fail conditions are linked to the symmetry
    of the product :math:`U_2 U_1^{-1}` and condition number of
    :math:`U_1`. Here, :math:`U` is the 2m-by-m matrix that holds the
    eigenvectors spanning the stable subspace with 2-m rows and partitioned
    into two m-row matrices. See [1]_ and [2]_ for more details.

    In order to improve the QZ decomposition accuracy, the pencil goes
    through a balancing step where the sum of absolute values of
    :math:`H` and :math:`J` entries (after removing the diagonal entries of
    the sum) is balanced following the recipe given in [3]_.

    .. versionadded:: 0.11.0

    References
    ----------
    .. [1]  P. van Dooren , "A Generalized Eigenvalue Approach For Solving
       Riccati Equations.", SIAM Journal on Scientific and Statistical
       Computing, Vol.2(2), :doi:`10.1137/0902010`

    .. [2] A.J. Laub, "A Schur Method for Solving Algebraic Riccati
       Equations.", Massachusetts Institute of Technology. Laboratory for
       Information and Decision Systems. LIDS-R ; 859. Available online :
       http://hdl.handle.net/1721.1/1301

    .. [3] P. Benner, "Symplectic Balancing of Hamiltonian Matrices", 2001,
       SIAM J. Sci. Comput., 2001, Vol.22(5), :doi:`10.1137/S1064827500367993`

    Examples
    --------
    Given `a`, `b`, `q`, and `r` solve for `x`:

    >>> import numpy as np
    >>> from scipy import linalg
    >>> a = np.array([[4, 3], [-4.5, -3.5]])
    >>> b = np.array([[1], [-1]])
    >>> q = np.array([[9, 6], [6, 4.]])
    >>> r = 1
    >>> x = linalg.solve_continuous_are(a, b, q, r)
    >>> x
    array([[ 21.72792206,  14.48528137],
           [ 14.48528137,   9.65685425]])
    >>> np.allclose(a.T.dot(x) + x.dot(a)-x.dot(b).dot(b.T).dot(x), -q)
    True

    ÚcarerK   ©ÚdtypeNç        r   r   ©ÚseparateÚpermuter   r:   ÚlhpTF©ÚsortÚoverwrite_aÚoverwrite_br2   r   ç      ð?ú!Failed to find a finite solution.©rQ   ©Úunit_diagonalç     @�@çš™™™™™¹?zQThe associated Hamiltonian pencil has eigenvalues too close to the imaginary axis)Ú_are_validate_argsr!   Úemptyr   r5   r   Ú
zeros_likerE   ÚabsÚdiag_indices_fromr
   ÚallcloseÚ	ones_likeÚlog2ÚroundÚr_Ú
reciprocalr   r"   r7   r   Úvstackr   r   Úspacingr   r	   r   Úmax)r$   r%   r&   r'   Úer)   ÚbalancedÚmÚnrB   Úgen_areÚHÚJÚMrD   ÚscaÚelwisescaleÚout_strr(   Úu00Úu10ÚupÚulÚuurI   Úu_symÚn_u_symÚsym_thresholdr/   r/   r0   r   H  s†    x      ÿ"$*,"
&"4<
 þ
<

þüû 
c              
   C   s   t | |||||dƒ\
} }}}}}}}}	}
tjd| | d| | f|	d�}| |d|…d|…f< ||d|…d| d…f< | ||d| …d|…f< |dkr¢t |¡n| ¡ j||d| …|d| …f< |dkrÐdn| ||d| …d| d…f< |dkrúdn| ¡ j|d| d…d|…f< ||d| d…d| d…f< tj||	d�}|dk�rVt |¡n||d|…d|…f< |  ¡ j||d| …|d| …f< | ¡ j |d| d…|d| …f< |�r~t |¡t |¡ }d|t |¡< t	|ddd�\}\}}t 
|t |¡¡�s~t |¡}t ||d| … |d|…  d ¡}dtj|| |d| d… f  }|dd…df t |¡ }||9 }||9 }t|dd…| d…f ƒ\}}|dd…|d…f  ¡ j |dd…dd| …f ¡}|dd…|d…f  ¡ j |dd…dd| …f ¡}|	tk�rd	nd
}t||dddd|d�\}}}}}}|dk	�r~tt | |d|…d|…f ¡||d…d|…f f¡ƒ\}}|d|…d|…f }||d…d|…f }t|ƒ\}}}dt|ƒ t d¡k �rÔtdƒ‚t| ¡ jt| ¡ j| ¡ jdd�dd� ¡ j | ¡ j¡}|�r6||d|…df |d|…  9 }| ¡ j |¡}t|dƒ}|| ¡ j }t t d¡d| g¡}t|dƒ|k�rŽtdƒ‚|| ¡ j d S )al  
    Solves the discrete-time algebraic Riccati equation (DARE).

    The DARE is defined as

    .. math::

          A^HXA - X - (A^HXB) (R + B^HXB)^{-1} (B^HXA) + Q = 0

    The limitations for a solution to exist are :

        * All eigenvalues of :math:`A` outside the unit disc, should be
          controllable.

        * The associated symplectic pencil (See Notes), should have
          eigenvalues sufficiently away from the unit circle.

    Moreover, if ``e`` and ``s`` are not both precisely ``None``, then the
    generalized version of DARE

    .. math::

          A^HXA - E^HXE - (A^HXB+S) (R+B^HXB)^{-1} (B^HXA+S^H) + Q = 0

    is solved. When omitted, ``e`` is assumed to be the identity and ``s``
    is assumed to be the zero matrix.

    Parameters
    ----------
    a : (M, M) array_like
        Square matrix
    b : (M, N) array_like
        Input
    q : (M, M) array_like
        Input
    r : (N, N) array_like
        Square matrix
    e : (M, M) array_like, optional
        Nonsingular square matrix
    s : (M, N) array_like, optional
        Input
    balanced : bool
        The boolean that indicates whether a balancing step is performed
        on the data. The default is set to True.

    Returns
    -------
    x : (M, M) ndarray
        Solution to the discrete algebraic Riccati equation.

    Raises
    ------
    LinAlgError
        For cases where the stable subspace of the pencil could not be
        isolated. See Notes section and the references for details.

    See Also
    --------
    solve_continuous_are : Solves the continuous algebraic Riccati equation

    Notes
    -----
    The equation is solved by forming the extended symplectic matrix pencil,
    as described in [1]_, :math:`H - \lambda J` given by the block matrices ::

           [  A   0   B ]             [ E   0   B ]
           [ -Q  E^H -S ] - \lambda * [ 0  A^H  0 ]
           [ S^H  0   R ]             [ 0 -B^H  0 ]

    and using a QZ decomposition method.

    In this algorithm, the fail conditions are linked to the symmetry
    of the product :math:`U_2 U_1^{-1}` and condition number of
    :math:`U_1`. Here, :math:`U` is the 2m-by-m matrix that holds the
    eigenvectors spanning the stable subspace with 2-m rows and partitioned
    into two m-row matrices. See [1]_ and [2]_ for more details.

    In order to improve the QZ decomposition accuracy, the pencil goes
    through a balancing step where the sum of absolute values of
    :math:`H` and :math:`J` rows/cols (after removing the diagonal entries)
    is balanced following the recipe given in [3]_. If the data has small
    numerical noise, balancing may amplify their effects and some clean up
    is required.

    .. versionadded:: 0.11.0

    References
    ----------
    .. [1]  P. van Dooren , "A Generalized Eigenvalue Approach For Solving
       Riccati Equations.", SIAM Journal on Scientific and Statistical
       Computing, Vol.2(2), :doi:`10.1137/0902010`

    .. [2] A.J. Laub, "A Schur Method for Solving Algebraic Riccati
       Equations.", Massachusetts Institute of Technology. Laboratory for
       Information and Decision Systems. LIDS-R ; 859. Available online :
       http://hdl.handle.net/1721.1/1301

    .. [3] P. Benner, "Symplectic Balancing of Hamiltonian Matrices", 2001,
       SIAM J. Sci. Comput., 2001, Vol.22(5), :doi:`10.1137/S1064827500367993`

    Examples
    --------
    Given `a`, `b`, `q`, and `r` solve for `x`:

    >>> import numpy as np
    >>> from scipy import linalg as la
    >>> a = np.array([[0, 1], [0, -1]])
    >>> b = np.array([[1, 0], [2, 1]])
    >>> q = np.array([[-4, -4], [-4, 7]])
    >>> r = np.array([[9, 3], [3, 1]])
    >>> x = la.solve_discrete_are(a, b, q, r)
    >>> x
    array([[-4., -4.],
           [-4.,  7.]])
    >>> R = la.solve(r + b.T.dot(x).dot(b), b.T.dot(x).dot(a))
    >>> np.allclose(a.T.dot(x).dot(a) - x - a.T.dot(x).dot(b).dot(R), -q)
    True

    ÚdarerK   rU   NrW   r   r   rX   r   r:   ÚiucTFr\   r`   ra   rb   rc   re   rf   zLThe associated symplectic pencil has eigenvaluestoo close to the unit circle)rg   r!   ÚzerosrE   r   r5   ri   rj   rk   r
   rl   rm   rn   ro   rp   rq   r   r"   r7   r   rr   r   r   rs   r   r	   r   rt   )r$   r%   r&   r'   ru   r)   rv   rw   rx   rB   ry   rz   r{   r|   rD   r}   r~   Zq_of_qrr   r(   r€   r�   r‚   rƒ   r„   rI   r…   r†   r‡   r/   r/   r0   r     s†    z      ÿ"4**("$
&"44ü
<

þüû 
rT   c              
   C   s   |  ¡ dkrtdƒ‚t t| dd�¡} t t|dd�¡}t t|dd�¡}t t|dd�¡}t |¡rjtnt}t| ||fƒD ]4\}}	t |	¡r’t}tj	|	j
Ž s|td d| ¡ƒ‚q||j
\}
}|
| j
d krÒtdƒ‚|
|j
d krètd	ƒ‚||j
d krþtd
ƒ‚t||fƒD ]F\}}	t|	|	 ¡ j dƒt t|	dƒ¡d k�r
td d| ¡ƒ‚�q
|dk�r˜t|dd�d }|dk�s�|t d¡t|dƒ k �r˜tdƒ‚|dk	�p¨|dk	}|�rˆ|dk	�rFt t|dd�¡}tj	|j
Ž �sâtdƒ‚|
|j
d k�rútdƒ‚t|dd�d }|dk�s.|t d¡t|dƒ k �r6tdƒ‚t |¡�rFt}|dk	�rˆt t|dd�¡}|j
|j
k�rxtdƒ‚t |¡�rˆt}| ||||||
|||f
S )a‹  
    A helper function to validate the arguments supplied to the
    Riccati equation solvers. Any discrepancy found in the input
    matrices leads to a ``ValueError`` exception.

    Essentially, it performs:

        - a check whether the input is free of NaN and Infs
        - a pass for the data through ``numpy.atleast_2d()``
        - squareness check of the relevant arrays
        - shape consistency check of the arrays
        - singularity check of the relevant arrays
        - symmetricity check of the relevant matrices
        - a check whether the regular or the generalized version is asked.

    This function is used by ``solve_continuous_are`` and
    ``solve_discrete_are``.

    Parameters
    ----------
    a, b, q, r, e, s : array_like
        Input data
    eq_type : str
        Accepted arguments are 'care' and 'dare'.

    Returns
    -------
    a, b, q, r, e, s : ndarray
        Regularized input data
    m, n : int
        shape of the problem
    r_or_c : type
        Data type of the problem, returns float or complex
    gen_or_not : bool
        Type of the equation, True for generalized and False for regular ARE.

    )rˆ   rT   z;Equation type unknown. Only 'care' and 'dare' is understoodTr1   r3   Zaqrr   z3Matrix a and b should have the same number of rows.r4   z3Matrix b and r should have the same number of cols.r   éd   z(Matrix {} should be symmetric/hermitian.r   rT   F)Ú
compute_uvéÿÿÿÿrW   r`   z!Matrix r is numerically singular.NzMatrix e should be square.z*Matrix a and e should have the same shape.z!Matrix e is numerically singular.z*Matrix b and s should have the same shape.)rQ   r=   r!   r6   r   r9   r:   r7   r8   r;   r<   r>   r   r   r5   rs   r   )r$   r%   r&   r'   ru   r)   Zeq_typerB   rC   Úmatrw   rx   Zmin_svZgeneralized_caser/   r/   r0   rg   æ  s`    '

*ÿ

$
$
rg   )N)NNT)NNT)rT   )'Ú__doc__r?   Únumpyr!   Únumpy.linalgr   r   r   r   r   Ú_basicr   r	   r
   Úlapackr   Ú_decomp_schurr   Ú
_decomp_lur   Ú
_decomp_qrr   Ú
_decomp_qzr   Ú_decompr   Ú_special_matricesr   r   Ú__all__r   r   r   rJ   rM   r   r   r   rg   r/   r/   r/   r0   Ú<module>   s:   
  ýO^
\
 N
 R