diff options
author | Thomas White <taw@physics.org> | 2011-07-18 18:21:30 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:33 +0100 |
commit | 599c277480ee1d3d5a1a2ffb486e855b845c0dbe (patch) | |
tree | 668685308cca58d126b11d10f98eb256c7dac0f6 /src | |
parent | 33077f930ed81d70081a95edb7d7004390fa4047 (diff) |
Compiles (with warnings)
Diffstat (limited to 'src')
-rw-r--r-- | src/compare_hkl.c | 19 | ||||
-rw-r--r-- | src/diffraction.c | 29 | ||||
-rw-r--r-- | src/diffraction.h | 3 | ||||
-rw-r--r-- | src/get_hkl.c | 79 | ||||
-rw-r--r-- | src/povray.c | 20 | ||||
-rw-r--r-- | src/povray.h | 3 | ||||
-rw-r--r-- | src/powder_plot.c | 19 | ||||
-rw-r--r-- | src/process_hkl.c | 25 | ||||
-rw-r--r-- | src/reflist-utils.c | 16 | ||||
-rw-r--r-- | src/reflist-utils.h | 7 | ||||
-rw-r--r-- | src/render_hkl.c | 34 | ||||
-rw-r--r-- | src/symmetry.c | 27 | ||||
-rw-r--r-- | src/symmetry.h | 27 |
13 files changed, 192 insertions, 116 deletions
diff --git a/src/compare_hkl.c b/src/compare_hkl.c index 0ed48311..c8a6fde5 100644 --- a/src/compare_hkl.c +++ b/src/compare_hkl.c @@ -51,7 +51,7 @@ static void show_help(const char *s) static void plot_shells(RefList *list1, double *arr2, double scale, - UnitCell *cell, const char *sym, + UnitCell *cell, const SymOpList *sym, double rmin_fix, double rmax_fix) { double num[NBINS]; @@ -170,7 +170,7 @@ static void plot_shells(RefList *list1, double *arr2, double scale, signed int hs, ks, ls; int bin; - get_asymm(h, k, l, &hs, &ks, &ls, sym); + get_asymm(sym, h, k, l, &hs, &ks, &ls); if ( lookup_count(counted, hs, ks, ls) ) continue; set_count(counted, hs, ks, ls, 1); @@ -259,7 +259,8 @@ int main(int argc, char *argv[]) char *ratiofile = NULL; char *afile = NULL; char *bfile = NULL; - char *sym = NULL; + char *sym_str = NULL; + SymOpList *sym; double scale, scale_r2, scale_rdig, R1, R2, R1i, Rdiff, pearson; double scale_rintint, scale_r1i, scale_r1, scale_r1fi; int ncom; @@ -306,7 +307,7 @@ int main(int argc, char *argv[]) break; case 'y' : - sym = strdup(optarg); + sym_str = strdup(optarg); break; case 'p' : @@ -345,9 +346,11 @@ int main(int argc, char *argv[]) return 1; } - if ( sym == NULL ) { - sym = strdup("1"); + if ( sym_str == NULL ) { + sym_str = strdup("1"); } + sym = get_pointgroup(sym_str); + free(sym_str); afile = strdup(argv[optind++]); bfile = strdup(argv[optind]); @@ -374,12 +377,12 @@ int main(int argc, char *argv[]) /* Check that the intensities have the correct symmetry */ if ( check_list_symmetry(list1, sym) ) { ERROR("The first input reflection list does not appear to" - " have symmetry %s\n", sym); + " have symmetry %s\n", symmetry_name(sym)); return 1; } if ( check_list_symmetry(list2, sym) ) { ERROR("The second input reflection list does not appear to" - " have symmetry %s\n", sym); + " have symmetry %s\n", symmetry_name(sym)); return 1; } diff --git a/src/diffraction.c b/src/diffraction.c index 0c90f556..aa04fd52 100644 --- a/src/diffraction.c +++ b/src/diffraction.c @@ -93,20 +93,21 @@ static double lattice_factor(struct rvec q, double ax, double ay, double az, static double sym_lookup_intensity(const double *intensities, - const unsigned char *flags, const char *sym, + const unsigned char *flags, + const SymOpList *sym, signed int h, signed int k, signed int l) { int i; double ret = 0.0; - for ( i=0; i<num_general_equivs(sym); i++ ) { + for ( i=0; i<num_equivs(sym); i++ ) { signed int he; signed int ke; signed int le; double f, val; - get_general_equiv(h, k, l, &he, &ke, &le, sym, i); + get_equiv(sym, i, h, k, l, &he, &ke, &le); f = (double)lookup_flag(flags, he, ke, le); val = lookup_intensity(intensities, he, ke, le); @@ -120,20 +121,20 @@ static double sym_lookup_intensity(const double *intensities, static double sym_lookup_phase(const double *phases, - const unsigned char *flags, const char *sym, + const unsigned char *flags, const SymOpList *sym, signed int h, signed int k, signed int l) { int i; double ret = 0.0; - for ( i=0; i<num_general_equivs(sym); i++ ) { + for ( i=0; i<num_equivs(sym); i++ ) { signed int he; signed int ke; signed int le; double f, val; - get_general_equiv(h, k, l, &he, &ke, &le, sym, i); + get_equiv(sym, i, h, k, l, &he, &ke, &le); f = (double)lookup_flag(flags, he, ke, le); val = lookup_phase(phases, he, ke, le); @@ -147,7 +148,7 @@ static double sym_lookup_phase(const double *phases, static double interpolate_linear(const double *ref, const unsigned char *flags, - const char *sym, float hd, + const SymOpList *sym, float hd, signed int k, signed int l) { signed int h; @@ -170,7 +171,7 @@ static double interpolate_linear(const double *ref, const unsigned char *flags, static double interpolate_bilinear(const double *ref, - const unsigned char *flags, const char *sym, + const unsigned char *flags, const SymOpList *sym, float hd, float kd, signed int l) { signed int k; @@ -190,7 +191,7 @@ static double interpolate_bilinear(const double *ref, static double interpolate_intensity(const double *ref, - const unsigned char *flags, const char *sym, + const unsigned char *flags, const SymOpList *sym, float hd, float kd, float ld) { signed int l; @@ -212,7 +213,7 @@ static double interpolate_intensity(const double *ref, static double complex interpolate_phased_linear(const double *ref, const double *phases, const unsigned char *flags, - const char *sym, + const SymOpList *sym, float hd, signed int k, signed int l) { @@ -252,7 +253,7 @@ static double complex interpolate_phased_linear(const double *ref, static double complex interpolate_phased_bilinear(const double *ref, const double *phases, const unsigned char *flags, - const char *sym, + const SymOpList *sym, float hd, float kd, signed int l) { @@ -275,7 +276,7 @@ static double complex interpolate_phased_bilinear(const double *ref, static double interpolate_phased_intensity(const double *ref, const double *phases, const unsigned char *flags, - const char *sym, + const SymOpList *sym, float hd, float kd, float ld) { signed int l; @@ -302,7 +303,7 @@ static double molecule_factor(const double *intensities, const double *phases, double ax, double ay, double az, double bx, double by, double bz, double cx, double cy, double cz, - GradientMethod m, const char *sym) + GradientMethod m, const SymOpList *sym) { float hd, kd, ld; signed int h, k, l; @@ -345,7 +346,7 @@ static double molecule_factor(const double *intensities, const double *phases, void get_diffraction(struct image *image, int na, int nb, int nc, const double *intensities, const double *phases, const unsigned char *flags, UnitCell *cell, - GradientMethod m, const char *sym) + GradientMethod m, const SymOpList *sym) { unsigned int fs, ss; double ax, ay, az; diff --git a/src/diffraction.h b/src/diffraction.h index 14a84197..f71d3cce 100644 --- a/src/diffraction.h +++ b/src/diffraction.h @@ -18,6 +18,7 @@ #include "image.h" #include "cell.h" +#include "symmetry.h" typedef enum { GRADIENT_MOSAIC, @@ -28,6 +29,6 @@ typedef enum { extern void get_diffraction(struct image *image, int na, int nb, int nc, const double *intensities, const double *phases, const unsigned char *flags, UnitCell *cell, - GradientMethod m, const char *sym); + GradientMethod m, const SymOpList *sym); #endif /* DIFFRACTION_H */ diff --git a/src/get_hkl.c b/src/get_hkl.c index cb2ef3fb..72e1c2a3 100644 --- a/src/get_hkl.c +++ b/src/get_hkl.c @@ -141,14 +141,16 @@ static RefList *template_reflections(RefList *list, RefList *template) static RefList *twin_reflections(RefList *in, - const char *holo, const char *mero) + const SymOpList *holo, const SymOpList *mero) { Reflection *refl; RefListIterator *iter; RefList *out; - if ( num_general_equivs(holo) < num_general_equivs(mero) ) { - ERROR("%s is not a subgroup of %s!\n", mero, holo); + /* FIXME: Check properly by coset decomposition */ + if ( num_equivs(holo) < num_equivs(mero) ) { + ERROR("%s is not a subgroup of %s!\n", symmetry_name(mero), + symmetry_name(holo)); return NULL; } @@ -170,19 +172,19 @@ static RefList *twin_reflections(RefList *in, * only once for each reflection in the holohedral group, which * contains fewer reflections. */ - get_asymm(h, k, l, &h, &k, &l, holo); + get_asymm(holo, h, k, l, &h, &k, &l); if ( find_refl(out, h, k, l) != NULL ) continue; total = 0.0; sigma = 0.0; skip = 0; - n = num_equivs(h, k, l, holo); + n = num_equivs(holo); for ( j=0; j<n; j++ ) { signed int he, ke, le; signed int hu, ku, lu; - get_equiv(h, k, l, &he, &ke, &le, holo, j); + get_equiv(holo, j, h, k, l, &he, &ke, &le); /* Do we have this reflection? * We might not have the particular (merohedral) @@ -196,7 +198,8 @@ static RefList *twin_reflections(RefList *in, "reflection (or an equivalent in %s), " "which I don't have. %i %i %i won't " "appear in the output\n", - h, k, l, he, ke, le, mero, h, k, l); + h, k, l, he, ke, le, symmetry_name(mero), + h, k, l); skip = 1; break; } @@ -220,15 +223,17 @@ static RefList *twin_reflections(RefList *in, } -static RefList *expand_reflections(RefList *in, - const char *target, const char *initial) +static RefList *expand_reflections(RefList *in, const SymOpList *target, + const SymOpList *initial) { Reflection *refl; RefListIterator *iter; RefList *out; - if ( num_general_equivs(target) > num_general_equivs(initial) ) { - ERROR("%s is not a subgroup of %s!\n", initial, target); + /* FIXME: Check properly */ + if ( num_equivs(target) > num_equivs(initial) ) { + ERROR("%s is not a subgroup of %s!\n", symmetry_name(initial), + symmetry_name(target)); return NULL; } @@ -245,7 +250,7 @@ static RefList *expand_reflections(RefList *in, get_indices(refl, &h, &k, &l); intensity = get_intensity(refl); - n = num_equivs(h, k, l, initial); + n = num_equivs(initial); /* For each equivalent in the higher symmetry group */ for ( j=0; j<n; j++ ) { @@ -254,10 +259,10 @@ static RefList *expand_reflections(RefList *in, Reflection *new; /* Get the equivalent */ - get_equiv(h, k, l, &he, &ke, &le, initial, j); + get_equiv(initial, j, h, k, l, &he, &ke, &le); /* Put it into the asymmetric unit for the target */ - get_asymm(he, ke, le, &he, &ke, &le, target); + get_asymm(target, he, ke, le, &he, &ke, &le); /* Make sure the intensity is in the right place */ new = add_refl(out, he, ke, le); @@ -277,9 +282,12 @@ int main(int argc, char *argv[]) int config_noise = 0; int config_poisson = 0; int config_multi = 0; - char *holo = NULL; - char *mero = NULL; - char *expand = NULL; + char *holo_str = NULL; + char *mero_str = NULL; + char *expand_str = NULL; + SymOpList *holo; + SymOpList *mero; + SymOpList *expand; char *input_file = NULL; char *template = NULL; char *output = NULL; @@ -327,15 +335,15 @@ int main(int argc, char *argv[]) break; case 'y' : - mero = strdup(optarg); + mero_str = strdup(optarg); break; case 'w' : - holo = strdup(optarg); + holo_str = strdup(optarg); break; case 'e' : - expand = strdup(optarg); + expand_str = strdup(optarg); break; case 'b' : @@ -359,7 +367,7 @@ int main(int argc, char *argv[]) } - if ( (holo != NULL) && (expand != NULL) ) { + if ( (holo_str != NULL) && (expand_str != NULL) ) { ERROR("You cannot 'twin' and 'expand' at the same time.\n"); ERROR("Decide which one you want to do first.\n"); return 1; @@ -379,11 +387,30 @@ int main(int argc, char *argv[]) return 1; } + if ( holo_str != NULL ) { + holo = get_pointgroup(holo_str); + free(holo_str); + } else { + holo = NULL; + } + if ( mero_str != NULL ) { + mero = get_pointgroup(mero_str); + free(mero_str); + } else { + mero = NULL; + } + if ( expand_str != NULL ) { + expand = get_pointgroup(expand_str); + free(expand_str); + } else { + expand = NULL; + } + input = read_reflections(input_file); free(input_file); if ( check_list_symmetry(input, mero) ) { ERROR("The input reflection list does not appear to" - " have symmetry %s\n", mero); + " have symmetry %s\n", symmetry_name(mero)); return 1; } @@ -402,7 +429,8 @@ int main(int argc, char *argv[]) if ( holo != NULL ) { RefList *new; - STATUS("Twinning from %s into %s\n", mero, holo); + STATUS("Twinning from %s into %s\n", symmetry_name(mero), + symmetry_name(holo)); new = twin_reflections(input, holo, mero); /* Replace old with new */ @@ -418,7 +446,8 @@ int main(int argc, char *argv[]) if ( expand != NULL ) { RefList *new; - STATUS("Expanding from %s into %s\n", mero, expand); + STATUS("Expanding from %s into %s\n", symmetry_name(mero), + symmetry_name(expand)); new = expand_reflections(input, expand, mero); /* Replace old with new */ @@ -442,7 +471,7 @@ int main(int argc, char *argv[]) get_indices(refl, &h, &k, &l); inty = get_intensity(refl); - inty *= (double)num_equivs(h, k, l, mero); + inty *= (double)num_equivs(mero); set_int(refl, inty); } diff --git a/src/povray.c b/src/povray.c index 660f1c59..9fb267f4 100644 --- a/src/povray.c +++ b/src/povray.c @@ -30,7 +30,7 @@ int povray_render_animation(UnitCell *cell, RefList *list, unsigned int nproc, - const char *sym, int wght, double boost, + const SymOpList *sym, int wght, double boost, double scale_top) { FILE *fh; @@ -174,8 +174,10 @@ int povray_render_animation(UnitCell *cell, RefList *list, unsigned int nproc, float val; signed int h, k, l; + SymOpList *sp; get_indices(refl, &h, &k, &l); + sp = special_position(sym, h, k, l); switch ( wght ) { case WGHT_I : @@ -187,7 +189,7 @@ int povray_render_animation(UnitCell *cell, RefList *list, unsigned int nproc, break; case WGHT_COUNTS : val = get_redundancy(refl); - val /= (float)num_equivs(h, k, l, sym); + val /= (double)num_equivs(sp); break; case WGHT_RAWCOUNTS : val = get_redundancy(refl); @@ -199,6 +201,8 @@ int povray_render_animation(UnitCell *cell, RefList *list, unsigned int nproc, if ( val > max ) max = val; + free_symoplist(sp); + } max /= boost; @@ -216,8 +220,12 @@ int povray_render_animation(UnitCell *cell, RefList *list, unsigned int nproc, int s; float val, p, r, g, b, trans; int j; + SymOpList *sp; + int neq; get_indices(refl, &h, &k, &l); + sp = special_position(sym, h, k, l); + neq = num_equivs(sp); switch ( wght ) { case WGHT_I : @@ -229,7 +237,7 @@ int povray_render_animation(UnitCell *cell, RefList *list, unsigned int nproc, break; case WGHT_COUNTS : val = get_redundancy(refl); - val /= (float)num_equivs(h, k, l, sym); + val /= (double)neq; break; case WGHT_RAWCOUNTS : val = get_redundancy(refl); @@ -281,12 +289,12 @@ int povray_render_animation(UnitCell *cell, RefList *list, unsigned int nproc, trans = 1.0-(val/max); /* For each equivalent */ - for ( j=0; j<num_equivs(h, k, l, sym); j++ ) { + for ( j=0; j<neq; j++ ) { signed int he, ke, le; float x, y, z; - get_equiv(h, k, l, &he, &ke, &le, sym, j); + get_equiv(sp, j, h, k, l, &he, &ke, &le); x = asx*he + bsx*ke + csx*le; y = asy*he + bsy*ke + csy*le; @@ -303,6 +311,8 @@ int povray_render_animation(UnitCell *cell, RefList *list, unsigned int nproc, } + free_symoplist(sp); + } fprintf(fh, "\n"); diff --git a/src/povray.h b/src/povray.h index 9dbf109d..f91c141c 100644 --- a/src/povray.h +++ b/src/povray.h @@ -18,9 +18,10 @@ #include "reflist.h" #include "cell.h" +#include "symmetry.h" extern int povray_render_animation(UnitCell *cell, RefList *list, - unsigned int nproc, const char *sym, + unsigned int nproc, const SymOpList *sym, int wght, double boost, double scale_top); #endif /* POVRAY_H */ diff --git a/src/powder_plot.c b/src/powder_plot.c index 7d12f31b..6065da07 100644 --- a/src/powder_plot.c +++ b/src/powder_plot.c @@ -305,7 +305,8 @@ static unsigned int process_h5(struct image *image, struct histogram_info *info, } -static unsigned int process_hkl(struct image *image, char *sym, UnitCell *cell, +static unsigned int process_hkl(struct image *image, const SymOpList *sym, + UnitCell *cell, struct histogram_info *info, struct bin_stats *histdata, int q_scaling, int use_redundancy) @@ -329,7 +330,9 @@ static unsigned int process_hkl(struct image *image, char *sym, UnitCell *cell, if ( use_redundancy ) { redundancy = get_redundancy(refl); } else { - redundancy = num_equivs(h, k, l, sym); + SymOpList *sp = special_position(sym, h, k, l); + redundancy = num_equivs(sp); + free_symoplist(sp); } /* Multiply by 2 to get 1/d (in m^-1) */ @@ -734,6 +737,7 @@ int main(int argc, char *argv[]) struct hdfile *hdfile = NULL; struct bin_stats *histdata = NULL; struct histogram_info hist_info; + SymOpList *sym; /* Default settings */ hist_info.histsize = 100; @@ -765,7 +769,7 @@ int main(int argc, char *argv[]) char *pdb = NULL; char *output = NULL; char *datatype = NULL; - char *sym = NULL; + char *sym_str = NULL; /* Long options */ const struct option longopts[] = { @@ -823,7 +827,7 @@ int main(int argc, char *argv[]) break; case 'y' : - sym = strdup(optarg); + sym_str = strdup(optarg); break; case 's' : @@ -1040,9 +1044,11 @@ int main(int argc, char *argv[]) } free(pdb); - if ( sym == NULL ) { - sym = strdup("1"); + if ( sym_str == NULL ) { + sym_str = strdup("1"); } + sym = get_pointgroup(sym_str); + free(sym_str); /* Set up histogram info*/ if (hist_info.q_min <= 0.0 ) { @@ -1173,7 +1179,6 @@ int main(int argc, char *argv[]) if ( image.beam != NULL ) free(image.beam); fclose(fh); free(histdata); - free(sym); return 0; } diff --git a/src/process_hkl.c b/src/process_hkl.c index 731344cb..06c5a54b 100644 --- a/src/process_hkl.c +++ b/src/process_hkl.c @@ -118,7 +118,7 @@ static void plot_histogram(double *vals, int n) static void merge_pattern(RefList *model, RefList *new, int max_only, - const char *sym, + const SymOpList *sym, double *hist_vals, signed int hist_h, signed int hist_k, signed int hist_l, int *hist_n, int pass) @@ -138,7 +138,7 @@ static void merge_pattern(RefList *model, RefList *new, int max_only, get_indices(refl, &h, &k, &l); /* Put into the asymmetric unit for the target group */ - get_asymm(h, k, l, &h, &k, &l, sym); + get_asymm(sym, h, k, l, &h, &k, &l); model_version = find_refl(model, h, k, l); if ( model_version == NULL ) { @@ -209,7 +209,7 @@ enum { }; -static void scale_intensities(RefList *model, RefList *new, const char *sym) +static void scale_intensities(RefList *model, RefList *new, const SymOpList *sym) { double s; double top = 0.0; @@ -235,7 +235,7 @@ static void scale_intensities(RefList *model, RefList *new, const char *sym) model_version = find_refl(model, h, k, l); if ( model_version == NULL ) continue; - get_asymm(h, k, l, &hu, &ku, &lu, sym); + get_asymm(sym, h, k, l, &hu, &ku, &lu); i1 = get_intensity(model_version); i2 = get_intensity(refl); @@ -294,7 +294,7 @@ static void scale_intensities(RefList *model, RefList *new, const char *sym) static void merge_all(FILE *fh, RefList *model, int config_maxonly, int config_scale, int config_sum, int config_startafter, int config_stopafter, - const char *sym, + const SymOpList *sym, int n_total_patterns, double *hist_vals, signed int hist_h, signed int hist_k, signed int hist_l, @@ -416,7 +416,8 @@ int main(int argc, char *argv[]) int config_sum = 0; int config_scale = 0; unsigned int n_total_patterns; - char *sym = NULL; + char *sym_str = NULL; + SymOpList *sym; char *pdb = NULL; char *histo = NULL; signed int hist_h, hist_k, hist_l; @@ -473,7 +474,7 @@ int main(int argc, char *argv[]) break; case 'y' : - sym = strdup(optarg); + sym_str = strdup(optarg); break; case 'g' : @@ -518,7 +519,9 @@ int main(int argc, char *argv[]) cell = NULL; } - if ( sym == NULL ) sym = strdup("1"); + if ( sym_str == NULL ) sym_str = strdup("1"); + sym = get_pointgroup(sym_str); + free(sym_str); /* Open the data stream */ if ( strcmp(filename, "-") == 0 ) { @@ -550,13 +553,13 @@ int main(int argc, char *argv[]) ERROR("Invalid indices for '--histogram'\n"); return 1; } - space_for_hist = n_total_patterns * num_general_equivs(sym); + space_for_hist = n_total_patterns * num_equivs(sym); hist_vals = malloc(space_for_hist * sizeof(double)); free(histo); STATUS("Histogramming %i %i %i -> ", hist_h, hist_k, hist_l); /* Put into the asymmetric cell for the target group */ - get_asymm(hist_h, hist_k, hist_l, - &hist_h, &hist_k, &hist_l, sym); + get_asymm(sym, hist_h, hist_k, hist_l, + &hist_h, &hist_k, &hist_l); STATUS("%i %i %i\n", hist_h, hist_k, hist_l); } diff --git a/src/reflist-utils.c b/src/reflist-utils.c index 016fa317..c0784dbb 100644 --- a/src/reflist-utils.c +++ b/src/reflist-utils.c @@ -104,7 +104,7 @@ unsigned char *flags_from_list(RefList *list) } -int check_list_symmetry(RefList *list, const char *sym) +int check_list_symmetry(RefList *list, const SymOpList *sym) { unsigned char *flags; Reflection *refl; @@ -122,10 +122,10 @@ int check_list_symmetry(RefList *list, const char *sym) get_indices(refl, &h, &k, &l); - for ( j=0; j<num_equivs(h, k, l, sym); j++ ) { + for ( j=0; j<num_equivs(sym); j++ ) { signed int he, ke, le; - get_equiv(h, k, l, &he, &ke, &le, sym, j); + get_equiv(sym, j, h, k, l, &he, &ke, &le); if ( abs(he) > INDMAX ) continue; if ( abs(le) > INDMAX ) continue; @@ -149,17 +149,17 @@ int check_list_symmetry(RefList *list, const char *sym) int find_equiv_in_list(RefList *list, signed int h, signed int k, - signed int l, const char *sym, signed int *hu, + signed int l, const SymOpList *sym, signed int *hu, signed int *ku, signed int *lu) { int i; int found = 0; - for ( i=0; i<num_equivs(h, k, l, sym); i++ ) { + for ( i=0; i<num_equivs( sym); i++ ) { signed int he, ke, le; Reflection *f; - get_equiv(h, k, l, &he, &ke, &le, sym, i); + get_equiv(sym, i, h, k, l, &he, &ke, &le); f = find_refl(list, he, ke, le); /* There must only be one equivalent. If there are more, it @@ -362,7 +362,7 @@ RefList *read_reflections(const char *filename) } -RefList *asymmetric_indices(RefList *in, const char *sym) +RefList *asymmetric_indices(RefList *in, const SymOpList *sym) { Reflection *refl; RefListIterator *iter; @@ -380,7 +380,7 @@ RefList *asymmetric_indices(RefList *in, const char *sym) get_indices(refl, &h, &k, &l); - get_asymm(h, k, l, &ha, &ka, &la, sym); + get_asymm(sym, h, k, l, &ha, &ka, &la); cr = add_refl(new, ha, ka, la); assert(cr != NULL); diff --git a/src/reflist-utils.h b/src/reflist-utils.h index 775e375a..59aa6172 100644 --- a/src/reflist-utils.h +++ b/src/reflist-utils.h @@ -19,6 +19,7 @@ #include "reflist.h" #include "cell.h" +#include "symmetry.h" #define REFLECTION_END_MARKER "End of reflections" @@ -36,11 +37,11 @@ extern double *intensities_from_list(RefList *list); extern double *phases_from_list(RefList *list); extern unsigned char *flags_from_list(RefList *list); -extern int check_list_symmetry(RefList *list, const char *sym); +extern int check_list_symmetry(RefList *list, const SymOpList *sym); extern int find_equiv_in_list(RefList *list, signed int h, signed int k, - signed int l, const char *sym, signed int *hu, + signed int l, const SymOpList *sym, signed int *hu, signed int *ku, signed int *lu); -extern RefList *asymmetric_indices(RefList *in, const char *sym); +extern RefList *asymmetric_indices(RefList *in, const SymOpList *sym); #endif /* REFLIST_UTILS_H */ diff --git a/src/render_hkl.c b/src/render_hkl.c index 58784e2f..823b6f1a 100644 --- a/src/render_hkl.c +++ b/src/render_hkl.c @@ -85,7 +85,7 @@ static void show_help(const char *s) static void draw_circles(signed int xh, signed int xk, signed int xl, signed int yh, signed int yk, signed int yl, signed int zh, signed int zk, signed int zl, - RefList *list, const char *sym, + RefList *list, const SymOpList *sym, cairo_t *dctx, int wght, double boost, int colscale, UnitCell *cell, double radius, double theta, double as, double bs, double cx, double cy, @@ -110,15 +110,19 @@ static void draw_circles(signed int xh, signed int xk, signed int xl, double u, v, val, res; signed int ha, ka, la; int xi, yi; - int i; + int i, n; + SymOpList *sp; get_indices(refl, &ha, &ka, &la); - for ( i=0; i<num_equivs(ha, ka, la, sym); i++ ) { + sp = special_position(sym, ha, ka, la); + n = num_equivs(sp); + + for ( i=0; i<n; i++ ) { signed int h, k, l; - get_equiv(ha, ka, la, &h, &k, &l, sym, i); + get_equiv(sp, i, ha, ka, la, &h, &k, &l); /* Is the reflection in the zone? */ if ( h*zh + k*zk + l*zl != 0 ) continue; @@ -136,7 +140,7 @@ static void draw_circles(signed int xh, signed int xk, signed int xl, break; case WGHT_COUNTS : val = get_redundancy(refl); - val /= (float)num_equivs(h, k, l, sym); + val /= (double)n; break; case WGHT_RAWCOUNTS : val = get_redundancy(refl); @@ -190,6 +194,8 @@ static void draw_circles(signed int xh, signed int xk, signed int xl, } + free_symoplist(sp); + } } @@ -245,7 +251,8 @@ static void render_overlined_indices(cairo_t *dctx, static void render_za(UnitCell *cell, RefList *list, - double boost, const char *sym, int wght, int colscale, + double boost, const SymOpList *sym, int wght, + int colscale, signed int xh, signed int xk, signed int xl, signed int yh, signed int yk, signed int yl, const char *outfile, double scale_top) @@ -558,7 +565,8 @@ int main(int argc, char *argv[]) char *pdb = NULL; int r = 0; double boost = 1.0; - char *sym = NULL; + char *sym_str = NULL; + SymOpList *sym; char *weighting = NULL; int wght; int colscale; @@ -612,7 +620,7 @@ int main(int argc, char *argv[]) break; case 'y' : - sym = strdup(optarg); + sym_str = strdup(optarg); break; case 'w' : @@ -664,9 +672,11 @@ int main(int argc, char *argv[]) return 1; } - if ( sym == NULL ) { - sym = strdup("1"); + if ( sym_str == NULL ) { + sym_str = strdup("1"); } + sym = get_pointgroup(sym_str); + free(sym_str); if ( weighting == NULL ) { weighting = strdup("I"); @@ -755,7 +765,7 @@ int main(int argc, char *argv[]) } if ( check_list_symmetry(list, sym) ) { ERROR("The input reflection list does not appear to" - " have symmetry %s\n", sym); + " have symmetry %s\n", symmetry_name(sym)); return 1; } @@ -770,7 +780,7 @@ int main(int argc, char *argv[]) } free(pdb); - free(sym); + free_symoplist(sym); reflist_free(list); if ( outfile != NULL ) free(outfile); diff --git a/src/symmetry.c b/src/symmetry.c index 42c66193..f09b3e9c 100644 --- a/src/symmetry.c +++ b/src/symmetry.c @@ -78,6 +78,7 @@ struct _symoplist struct sym_op *ops; int n_ops; int max_ops; + char *name; }; @@ -97,6 +98,7 @@ static SymOpList *new_symoplist() new->max_ops = 16; new->n_ops = 0; new->ops = NULL; + new->name = NULL; alloc_ops(new); return new; } @@ -118,6 +120,7 @@ void free_symoplist(SymOpList *ops) free(ops->ops[i].l); } if ( ops->ops != NULL ) free(ops->ops); + if ( ops->name != NULL ) free(ops->name); free(ops); } @@ -253,6 +256,7 @@ static SymOpList *make_1bar() { SymOpList *new = new_symoplist(); add_symop(new, v(-1,0,0,0), v(0,-1,0,0), v(0,0,0,-1)); /* -I */ + new->name = strdup("-1"); return new; } @@ -260,6 +264,7 @@ static SymOpList *make_1bar() static SymOpList *make_1() { SymOpList *new = new_symoplist(); + new->name = strdup("1"); return new; } @@ -271,6 +276,7 @@ static SymOpList *make_2m() SymOpList *new = new_symoplist(); add_symop(new, v(-1,0,0,0), v(0,1,0,0), v(0,0,0,-1)); /* 2 */ add_symop(new, v(1,0,0,0), v(0,-1,0,0), v(0,0,0,1)); /* m */ + new->name = strdup("2/m"); return NULL; } @@ -279,6 +285,7 @@ static SymOpList *make_2() { SymOpList *new = new_symoplist(); add_symop(new, v(-1,0,0,0), v(0,1,0,0), v(0,0,0,-1)); /* 2 */ + new->name = strdup("2"); return NULL; } @@ -287,6 +294,7 @@ static SymOpList *make_m() { SymOpList *new = new_symoplist(); add_symop(new, v(1,0,0,0), v(0,-1,0,0), v(0,0,0,1)); /* m */ + new->name = strdup("m"); return NULL; } @@ -299,6 +307,7 @@ static SymOpList *make_mmm() add_symop(new, v(-1,0,0,0), v(0,-1,0,0), v(0,0,0,1)); /* 2 */ add_symop(new, v(-1,0,0,0), v(0,1,0,0), v(0,0,0,-1)); /* 2 */ add_symop(new, v(1,0,0,0), v(0,-1,0,0), v(0,0,0,1)); /* m */ + new->name = strdup("mmm"); return NULL; } @@ -308,6 +317,7 @@ static SymOpList *make_222() SymOpList *new = new_symoplist(); add_symop(new, v(-1,0,0,0), v(0,-1,0,0), v(0,0,0,1)); /* 2 */ add_symop(new, v(-1,0,0,0), v(0,1,0,0), v(0,0,0,-1)); /* 2 */ + new->name = strdup("222"); return NULL; } @@ -317,6 +327,7 @@ static SymOpList *make_mm2() SymOpList *new = new_symoplist(); add_symop(new, v(-1,0,0,0), v(0,-1,0,0), v(0,0,0,1)); /* 2 */ add_symop(new, v(1,0,0,0), v(0,-1,0,0), v(0,0,0,1)); /* m */ + new->name = strdup("mm2"); return NULL; } @@ -455,7 +466,7 @@ SymOpList *get_pointgroup(const char *sym) } -static void do_op(struct sym_op *op, +static void do_op(const struct sym_op *op, signed int h, signed int k, signed int l, signed int *he, signed int *ke, signed int *le) { @@ -485,7 +496,7 @@ static void do_op(struct sym_op *op, * given reflection is a special high-symmetry one), call special_position() * first to get a "specialised" SymOpList and use that instead. **/ -void get_equiv(SymOpList *ops, int idx, +void get_equiv(const SymOpList *ops, int idx, signed int h, signed int k, signed int l, signed int *he, signed int *ke, signed int *le) { @@ -531,7 +542,7 @@ void get_equiv(SymOpList *ops, int idx, * * Returns: the "specialised" %SymOpList. **/ -SymOpList *special_position(SymOpList *ops, +SymOpList *special_position(const SymOpList *ops, signed int h, signed int k, signed int l) { int i, n; @@ -554,7 +565,7 @@ SymOpList *special_position(SymOpList *ops, } -void get_asymm(SymOpList *ops, int idx, +void get_asymm(const SymOpList *ops, signed int h, signed int k, signed int l, signed int *hp, signed int *kp, signed int *lp) { @@ -595,7 +606,7 @@ void get_asymm(SymOpList *ops, int idx, * * To count the number of possibilities, use num_ops() on the result. */ -SymOpList *get_twins(SymOpList *source, SymOpList *target) +SymOpList *get_twins(const SymOpList *source, const SymOpList *target) { int n_src, n_tgt; int i; @@ -611,3 +622,9 @@ SymOpList *get_twins(SymOpList *source, SymOpList *target) return twins; } + + +const char *symmetry_name(const SymOpList *ops) +{ + return ops->name; +} diff --git a/src/symmetry.h b/src/symmetry.h index 23c00160..4dcaae06 100644 --- a/src/symmetry.h +++ b/src/symmetry.h @@ -28,26 +28,21 @@ extern void free_symoplist(SymOpList *ops); extern SymOpList *get_pointgroup(const char *sym); -extern SymOpList *special_position(SymOpList *ops, - signed int h, signed int k, signed int l); - -extern void get_asymm(signed int h, signed int k, signed int l, - signed int *hp, signed int *kp, signed int *lp, - const char *sym); +extern const char *symmetry_name(const SymOpList *ops); -extern int num_equivs(signed int h, signed int k, signed int l, - const char *sym); +extern SymOpList *special_position(const SymOpList *ops, + signed int h, signed int k, signed int l); -extern int num_general_equivs(const char *sym); +extern void get_asymm(const SymOpList *ops, + signed int h, signed int k, signed int l, + signed int *hp, signed int *kp, signed int *lp); -extern void get_equiv(signed int h, signed int k, signed int l, - signed int *he, signed int *ke, signed int *le, - const char *sym, int idx); +extern int num_equivs(const SymOpList *ops); -extern void get_general_equiv(signed int h, signed int k, signed int l, - signed int *he, signed int *ke, signed int *le, - const char *sym, int idx); +extern void get_equiv(const SymOpList *ops, int idx, + signed int h, signed int k, signed int l, + signed int *he, signed int *ke, signed int *le); -extern SymOpList *get_twins(SymOpList *source, SymOpList *target); +extern SymOpList *get_twins(const SymOpList *source, const SymOpList *target); #endif /* SYMMETRY_H */ |