From 86dd02420afb7ef40e8a2b570f6751b7d56e47a3 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 31 Jul 2013 16:58:43 +0200 Subject: Rescale the normal equations before attempting to solve This makes the equations insensitive to the units of the parameters being refined, e.g. divergence is measured in radians whereas cell parameters are measured in m^-1, so their magnitudes are very different. --- src/post-refinement.c | 57 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/post-refinement.c b/src/post-refinement.c index a259ece2..b0e70e1f 100644 --- a/src/post-refinement.c +++ b/src/post-refinement.c @@ -37,6 +37,7 @@ #include #include #include +#include #include "image.h" #include "post-refinement.h" @@ -359,37 +360,73 @@ static gsl_vector *solve_svd(gsl_vector *v, gsl_matrix *M) gsl_vector *s_val; int err, n; gsl_vector *shifts; + gsl_vector *SB; + gsl_vector *SinvX; + gsl_matrix *S; /* rescaling matrix due to Bricogne */ + gsl_matrix *AS; + gsl_matrix *SAS; + int i; n = v->size; if ( v->size != M->size1 ) return NULL; if ( v->size != M->size2 ) return NULL; + /* Calculate the rescaling matrix S */ + S = gsl_matrix_calloc(n, n); + for ( i=0; i