a
    kh9                     @   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- d dlm.Z. edege dggZ/eddgddggZ0edgeggZ1G dd deZ2G dd deZ3G dd deZ4G dd deZ5e2dZ6e3dZ7e4d Z8e5d!Z9e7ee1fee7e1fe6e1fee6ee1fe8e/fee8ee/fee6e7e1e1j: fee8e9ee/e0fe8d e/d fe8e9 de8  e/e0 de/  fee8e9e/e0 e0e/  fee8e9e/e0 e0e/  fee7e6e1j:e1 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.ZAd/d0 ZBd1d2 ZCe'd3ZDe)d3ZEe(d4ZFd5d6 ZGd7d8 ZHd9d: ZId;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)raises            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*   X/var/www/auris/lib/python3.9/site-packages/sympy/physics/quantum/tests/test_represent.py
dual_class   s    zAKet.dual_classc                 K   s   | j di |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)   basisr1   r*   r*   r+   r/   &   s    zAKet._represent_AOpN)__name__
__module____qualname__classmethodr,   r2   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)r6   r7   r8   r9   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i |S r-   r.   r0   r*   r*   r+   r2   3   s    zAOp._represent_default_basisc                 K   s   t S r&   )Amatr4   r*   r*   r+   r/   6   s    zAOp._represent_AOpNr6   r7   r8   r2   r/   r*   r*   r*   r+   r:   1   s   r:   c                   @   s   e Zd Zdd Zdd ZdS )BOpc                 K   s   | j di |S r-   r.   r0   r*   r*   r+   r2   <   s    zBOp._represent_default_basisc                 K   s   t S r&   )Bmatr4   r*   r*   r+   r/   ?   s    zBOp._represent_AOpNr<   r*   r*   r*   r+   r=   :   s   r=   aABc                  C   s8   t D ].} t| d tdd}t| d }||ksJ qd S )Nr   Zsympyr5   formatr!   )_testsr	   r@   r   testlhsrhsr*   r*   r+   test_format_sympyc   s    rI   c                   C   sL   t tdtdksJ t tdtdks0J t dt dt ksHJ d S )Nr!         ?)r	   r   r   r   r*   r*   r*   r+   test_scalar_sympyj   s    rK   numpyc                  C   s`   t std tD ]J} t| d tdd}t| d }t|trN||k sZJ q||ksJ qd S )Nnumpy not installed.r   rL   rB   r!   )	npr   rD   r	   r@   r   
isinstancer   allrE   r*   r*   r+   test_format_numpys   s    
rQ   c                   C   sX   t std ttddddks$J ttddddks<J tdt dddksTJ d S )NrM   r!   rL   rC   rJ         ?      ?)rN   r   r	   r   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srJ q||ksJ qd S )NrM   scipy not installed.r   scipy.sparserB   r!   g        )rN   r   rU   rD   r	   r@   r   rO   r   ZlinalgZnormZtodenserE   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s0J ttddddksHJ tdt dddks`J d S )NrM   rX   r!   rY   rR   rJ   rS   )rN   r   rU   r	   r   r   r   r*   r*   r*   r+   test_scalar_scipy_sparse   s    r[   xXc                   C   sN   t tttdt ksJ t ttttd ks<J ttdd  d S )NZx_1c                   S   s   t tS r&   )r
   x_opr*   r*   r*   r+   <lambda>       z*test_innerprod_represent.<locals>.<lambda>)	r
   x_ketr   r   Zdoitx_brar   r    	TypeErrorr*   r*   r*   r+   test_innerprod_represent   s    rd   c                  C   s:   t ttdd} ttt| d jt | d  ks6J d S )Nr!   r"   r   )r   r   r^   r   r   Zdual)Z
basis_ketsr*   r*   r+   test_operator_represent   s    re   c                  C   sN   t d} t| ddt dgks"J t| g dt dt dt dgksJJ d S )NZfoor!   Zfoo_1)r!   r"   r$   Zfoo_2Zfoo_4)r   r   )rF   r*   r*   r+   test_enumerate_states   s    rf   N)JZ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;   r>   r3   r%   r'   r:   r=   kbr@   rA   HrD   rI   rK   rN   rQ   rT   rU   rZ   r[   ra   rb   r^   rd   re   rf   r*   r*   r*   r+   <module>   sp   		

	
