ó
?xTc           @   sV   d  d l  m Z d  d l Z d  d l m Z d  d l m Z d e f d     YZ	 d S(   i˙˙˙˙(   t   divisionN(   t   flex(   t   maptbxt   lbfgsc           B   s5   e  Z d  Z d d  Z d   Z d   Z d   Z RS(   s  
     If you run the lbfgs with a non-crystallographic basic_map, and it
     throws an out-of-bounds error, then change the out_of_bounds handle in
     the basic_map to:
        my_basic_map.set_out_of_bounds_handle(maptbx.out_of_bounds_clamp(0).as_handle())
  g      đ?c         C   sĆ   | |  _  | |  _ t j | j   d d  |  _ t j | j   d  |  _ | |  _ t j	 j
 d |  d t j	 j d d   |  _ |  j   |  j d t  | j   | j |  j  |  ` |  ` d  S(	   Ni   i    g      đ?t   target_evaluatort   termination_paramst   max_iterationsič  t   compute_gradients(   t
   sites_cartt	   basic_mapR   t   doublet   sizet   xt   weightst   delta_ht   scitbxR   t   runt   termination_parameterst	   minimizert   apply_shiftst   compute_targett   Falset   cleart   extendt   sites_shifted(   t   selfR	   R   R   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/maptbx/real_space_refinement.pyt   __init__   s    			

c         C   s0   |  j    |  j d t  |  j |  j j   f S(   NR   (   R   R   t   Truet   residualt	   gradientst	   as_double(   R   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/maptbx/real_space_refinement.pyt    compute_functional_and_gradients   s    
c         C   s    |  j  t j |  j  |  _ d  S(   N(   R   R   t   vec3_doubleR   R   (   R   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/maptbx/real_space_refinement.pyR   #   s    c         C   sj   t  j d |  j d |  j d |  j  |  _ | r] t  j d |  j d |  j d |  j  |  _ n	 d  |  _ d  S(   NR	   t   sitesR   R   (
   R   t   real_space_refinement_residualR	   R   R   R   t   real_space_refinement_gradientsR   R   t   None(   R   R   (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/maptbx/real_space_refinement.pyR   &   s    						(   t   __name__t
   __module__t   __doc__R   R   R   R   (    (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/maptbx/real_space_refinement.pyR      s
   		(
   t
   __future__R    t   scitbx.lbfgsR   t   cctbx.array_familyR   t   cctbxR   t   objectR   (    (    (    sP   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/cctbx/maptbx/real_space_refinement.pyt   <module>   s   