diff options
author | Thomas White <taw@physics.org> | 2011-06-17 15:06:26 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:29 +0100 |
commit | 401c581e1b243919e24cc93543b46529806bca66 (patch) | |
tree | 3890bef6f2a556578d04ba2045262bc8d86fd522 | |
parent | 32e1b660775a2b5026e9b5ddbda94644f93b6653 (diff) |
Split off solve_diagonal()
-rw-r--r-- | src/hrs-scaling.c | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/src/hrs-scaling.c b/src/hrs-scaling.c index f0978ddb..8fed4304 100644 --- a/src/hrs-scaling.c +++ b/src/hrs-scaling.c @@ -182,6 +182,37 @@ static gsl_vector *solve_by_eigenvalue_filtration(gsl_vector *v, gsl_matrix *M) } +static gsl_vector *solve_diagonal(gsl_vector *v, gsl_matrix *M) +{ + gsl_vector *shifts; + int n, frame; + + n = v->size; + if ( v->size != M->size1 ) return NULL; + if ( v->size != M->size2 ) return NULL; + + shifts = gsl_vector_alloc(n); + if ( shifts == NULL ) return NULL; + + for ( frame=0; frame<n; frame++ ) { + + double num, den, sh; + + num = gsl_vector_get(v, frame); + den = gsl_matrix_get(M, frame, frame); + sh = num/den; + + if ( isnan(sh) ) { + gsl_vector_set(shifts, frame, 0.0); + } else { + gsl_vector_set(shifts, frame, sh); + } + } + + return shifts; +} + + static double iterate_scale(struct image *images, int n, ReflItemList *obs, const char *sym, char *cref, double *reference) @@ -316,21 +347,7 @@ static double iterate_scale(struct image *images, int n, if ( reference == NULL ) { shifts = solve_by_eigenvalue_filtration(v, M); } else { - shifts = gsl_vector_alloc(n); - for ( frame=0; frame<n; frame++ ) { - - double num, den, sh; - - num = gsl_vector_get(v, frame); - den = gsl_matrix_get(M, frame, frame); - sh = num/den; - - if ( isnan(sh) ) { - gsl_vector_set(shifts, frame, 0.0); - } else { - gsl_vector_set(shifts, frame, sh); - } - } + shifts = solve_diagonal(v, M); } gsl_matrix_free(M); |