From c599be94db27e28366d0f2aa80846bcc9aa7b536 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 7 Jul 2011 10:30:58 +0200 Subject: Avoid looking up the same intensity "n" times, where "n" is the number of patterns --- src/hrs-scaling.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/hrs-scaling.c b/src/hrs-scaling.c index ff73ee77..f5c43478 100644 --- a/src/hrs-scaling.c +++ b/src/hrs-scaling.c @@ -257,9 +257,32 @@ static double iterate_scale(struct image *images, int n, RefList *scalable, { int a; signed int h, k, l; + double uh, Ih; get_indices(refl, &h, &k, &l); + uh = lookup_intensity(uh_arr, h, k, l); + + if ( !reference ) { + double vh; + vh = lookup_intensity(vh_arr, h, k, l); + Ih = vh / uh; + /* 0 / 0 = 0, not NaN */ + if ( isnan(Ih) ) Ih = 0.0; + } else { + /* Look up by asymmetric indices */ + Reflection *r = find_refl(reference, h, k, l); + if ( r == NULL ) { + ERROR("%3i %3i %3i isn't in the " + "reference list, so why is it " + "marked as scalable?\n", h, k, l); + Ih = 0.0; + } else { + Ih = get_intensity(r); + } + } + + /* For this reflection, calculate all the possible * values of uha and vha */ for ( a=0; aosf * uha * Ih; vc = Ih * rha; -- cgit v1.2.3