B
    dd  ใ               @   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	   ๚e/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/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 d |t _X d S )N)ฺ_dotprodsimp_stater   )ฺxฺoldr	   r	   r
   r      s
    
r   c             C   s   | S )Nr	   )r   r	   r	   r
   ฺ<lambda>   ๓    r   Nc             C   s0   |dkst jdkr|S |dks(t jdk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.
    FT)r   r   )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.ฺis_zeroN)ฺgetattr)r   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   ฺ	threadingr   Zsympy.core.functionr   Zsympy.simplify.simplifyr   Z_dotprodsimpr   r   r   r   r   r   r	   r	   r	   r
   ฺ<module>   s   

