ó
j™xTc           @   si   d  d l  m Z d  d l m Z d  d l m Z d e f d „  ƒ  YZ d „  Z	 e
 d k re e	 ƒ  n  d S(	   iÿÿÿÿ(   t   division(   t   flex(   t   matht   classic_spe_enginec           B   s    e  Z d  d d „ Z d „  Z RS(   g333333ë?i'  c         C   s8   | |  _  | |  _ | |  _ |  j | |  _ d |  _ d  S(   Ngê-�™—q=(   t   dmatt   lt	   max_cyclet   dlt   eps(   t   selfR   R   R   (    (    s=   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/math/spe.pyt   __init__!   s
    			c         C   s¼  g  } x. t  | ƒ D]  } | j t j | ƒ d ƒ q Wt |  j ƒ } x_t  |  j ƒ D]N} t j t j t | ƒ ƒ ƒ } d } x| D]} t |  j	 | ƒ }	 t j t j |	 ƒ ƒ d }
 |  j	 | |
 } | d } | d } | | } | | } t
 j t j | | | | ƒ ƒ } | | d | | | |  j | | } | | d | | | |  j | | } | t | | ƒ 7} | | | <| | | <q‡ W| |  j } qV W| | t | ƒ f S(   Nid   g        i    i   g      à?(   t   ranget   appendR   t   random_doublet   floatR   R   t   sort_permutationt   lenR   t   smatht   sqrtt   sumR   t   absR   (   R	   t   n_dimensionst   n_pointst   xt   iiR   t   mmt
   atom_ordert   straint
   n_contactst   jj_indext   jj_infot   jjt   tdt   xit   xjt   cdt   new_xit   new_xj(    (    s=   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/math/spe.pyt   embed(   s.    



$))
(   t   __name__t
   __module__R
   R&   (    (    (    s=   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/math/spe.pyR       s   c          C   s�  d }  g  } xq t  |  ƒ D]c } d } | t j d |  } | t j | ƒ } | t j | ƒ } | j t j | | g ƒ ƒ q Wg  } x» t  |  ƒ D]­ } g  } x‘ t  |  ƒ D]ƒ }	 | | d }
 | |	 d } | | d } | |	 d } t j |
 | d | | d ƒ } |	 | k r¬ | j |	 | f ƒ q¬ q¬ W| j | ƒ q“ Wt	 | d d d	 d
 ƒ} | j
 d |  ƒ \ } } | d k  s†t ‚ d GHd  S(   Ni
   g      $@i   i    i   g       @R   g      ð?R   iˆ  g-Cëâ6?t   OK(   R   R   t   pit   cost   sinR   R   t   doubleR   R   R&   t   AssertionError(   t   Mt   xyR   t   rt   phiR   t   yR   t   tmpR   t   x1t   x2t   y1t   y2t   ddt   speet   s(    (    s=   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/math/spe.pyt   tstC   s0     #t   __main__N(   t
   __future__R    t   scitbx.array_familyR   t   stdlibR   R   t   objectR   R<   R'   (    (    (    s=   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/math/spe.pyt   <module>   s   #	