From b1f4e521baf644069f02dd9efe869e63aed9225e Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 4 Mar 2014 18:35:04 +0100 Subject: Fix the algorithm --- src/ambigator.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ambigator.c b/src/ambigator.c index 6580b97f..e18636ff 100644 --- a/src/ambigator.c +++ b/src/ambigator.c @@ -219,9 +219,9 @@ static float corr(struct flist *a, struct flist *b, int *pn) t1 = s_x2 - s_x*s_x / n; t2 = s_y2 - s_y*s_y / n; - if ( (t1 < 0.0) || (t2 <= 0.0) ) return 0.0; + if ( (t1 <= 0.0) || (t2 <= 0.0) ) return 0.0; - return ((s_xy - s_x*s_y)/n)/sqrt(t1*t2); + return (s_xy - s_x*s_y/n) / sqrt(t1*t2); } @@ -230,6 +230,8 @@ static void detwin(struct flist **crystals, int n_crystals, SymOpList *amb, { int i; int nch = 0; + float mf = 0.0; + int nmf = 0; for ( i=0; i g ) { + if ( f < g ) { assignments[i] = 1 - assignments[i]; nch++; } @@ -271,7 +278,7 @@ static void detwin(struct flist **crystals, int n_crystals, SymOpList *amb, } - STATUS("Changed %i assignments this time.\n", nch); + STATUS("Mean f = %f, changed %i assignments this time.\n", mf/nmf, nch); } -- cgit v1.2.3