
    EdE                         d dl mZ d dlmZ d dlmZ  G d de          Z e            Zed             ZddZ	d	 d
 e	dfdZ
ddZd Zd Zd ZdS )    )contextmanager)local
expand_mulc                       e Zd Zd ZdS )DotProdSimpStatec                     d | _         d S N)state)selfs    8lib/python3.11/site-packages/sympy/matrices/utilities.py__init__zDotProdSimpState.__init__   s    


    N)__name__
__module____qualname__r    r   r   r   r      s#            r   r   c              #   ~   K   t           j        }	 | t           _        d V  |t           _        d S # |t           _        w xY wr
   _dotprodsimp_stater   )xolds     r   dotprodsimpr      sI      

"C'#$ #&   3 &&&&s   . <Fc                 (    ddl m}  || |          S )z;Wrapper for simplify.dotprodsimp to avoid circular imports.r   )r   )withsimp)sympy.simplify.simplifyr   )exprr   dpss      r   _dotprodsimpr      s)    ::::::3th''''r   c                     | S r
   r   r   s    r   <lambda>r"      s    Q r   c                     | S r
   r   r!   s    r   r"   r"      s    ! r   Nc                 V    |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   )deffuncofffunconfuncr   s       r   _get_intermediate_simpr(      sM     e 175@ d 06$> Nr   c                 &    t          | dd|          S )zYSame as ``_get_intermediate_simp`` but returns bools instead of functions
    by default.FT)r(   )defaultr   s     r   _get_intermediate_simp_boolr+   3   s     "'5$DDDr   c                 $    t          | dd          S )zReturns True if x is zero.is_zeroN)getattrr!   s    r   _iszeror/   :   s    1i&&&r   c                 (    t          |           dk    S )zNTests by expand_mul only, suitable for polynomials and rational
    functions.r   r   r!   s    r   _is_zero_after_expand_mulr1   ?   s     a==Ar   c                 $    ddl m}  ||           S )z$ Wrapper to avoid circular imports. r   )simplify)r   r3   )r   r3   s     r   	_simplifyr4   E   s"    0000008D>>r   )F)FN)
contextlibr   	threadingr   sympy.core.functionr   r   r   r   r   r(   r+   r/   r1   r4   r   r   r   <module>r8      s   % % % % % %       * * * * * *    u    &%'' ' ' '( ( ( ( $/;   *E E E E' ' '
      r   