U
    	-e.                     @   s  d dl mZmZmZ d dlmZ 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mZ d dlmZmZ d d	lmZ d d
lmZ 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$m%Z% d dl&m'Z'm(Z(m)Z) d dl*m+Z+ d dl,m-Z- edege dggZ.eddgddggZ/edgeggZ0G dd deZ1G dd deZ2G dd deZ3G dd deZ4e1dZ5e2dZ6e3dZ7e4d Z8e6ee0fee6e0fe5e0fee5ee0fe7e.fee7ee.fee5e6e0e0j9 fee7e8ee.e/fe7d e.d fe7e8 de7  e.e/ de.  fee7e8e.e/ e/e.  fee7e8e.e/ e/e.  fee6e5e0j9e0 d  fgZ:d!d" Z;d#d$ Z<ed%Z=d&d' Z>d(d) Z?ed*d+d,gid-Z@d.d/ ZAd0d1 ZBe'd2ZCe)d2ZDe(d3ZEd4d5 ZFd6d7 ZGd8d9 ZHd:S );    )FloatIInteger)Matrix)import_module)skip)Dagger)	representrep_innerproductrep_expectationenumerate_states)BraKet)OperatorOuterProduct)TensorProduct)matrix_tensor_product)
Commutator)AntiCommutator)InnerProduct)numpy_ndarrayscipy_sparse_matrixto_numpyto_scipy_sparseto_sympy)XKetXOpXBra)qapply)operators_to_state            c                   @   s(   e Zd Zedd Zdd Zdd ZdS )AKetc                 C   s   t S N)ABraself r)   k/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/sympy/physics/quantum/tests/test_represent.py
dual_class   s    zAKet.dual_classc                 K   s   | j d|S N)N_represent_AOpr(   optionsr)   r)   r*   _represent_default_basis"   s    zAKet._represent_default_basisc                 K   s   t S r%   )Avecr(   basisr0   r)   r)   r*   r.   %   s    zAKet._represent_AOpN)__name__
__module____qualname__classmethodr+   r1   r.   r)   r)   r)   r*   r$      s   
r$   c                   @   s   e Zd Zedd ZdS )r&   c                 C   s   t S r%   )r$   r'   r)   r)   r*   r+   +   s    zABra.dual_classN)r5   r6   r7   r8   r+   r)   r)   r)   r*   r&   )   s   r&   c                   @   s   e Zd Zdd Zdd ZdS )AOpc                 K   s   | j d|S r,   r-   r/   r)   r)   r*   r1   2   s    zAOp._represent_default_basisc                 K   s   t S r%   )Amatr3   r)   r)   r*   r.   5   s    zAOp._represent_AOpNr5   r6   r7   r1   r.   r)   r)   r)   r*   r9   0   s   r9   c                   @   s   e Zd Zdd Zdd ZdS )BOpc                 K   s   | j d|S r,   r-   r/   r)   r)   r*   r1   ;   s    zBOp._represent_default_basisc                 K   s   t S r%   )Bmatr3   r)   r)   r*   r.   >   s    zBOp._represent_AOpNr;   r)   r)   r)   r*   r<   9   s   r<   aABc                  C   s8   t D ].} t| d tdd}t| d }||kstqd S )Nr   Zsympyr4   formatr    )_testsr	   r?   r   AssertionErrortestlhsrhsr)   r)   r*   test_format_sympyb   s    rI   c                   C   sL   t tdtdkstt tdtdks0tt dt dt ksHtd S )Nr          ?)r	   r   rD   r   r   r)   r)   r)   r*   test_scalar_sympyi   s    rK   numpyc                  C   s`   t std tD ]J} t| d tdd}t| d }t|trN||k sZt	q||kst	qd S )Nnumpy not installed.r   rL   rA   r    )
npr   rC   r	   r?   r   
isinstancer   allrD   rE   r)   r)   r*   test_format_numpyr   s    
rQ   c                   C   sX   t std ttddddks$tttddddks<ttdt dddksTtd S )NrM   r    rL   rB   rJ         ?      ?)rN   r   r	   r   rD   r   r   r)   r)   r)   r*   test_scalar_numpy   s
    rT   scipyfromlistsparse)Zimport_kwargsc                  C   sx   t std tstd tD ]V} t| d tdd}t| d }t|trft j	
||  dksrtq||kstqd S )NrM   scipy not installed.r   scipy.sparserA   r    g        )rN   r   rU   rC   r	   r?   r   rO   r   ZlinalgZnormZtodenserD   rE   r)   r)   r*   test_format_scipy_sparse   s    
rZ   c                   C   sd   t std tstd ttddddks0tttddddksHttdt dddks`td S )NrM   rX   r    rY   rR   rJ   rS   )rN   r   rU   r	   r   rD   r   r   r)   r)   r)   r*   test_scalar_scipy_sparse   s    r[   xXc                   C   sd   t tttdt kstt ttttd ks<tzt t W n t	k
r^   Y dS X d S )NZx_1T)
r
   x_ketr   r   ZdoitrD   x_brar   x_op	TypeErrorr)   r)   r)   r*   test_innerprod_represent   s    rb   c                  C   s:   t ttdd} ttt| d jt | d  ks6td S )Nr    r!   r   )r   r   r`   r   r   ZdualrD   )Z
basis_ketsr)   r)   r*   test_operator_represent   s    rc   c                  C   sP   t d} t| ddt dgks"tt| dddgt dt dt dgksLtd S )NZfoor    Zfoo_1r!   r#   Zfoo_2Zfoo_4)r   r   rD   )rF   r)   r)   r*   test_enumerate_states   s     rd   N)IZsympy.core.numbersr   r   r   Zsympy.matrices.denser   Zsympy.externalr   Zsympy.testing.pytestr   Zsympy.physics.quantum.daggerr   Zsympy.physics.quantum.representr	   r
   r   r   Zsympy.physics.quantum.stater   r   Zsympy.physics.quantum.operatorr   r   Z#sympy.physics.quantum.tensorproductr   r   Z sympy.physics.quantum.commutatorr   Z$sympy.physics.quantum.anticommutatorr   Z"sympy.physics.quantum.innerproductr   Z!sympy.physics.quantum.matrixutilsr   r   r   r   r   Zsympy.physics.quantum.cartesianr   r   r   Zsympy.physics.quantum.qapplyr   Z!sympy.physics.quantum.operatorsetr   r:   r=   r2   r$   r&   r9   r<   kbr?   r@   HrC   rI   rK   rN   rQ   rT   rU   rZ   r[   r^   r_   r`   rb   rc   rd   r)   r)   r)   r*   <module>   sn   		

	

