Commit 599c2774 authored by Thomas White's avatar Thomas White
Browse files

Compiles (with warnings)

parent 33077f93
......@@ -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;
}
......
......@@ -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;
......
......@@ -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 */
......@@ -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);
}
......
......@@ -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");
......
......@@ -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 */
......@@ -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;
}
......@@ -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);