o
    8Va                     @   s   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	e	 Z
edd Zd	d
 d	d
 edfddZdddZdd Zdd ZdS )    )contextmanager)local
expand_mul)dotprodsimpc                   @   s   e Zd Zdd ZdS )DotProdSimpStatec                 C   s
   d | _ d S N)state)self r   :/usr/lib/python3/dist-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   r      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   Fc                 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_bool,   s   r   c                 C   s   t | ddS )zReturns True if x is zero.Zis_zeroN)getattrr   r   r   r   _iszero3   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_mul8   s   r   )FN)
contextlibr   Z	threadingr   Zsympy.core.functionr   Zsympy.simplify.simplifyr   Z_dotprodsimpr   r   r   r   r   r   r   r   r   r   <module>   s    
	

