ó
J™xTc           @   s³   d  d l  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 Z d  d l Z d „  Z d	 „  Z d
 „  Z e d k r¯ e ƒ  n  d S(   iÿÿÿÿ(   t   division(   t   adptbxt   sgtbx(   t   debug_utils(   t   row_echelon_full_pivoting(   t   flex(   t   approx_equalNc         C   s‰   d } |  d } xX t  d d ƒ D]G } | d r= | | } n | | | } | | |  | 7} |  | } q  W| | | | |  d 7} | S(   s2    A non-linear function of the 6 components u_cart i    i   i   i   (   t   xrange(   t   u_cartt   resultt   ut   it   v(    (    s\   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/regression/tst_adp_constraints_cartesian.pyt   f   s    

 c   "      C   s  | j  d d ƒ } | j ƒ  } | j ƒ  } xÞt | j ƒ  ƒ D]Ê} | j | ƒ } d | j ƒ  G| j ƒ  } t d | i d d 6d d 6d	 d
 6ƒ } t	 j
 | j ƒ  | j ƒ  | ƒ }	 |	 j ƒ  }
 |	 j | ƒ } | j ƒ  } | |
 j ƒ  k sô t ‚ g  } x8 t | ƒ D]* } d g | } d | | <| j | ƒ qWg  | D] } | j | ƒ ^ q<} g  | D] } |
 j | ƒ ^ q^} g  | D] } t j | | ƒ ^ q€} t j | ƒ } t d | d d ƒ } x5 | D]- } | j d t j | ƒ d d ƒ sÉt ‚ qÉWd } t g  t | ƒ D] } t j ƒ  ^ qƒ } | j | ƒ } g  } x‰ t | ƒ D]{ } t | ƒ } | | c | 7<t | ƒ } | | c | 8<t | j | ƒ ƒ t | j | ƒ ƒ d | } | j | ƒ qMWg  } xw t d ƒ D]i } t | ƒ } | | c | 7<t | ƒ } | | c | 8<t | ƒ t | ƒ d | } | j | ƒ qßW| j t | ƒ ƒ } t j t j t j | ƒ t j | ƒ ƒ ƒ d | d k  s£t ‚ t g  t | ƒ D] } t j ƒ  ^ q³ƒ } | j | ƒ }  | j |  ƒ }! t  | |! d d ƒs= t ‚ q= WHd S(   s     Set-up crystal and constraints t   volumeiè  s   %s,s   (%s)gš™™™™™¹?t   xgš™™™™™É?t   yg333333Ó?t   zi    i   t   a_workt   min_abs_pivotg•Ö&è.>t   epsilong-Cëâ6?i   i   i   t   epsgê-�™—q=N(!   t   any_compatible_crystal_symmetryt	   unit_cellt   wyckoff_tableR   t   sizet   positiont   lettert
   special_opt   evalR   t   site_symmetryt   space_groupt   adp_constraintst   cartesian_adp_constraintst   n_independent_paramst   AssertionErrort   appendt
   all_paramsR   t   u_star_as_u_cartR   t   doubleR   t   is_in_row_spacet   tuplet   randomt   listR   t   independent_gradientst   maxt   abst   independent_paramsR   ("   t   flagst   space_group_infot   crystalR   t   wyckoffsR   t   wyckoff_posR   t
   exact_siteR   t   u_star_constraintst   u_cart_constraintst   nt   basisR   t   u_cart_basist   u_star_basisR
   t   u_cart_basis_bisR   t   u_cart_basis_echelonR   t   v0t   u_cart_0t   grad_f_wrt_independent_u_cartt   v_upt   v_downt   dert   grad_f_wrt_u_cartt	   u_cart_upt   u_cart_downt   grad_f_wrt_independent_u_cart_1R   t   w(    (    s\   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/regression/tst_adp_constraints_cartesian.pyt   exercise_all_wyckoff   sx    		(		
"""	"+*+c           C   s   t  j t j d t ƒ d  S(   Ni   (   R   t   parse_options_loop_space_groupst   syst   argvRI   (    (    (    s\   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/regression/tst_adp_constraints_cartesian.pyt   runa   s    t   __main__(   t
   __future__R    t   cctbxR   R   t   cctbx.developmentR   t   scitbx.mathR   t   scitbx.array_familyR   t   libtbx.test_utilsR   R*   RK   R   RI   RM   t   __name__(    (    (    s\   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/regression/tst_adp_constraints_cartesian.pyt   <module>   s   		I	