
    g[                        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Z7 G d de          Z8 G d de8          Z9 G d de9          Z: G d de:          Z; G d de          Z< G 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)zMatrixEigen.is_indefinitez MatrixEigen.is_negative_definitez$MatrixEigen.is_negative_semidefinitez MatrixEigen.is_positive_definitez$MatrixEigen.is_positive_semidefinite
matplotlibc                       e Zd ZdZefdZd ZedfdZd Z	d Z
d Zdd
ZdefdZddZddZddZd ZddZ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 )MatrixDeterminantzProvides basic matrix determinant operations. Should not be instantiated
    directly. See ``determinant.py`` for their implementations.c                 $    t          | |          S )N)
iszerofuncr   )selfr5   s     S/var/www/html/ai-engine/env/lib/python3.11/site-packages/sympy/matrices/matrices.py_eval_det_bareissz#MatrixDeterminant._eval_det_bareiss3   s    DZ8888    c                      t          |           S N)r   r7   s    r8   _eval_det_berkowitzz%MatrixDeterminant._eval_det_berkowitz6   s    d###r:   Nc                 &    t          | ||          S )N)r5   simpfunc)r   )r7   r5   r@   s      r8   _eval_det_luzMatrixDeterminant._eval_det_lu9   s    t
XFFFFr:   c                      t          |           S r<   )r   r=   s    r8   _eval_det_birdz MatrixDeterminant._eval_det_bird<   s    r:   c                      t          |           S r<   )r   r=   s    r8   _eval_det_laplacez#MatrixDeterminant._eval_det_laplace?       D!!!r:   c                      t          |           S r<   r   r=   s    r8   _eval_determinantz#MatrixDeterminant._eval_determinantB       Dzzr:   	berkowitzc                 $    t          | |          S Nmethod)r   r7   rO   s     r8   adjugatezMatrixDeterminant.adjugateE   s    f----r:   lambdac                 &    t          | ||          S )N)xsimplify)r   r7   rT   rU   s      r8   charpolyzMatrixDeterminant.charpolyH   s    X6666r:   c                 (    t          | |||          S rM   )r   r7   ijrO   s       r8   cofactorzMatrixDeterminant.cofactorK   s    q!F3333r:   c                 $    t          | |          S rM   )r   rP   s     r8   cofactor_matrixz!MatrixDeterminant.cofactor_matrixN   s    V4444r:   bareissc                 &    t          | ||          S )N)rO   r5   rH   )r7   rO   r5   s      r8   detzMatrixDeterminant.detQ   s    DJ????r:   c                      t          |           S r<   )r   r=   s    r8   perzMatrixDeterminant.perT   rJ   r:   c                 (    t          | |||          S rM   )r   rY   s       r8   minorzMatrixDeterminant.minorW   s    dAq0000r:   c                 $    t          | ||          S r<   )r   r7   rZ   r[   s      r8   minor_submatrixz!MatrixDeterminant.minor_submatrixZ   s    a+++r:   rK   )r_   N)$__name__
__module____qualname____doc__r	   r9   r>   r   rA   rC   rE   rI   rQ   r
   rW   r\   r^   ra   rc   re   rh   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r:   r8   r3   r3   /   s       C C ,E 9 9 9 9$ $ $ '. G G G G  " " "  . . . . "I 7 7 7 74 4 4 45 5 5 5@ @ @ @  1 1 1 1, , , ,B+I"+G+O (+7+?+9+A(1(9N+7+?+2?L+/<+4+<H+4+<H+4+<H+;+CO+/<CK+/<CK+1>EM+;+COr:   r3   c                       e Zd ZdZeddfdZed             ZedfdZd Z	edddfdZ
ej        e_        ej        e_        ej        e_        ej        e
_        dd
Zd Zd Zd Zd Zd Zd ZddZddZdS )MatrixReductionszProvides basic matrix row/column operations. Should not be instantiated
    directly. See ``reductions.py`` for some of their implementations.Fc                 (    t          | |||          S )N)r5   rU   with_pivots)r   )r7   r5   rU   rr   s       r8   echelon_formzMatrixReductions.echelon_forms   s"    Tj8') ) ) 	)r:   c                      t          |           S r<   )r   r=   s    r8   
