aboutsummaryrefslogtreecommitdiff
path: root/src/hrs-scaling.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-07-07 10:30:58 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:32 +0100
commitc599be94db27e28366d0f2aa80846bcc9aa7b536 (patch)
tree317af4e684c9c893fdc82bad810703f54885fbed /src/hrs-scaling.c
parent4d942ca413eb687d41ff7531de81fd0377c8c049 (diff)
Avoid looking up the same intensity "n" times, where "n" is the number of patterns
Diffstat (limited to 'src/hrs-scaling.c')
-rw-r--r--src/hrs-scaling.c46
1 files changed, 24 insertions, 22 deletions
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; a<n; a++ ) {
@@ -276,33 +299,12 @@ static double iterate_scale(struct image *images, int n, RefList *scalable,
int b; /* Frame (scale factor) number */
struct image *image_a = &images[a];
- double vc, Ih, uh, rha, vha, uha;
+ double vc, rha, vha, uha;
double vval;
/* Determine the "solution" vector component */
uha = uha_arr[a];
vha = vha_arr[a];
- 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);
- }
- }
-
rha = vha - image_a->osf * uha * Ih;
vc = Ih * rha;