--- src/clipper_progs/src/intensity_target.h.orig 2010-01-21 11:27:13.236795886 -0600 +++ src/clipper_progs/src/intensity_target.h 2010-01-21 11:31:33.450686927 -0600 @@ -70,9 +70,31 @@ { public: //! constructor: takes the datalist against which to calc target - TargetFn_scaleLogI1I2( const HKL_data& hkl_data1_, const HKL_data& hkl_data2_ ); + TargetFn_scaleLogI1I2( const HKL_data& hkl_data1_, const HKL_data& hkl_data2_ ) + { + hkl_data1 = &hkl_data1_; + hkl_data2 = &hkl_data2_; + } //! return the value and derivatives of the target function - Rderiv rderiv( const HKL_info::HKL_reference_index& ih, const ftype& intensityh ) const; + Rderiv rderiv( const HKL_info::HKL_reference_index& ih, const ftype& intensityh ) const + { + Rderiv result; + result.r = result.dr = result.dr2 = 0.0; + const T1& it1 = (*hkl_data1)[ih]; + const T2& it2 = (*hkl_data2)[ih]; + if ( !it1.missing() && !it2.missing() ) + if ( it1.I() > 1.0e-6 && it2.I() > 1.0e-6 ) { + const ftype eps = ih.hkl_class().epsilon(); + const ftype i1 = it1.I() / eps; + const ftype i2 = it2.I() / eps; + const ftype w = sqrt( i1 * i2 ); + const ftype d = intensityh + log(i1) - log(i2); + result.r = w * d * d; + result.dr = 2.0 * w * d; + result.dr2 = 2.0 * w; + } + return result; + } //! the type of the function: optionally used to improve convergence FNtype type() const { return QUADRATIC; } private: @@ -109,33 +131,4 @@ return result; } - // Log I1-I2 scaling - - template TargetFn_scaleLogI1I2::TargetFn_scaleLogI1I2( const HKL_data& hkl_data1_, const HKL_data& hkl_data2_ ) - { - hkl_data1 = &hkl_data1_; - hkl_data2 = &hkl_data2_; - } - - template TargetFn_base::Rderiv TargetFn_scaleLogI1I2::rderiv( const HKL_info::HKL_reference_index& ih, const ftype& intensityh ) const - { - Rderiv result; - result.r = result.dr = result.dr2 = 0.0; - const T1& it1 = (*hkl_data1)[ih]; - const T2& it2 = (*hkl_data2)[ih]; - if ( !it1.missing() && !it2.missing() ) - if ( it1.I() > 1.0e-6 && it2.I() > 1.0e-6 ) { - const ftype eps = ih.hkl_class().epsilon(); - const ftype i1 = it1.I() / eps; - const ftype i2 = it2.I() / eps; - const ftype w = sqrt( i1 * i2 ); - const ftype d = intensityh + log(i1) - log(i2); - result.r = w * d * d; - result.dr = 2.0 * w * d; - result.dr2 = 2.0 * w; - } - return result; - } - - #endif