ó
^™xTc           @   s�   d  d l  m Z d  d l j Z d  d l Z d  d l m Z d  d l m Z d d „ Z	 d d „ Z
 d	 „  Z d
 „  Z d „  Z e d k r™ e ƒ  d GHn  d S(   iÿÿÿÿ(   t   divisionN(   t   approx_equal(   t   flexg      ð?c         C   s  t  j d ƒ } d } x† t |  ƒ D]x } | j d | ƒ | } | j d | ƒ | } | t j t | | ƒ ƒ 7} t j d | ƒ t j | ƒ d d } q" W| t |  ƒ } | | | 9} t j d | ƒ t j | ƒ d d } t | | d d d	 ƒst ‚ d  S(
   Ni   g        i   i   g       Àg      ð?g       @t   epsg{®Gáz„?(	   t   smt   haltont   xranget   nth_given_baset   matht   expt   floatR   t   AssertionError(   t   n_pointst
   high_limitt   h_gent   resultt   iit   xt   yt   tmp(    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/math/tests/tst_halton.pyt   test_halton_sequence_1   s    ,(g      @c   	      C   sØ   t  j d } t j d ƒ } d } xx t |  ƒ D]j } d d | j d | ƒ | } d d | j d | ƒ | } | t  j | | | | d ƒ | 7} q/ W| | d | t |  ƒ } t | d d	 d
 ƒsÔ t	 ‚ d  S(   Ng       @i   g        g      ð?i   i   g      à?g      @R   g{®Gáz„?(
   R   t   piR   R   R   R   R	   R
   R   R   (	   R   R   t   normR   R   R   R   R   R   (    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/math/tests/tst_halton.pyt   test_halton_sequence_2'   s    ,c          C   sª   t  j d d d d ƒ }  d
 } t | |  j ƒ  d d ƒs? t ‚ x t d ƒ D] } |  j ƒ  qL W|  j ƒ  d k sx t ‚ |  j d	 ƒ t | |  j ƒ  d d ƒs¦ t ‚ d  S(   Ngš™™™™™¹?gš™™™™™é?g      $@g      T@R   g-Cëâ6?i   i   i    (   gš™™™™™¹?g      $@(   R   t   square_halton_samplingR   t   nextR   R   t   statet	   set_state(   t   squaret   start_valuesR   (    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/math/tests/tst_halton.pyt	   test_cube2   s    !c          C   s�   t  j d ƒ }  t j d d d d d g ƒ } x6 t d ƒ D]( } t j |  j | ƒ ƒ } | | 7} q: W| d } x& | D] } t | d d ƒ sw t ‚ qw Wd  S(   Ni   i    iˆ  g     ˆ³@g      à?g{®Gáz„?(   R   R   R   t   doubleR   t   nth_allR   R   (   t   hcubeR   R   t   vec(    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/math/tests/tst_halton.pyt   tst_five_d_cube<   s    
c           C   s,   t  d d ƒ t d d ƒ t ƒ  t ƒ  d  S(   Niè  i   i
   (   R   R   R   R#   (    (    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/math/tests/tst_halton.pyt   runF   s    t   __main__t   OK(   t
   __future__R    t   scitbx.mathR   R   t   libtbx.test_utilsR   t   scitbx.array_familyR   R   R   R   R#   R$   t   __name__(    (    (    sJ   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/math/tests/tst_halton.pyt   <module>   s   	
	
	