is_echelonzMatrixReductions.is_echelonw   s    4   r:   c                 &    t          | ||          S )N)r5   rU   )r   )r7   r5   rU   s      r8   rankzMatrixReductions.rank{   s    Tj8DDDDr:   c                     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)r7   rhsr_s       r8   rref_rhszMatrixReductions.rref_rhs~   sf    " T[[txx	':':C@@AA1JTYJ111sxijj=!111r:   Tc                 *    t          | ||||          S )N)r5   rU   pivotsnormalize_last)r   )r7   r5   rU   r   r   s        r8   rrefzMatrixReductions.rref   s$    Tj8.: : : 	:r:   colc                    |dvr#t          d                    ||                    |dk    r| j        n| j        }|dk    r`||n|}||"t          d                    |                    d|cxk    r|k     s%n t          d                    ||                    n|d	k    r||||h                    dg          }t          |          d
k    r|||h                    dg          }t          |          d
k    r"t          d                    |                    |\  }}d|cxk    r|k     s%n t          d                    ||                    d|cxk    r|k     s%n t          d                    ||                    n|dk    r||n|}||n|}|||"t          d                    |                    ||k    r"t          d                    |                    d|cxk    r|k     s%n t          d                    ||                    d|cxk    r|k     s%n t          d                    ||                    nt          dt          |          z            |||||fS )zValidate 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formatr|   r{   
differencelenrepr)	r7   opr   kcol1col2	error_str	self_colsr|   s	            r8   _normalize_op_argsz#MatrixReductions._normalize_op_args   s1    222 ??EviQS?T?TV V V "+e!3!3DII	 ==##dC{ai  "88>y8I8IK K K''''i'''' !F!M!MiY\!]!]^^^ ( 7]] D$'22D6::D4yy1}}T4(33TF;;4yyA~~  "<<BF9<M<MO O OJD$((((y(((( !F!M!MiY]!^!^___((((y(((( !F!M!MiY]!^!^___ ) 9__+$$3C<44TD{dlai  "AAG	ARART T Td{{  "117	1B1BD D D''''i'''' !F!M!MiY\!]!]^^^((((y(((( !F!M!MiY]!^!^___ ) 3d2hh>???34%%r:   c                 X      fd}                       j         j        |          S )Nc                 >    |k    r| |f         z  S | |f         S r<   rn   )rZ   r[   r   r   r7   s     r8   entryzBMatrixReductions._eval_col_op_multiply_col_by_const.<locals>.entry   ,    Cxx41:~%1:r:   _newr{   r|   )r7   r   r   r   s   ``` r8   "_eval_col_op_multiply_col_by_constz3MatrixReductions._eval_col_op_multiply_col_by_const   D    	 	 	 	 	 	 	 yyDIu555r:   c                 X      fd}                       j         j        |          S )Nc                 X    |k    r
| f         S |k    r
| f         S | |f         S r<   rn   )rZ   r[   r   r   r7   s     r8   r   z1MatrixReductions._eval_col_op_swap.<locals>.entry   s?    DyyAtG}$dAtG}$1:r:   r   )r7   r   r   r   s   ``` r8   _eval_col_op_swapz"MatrixReductions._eval_col_op_swap   D    	 	 	 	 	 	 	 yyDIu555r:   c                 \      fd}                       j         j        |          S )Nc                 T    |k    r| |f         | f         z  z   S | |f         S r<   rn   )rZ   r[   r   r   r   r7   s     r8   r   zFMatrixReductions._eval_col_op_add_multiple_to_other_col.<locals>.entry   s:    CxxAqDzAQW$5551:r:   r   )r7   r   r   r   r   s   ```` r8   &_eval_col_op_add_multiple_to_other_colz7MatrixReductions._eval_col_op_add_multiple_to_other_col   J    	 	 	 	 	 	 	 	 yyDIu555r:   c                 X      fd}                       j         j        |          S )Nc                 X    | k    r
|f         S | k    r
|f         S | |f         S r<   rn   )rZ   r[   row1row2r7   s     r8   r   z1MatrixReductions._eval_row_op_swap.<locals>.entry   s?    DyyD!G}$dD!G}$1:r:   r   )r7   r   r   r   s   ``` r8   _eval_row_op_swapz"MatrixReductions._eval_row_op_swap   r   r:   c                 X      fd}                       j         j        |          S )Nc                 >    | k    r| |f         z  S | |f         S r<   rn   )rZ   r[   r   rowr7   s     r8   r   zBMatrixReductions._eval_row_op_multiply_row_by_const.<locals>.entry   r   r:   r   )r7   r   r   r   s   ``` r8   "_eval_row_op_multiply_row_by_constz3MatrixReductions._eval_row_op_multiply_row_by_const   r   r:   c                 \      fd}                       j         j        |          S )Nc                 T    | k    r| |f         |f         z  z   S | |f         S r<   rn   )rZ   r[   r   r   r   r7   s     r8   r   zFMatrixReductions._eval_row_op_add_multiple_to_other_row.<locals>.entry   s:    CxxAqDzAT1W$5551:r:   r   )r7   r   r   r   r   s   ```` r8   &_eval_row_op_add_multiple_to_other_rowz7MatrixReductions._eval_row_op_add_multiple_to_other_row   r   r:   r   Nc                     |                      |||||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   )r7   r   r   r   r   r   s         r8   elementary_col_opz"MatrixReductions.elementary_col_op      ( "&!8!8S!T4QV!W!WCD$ ==::3BBB==))$555??>>sAtLLL ?r:   c                     |                      |||||d          \  }}}}}|dk    r|                     ||          S |dk    r|                     ||          S |dk    r|                     |||          S dS )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   )r7   r   r   r   r   r   s         r8   elementary_row_opz"MatrixReductions.elementary_row_op  r   r:   )r   )r   NNNN)rj   rk   rl   rm   r   rs   propertyru   rw   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rn   r:   r8   rp   rp   o   sq       J J '.5 ) ) ) ) ! ! X! & E E E E2 2 2( &d: : : :
 )0L&.J =DL =DL5& 5& 5& 5&n6 6 66 6 66 6 66 6 66 6 66 6 6M M M M<M M M M M Mr:   rp   c                       e Zd ZdZddZdefdZddZd Ze	j        e_        e
