o
    *ήcB                     @   s   d dl mZ d dlmZ d dlmZmZmZ d dlm	Z	 d dl
mZmZ d dlmZmZ d dlmZmZmZmZ e	d\ZZZed	eeZed
eeZedeeZedeeZdd Zdd Zdd Zdd Zdd Z dd Z!dd Z"dd Z#dS )    )Matrix)MatAdd)Identity	OneMatrix
ZeroMatrix)symbols)raiseswarns_deprecated_sympy)
ShapeErrorMatrixSymbol)HadamardProducthadamard_productHadamardPowerhadamard_powerzn,m,kZABCc                  C   s   t tttjtjksJ ttdd  ttdd  ttdd  t tdt t d dtd  td  td  ks<J t tt tt } | jt	t
fksNJ tt tttjjtjtjtjhksbJ d S )Nc                   S   s   t ttjS N)r   r   r   T r   r   U/tmp/pip-target-vg8gfxp4/lib/python/sympy/matrices/expressions/tests/test_hadamard.py<lambda>   s    z&test_HadamardProduct.<locals>.<lambda>c                   S   s
   t ttS r   )r   r   nr   r   r   r   r         
 c                   S   s
   t tdS )N   )r   r   r   r   r   r   r      r      r   r   )r   r   r   shaper   r
   	TypeErrorr   r   r   ksetr   args)mixr   r   r   test_HadamardProduct   s   ,r%   c                   C   s   t ttt ttksJ d S r   )r   r   r   r   r   r   r   %test_HadamardProduct_isnt_commutative!   s   r&   c                  C   sn   t ddd} t ddd}t ddd}| t|| d | d |d  |d  | d |d  |d   ks5J d S )NXr   Yr   r   r   r   r   r   r   )r   r   )r'   r(   r   r   r   r   test_mixed_indexing%   s   .r,   c                  C   s   t ddd} t ddd}t  t| dd}W d    n1 s w   Y  t|ts,J | }t|t s7J tdd}tdd}t||  |ksLJ t|| | | t| dks\J t| || t| |kskJ t| ||| |ksxJ d S )Nr'   r   r(   F)check)r   r	   r   
isinstancedoitr   r   r   )r'   r(   exprexpr2r   Ur   r   r   test_canonicalize.   s   

 r3   c            
      C   sZ  t ddd\} }}td| |}td| |}td| |}td| | }t| }tt t  W d    n1 s7w   Y  t||ksDJ tt||tsNJ t|| t||ks\J tt	 t|| t|| W d    n1 suw   Y  t|||ksJ tt||tsJ tdt
d	}ttt
d	tt
d	}	t|	|}	|	 |ksJ d S )
Nm, n, pTintegerr   r   r   r'   ar   )r   r   r   r   r    r   r.   r   r/   r
   r!   r   r   r   )
mr   pr   r   r   r'   Ir7   r0   r   r   r   test_hadamard?   s,   



r;   c                  C   s   t ddd } t ddd }t ddd}t| |}tdd t| |D dd}||ks1J t| ||}|t||ks@J d S )Nr      r   r'   c                 S   s   g | ]\}}|| qS r   r   ).0ijr   r   r   
<listcomp>\   s    z;test_hadamard_product_with_explicit_mat.<locals>.<listcomp>)r   as_explicitr   r   zipreshaper   )r   r   r'   r0   retr   r   r   'test_hadamard_product_with_explicit_matW   s   
 rE   c                     s   t ddd\} }}td| | t d ksJ tt dts"J t |jt j|ks0J t |d  d | ks?J t| || | ksJJ tt fdd	 d S )
Nr4   Tr5   r   r   r   r)   c                      s
   t   S r   )r   r   r   r   r   r   k   r   z%test_hadamard_power.<locals>.<lambda>)r   r   r   r.   r   r   r   
ValueError)r8   r   r9   r   rF   r   test_hadamard_powerb   s   rH   c                  C   s   t ddd} t ddd}td\}}t|||| ksJ t|| t||d  ||d  g||d  ||d  ggks@J t| | t| d | | d | g| d | | d | ggkscJ t| | t| d |d  | d |d  g| d |d  | d |d  ggksJ d S )	Nr   r   r   za br)   r*   r+   r   )r   r   r   rA   r   )r   r   r7   br   r   r   test_hadamard_power_explicitn   s,   rJ   N)$sympy.matrices.denser   !sympy.matrices.expressions.mataddr   "sympy.matrices.expressions.specialr   r   r   
sympy.corer   sympy.testing.pytestr   r	   sympy.matricesr
   r   sympy.matrices.expressionsr   r   r   r   r   r8   r!   r   r   r   r   r%   r&   r,   r3   r;   rE   rH   rJ   r   r   r   r   <module>   s(    	