aboutsummaryrefslogtreecommitdiff
path: root/src/post-refinement.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-06-22 15:11:17 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:29 +0100
commitb2fe958bdb5bda8e140b80735c67868d49e7faf3 (patch)
tree971082991c0f00c177efc7453cfd95c6e58b2f95 /src/post-refinement.c
parent93fd0cbb09b71179ff0407a9d04c05882d70c385 (diff)
Clean up, fix matrix as symmetric
Diffstat (limited to 'src/post-refinement.c')
-rw-r--r--src/post-refinement.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/post-refinement.c b/src/post-refinement.c
index c1bc9314..a6dd5f75 100644
--- a/src/post-refinement.c
+++ b/src/post-refinement.c
@@ -341,12 +341,11 @@ static double pr_iterate(struct image *image, const RefList *full,
/* Some reflections may have recently become scalable, but
* scale_intensities() might not yet have been called, so the
* full version may not have been calculated yet. */
- I_full = get_intensity(match);
+ I_full = image->osf * get_intensity(match);
/* Actual measurement of this reflection from this pattern? */
I_partial = get_intensity(refl);
p = get_partiality(refl);
- delta_I = I_partial - (p * image->osf * I_full);
/* Calculate all gradients for this reflection */
for ( k=0; k<NUM_PARAMS; k++ ) {
@@ -359,22 +358,25 @@ static double pr_iterate(struct image *image, const RefList *full,
int g;
double v_c, v_curr;
- double gr;
for ( g=0; g<NUM_PARAMS; g++ ) {
double M_c, M_curr;
+ /* Matrix is symmetric */
+ if ( g > k ) continue;
+
M_c = gradients[g] * gradients[k];
M_c *= pow(image->osf * I_full, 2.0);
- M_curr = gsl_matrix_get(M, g, k);
+ M_curr = gsl_matrix_get(M, k, g);
+ gsl_matrix_set(M, k, g, M_curr + M_c);
gsl_matrix_set(M, g, k, M_curr + M_c);
}
- gr = gradients[k];
- v_c = delta_I * image->osf * I_full * gr;
+ delta_I = I_partial - (p * I_full);
+ v_c = delta_I * I_full * gradients[k];
v_curr = gsl_vector_get(v, k);
gsl_vector_set(v, k, v_curr + v_c);