j        e_        ej        e_        ej        e_         ee          ZdS )	MatrixSubspaceszProvides methods relating to the fundamental subspaces of a matrix.
    Should not be instantiated directly. See ``subspaces.py`` for their
    implementations.Fc                 $    t          | |          S N)rU   )r   r7   rU   s     r8   columnspacezMatrixSubspaces.columnspaceC  s    D84444r:   c                 &    t          | ||          S )N)rU   r5   )r   )r7   rU   r5   s      r8   	nullspacezMatrixSubspaces.nullspaceF  s    $jIIIIr:   c                 $    t          | |          S r   )r    r   s     r8   rowspacezMatrixSubspaces.rowspaceI  s    1111r:   c                 "    t          | g|R i |S r<   )r!   )clsvecskwargss      r8   orthogonalizezMatrixSubspaces.orthogonalizeO  s     c3D333F333r:   NF)rj   rk   rl   rm   r   r   r   r   r   r   r   r    r!   classmethodrn   r:   r8   r   r   >  s         5 5 5 5 "'7 J J J J2 2 2 24 4 4 )0K&.I%-H*2M'K66MMMr:   r   c                      e Zd ZdZddZdefdZddZddZddZ	dd	Z
ed
             Zed             Zed             Zed             Zed             ZddZd Z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 )MatrixEigenzProvides basic matrix eigenvalue/vector operations.
    Should not be instantiated directly. See ``eigen.py`` for their
    implementations.Tc                      t          | fd|i|S )Nerror_when_incomplete)r"   )r7   r   flagss      r8   	eigenvalszMatrixEigen.eigenvals_  s    $UU6KUuUUUr:   c                 "    t          | f||d|S )N)r   r5   )r#   )r7   r   r5   r   s       r8   
