
    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	 d dl
mZ  G d de          Zd	 Z G d
 de          Zd Zd dlmZmZ d dlmZ d Zeed<   dS )    )Basic)Expr)S)sympify)NonSquareMatrixError)
MatrixBasec                   N    e Zd ZdZdZd Zed             Zed             Zd Z	dS )Determinanta  Matrix Determinant

    Represents the determinant of a matrix expression.

    Examples
    ========

    >>> from sympy import MatrixSymbol, Determinant, eye
    >>> A = MatrixSymbol('A', 3, 3)
    >>> Determinant(A)
    Determinant(A)
    >>> Determinant(eye(3)).doit()
    1
    Tc                     t          |          }|j        st          dt          |          z            |j        du rt          d          t          j        | |          S )Nz&Input to Determinant, %s, not a matrixFzDet of a non-square matrix)r   	is_Matrix	TypeErrorstr	is_squarer   r   __new__clsmats     b/var/www/html/ai-engine/env/lib/python3.11/site-packages/sympy/matrices/expressions/determinant.pyr   zDeterminant.__new__   s`    cll} 	QDs3xxOPPP=E!!&'CDDD}S#&&&    c                     | j         d         S Nr   argsselfs    r   argzDeterminant.arg$       y|r   c                 $    | j         j        j        S N)r   kindelement_kindr   s    r   r    zDeterminant.kind(   s    x}))r   c                     | j         }|                    dd          r |j        di |}|                                }||S | S )NdeepT )r   getdoit_eval_determinant)r   hintsr   results       r   r&   zDeterminant.doit,   sW    h99VT"" 	$#(##U##C&&((Mr   N)
__name__
__module____qualname____doc__is_commutativer   propertyr   r    r&   r$   r   r   r
   r
   	   sy          N' ' '   X * * X*	 	 	 	 	r   r
   c                 D    t          |                                           S )z Matrix Determinant

    Examples
    ========

    >>> from sympy import MatrixSymbol, det, eye
    >>> A = MatrixSymbol('A', 3, 3)
    >>> det(A)
    Determinant(A)
    >>> det(eye(3))
    1
    )r
   r&   matexprs    r   detr3   8   s     w$$&&&r   c                   6    e Zd ZdZd Zed             ZddZdS )	Permanenta  Matrix Permanent

    Represents the permanent of a matrix expression.

    Examples
    ========

    >>> from sympy import MatrixSymbol, Permanent, ones
    >>> A = MatrixSymbol('A', 3, 3)
    >>> Permanent(A)
    Permanent(A)
    >>> Permanent(ones(3, 3)).doit()
    6
    c                     t          |          }|j        st          dt          |          z            t	          j        | |          S )Nz$Input to Permanent, %s, not a matrix)r   r   r   r   r   r   r   s     r   r   zPermanent.__new__X   sD    cll} 	OBSXXMNNN}S#&&&r   c                     | j         d         S r   r   r   s    r   r   zPermanent.arg_   r   r   Fc                 l    t          | j        t                    r| j                                        S | S r   )
isinstancer   r   per)r   expandr(   s      r   r&   zPermanent.doitc   s+    dh
++ 	8<<>>!Kr   N)F)r*   r+   r,   r-   r   r/   r   r&   r$   r   r   r5   r5   H   s\         ' ' '   X     r   r5   c                 D    t          |                                           S )a   Matrix Permanent

    Examples
    ========

    >>> from sympy import MatrixSymbol, Matrix, per, ones
    >>> A = MatrixSymbol('A', 3, 3)
    >>> per(A)
    Permanent(A)
    >>> per(ones(5, 5))
    120
    >>> M = Matrix([1, 2, 5])
    >>> per(M)
    8
    )r5   r&   r1   s    r   r:   r:   i   s    " W""$$$r   )askQ)handlers_dictc                 8   t          t          j        | j                  |          rt          j        S t          t          j        | j                  |          rt          j        S t          t          j        | j                  |          rt          j        S | S )z
    >>> from sympy import MatrixSymbol, Q, assuming, refine, det
    >>> X = MatrixSymbol('X', 2, 2)
    >>> det(X)
    Determinant(X)
    >>> with assuming(Q.orthogonal(X)):
    ...     print(refine(det(X)))
    1
    )	r=   r>   
orthogonalr   r   OnesingularZerounit_triangular)exprassumptionss     r   refine_DeterminantrH      sy     1<!!;// u	QZ!!;	/	/ v	Qtx((+	6	6 uKr   N)sympy.core.basicr   sympy.core.exprr   sympy.core.singletonr   sympy.core.sympifyr   sympy.matrices.exceptionsr   sympy.matrices.matrixbaser   r
   r3   r5   r:   sympy.assumptions.askr=   r>   sympy.assumptions.refiner?   rH   r$   r   r   <module>rQ      s2   " " " " " "             " " " " " " & & & & & & : : : : : : 0 0 0 0 0 0, , , , ,$ , , ,^' ' '        B% % %& ) ( ( ( ( ( ( ( 2 2 2 2 2 2  (  2m   r   