o
    g                     @   s   d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	m
Z
 d dlmZ d dlmZmZmZ d dlmZmZ d dlmZ d d	lm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d Z dd Z!dd Z"d d! Z#d"S )#    )Permutation)	unchanged)Matrix)MatMulBlockDiagMatrixDeterminantInverse)MatrixSymbol)
ZeroMatrix	OneMatrixIdentity)MatrixPermutePermutationMatrix)raises)Symbolc                  C   sn   t ddg} tt| sJ ttdd  t|  tddgddggks&J tt| tddd t	s5J d S )N   r   c                   S   s   t dS )Nr   r      )r    r   r   h/var/www/visachat/venv/lib/python3.10/site-packages/sympy/matrices/expressions/tests/test_permutation.py<lambda>   s    z.test_PermutationMatrix_basic.<locals>.<lambda>Ar   )
r   r   r   r   
ValueErroras_explicitr   
isinstancer	   r   pr   r   r   test_PermutationMatrix_basic   s
   $"r   c                  C   s   t g d} t| }tg dg dg dg}||  | | ks%J ||  ||  ks3J tt g d}tt g d}tt g d}|| |ksSJ d S )Nr   r   r   r   )         )         )r   r   r   )r   r   r   )r   r   r   r   )r   PMP1P2P3r   r   r   test_PermutationMatrix_matmul   s   r*   c                  C   sP   t g d} t| }t g d}t|}|d |ksJ |d tdks&J d S )Nr   r   r   r   r   r   )r   r   r   )p1r'   p2r(   r   r   r   test_PermutationMatrix_matpow#   s   r.   c                  C   s8   t ddg} t| jsJ t ddg} t| jrJ d S )Nr   r   )r   r   is_Identityr   r   r   r   test_PermutationMatrix_identity,   s   r0   c                  C   sp   t tg d} t|  dksJ t tg d} t|  dks$J t tg d} t|  dks6J d S )Nr   r   )r   r   r   r+   )r   r   r   doitr%   r   r   r   "test_PermutationMatrix_determinant4   s   r4   c                  C   s4   t tddd} t|  t tdddksJ d S )Nr   r   r   )r   r   r   r2   r3   r   r   r   test_PermutationMatrix_inverse=   s   $r5   c                  C   sL  t tg d} t tdg}| tt||||||ksJ t tg d} t tdd}| tt|||||ks=J t tg d} | tt|||ksRJ t tg d} t tg d}| tt|||ksoJ t tg d} t tg d	}| tt|||ksJ t tdd
dddd} | tt| ksJ d S )N)r   r   r   r   r    r!   r   )r   r   r   r   r    r!   r   )r   r   r   r   r!   r    )r   r    r   r   r   r!   )r   r   r   r   )r   r    r   r   r   r!   )r   r   r   r   r   r    r   r!   )r   r   rewriter   )r%   P0P10P3210P3120r   r   r   .test_PermutationMatrix_rewrite_BlockDiagMatrixB   s4   


r;   c                     s   t ddt} tddd ttfdd tt fdd t | t ks-J tt fdd t ddd	d
t t ksJJ t dddtt fdd d S )Nr   r   r   r   c                      s   t td S Nxr   r   r   r   r   r   r   d       z+test_MartrixPermute_basic.<locals>.<lambda>c                      s   t  tdS r<   r>   r   )r   r   r   r   e   r?   c                      s   t  dS )Nr   r   r   )r   r   r   r   r   h   s    r   sizec                      s
   t  S )Nr@   r   )r   ppr   r   r   m   s   
 )r   r   r	   r   r   r   r3   r   )r   r   rC   r   test_MartrixPermute_basic_   s   
rD   c                  C   s.   t dd} tddd}t|| jdksJ d S )Nr   r   r   r   r   )r   r   )r   r	   r   shaper   r   r   r   r   test_MatrixPermute_shapep   s   
rG   c                  C   sh   t ddd} tddd}| }t|| d |j| ddks!J t|| d |j| ddks2J d S )	Nr   r   r   r   r   rows)orientationcols)r   r	   r   r   permute)r   r   AAr   r   r   test_MatrixPermute_explicitv   s   rM   c                  C   sp   t ddd} tddd}t|| dt t|| d ks!J t|| dt t|| d ks6J d S )Nr   r   r   r   r   )r   r	   r   r6   r   r   rF   r   r   r   !test_MatrixPermute_rewrite_MatMul   s   rN   c                  C   s  t ddd} tddd}t||  t|| ksJ t ddd} tddd}t||   t||  ks8J t ddd} td}t|| d  t|| d ksVJ t|| d  t|| d ksjJ tdd}t||  |kszJ tdd}t||  |ksJ tddd}t dddd}t dddd}tt||d|d}| |  ksJ tt||d|d}| |  ksJ d S )Nr   r   r   r   r   rA   r    )r   r	   r   r2   r   r   r
   r   )r   r   r,   r-   exprr   r   r   test_MatrixPermute_doit   s6   

rP   N)$sympy.combinatoricsr   sympy.core.exprr   sympy.matricesr   sympy.matrices.expressionsr   r   r   r   "sympy.matrices.expressions.matexprr	   "sympy.matrices.expressions.specialr
   r   r   &sympy.matrices.expressions.permutationr   r   sympy.testing.pytestr   sympy.core.symbolr   r   r*   r.   r0   r4   r5   r;   rD   rG   rM   rN   rP   r   r   r   r   <module>   s*    		

