aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2011-01-31 22:16:45 +0100
committerThomas White <taw@physics.org>2012-02-22 15:27:12 +0100
commitb70749514f280e038ebf734a2deb0fbbc84a063a (patch)
treeff04bf763878b78ae87d0cf67f7366a19334a0ce
parentb3ff6fa9453add05e7b151aa8388754bd24fd663 (diff)
Fix Kabsch scaling...!
-rw-r--r--src/hrs-scaling.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/hrs-scaling.c b/src/hrs-scaling.c
index 13c945e9..4a91adc2 100644
--- a/src/hrs-scaling.c
+++ b/src/hrs-scaling.c
@@ -140,26 +140,30 @@ static double s_vha(signed int hat, signed int kat, signed int lat,
}
-static double s_uh(struct image *images, int n, double uha)
+static double s_uh(struct image *images, int n,
+ signed int h, signed int k, signed int l, const char *sym)
{
- int k;
+ int a;
double val = 0.0;
- for ( k=0; k<n; k++ ) {
- val += pow(images[k].osf, 2.0) * uha;
+ for ( a=0; a<n; a++ ) {
+ double uha = s_vha(h, k, l, images, n, sym, a);
+ val += pow(images[a].osf, 2.0) * uha;
}
return val;
}
-static double s_vh(struct image *images, int n, double vha)
+static double s_vh(struct image *images, int n,
+ signed int h, signed int k, signed int l, const char *sym)
{
- int k;
+ int a;
double val = 0.0;
- for ( k=0; k<n; k++ ) {
- val += images[k].osf * vha;
+ for ( a=0; a<n; a++ ) {
+ double vha = s_vha(h, k, l, images, n, sym, a);
+ val += images[a].osf * vha;
}
return val;
@@ -197,12 +201,15 @@ static double iterate_scale(struct image *images, int n,
double vc, Ih, uh, rha, vha, uha;
struct refl_item *it = get_item(obs, h);
+ const signed int h = it->h;
+ const signed int k = it->k;
+ const signed int l = it->l;
/* Determine the "solution" vector component */
- vha = s_vha(it->h, it->k, it->l, images, n, sym, a);
- uha = s_uha(it->h, it->k, it->l, images, n, sym, a);
- uh = s_uh(images, n, uha);
- Ih = s_vh(images, n, vha) / uh;
+ vha = s_vha(h, k, l, images, n, sym, a);
+ uha = s_uha(h, k, l, images, n, sym, a);
+ uh = s_uh(images, n, h, k, l, sym);
+ Ih = s_vh(images, n, h, k, l, sym) / uh;
rha = vha - image_a->osf * uha * Ih;
vc = Ih * rha;
vc_tot += vc;
@@ -221,10 +228,8 @@ static double iterate_scale(struct image *images, int n,
bcomp = b;
if ( b > crossed ) bcomp--;
- vhb = s_vha(it->h, it->k, it->l, images, n,
- sym, b);
- uhb = s_uha(it->h, it->k, it->l, images, n,
- sym, b);
+ vhb = s_vha(h, k, l, images, n, sym, b);
+ uhb = s_uha(h, k, l, images, n, sym, b);
rhb = vhb - image_b->osf * uhb * Ih;
mc = (rha*vhb + vha*rhb - vha*vhb) / uh;