o
    §ƒðjð[  ã                   @   sr  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
mZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZmZmZm Z  dd	l!m"Z"m#Z#m$Z$m%Z% dd
l&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4 ddl5m6Z6 ddgiZ7G dd„ deƒZ8G dd„ de8ƒZ9G dd„ de9ƒZ:G dd„ de:ƒZ;G dd„ deƒZ<G dd„ deƒZ=dS )é    )ÚBasic)ÚDummyé   )ÚMatrixCommon)ÚNonSquareMatrixError)Ú_iszeroÚ_is_zero_after_expand_mulÚ	_simplify)Ú_find_reasonable_pivotÚ_find_reasonable_pivot_naiveÚ	_adjugateÚ	_charpolyÚ	_cofactorÚ_cofactor_matrixÚ_perÚ_detÚ_det_bareissÚ_det_berkowitzÚ	_det_birdÚ_det_laplaceÚ_det_LUÚ_minorÚ_minor_submatrix)Ú_is_echelonÚ_echelon_formÚ_rankÚ_rref)Ú_columnspaceÚ
_nullspaceÚ	_rowspaceÚ_orthogonalize)Ú
_eigenvalsÚ_eigenvectsÚ_bidiagonalizeÚ_bidiagonal_decompositionÚ_is_diagonalizableÚ_diagonalizeÚ_is_positive_definiteÚ_is_positive_semidefiniteÚ_is_negative_definiteÚ_is_negative_semidefiniteÚ_is_indefiniteÚ_jordan_formÚ_left_eigenvectsÚ_singular_values)Ú
MatrixBase)úMatrixEigen.is_indefiniteú MatrixEigen.is_negative_definiteú$MatrixEigen.is_negative_semidefiniteú MatrixEigen.is_positive_definiteú$MatrixEigen.is_positive_semidefiniteÚ
matplotlibc                   @   s  e Zd ZdZefdd„Zdd„ Zedfdd„Zd	d
„ Z	dd„ Z
dd„ Zd"dd„Zdefdd„Zd"dd„Zd"dd„Zd#dd„Zdd„ Zd"dd„Zd d!„ Zeje_eje_eje_eje_eje	_eje
_eje_eje_eje_eje_eje_e je_eje_e!je_e"je_e#je_dS )$ÚMatrixDeterminantzˆProvides basic matrix determinant operations. Should not be instantiated
    directly. See ``determinant.py`` for their implementations.c                 C   ó   t | |d�S )N)Ú
iszerofunc©r   )Úselfr8   © r;   ú™/tmp/claude-1000/-var-www-html-academy/3f42efd1-c2b7-4d08-9b05-30d86bb35479/scratchpad/piper/venv/lib/python3.10/site-packages/sympy/matrices/matrices.pyÚ_eval_det_bareiss3   ó   z#MatrixDeterminant._eval_det_bareissc                 C   ó   t | ƒS ©N)r   ©r:   r;   r;   r<   Ú_eval_det_berkowitz6   ó   z%MatrixDeterminant._eval_det_berkowitzNc                 C   ó   t | ||d�S )N)r8   Úsimpfunc)r   )r:   r8   rE   r;   r;   r<   Ú_eval_det_lu9   ó   zMatrixDeterminant._eval_det_luc                 C   r?   r@   )r   rA   r;   r;   r<   Ú_eval_det_bird<   rC   z MatrixDeterminant._eval_det_birdc                 C   r?   r@   )r   rA   r;   r;   r<   Ú_eval_det_laplace?   rC   z#MatrixDeterminant._eval_det_laplacec                 C   r?   r@   ©r   rA   r;   r;   r<   Ú_eval_determinantB   rC   z#MatrixDeterminant._eval_determinantÚ	berkowitzc                 C   r7   ©N©Úmethod)r   ©r:   rO   r;   r;   r<   ÚadjugateE   r>   zMatrixDeterminant.adjugateÚlambdac                 C   rD   )N)ÚxÚsimplify)r   ©r:   rS   rT   r;   r;   r<   ÚcharpolyH   rG   zMatrixDeterminant.charpolyc                 C   ó   t | |||d�S rM   )r   ©r:   ÚiÚjrO   r;   r;   r<   ÚcofactorK   ó   zMatrixDeterminant.cofactorc                 C   r7   rM   )r   rP   r;   r;   r<   Úcofactor_matrixN   r>   z!MatrixDeterminant.cofactor_matrixÚbareissc                 C   rD   )N)rO   r8   rJ   )r:   rO   r8   r;   r;   r<   ÚdetQ   rG   zMatrixDeterminant.detc                 C   r?   r@   )r   rA   r;   r;   r<   ÚperT   rC   zMatrixDeterminant.perc                 C   rW   rM   )r   rX   r;   r;   r<   ÚminorW   r\   zMatrixDeterminant.minorc                 C   s   t | ||ƒS r@   )r   ©r:   rY   rZ   r;   r;   r<   Úminor_submatrixZ   r>   z!MatrixDeterminant.minor_submatrix©rL   )r^   N)$Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r=   rB   r   rF   rH   rI   rK   rQ   r	   rV   r[   r]   r_   r`   ra   rc   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r;   r;   r<   r6   /   s@    




