From 59ae49baa64e841aaf3a5030b92fb3bce7d984e5 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 4 Feb 2011 15:07:12 +0100 Subject: Next round of refactorings --- src/hrs-scaling.c | 69 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 22 deletions(-) (limited to 'src/hrs-scaling.c') diff --git a/src/hrs-scaling.c b/src/hrs-scaling.c index dc5728f8..7661cb5f 100644 --- a/src/hrs-scaling.c +++ b/src/hrs-scaling.c @@ -113,12 +113,14 @@ static double iterate_scale(struct image *images, int n, gsl_matrix *M; gsl_vector *v; gsl_vector *shifts; - int a; double max_shift; int n_ref; double *uh_arr; double *vh_arr; + double *uha_arr; + double *vha_arr; int h; /* Reflection index */ + int frame; M = gsl_matrix_calloc(n, n); v = gsl_vector_calloc(n); @@ -139,29 +141,45 @@ static double iterate_scale(struct image *images, int n, } - for ( a=0; ah; + const signed int k = it->k; + const signed int l = it->l; + + /* For this reflection, calculate all the possible + * values of uha and vha */ + for ( a=0; ah; - const signed int k = it->k; - const signed int l = it->l; + double vval; /* Determine the "solution" vector component */ - s_uhavha(h, k, l, images, n, sym, a, &uha, &vha); + uha = uha_arr[a]; + vha = vha_arr[a]; uh = lookup_intensity(uh_arr, h, k, l); vh = lookup_intensity(vh_arr, h, k, l); Ih = vh / uh; if ( isnan(Ih) ) Ih = 0.0; /* 0 / 0 = 0, not NaN */ rha = vha - image_a->osf * uha * Ih; vc = Ih * rha; - vc_tot += vc; /* Determine the matrix component */ for ( b=0; b a ) continue; - s_uhavha(h, k, l, images, n, sym, b, &uhb, &vhb); + uhb = uha_arr[b]; + vhb = vha_arr[b]; rhb = vhb - image_b->osf * uhb * Ih; mc = (rha*vhb + vha*rhb - vha*vhb) / uh; @@ -189,12 +208,18 @@ static double iterate_scale(struct image *images, int n, } - } + vval = gsl_vector_get(v, a); + gsl_vector_set(v, a, vval+vc); - gsl_vector_set(v, a, vc_tot); + } } + free(uh_arr); + free(vh_arr); + free(uha_arr); + free(vha_arr); + /* Fox and Holmes method */ gsl_eigen_symmv_workspace *work; gsl_vector *e_val; @@ -217,11 +242,11 @@ static double iterate_scale(struct image *images, int n, /* Solve (now easy) */ gsl_vector *sprime; sprime = gsl_vector_alloc(n); - for ( a=0; a fabs(max_shift) ) { max_shift = fabs(shift); -- cgit v1.2.3