o
    +< iE  ã                   @   s   d dl mZ d dlmZ d dlmZ G dd„ deƒZeƒ Zedd„ ƒZdd	d
„Z	dd„ dd„ e	dfdd„Z
ddd„Zdd„ Zdd„ Zdd„ ZdS )é    )Úcontextmanager)Úlocal©Ú
expand_mulc                   @   s   e Zd Zdd„ ZdS )ÚDotProdSimpStatec                 C   s
   d | _ d S ©N)Ústate)Úself© r
   úS/home/app/PyTorch/.pytorch/lib/python3.10/site-packages/sympy/matrices/utilities.pyÚ__init__   s   
zDotProdSimpState.__init__N)Ú__name__Ú
__module__Ú__qualname__r   r
   r
   r
   r   r      s    r   c                 c   s*    t j}z| t _d V  W |t _d S |t _w r   ©Ú_dotprodsimp_stater   )ÚxÚoldr
   r
   r   Údotprodsimp   s   €r   Fc                 C   s   ddl m} || |dS )z;Wrapper for simplify.dotprodsimp to avoid circular imports.r   )r   )Úwithsimp)Úsympy.simplify.simplifyr   )Úexprr   Zdpsr
   r
   r   Ú_dotprodsimp   s   r   c                 C   s   | S r   r
   ©r   r
   r
   r   Ú<lambda>   s    r   Nc                 C   s0   |du s	t jdu r|S |du st jdu r|S | S )a  Support function for controlling intermediate simplification. Returns a
    simplification function according to the global setting of dotprodsimp
    operation.

    ``deffunc``     - Function to be used by default.
    ``offfunc``     - Function to be used if dotprodsimp has been turned off.
    ``onfunc``      - Function to be used if dotprodsimp has been turned on.
    ``dotprodsimp`` - True, False or None. Will be overridden by global
                      _dotprodsimp_state.state if that is not None.
    FTr   )ZdeffuncZofffuncZonfuncr   r
   r
   r   Ú_get_intermediate_simp   s
   r   c                 C   s   t | dd|ƒS )zYSame as ``_get_intermediate_simp`` but returns bools instead of functions
    by default.FT)r   )Údefaultr   r
   r
   r   Ú_get_intermediate_simp_bool3   s   r   c                 C   s   t | ddƒS )zReturns True if x is zero.Úis_zeroN)Úgetattrr   r
   r
   r   Ú_iszero:   s   r    c                 C   s   t | ƒdkS )zNTests by expand_mul only, suitable for polynomials and rational
    functions.r   r   r   r
   r
   r   Ú_is_zero_after_expand_mul?   s   r!   c                 C   s   ddl m} || ƒS )z$ Wrapper to avoid circular imports. r   )Úsimplify)r   r"   )r   r"   r
   r
   r   Ú	_simplifyE   s   r#   )F)FN)Ú
contextlibr   Ú	threadingr   Zsympy.core.functionr   r   r   r   r   r   r   r    r!   r#   r
   r
   r
   r   Ú<module>   s    



ÿ