r6   c                   @   sÂ   e Zd ZdZeddfdd„Zedd„ ƒZedfdd„Zd	d
„ Z	edddfdd„Z
eje_eje_eje_eje
_d#dd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd$dd „Zd$d!d"„ZdS )%ÚMatrixReductionszŽProvides basic matrix row/column operations. Should not be instantiated
    directly. See ``reductions.py`` for some of their implementations.Fc                 C   rW   )N)r8   rT   Úwith_pivots)r   )r:   r8   rT   rj   r;   r;   r<   Úechelon_forms   ó   ÿzMatrixReductions.echelon_formc                 C   r?   r@   )r   rA   r;   r;   r<   Ú
is_echelonw   ó   zMatrixReductions.is_echelonc                 C   rD   )N)r8   rT   )r   )r:   r8   rT   r;   r;   r<   Úrank{   rG   zMatrixReductions.rankc                 C   sL   t |  | |  | j¡|¡ƒ\}}|dd…d| j…f |dd…|j d…f fS )aÅ  Return reduced row-echelon form of matrix, matrix showing
        rhs after reduction steps. ``rhs`` must have the same number
        of rows as ``self``.

        Examples
        ========

        >>> from sympy import Matrix, symbols
        >>> r1, r2 = symbols('r1 r2')
        >>> Matrix([[1, 1], [2, 1]]).rref_rhs(Matrix([r1, r2]))
        (Matrix([
        [1, 0],
        [0, 1]]), Matrix([
        [ -r1 + r2],
        [2*r1 - r2]]))
        N)r   ÚhstackÚeyeÚrowsÚcols)r:   ÚrhsÚrÚ_r;   r;   r<   Úrref_rhs~   s   .zMatrixReductions.rref_rhsTc                 C   s   t | ||||d�S )N)r8   rT   ÚpivotsÚnormalize_last)r   )r:   r8   rT   rx   ry   r;   r;   r<   Úrref’   s   ÿzMatrixReductions.rrefÚcolc           	      C   s  |dvrt d ||¡ƒ‚|dkr| jn| j}|dkrE|dur |n|}|du s*|du r1t d |¡ƒ‚d|  kr;|k sDn t d ||¡ƒ‚n¶|d	krš||||h dg¡}t|ƒd
