ó
¡¼™\c           @   sñ  d  d l  m Z 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 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 ƒ Z/ d e f d „  ƒ  YZ0 d e f d „  ƒ  YZ1 d e f d „  ƒ  YZ2 d e f d „  ƒ  YZ3 e0 d ƒ Z4 e1 d ƒ Z5 e2 d ƒ Z6 e3 d ƒ Z7 e5 e
 e/ ƒ f e
 e5 ƒ e/ f e4 e/ f e
 e4 ƒ e
 e/ ƒ f e6 e- f e
 e6 ƒ e
 e- ƒ f e e4 e5 ƒ e/ e/ j8 f e e6 e7 ƒ e e- e. ƒ f e6 d e- d f e6 e7 d e6 e- e. d e- f e e6 e7 ƒ e- e. e. e- f e e6 e7 ƒ e- e. e. e- f e e5 e4 ƒ e/ j8 e/ d  f g Z9 d! „  Z: d" „  Z; e d# ƒ Z< d$ „  Z= d% „  Z> e d& d' i d( g d) 6ƒZ? d* „  Z@ d+ „  ZA e& d, ƒ ZB e( d, ƒ ZC e' d- ƒ ZD d. „  ZE d/ „  ZF d0 „  ZG d1 S(2   iÿÿÿÿ(   t   Floatt   It   Integert   Matrix(   t   import_module(   t   skip(   t   Dagger(   t	   representt   rep_innerproductt   rep_expectationt   enumerate_states(   t   Brat   Ket(   t   Operatort   OuterProduct(   t   TensorProduct(   t   matrix_tensor_product(   t
   Commutator(   t   AntiCommutator(   t   InnerProduct(   t   numpy_ndarrayt   scipy_sparse_matrixt   to_numpyt   to_scipy_sparset   to_sympy(   t   XKett   XOpt   XBra(   t   qapply(   t   operators_to_statei   i   i   i   t   AKetc           B   s)   e  Z e d  „  ƒ Z d „  Z d „  Z RS(   c         C   s   t  S(   N(   t   ABra(   t   self(    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyt
   dual_class   s    c         K   s   |  j  d  |  S(   N(   t   _represent_AOpt   None(   R    t   options(    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyt   _represent_default_basis!   s    c         K   s   t  S(   N(   t   Avec(   R    t   basisR$   (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyR"   $   s    (   t   __name__t
   __module__t   classmethodR!   R%   R"   (    (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyR      s   	R   c           B   s   e  Z e d  „  ƒ Z RS(   c         C   s   t  S(   N(   R   (   R    (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyR!   *   s    (   R(   R)   R*   R!   (    (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyR   (   s   t   AOpc           B   s   e  Z d  „  Z d „  Z RS(   c         K   s   |  j  d  |  S(   N(   R"   R#   (   R    R$   (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyR%   1   s    c         K   s   t  S(   N(   t   Amat(   R    R'   R$   (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyR"   4   s    (   R(   R)   R%   R"   (    (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyR+   /   s   	t   BOpc           B   s   e  Z d  „  Z d „  Z RS(   c         K   s   |  j  d  |  S(   N(   R"   R#   (   R    R$   (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyR%   :   s    c         K   s   t  S(   N(   t   Bmat(   R    R'   R$   (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyR"   =   s    (   R(   R)   R%   R"   (    (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyR-   8   s   	t   at   At   Bi    c          C   sS   xL t  D]D }  t |  d d t d d ƒ} t |  d ƒ } | | k s t ‚ q Wd  S(   Ni    R'   t   formatt   sympyi   (   t   _testsR   R0   R   t   AssertionError(   t   testt   lhst   rhs(    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyt   test_format_sympya   s    c           C   sl   t  t d ƒ ƒ t d ƒ k s$ t ‚ t  t d ƒ ƒ t d ƒ k sH t ‚ t  d t ƒ d t k sh t ‚ d  S(   Ni   g      ð?(   R   R   R5   R    R   (    (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyt   test_scalar_sympyh   s    $$t   numpyc          C   s   t  s t d ƒ n  xv t D]n }  t |  d d t d d ƒ} t |  d ƒ } t | t ƒ rv | | k j ƒ  sˆ t	 ‚ q | | k s t	 ‚ q Wd  S(   Ns   numpy not installed.i    R'   R2   R;   i   (
   t   npR   R4   R   R0   R   t
   isinstanceR   t   allR5   (   R6   R7   R8   (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyt   test_format_numpyq   s    c           C   s   t  s t d ƒ n  t t d ƒ d d ƒd k s7 t ‚ t t d ƒ d d ƒd k s[ t ‚ t d t d d ƒd k s} t ‚ d  S(   Ns   numpy not installed.i   R2   R;   g      ð?y              ð?y      ð?      ð?(   R<   R   R   R   R5   R    R   (    (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyt   test_scalar_numpy~   s
    $$t   scipyt   __import__kwargst   sparset   fromlistc          C   s³   t  s t d ƒ n  t s& t d ƒ n  x† t D]~ }  t |  d d t d d ƒ} t |  d ƒ } t | t ƒ r™ t  j	 j
 | | j ƒ  ƒ d k s« t ‚ q- | | k s- t ‚ q- Wd  S(	   Ns   numpy not installed.s   scipy not installed.i    R'   R2   s   scipy.sparsei   g        (   R<   R   RA   R4   R   R0   R   R=   R   t   linalgt   normt   todenseR5   (   R6   R7   R8   (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyt   test_format_scipy_sparseŠ   s    +c           C   s”   t  s t d ƒ n  t s& t d ƒ n  t t d ƒ d d ƒd k sJ t ‚ t t d ƒ d d ƒd k sn t ‚ t d t d d ƒd k s t ‚ d  S(	   Ns   numpy not installed.s   scipy not installed.i   R2   s   scipy.sparseg      ð?y              ð?y      ð?      ð?(   R<   R   RA   R   R   R5   R    R   (    (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyt   test_scalar_scipy_sparse™   s    $$t   xt   Xc           C   s   t  t ƒ t t d ƒ t ƒ j ƒ  k s- t ‚ t  t ƒ t t t d ƒ ƒ j ƒ  k sZ t ‚ y t  t ƒ Wn t	 k
 r| t
 SXd  S(   Nt   x_1(   R   t   x_ketR   R   t   doitR5   t   x_braR   t   x_opt	   TypeErrort   True(    (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyt   test_innerprod_represent¨   s    --c          C   sM   t  t t ƒ d d ƒ }  t t ƒ t |  d j t |  d ƒ k sI t ‚ d  S(   Ni   i   i    (   R
   R   RP   R	   R   t   dualR5   (   t
   basis_kets(    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyt   test_operator_represent²   s    c          C   sv   t  d ƒ }  t |  d d ƒ t  d ƒ g k s3 t ‚ t |  d d d g ƒ t  d ƒ t  d ƒ t  d ƒ g k sr t ‚ d  S(   Nt   fooi   t   foo_1i   i   t   foo_2t   foo_4(   R   R
   R5   (   R6   (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyt   test_enumerate_states¸   s    'N(H   R3   R    R   R   R   t   sympy.externalR   t   sympy.utilities.pytestR   t   sympy.physics.quantum.daggerR   t   sympy.physics.quantum.representR   R   R	   R
   t   sympy.physics.quantum.stateR   R   t   sympy.physics.quantum.operatorR   R   t#   sympy.physics.quantum.tensorproductR   R   t    sympy.physics.quantum.commutatorR   t$   sympy.physics.quantum.anticommutatorR   t"   sympy.physics.quantum.innerproductR   t!   sympy.physics.quantum.matrixutilsR   R   R   R   R   t   sympy.physics.quantum.cartesianR   R   R   t   sympy.physics.quantum.qapplyR   t!   sympy.physics.quantum.operatorsetR   R,   R.   R&   R   R   R+   R-   t   kt   bR0   R1   t   HR4   R9   R:   R<   R?   R@   RA   RH   RI   RM   RO   RP   RS   RV   R[   (    (    (    sI   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_represent.pyt   <module>   sj   ""(				!#							
	
	