a
    RG5d`  ã                   @   sœ   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„ deƒZ
dd	„ ZG d
d„ deƒZdd„ Zd dlmZmZ d dlmZ dd„ Zeed< dS )é    )ÚBasic)ÚExpr)ÚS)Úsympify)ÚNonSquareMatrixErrorc                   @   s>   e Zd ZdZdZdd„ Zedd„ ƒZedd„ ƒZd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                 C   s8   t |ƒ}|jstdt|ƒ ƒ‚|js,tdƒ‚t | |¡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Úmat© r   úb/var/www/html/django/DPS/env/lib/python3.9/site-packages/sympy/matrices/expressions/determinant.pyr      s    zDeterminant.__new__c                 C   s
   | j d S ©Nr   ©Úargs©Úselfr   r   r   Úarg#   s    zDeterminant.argc                 C   s
   | j jjS ©N)r   ÚkindÚelement_kindr   r   r   r   r   '   s    zDeterminant.kindFc              	   K   s,   z| j  ¡ W S  ttfy&   |  Y S 0 d S r   )r   Ú_eval_determinantÚAttributeErrorÚNotImplementedError©r   ÚexpandÚhintsr   r   r   Údoit+   s    zDeterminant.doitN)F)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úis_commutativer   Úpropertyr   r   r!   r   r   r   r   r      s   


r   c                 C   s   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!   ©Úmatexprr   r   r   Údet1   s    r*   c                   @   s.   e Zd ZdZdd„ Zedd„ ƒZd
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                 C   s*   t |ƒ}|jstdt|ƒ ƒ‚t | |¡S )Nz$Input to Permanent, %s, not a matrix)r   r   r	   r
   r   r   r   r   r   r   r   Q   s    zPermanent.__new__c                 C   s
   | j d S r   r   r   r   r   r   r   X   s    zPermanent.argFc              	   K   s,   z| j  ¡ W S  ttfy&   |  Y S 0 d S r   )r   Úperr   r   r   r   r   r   r!   \   s    zPermanent.doitN)F)r"   r#   r$   r%   r   r'   r   r!   r   r   r   r   r+   A   s
   
r+   c                 C   s   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
    )r+   r!   r(   r   r   r   r,   b   s    r,   )ÚaskÚQ)Úhandlers_dictc                 C   sL   t t | j¡|ƒrtjS t t | j¡|ƒr0tjS t t | j¡|ƒrHt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Úassumptionsr   r   r   Úrefine_Determinanty   s    
r7   N)Úsympy.core.basicr   Úsympy.core.exprr   Zsympy.core.singletonr   Úsympy.core.sympifyr   Úsympy.matrices.commonr   r   r*   r+   r,   Úsympy.assumptions.askr-   r.   Úsympy.assumptions.refiner/   r7   r   r   r   r   Ú<module>   s   )!