krb|||h dg¡}t|ƒd
krot d |¡ƒ‚|\}}d|  kr}|k s†n t d ||¡ƒ‚d|  kr�|k s™n t d ||¡ƒ‚na|dkró|du r¤|n|}|du r¬|n|}|du sº|du sº|du rÁt d |¡ƒ‚||krÌt d |¡ƒ‚d|  krÖ|k sßn t d ||¡ƒ‚d|  kré|k sòn t d ||¡ƒ‚nt dt|ƒ ƒ‚|||||fS )z�Validate the arguments for a row/column operation.  ``error_str``
        can be one of "row" or "col" depending on the arguments being parsed.)ún->knún<->mún->n+kmzOUnknown {} operation '{}'. Valid col operations are 'n->kn', 'n<->m', 'n->n+km'r{   r|   NzEFor a {0} operation 'n->kn' you must provide the kwargs `{0}` and `k`r   z#This matrix does not have a {} '{}'r}   é   zIFor a {0} operation 'n<->m' you must provide the kwargs `{0}1` and `{0}2`r~   zPFor a {0} operation 'n->n+km' you must provide the kwargs `{0}`, `k`, and `{0}2`zAFor a {0} operation 'n->n+km' `{0}` and `{0}2` must be different.zinvalid operation %s)Ú
ValueErrorÚformatrs   rr   Ú
differenceÚlenÚrepr)	r:   Úopr{   ÚkÚcol1Úcol2Ú	error_strÚ	self_colsrs   r;   r;   r<   Ú_normalize_op_argsœ   s\   ÿÿÿÿÿÿÿÿz#MatrixReductions._normalize_op_argsc                    ó"   ‡ ‡‡fdd„}ˆ  ˆjˆj|¡S )Nc                    s$   |ˆ krˆˆ| |f  S ˆ| |f S r@   r;   ©rY   rZ   ©r{   r†   r:   r;   r<   ÚentryÔ   ó   zBMatrixReductions._eval_col_op_multiply_col_by_const.<locals>.entry©Ú_newrr   rs   )r:   r{   r†   r�   r;   rŽ   r<   Ú"_eval_col_op_multiply_col_by_constÓ   ó   z3MatrixReductions._eval_col_op_multiply_col_by_constc                    rŒ   )Nc                    s4   |ˆ kr
ˆ| ˆf S |ˆkrˆ| ˆ f S ˆ| |f S r@   r;   r�   ©r‡   rˆ   r:   r;   r<   r�   Û   ó
   z1MatrixReductions._eval_col_op_swap.<locals>.entryr‘   )r:   r‡   rˆ   r�   r;   r•   r<   Ú_eval_col_op_swapÚ   ó   z"MatrixReductions._eval_col_op_swapc                    ó$   ‡ ‡‡‡fdd„}ˆ  ˆjˆj|¡S )Nc                    s0   |ˆ krˆ| |f ˆˆ| ˆf   S ˆ| |f S r@   r;   r�   ©r{   rˆ   r†   r:   r;   r<   r�   ä   ó   zFMatrixReductions._eval_col_op_add_multiple_to_other_col.<locals>.entryr‘   )r:   r{   r†   rˆ   r�   r;   rš   r<   Ú&_eval_col_op_add_multiple_to_other_colã   ó   z7MatrixReductions._eval_col_op_add_multiple_to_other_colc                    rŒ   )Nc                    s4   | ˆ kr
