
    Ed`                         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)NonSquareMatrixErrorc                   P    e Zd ZdZdZd Zed             Zed             Zd	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        st          d          t          j        | |          S )Nz&Input to Determinant, %s, not a matrixzDet of a non-square matrix)r   	is_Matrix	TypeErrorstr	is_squarer   r   __new__clsmats     Flib/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   Fc                 h    	 | j                                         S # t          t          f$ r | cY S w xY wr   )r   _eval_determinantAttributeErrorNotImplementedErrorr   expandhintss      r   doitzDeterminant.doit+   sE    	8--/// 34 	 	 	KKK	    11NF)
__name__
__module____qualname____doc__is_commutativer   propertyr   r   r(    r   r   r	   r	      s~          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   detr5   1   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__Q   sD    cll} 	OBSXXMNNN}S#&&&r   c                     | j         d         S r   r   r   s    r   r   zPermanent.argX   r   r   Fc                 h    	 | j                                         S # t          t          f$ r | cY S w xY wr   )r   perr#   r$   r%   s      r   r(   zPermanent.doit\   sA    	8<<>>! 34 	 	 	KKK	r)   Nr*   )r+   r,   r-   r.   r   r0   r   r(   r1   r   r   r7   r7   A   s\         ' ' '   X     r   r7   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
    )r7   r(   r3   s    r   r;   r;   b   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   y   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.commonr   r	   r5   r7   r;   sympy.assumptions.askr=   r>   sympy.assumptions.refiner?   rH   r1   r   r   <module>rP      s    " " " " " "             " " " " " " & & & & & & 6 6 6 6 6 6' ' ' ' '$ ' ' 'R' ' '        B% % %& ) ( ( ( ( ( ( ( 2 2 2 2 2 2  (  2m   r   