From b361d7c9bd36a831c712aac55e60f733aa15f7b3 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 6 Mar 2014 16:13:20 +0100 Subject: Add --ncorr --- src/ambigator.c | 162 ++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 128 insertions(+), 34 deletions(-) (limited to 'src/ambigator.c') diff --git a/src/ambigator.c b/src/ambigator.c index 5be72053..8d7cd4f2 100644 --- a/src/ambigator.c +++ b/src/ambigator.c @@ -67,6 +67,7 @@ static void show_help(const char *s) " --lowres= Low resolution cutoff in A.\n" " --end-assignments= Save end assignments to file .\n" " --fg-graph= Save f and g correlation values to file .\n" +" --ncorr= Use correlations per crystal. Default 1000\n" ); } @@ -292,8 +293,93 @@ static float corr(struct flist *a, struct flist *b, int *pn, int a_reidx) } -static void detwin(struct flist **crystals, int n_crystals, int *assignments, - SymOpList *amb, FILE *fh) +struct cc_list +{ + signed int *ind; + float *cc; + + signed int *ind_reidx; + float *cc_reidx; +}; + + +static struct cc_list *calc_ccs(struct flist **crystals, int n_crystals, + int ncorr, SymOpList *amb) +{ + struct cc_list *ccs; + int i; + + assert(n_crystals >= ncorr); + ncorr++; /* Extra value at end for sentinel */ + + ccs = malloc(n_crystals*sizeof(struct cc_list)); + if ( ccs == NULL ) return NULL; + + for ( i=0; i 2 ) { - - if ( assignments[i] == assignments[j] ) { - f += cc; - p++; - } else { - g += cc; - q++; - } - - } + } - if ( (amb != NULL) && (n_reidx > 2) ) { + for ( k=0; (ccs[i].ind_reidx[k] != 0); k++ ) { - if ( assignments[i] == assignments[j] ) { - g += cc_reidx; - q++; - } else { - f += cc_reidx; - p++; - } + int j = ccs[i].ind_reidx[k]-1; + float cc = ccs[i].cc_reidx[k]; + if ( assignments[i] == assignments[j] ) { + g += cc; + q++; + } else { + f += cc; + p++; } } @@ -404,6 +480,8 @@ int main(int argc, char *argv[]) double rmin = 0.0; /* m^-1 */ double rmax = INFINITY; /* m^-1 */ FILE *fgfh = NULL; + struct cc_list *ccs; + int ncorr = 1000; /* Long options */ const struct option longopts[] = { @@ -416,6 +494,7 @@ int main(int argc, char *argv[]) {"lowres", 1, NULL, 3}, {"end-assignments", 1, NULL, 4}, {"fg-graph", 1, NULL, 5}, + {"ncorr", 1, NULL, 6}, {0, 0, NULL, 0} }; @@ -471,6 +550,13 @@ int main(int argc, char *argv[]) fg_graph_fn = strdup(optarg); break; + case 6 : + if ( sscanf(optarg, "%i", &ncorr) != 1 ) { + ERROR("Invalid value for --ncorr\n"); + return 1; + } + break; + case 0 : break; @@ -611,8 +697,16 @@ int main(int argc, char *argv[]) } } + ccs = calc_ccs(crystals, n_crystals, ncorr, amb); + if ( ccs == NULL ) { + ERROR("Failed to allocate CCs\n"); + return 1; + } + + /* FIXME: Free crystals */ + for ( i=0; i