eigenvectszMatrixEigen.eigenvectsb  s.    4 07L%0 0).0 0 	0r:   Fc                      t          | fd|i|S )N
reals_only)r&   )r7   r   r   s      r8   is_diagonalizablezMatrixEigen.is_diagonalizablef  s    !$HH:HHHHr:   c                 (    t          | |||          S )N)r   sort	normalize)r'   )r7   r   r   r   s       r8   diagonalizezMatrixEigen.diagonalizei  s"    DZd#% % % 	%r:   c                 $    t          | |          S N)upper)r$   r7   r   s     r8   bidiagonalizezMatrixEigen.bidiagonalizem  s    d%0000r:   c                 $    t          | |          S r   )r%   r   s     r8   bidiagonal_decompositionz$MatrixEigen.bidiagonal_decompositionp  s    (U;;;;r:   c                      t          |           S r<   )r(   r=   s    r8   is_positive_definitez MatrixEigen.is_positive_definites      $T***r:   c                      t          |           S r<   )r)   r=   s    r8   is_positive_semidefinitez$MatrixEigen.is_positive_semidefinitew      (...r:   c                      t          |           S r<   )r*   r=   s    r8   is_negative_definitez MatrixEigen.is_negative_definite{  r   r:   c                      t          |           S r<   )r+   r=   s    r8   is_negative_semidefinitez$MatrixEigen.is_negative_semidefinite  r   r:   c                      t          |           S r<   )r,   r=   s    r8   is_indefinitezMatrixEigen.is_indefinite  s    d###r:   c                      t          | fd|i|S )Ncalc_transform)r-   )r7   r   r   s      r8   jordan_formzMatrixEigen.jordan_form  s    DJJJ6JJJr:   c                     t          | fi |S r<   )r.   r7   r   s     r8   left_eigenvectszMatrixEigen.left_eigenvects  s    .....r:   c                      t          |           S r<   )r/   r=   s    r8   singular_valueszMatrixEigen.singular_values  s    %%%r:   NTr   )FFF)"rj   rk   rl   rm   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%   rn   r:   r8   r   r   Z  s         V V V V 04 0 0 0 0I I I I% % % %1 1 1 1< < < < + + X+ / / X/ + + X+ / / X/ $ $ X$K K K K/ / /& & & *4);I)4)<J);)C)5)=K)>)F )B)J$)>)F )B)J$)7)?M)5)=K)9)AO)9)AO)7)?M)B)J$$$r:   r   c                   6    e Zd ZdZdddZd Zd Zd Zd Zd	S )
MatrixCalculusz,Provides calculus-related matrix operations.T)evaluatec                    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)r7   r   argsr   r   derivs         r8   diffzMatrixCalculus.diff  sf    * 	IHHHHH?t???h??$&& 	&8 	&##%%%r:   c                 4    |                      fd          S )Nc                 .    |                                S r<   r   )rT   args    r8   <lambda>z1MatrixCalculus._eval_derivative.<locals>.<lambda>  s    s r:   	applyfunc)r7   r  s    `r8   _eval_derivativezMatrixCalculus._eval_derivative  s    ~~3333444r:   c                 8    |                      f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                      | j         i S r<   )	integrate)rT   r   r   s    r8   r  z*MatrixCalculus.integrate.<locals>.<lambda>  s    T(DV(D(D r:   r  )r7   r   r   s    ``r8   r
  zMatrixCalculus.integrate  s%    2 ~~DDDDDEEEr:   c                     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    rj        d         }n.j        d         dk    rj        d         }nt	          d                               || f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                 F    |                               |                   S r<   r  )r[   rZ   Xr7   s     r8   r  z)MatrixCalculus.jacobian.<locals>.<lambda>  s    DGLL1,>,> r:   )r   r0   r   shape	TypeError)r7   r  mns   ``  r8   jacobianzMatrixCalculus.jacobian  s    H !Z(( 			!A :a=A
1AAZ]a
1AAGHHH71:??
AAWQZ1__
AA@AAA yyA>>>>>???r:   c                 4    |                      fd          S )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                      | j          S r<   )limit)rT   r   s    r8   r  z&MatrixCalculus.limit.<locals>.<lambda>+  s     r:   r  )r7   r   s    `r8   r  zMatrixCalculus.limit  s!    * ~~6666777r:   N)	rj   rk   rl   rm   r   r  r
  r  r  rn   r:   r8   r   r     sy        66#'     85 5 5F F F67@ 7@ 7@r8 8 8 8 8r:   r   c                       e Zd ZdZ ed          efdZd Zd Zd Z	d Z
dd	Zd
 Zd Zd ZddZddZd Zd Zd ZdS )MatrixDeprecatedz+A class to house deprecated matrix methods.rR   c                 .    |                      |          S )N)rT   )rW   rV   s      r8   berkowitz_charpolyz#MatrixDeprecated.berkowitz_charpoly1  s    }}q}!!!r:   c                 .    |                      d          S )zwComputes determinant using Berkowitz method.

        See Also
        ========

        det
        berkowitz
        rK   rN   ra   r=   s    r8   berkowitz_detzMatrixDeprecated.berkowitz_det4  s     xx{x+++r:   c                      | j         di |S )zwComputes eigenvalues of a Matrix using Berkowitz method.

        See Also
        ========

        berkowitz
        rn   )r   r   s     r8   berkowitz_eigenvalsz$MatrixDeprecated.berkowitz_eigenvals?  s     t~&&&&&r:   c                     | j         g }}|                                 D ]#}|                    ||d         z             | }$t          |          S )zpComputes principal minors using Berkowitz method.

        See Also
        ========

        berkowitz
        )onerK   appendtuple)r7   signminorspolys       r8   berkowitz_minorsz!MatrixDeprecated.berkowitz_minorsI  sW     xfNN$$ 	 	DMM$b/***5DDV}}r:   c                 B   ddl m} d}| s|S | j        st                      | | j        }}dg|dz
  z  }t          |dd          D ]} ||dz   |          |dz
  }}||d |f          |d ||f         }
}	|d |d |f         |||f          }}|
g}t          d|dz
            D ] }|                    |||         z             !t          |          D ]\  }}|	|z  d         ||<   | j        |g|z   }t          |          D ]}|d ||z
  dz            ||d |f<   |||dz
  <   | 	                    | j        |d          g          g}t          |          D ]#\  }}|                    |||         z             $|t          t          t          |                    z   S )Nr   )zeros))r   r   r   r   )r   r   )sympy.matricesr)  	is_squarer   r{   ranger"  	enumerater!  r   r#  map)r7   r)  berkAN
transformsr  Tr   RCaitemsrZ   Bpolyss                   r8   rK   zMatrixDeprecated.berkowitzY  s   (((((( 	K~ 	)&(((TY1SAE]
q!R 	" 	"A5Q??AEqAa!eH9aAhqARaR!V9qAwhqACE1a!e__ + +Qq\****!%(( ) )1E4=aXqME)E1XX - - !a%!),!""a% !Jq1uDHqwh/001j)) 	' 	'DAqLLU1X&&&&eCu--....r:   rK   c                 .    |                      |          S rM   )r^   rP   s     r8   cofactorMatrixzMatrixDeprecated.cofactorMatrix  s    ##6#222r:   c                      t          |           S r<   r6   r=   s    r8   
det_bareiszMatrixDeprecated.det_bareis  rF   r:   c                 .    |                      d          S )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  r=   s    r8   det_LU_decompositionz%MatrixDeprecated.det_LU_decomposition  s    & xxtx$$$r:   c                 0    |                      ||          S )N)size
eigenvalue)jordan_block)r7   eigenvalr  s      r8   jordan_cellzMatrixDeprecated.jordan_cell  s      aH ===r:   Tc                 \    |                                  \  }}||                                fS r<   )r   get_diag_blocks)r7   calc_transformationPJs       r8   jordan_cellszMatrixDeprecated.jordan_cells  s.    !!1!##%%%%r:   c                 2    |                      |||          S rM   )re   rY   s       r8   
minorEntryzMatrixDeprecated.minorEntry  s    zz!Qvz...r:   c                 .    |                      ||          S r<   )rh   rg   s      r8   minorMatrixzMatrixDeprecated.minorMatrix  s    ##Aq)))r:   c                 0    |                      |d          S )zEPermute the rows of the matrix with the given permutation in reverse.backward	directionpermute_rowsr7   perms     r8   permuteBkwdzMatrixDeprecated.permuteBkwd  s       <<<r:   c                 0    |                      |d          S )z:Permute the rows of the matrix with the given permutation.forwardrS  rU  rW  s     r8   
permuteFwdzMatrixDeprecated.permuteFwd  s       ;;;r:   Nri   r   )rj   rk   rl   rm   r   r
   r  r  r  r'  rK   r;  r=  r@  rF  rL  rN  rP  rY  r\  rn   r:   r8   r  r  /  s       55#(5??Y " " " "	, 	, 	,' ' '   &/ &/ &/P3 3 3 3" " "% % %*> > >& & & &/ / / /* * *= = =< < < < <r:   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/   
matrixbaser0   __doctest_requires__r3   rp   r   r   r   r  rn   r:   r8   <module>rh     sp  
 # " " " " " # # # # # #             , , , , , , D D D D D D D D D D                                  A @ @ @ @ @ @ @ @ @ @ @ J J J J J J J J J J J J6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 # " " " " "- 0<n =D =D =D =D =D =D =D =D@LM LM LM LM LM( LM LM LM^7 7 7 7 7& 7 7 78CK CK CK CK CK/ CK CK CKLK8 K8 K8 K8 K8\ K8 K8 K8^@< @< @< @< @<| @< @< @< @< @<r:   