| Clipper | 
2nd order resolution function evaluator More...
#include <resol_fn.h>
 
  
 | Public Member Functions | |
| ResolutionFn (const HKL_info &hkl_info, const BasisFn_base &basisfn, const TargetFn_base &targetfn, const std::vector< ftype > ¶ms, const ftype damp=0.0, const bool debug=false) | |
| constructor: need reflections, basis fn and target fn. | |
| ftype | f (const HKL_info::HKL_reference_index &ih) const | 
| return the value of the basis function with the current paramters | |
| const std::vector< ftype > & | params () const | 
| return the values of the parameters | |
| void | debug () const | 
| print the target, gradient, and curvatures with respect to the params | |
| Protected Member Functions | |
| void | calc_derivs (const std::vector< ftype > ¶ms, ftype &r, std::vector< ftype > &drdp, Matrix<> &drdp2) const | 
| calculate derivatives of target wrt params | |
| ResolutionFn () | |
| null constructor | |
| Protected Attributes | |
| const HKL_info * | hkl_info_ | 
| reflection list | |
| const TargetFn_base * | targetfn_ | 
| target function | |
| const BasisFn_base * | basisfn_ | 
| basis function | |
| std::vector< ftype > | params_ | 
| basis function parameters | |
| Cell | cell_ | 
| cell | |
2nd order resolution function evaluator
This is an automatic evaluator for arbitrary functions of HKL, most commonly used for evaluating a function of resolution (such a mean F^2 or sigmaa), although more general tasks including local scaling of reflections and anisotropic functions can also be handled. This form is for target functions which approach zero quadratically, e.g. least-squares targets.
This version implements a naive Newton-Raphson minimiser, which only uses the gradient and curvature of the target function, ignoring its value. It is ideal for quadratic targets with linear basis functions.
To evaluate a resolution function, this class must be provided with two objects:
For example, the following code may be used to calculate a smooth scaling function to scale one set of data to another using an anisotropic Gaussian scaling function:
// make data object clipper::HKL_info hkls; clipper::HKL_data<clipper::data32::F_sigF> fsig1( hkls ); clipper::HKL_data<clipper::data32::F_sigF> fsig2( hkls ); // INITIALISE THEM HERE! // calculate the scaling function std::vector<clipper::ftype> params( 7, 0.0 ); // initial parameters clipper::BasisFn_aniso_gaussian basisfn; // aniso gaussian clipper::TargetFn_scaleF1F2<clipper::data32::F_sigF,clipper::data32::F_sigF>targetfn( fsig1, fsig2 ); clipper::ResolutionFn_nonlinear rfn( hkls, basisfn, targetfn, params ); // now scale the data clipper::HKL_info::HKL_reference_index ih; for ( ih = hkls.first(); !ih.last(); ih.next() ) fsig1[ih].scale( sqrt( rfn.f(ih) ) );
The most useful isotropic resolution function is the BasisFn_spline, since it is linear and provides a good fit to most data.
| clipper::ResolutionFn::ResolutionFn | ( | const HKL_info & | hkl_info, | 
| const BasisFn_base & | basisfn, | ||
| const TargetFn_base & | targetfn, | ||
| const std::vector< ftype > & | params, | ||
| const ftype | damp = 0.0, | ||
| const bool | debug = false | ||
| ) | 
constructor: need reflections, basis fn and target fn.
The constructor performs the full minimisation calculation.
| hkl_info | HKL_info object which provides the reflection list. | 
| basisfn | The basis function used to describe the desired property. | 
| targetfn | The target function to be minimised. | 
| params | Initial values for the function parameters. | 
| damp_ | If > 0.0, shifts are fdamped during early cycles to help convergence with difficult bases/target conbinations. | 
References basisfn_, calc_derivs(), clipper::HKL_info::cell(), cell_, hkl_info_, clipper::BasisFn_base::num_params(), params(), params_, clipper::Matrix< T >::solve(), targetfn_, clipper::TargetFn_base::type(), and clipper::BasisFn_base::type().
| const std::vector< ftype > & clipper::ResolutionFn::params | ( | ) | const | 
return the values of the parameters
References params_.
Referenced by calc_derivs(), ResolutionFn(), and clipper::ResolutionFn_nonlinear::ResolutionFn_nonlinear().
| void clipper::ResolutionFn::calc_derivs | ( | const std::vector< ftype > & | params, | 
| ftype & | r, | ||
| std::vector< ftype > & | drdp, | ||
| Matrix<> & | drdp2 | ||
| ) | const  [protected] | 
calculate derivatives of target wrt params
The target and its derivatives are calculated by the chain rule and accumulated over all HKLs.
| params | Current value of parameters. | 
| r | The value of the target function. | 
| drdp | The derivative of the target function. | 
| drdp2 | The curvature of the target function. | 
References basisfn_, cell_, clipper::BasisFn_base::Fderiv::df, clipper::BasisFn_base::Fderiv::df2, clipper::TargetFn_base::Rderiv::dr, clipper::TargetFn_base::Rderiv::dr2, clipper::HKL_class::epsilonc(), f(), clipper::BasisFn_base::fderiv(), clipper::HKL_info::first(), clipper::HKL_info::HKL_reference_index::hkl(), clipper::HKL_info::HKL_reference_index::hkl_class(), hkl_info_, clipper::HKL_info::HKL_reference_index::last(), clipper::Util::max(), clipper::Util::min(), clipper::HKL_info::HKL_reference_index::next(), clipper::BasisFn_base::num_diagonals(), clipper::BasisFn_base::num_params(), params(), clipper::TargetFn_base::Rderiv::r, clipper::TargetFn_base::rderiv(), and targetfn_.
Referenced by ResolutionFn(), and clipper::ResolutionFn_nonlinear::ResolutionFn_nonlinear().
 1.7.4
 1.7.4