ó
¡¼™\c           @   s4  d  d l  m Z d  d l m Z m Z m Z m Z d  d l m Z m	 Z	 m
 Z
 m Z m Z m Z m Z m Z d  d l m Z d  d l m Z d  d l m Z e d d g d	 d
 g g ƒ Z d „  Z d „  Z e d ƒ Z d „  Z d „  Z e d d i d g d 6ƒZ d „  Z d Z d „  Z d „  Z  d „  Z! d S(   iÿÿÿÿ(   t   randint(   t   Matrixt   zerost   onest   Integer(   t   to_sympyt   to_numpyt   to_scipy_sparset   matrix_tensor_productt   matrix_to_zerot   matrix_zerost   numpy_ndarrayt   scipy_sparse_matrix(   t   range(   t   import_module(   t   skipi   i   i   i   c           C   s   t  t ƒ t k s t ‚ d  S(   N(   R   t   mt   AssertionError(    (    (    sK   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_matrixutils.pyt   test_sympy_to_sympy   s    c           C   sR   t  t ƒ t k s t ‚ t  t d d g d d g g ƒ ƒ t d ƒ k sN t ‚ d  S(   Ni    (   R	   R   R   R   R   (    (    (    sK   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_matrixutils.pyt   test_matrix_to_zero   s    t   numpyc          C   s\   t  s t d ƒ n  t  j d d g d d g g d d ƒ}  t t ƒ |  k j ƒ  sX t ‚ d  S(   Ns   numpy not installed.i   i   i   i   t   dtypet   complex(   t   npR   t   matrixR   R   t   allR   (   t   result(    (    sK   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_matrixutils.pyt   test_to_numpy   s    'c          C   sÛ  t  s t d ƒ n  t d ƒ }  x" t d ƒ D] } d | |  | <q, Wt d ƒ } x t d ƒ D] } | | | <q] Wt d ƒ } x t d ƒ D] } | | | <qŠ Wt d d d g ƒ } t  j |  j ƒ  ƒ } t  j | j ƒ  ƒ } t  j | | ƒ } |  | g } t | Œ  }	 | j ƒ  |	 j ƒ  k s%t	 ‚ t  j | | ƒ } | |  g } t | Œ  }	 | j ƒ  |	 j ƒ  k smt	 ‚ t  j | j ƒ  ƒ } t  j | | ƒ } |  | g } t | Œ  }	 | j ƒ  |	 j ƒ  k sÊt	 ‚ t  j | | ƒ } | |  g } t | Œ  }	 | j ƒ  |	 j ƒ  k st	 ‚ t  j | j ƒ  ƒ } t  j | | ƒ } |  | g } t | Œ  }	 | j ƒ  |	 j ƒ  k sot	 ‚ t  j | | ƒ } | |  g } t | Œ  }	 | j ƒ  |	 j ƒ  k s·t	 ‚ t  j
 j t d d ƒ t d d ƒ ƒ }
 t  j
 j t d d ƒ t d d ƒ ƒ } t  j |
 | ƒ } t |
 j ƒ  ƒ t | j ƒ  ƒ g } t | Œ  }	 |	 t | j ƒ  ƒ j ƒ  t |	 j |	 j ƒ t j ƒ  k s‰t	 ‚ t |  | | ƒ }	 t  j |  t  j | | ƒ ƒ } | j ƒ  |	 j ƒ  k s×t	 ‚ d  S(   Ns   numpy not installed.i   i   i   i   i   i   (   R   R   R   R   R   R   t   tolistt   kronR   R   t   randomt   randR    R   t   rowst   colst   epsilon(   t   l1t   it   l2t   l3t   vect   numpyl1t   numpyl2t   numpy_productt   argst   sympy_productt   random_matrix1t   random_matrix2(    (    sK   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_matrixutils.pyt   test_matrix_tensor_product$   sd    ''$)t   scipyt   __import__kwargst   sparset   fromlistc          C   sˆ   t  s t d ƒ n  t s& t d ƒ n	 t j }  |  j d d g d d g g d d ƒ} t  j j t t ƒ | j	 ƒ  ƒ d	 k s„ t
 ‚ d  S(
   Ns   numpy not installed.s   scipy not installed.i   i   i   i   R   R   g        (   R   R   R0   R2   t
   csr_matrixt   linalgt   normR   R   t   todenseR   (   R2   R   (    (    sK   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_matrixutils.pyt   test_to_scipy_sparseh   s    	'gíµ ÷Æ°>c          C   s.   t  d d d d ƒ}  t |  t ƒ s* t ‚ d  S(   Ni   t   formatt   sympy(   R
   t
   isinstanceR   R   (   t   sym(    (    sK   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_matrixutils.pyt   test_matrix_zeros_sympyv   s    c          C   sA   t  s t d ƒ n  t d d d d ƒ}  t |  t ƒ s= t ‚ d  S(   Ns   numpy not installed.i   R9   R   (   R   R   R
   R;   R   R   (   t   num(    (    sK   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_matrixutils.pyt   test_matrix_zeros_numpyz   s    c          C   sT   t  s t d ƒ n  t s& t d ƒ n  t d d d d ƒ}  t |  t ƒ sP t ‚ d  S(   Ns   numpy not installed.s   scipy not installed.i   R9   s   scipy.sparse(   R   R   R0   R
   R;   R   R   (   t   sci(    (    sK   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_matrixutils.pyt   test_matrix_zeros_scipy   s    N("   R   R    R:   R   R   R   R   t!   sympy.physics.quantum.matrixutilsR   R   R   R   R	   R
   R   R   t   sympy.core.compatibilityR   t   sympy.externalR   t   sympy.utilities.pytestR   R   R   R   R   R   R/   R0   R8   R"   R=   R?   RA   (    (    (    sK   lib/python2.7/site-packages/sympy/physics/quantum/tests/test_matrixutils.pyt   <module>   s"   ":				A			