ˆˆ|f S | ˆkrˆˆ |f S ˆ| |f S r@   r;   r�   ©Úrow1Úrow2r:   r;   r<   r�   ë   r–   z1MatrixReductions._eval_row_op_swap.<locals>.entryr‘   )r:   rŸ   r    r�   r;   rž   r<   Ú_eval_row_op_swapê   r˜   z"MatrixReductions._eval_row_op_swapc                    rŒ   )Nc                    s$   | ˆkrˆ ˆ| |f  S ˆ| |f S r@   r;   r�   ©r†   Úrowr:   r;   r<   r�   ô   r�   zBMatrixReductions._eval_row_op_multiply_row_by_const.<locals>.entryr‘   )r:   r£   r†   r�   r;   r¢   r<   Ú"_eval_row_op_multiply_row_by_constó   r”   z3MatrixReductions._eval_row_op_multiply_row_by_constc                    r™   )Nc                    s0   | ˆkrˆ| |f ˆ ˆˆ|f   S ˆ| |f S r@   r;   r�   ©r†   r£   r    r:   r;   r<   r�   û   r›   zFMatrixReductions._eval_row_op_add_multiple_to_other_row.<locals>.entryr‘   )r:   r£   r†   r    r�   r;   r¥   r<   Ú&_eval_row_op_add_multiple_to_other_rowú   r�   z7MatrixReductions._eval_row_op_add_multiple_to_other_rowr|   Nc                 C   ó`   |   |||||d¡\}}}}}|dkr|  ||¡S |dkr#|  ||¡S |dkr.|  |||¡S dS )ad  Performs the elementary column operation `op`.

        `op` may be one of

            * ``"n->kn"`` (column n goes to k*n)
            * ``"n<->m"`` (swap column n and column m)
            * ``"n->n+km"`` (column n goes to column n + k*column m)

        Parameters
        ==========

        op : string; the elementary row operation
        col : the column to apply the column operation
        k : the multiple to apply in the column operation
        col1 : one column of a column swap
        col2 : second column of a column swap or column "m" in the column operation
               "n->n+km"
        r{   r|   r}   r~   N)r‹   r“   r—   rœ   )r:   r…   r{   r†   r‡   rˆ   r;   r;   r<   Úelementary_col_op  ó   ÿz"MatrixReductions.elementary_col_opc                 C   r§   )a4  Performs the elementary row operation `op`.

        `op` may be one of

            * ``"n->kn"`` (row n goes to k*n)
            * ``"n<->m"`` (swap row n and row m)
            * ``"n->n+km"`` (row n goes to row n + k*row m)

        Parameters
        ==========

        op : string; the elementary row operation
        row : the row to apply the row operation
        k : the multiple to apply in the row operation
        row1 : one row of a row swap
        row2 : second row of a row swap or row "m" in the row operation
               "n->n+km"
        r£   r|   r}   r~   N)r‹   r¤   r¡   r¦   )r:   r…   r£   r†   rŸ   r    r;   r;   r<   Úelementary_row_op  r©   z"MatrixReductions.elementary_row_op)r{   )r|   NNNN)re   rf   rg   rh   r   rk   Úpropertyrm   ro   rw   rz   r   r   r   r   r‹   r“   r—   rœ   r¡   r¤   r¦   r¨   rª   r;   r;   r;   r<   ri   o   s.    

ÿ
7		
ri   c                   @   sb   e Zd ZdZddd„Zdefdd„Zddd„Zd	d
„ Ze	je_e
je_eje_eje_eeƒZdS )ÚMatrixSubspacesz Provides methods relating to the fundamental subspaces of a matrix.
    Should not be instantiated directly. See ``subspaces.py`` for their
    implementations.Fc                 C   r7   ©N)rT   )r   ©r:   rT   r;   r;   r<   ÚcolumnspaceC  r>   zMatrixSubspaces.columnspacec                 C   rD   )N)rT   r8   )r   )r:   rT   r8   r;   r;   r<   Ú	nullspaceF  rG   zMatrixSubspaces.nullspacec                 C   r7   r­   )r   r®   r;   r;   r<   ÚrowspaceI  r>   zMatrixSubspaces.rowspacec                 O   s   t | g|¢R i |¤ŽS r@   )r    )ÚclsÚvecsÚkwargsr;   r;   r<   ÚorthogonalizeO  s   zMatrixSubspaces.orthogonalizeN©F)re   rf   rg   rh   r¯   r   r°   r±   rµ   r   r   r   r    Úclassmethodr;   r;   r;   r<   r¬   >  s    

r¬   c                   @   s  e Zd ZdZd!dd„Zdefdd„Zd"dd	„Zd#d
d„Zd!d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d!dd„Zdd„ Zdd„ Zeje_eje_eje_eje_eje_eje_eje_eje_eje_eje_eje_eje_e je	_e!je
_d S )$ÚMatrixEigenzŒProvides basic matrix eigenvalue/vector operations.
    Should not be instantiated directly. See ``eigen.py`` for their
    implementations.Tc                 K   ó   t | fd|i|¤ŽS )NÚerror_when_incomplete)r!   )r:   rº   Úflagsr;   r;   r<   Ú	eigenvals_  ó   zMatrixEigen.eigenvalsc                 K   s   t | f||dœ|¤ŽS )N)rº   r8   )r"   )r:   rº   r8   r»   r;   r;   r<   Ú
eigenvectsb  s
   ÿÿzMatrixEigen.eigenvectsFc                 K   r¹   )NÚ
reals_only)r%   )r:   r¿   r´   r;   r;   r<   Úis_diagonalizablef  r½   zMatrixEigen.is_diagonalizablec                 C   rW   )N)r¿   ÚsortÚ	normalize)r&   )r:   r¿   rÁ   rÂ   r;   r;   r<   Údiagonalizei  rl   zMatrixEigen.diagonalizec                 C   r7   ©N)Úupper)r#   ©r:   rÅ   r;   r;   r<   Úbidiagonalizem  r>   zMatrixEigen.bidiagonalizec                 C   r7   rÄ   )r$   rÆ   r;   r;   r<   Úbidiagonal_decompositionp  r>   z$MatrixEigen.bidiagonal_decompositionc                 C   r?   r@   )r'   rA   r;   r;   r<   Úis_positive_definites  rn   r3   c                 C   r?   r@   )r(   rA   r;   r;   r<   Úis_positive_semidefinitew  rn   r4   c                 C   r?   r@   )r)   rA   r;   r;   r<   Úis_negative_definite{  rn   r1   c                 C   r?   r@   )r*   rA   r;   r;   r<   Úis_negative_semidefinite  rn   r2   c                 C   r?   r@   )r+   rA   r;   r;   r<   Úis_indefiniteƒ  rn   r0   c                 K   r¹   )NÚcalc_transform)r,   )r:   rÎ   r´   r;   r;   r<   Újordan_form‡  r½   zMatrixEigen.jordan_formc                 K   s   t | fi |¤ŽS r@   )r-   ©r:   r»   r;   r;   r<   Úleft_eigenvectsŠ  r\   zMatrixEigen.left_eigenvectsc                 C   r?   r@   )r.   rA   r;   r;   r<   Úsingular_values�  rC   zMatrixEigen.singular_valuesN©Tr¶   )FFF)"re   rf   rg   rh   r¼   r   r¾   rÀ   rÃ   rÇ   rÈ   r«   rÉ   rÊ   rË   rÌ   rÍ   rÏ   rÑ   rÒ   r!   r"   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r#   r$   r;   r;   r;   r<   r¸   Z  sF    










r¸   c                   @   s>   e Zd ZdZddœdd„Zdd„ Zdd	„ Zd
d„ Zdd„ ZdS )ÚMatrixCalculusz,Provides calculus-related matrix operations.T)Úevaluatec                O   s<   ddl m} || g|¢R d|iŽ}t| tƒs|r| ¡ S |S )ae  Calculate the derivative of each element in the matrix.

        Examples
        ========

        >>> from sympy import Matrix
        >>> from sympy.abc import x, y
        >>> M = Matrix([[x, y], [1, 0]])
        >>> M.diff(x)
        Matrix([
        [1, 0],
        [0, 0]])

        See Also
        ========

        integrate
        limit
        r   )ÚArrayDerivativerÕ   )Ú$sympy.tensor.array.array_derivativesrÖ   Ú
isinstancer   Ú
as_mutable)r:   rÕ   Úargsr´   rÖ   Úderivr;   r;   r<   Údiff£  s
   zMatrixCalculus.diffc                    ó   |   ‡ fdd„¡S )Nc                    s
   |   ˆ ¡S r@   ©rÜ   ©rS   ©Úargr;   r<   Ú<lambda>À  ó   
 z1MatrixCalculus._eval_derivative.<locals>.<lambda>©Ú	applyfunc)r:   rá   r;   rà   r<   Ú_eval_derivative¿  s   zMatrixCalculus._eval_derivativec                    s   |   ‡ ‡fdd„¡S )aþ  Integrate each element of the matrix.  ``args`` will
        be passed to the ``integrate`` function.

        Examples
        ========

        >>> from sympy import Matrix
        >>> from sympy.abc import x, y
        >>> M = Matrix([[x, y], [1, 0]])
        >>> M.integrate((x, ))
        Matrix([
        [x**2/2, x*y],
        [     x,   0]])
        >>> M.integrate((x, 0, 2))
        Matrix([
        [2, 2*y],
        [2,   0]])

        See Also
        ========

        limit
        diff
        c                    s   | j ˆ i ˆ¤ŽS r@   )Ú	integraterß   ©rÚ   r´   r;   r<   râ   Û  s    z*MatrixCalculus.integrate.<locals>.<lambda>rä   )r:   rÚ   r´   r;   rè   r<   rç   Â  s   zMatrixCalculus.integratec                    s¤   t ˆ tƒs
ˆ ˆ ¡‰ ˆjd dkrˆjd }nˆjd dkr$ˆjd }ntdƒ‚ˆ jd dkr5ˆ jd }nˆ jd dkrBˆ jd }ntdƒ‚ˆ ||‡ ‡fdd„¡S )aæ  Calculates the Jacobian matrix (derivative of a vector-valued function).

        Parameters
        ==========

        ``self`` : vector of expressions representing functions f_i(x_1, ..., x_n).
        X : set of x_i's in order, it can be a list or a Matrix

        Both ``self`` and X can be a row or a column matrix in any order
        (i.e., jacobian() should always work).

        Examples
        ========

        >>> from sympy import sin, cos, Matrix
        >>> from sympy.abc import rho, phi
        >>> X = Matrix([rho*cos(phi), rho*sin(phi), rho**2])
        >>> Y = Matrix([rho, phi])
        >>> X.jacobian(Y)
        Matrix([
        [cos(phi), -rho*sin(phi)],
        [sin(phi),  rho*cos(phi)],
        [   2*rho,             0]])
        >>> X = Matrix([rho*cos(phi), rho*sin(phi)])
        >>> X.jacobian(Y)
        Matrix([
        [cos(phi), -rho*sin(phi)],
        [sin(phi),  rho*cos(phi)]])

        See Also
        ========

        hessian
        wronskian
        r   r   z)``self`` must be a row or a column matrixz"X must be a row or a column matrixc                    s   ˆ|    ˆ | ¡S r@   rÞ   )rZ   rY   ©ÚXr:   r;   r<   râ     s    z)MatrixCalculus.jacobian.<locals>.<lambda>)rØ   r/   r’   ÚshapeÚ	TypeError)r:   rê   ÚmÚnr;   ré   r<   ÚjacobianÝ  s   
$
zMatrixCalculus.jacobianc                    rÝ   )až  Calculate the limit of each element in the matrix.
        ``args`` will be passed to the ``limit`` function.

        Examples
        ========

        >>> from sympy import Matrix
        >>> from sympy.abc import x, y
        >>> M = Matrix([[x, y], [1, 0]])
        >>> M.limit(x, 2)
        Matrix([
        [2, y],
        [1, 0]])

        See Also
        ========

        integrate
        diff
        c                    s
   | j ˆ Ž S r@   )Úlimitrß   ©rÚ   r;   r<   râ   +  rã   z&MatrixCalculus.limit.<locals>.<lambda>rä   )r:   rÚ   r;   rñ   r<   rð     s   zMatrixCalculus.limitN)	re   rf   rg   rh   rÜ   ræ   rç   rï   rð   r;   r;   r;   r<   rÔ      s    9rÔ   c                   @   s�   e Zd ZdZedƒefdd„Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
d"dd„Zdd„ Zdd„ Zdd„ Zd#dd„Zd"dd„Zdd„ Zdd„ Zdd „ Zd!S )$ÚMatrixDeprecatedz+A class to house deprecated matrix methods.rR   c                 C   ó   | j |d�S )Nrß   )rV   rU   r;   r;   r<   Úberkowitz_charpoly1  r>   z#MatrixDeprecated.berkowitz_charpolyc                 C   ó   | j dd�S )zwComputes determinant using Berkowitz method.

        See Also
        ========

        det
        berkowitz
        rL   rN   ©r_   rA   r;   r;   r<   Úberkowitz_det4  s   	zMatrixDeprecated.berkowitz_detc                 K   s   | j di |¤ŽS )zwComputes eigenvalues of a Matrix using Berkowitz method.

        See Also
        ========

        berkowitz
        Nr;   )r¼   rÐ   r;   r;   r<   Úberkowitz_eigenvals?  s   z$MatrixDeprecated.berkowitz_eigenvalsc                 C   s:   | j g }}|  ¡ D ]}| ||d  ¡ | }q
t|ƒS )zpComputes principal minors using Berkowitz method.

        See Also
        ========

        berkowitz
        éÿÿÿÿ)ÚonerL   ÚappendÚtuple)r:   ÚsignÚminorsÚpolyr;   r;   r<   Úberkowitz_minorsI  s
   z!MatrixDeprecated.berkowitz_minorsc                 C   s”  ddl m} d}| s|S | jstƒ ‚| | j}}dg|d  }t|ddƒD ]}}||d |ƒ|d }}||d |…f  |d |…|f }	}
|d |…d |…f |||f  }}|
g}td|d ƒD ]}| |||  ¡ qat|ƒD ]\}}|	| d ||< qq| j|g| }t|ƒD ]}|d || d … ||d …|f< q‰|||d < q%|  	| j|d  g¡g}t|ƒD ]\}}| |||  ¡ q³|t
tt
|ƒƒ S )Nr   )Úzeros))r   r   rù   r   )r   r   )Úsympy.matricesr  Ú	is_squarer   rr   Úrangerû   Ú	enumeraterú   r’   rü   Úmap)r:   r  ÚberkÚAÚNÚ
transformsrî   ÚTr†   ÚRÚCÚaÚitemsrY   ÚBÚpolysr;   r;   r<   rL   Y  s2   $$"zMatrixDeprecated.berkowitzrL   c                 C   ró   rM   )r]   rP   r;   r;   r<   ÚcofactorMatrix�  r>   zMatrixDeprecated.cofactorMatrixc                 C   r?   r@   r9   rA   r;   r;   r<   Ú
det_bareis„  rC   zMatrixDeprecated.det_bareisc                 C   rõ   )a´  Compute matrix determinant using LU decomposition.


        Note that this method fails if the LU decomposition itself
        fails. In particular, if the matrix has no inverse this method
        will fail.

        TODO: Implement algorithm for sparse matrices (SFF),
        https://www.eecis.udel.edu/~saunders/papers/sffge/it5.ps

        See Also
        ========


        det
        det_bareiss
        berkowitz_det
        ÚlurN   rö   rA   r;   r;   r<   Údet_LU_decomposition‡  s   z%MatrixDeprecated.det_LU_decompositionc                 C   s   | j ||d�S )N)ÚsizeÚ
eigenvalue)Újordan_block)r:   Úeigenvalrî   r;   r;   r<   Újordan_cellœ  rG   zMatrixDeprecated.jordan_cellTc                 C   s   |   ¡ \}}|| ¡ fS r@   )rÏ   Úget_diag_blocks)r:   Úcalc_transformationÚPÚJr;   r;   r<   Újordan_cellsŸ  s   zMatrixDeprecated.jordan_cellsc                 C   s   | j |||d�S rM   )ra   rX   r;   r;   r<   Ú
minorEntry£  r\   zMatrixDeprecated.minorEntryc                 C   s   |   ||¡S r@   )rc   rb   r;   r;   r<   ÚminorMatrix¦  r>   zMatrixDeprecated.minorMatrixc                 C   ó   | j |dd�S )zEPermute the rows of the matrix with the given permutation in reverse.Úbackward©Ú	direction©Úpermute_rows©r:   Úpermr;   r;   r<   ÚpermuteBkwd©  ó   zMatrixDeprecated.permuteBkwdc                 C   r"  )z:Permute the rows of the matrix with the given permutation.Úforwardr$  r&  r(  r;   r;   r<   Ú
permuteFwd­  r+  zMatrixDeprecated.permuteFwdNrd   rÓ   )re   rf   rg   rh   r   r	   rô   r÷   rø   r   rL   r  r  r  r  r  r   r!  r*  r-  r;   r;   r;   r<   rò   /  s     

(

rò   N)>Úsympy.core.basicr   Úsympy.core.symbolr   Úcommonr   Ú
exceptionsr   Ú	utilitiesr   r   r	   Údeterminantr
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Ú
reductionsr   r   r   r   Ú	subspacesr   r   r   r    Úeigenr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   Ú
matrixbaser/   Ú__doctest_requires__r6   ri   r¬   r¸   rÔ   rò   r;   r;   r;   r<   Ú<module>   s*   D@û	@ PF 