aboutsummaryrefslogtreecommitdiff
path: root/src/reflist.h
blob: 87dbbeaab211d63585e1ea7ac440bc06f03aedbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * reflist.h
 *
 * Reflection-handling code
 *
 * (c) 2006-2008 Thomas White <taw27@cam.ac.uk>
 *
 *  synth2d - two-dimensional Fourier synthesis
 *
 */

#ifndef REFLIST_H
#define REFLIST_H

#include <fftw3.h>

#define MAX_REFLECTIONS 20000

typedef struct {

	signed int h;
	signed int k;
	signed int l;

	/* Some, all or none of the following may be filled in, depending on the context */
	
	double amplitude;		/* Structure amplitude F (not I=F^2).  Must be positive */
	double am_error;		/* Standard error in amplitude */
	double weight;			/* Statistical weight for this data point */

	double phase_known;		/* Phase known a priori */
	unsigned int phase_known_set;
	double phase_calc;		/* Phase calculated */
	unsigned int phase_calc_set;
	
	double re;
	double im;			/* LSQ routine does crazy things with these */

	double alpha;			/* For convergence procedure and tangent refinement */
	double delta_theta;		/* Some kind of phase relationship, */
	signed int multiplier;		/*	for symmetry stuff          */
	
	double amplitude_dyn;
	double phase_dyn;		/* As calculated by the multislice routine */
	
	unsigned int parent_index;	/* Position of the same reflection in a related list */
	
} Reflection;

typedef struct _reflectionlist {
	Reflection refs[MAX_REFLECTIONS];
	unsigned int n_reflections;
	struct _reflectionlist *parent;
	double scale;
} ReflectionList;

typedef struct {
	ReflectionList *a;
	ReflectionList *b;
} ReflectionListPair;

extern ReflectionList *reflist_new(void);
extern ReflectionList *reflist_new_parent(ReflectionList *parent);
extern ReflectionList *reflist_copy(ReflectionList *list);
extern void reflist_free(ReflectionList *list);

extern int reflist_addref(ReflectionList *list, signed int h, signed int k, signed int l);
extern int reflist_addref_parent(ReflectionList *list, signed int h, signed int k, signed int l, unsigned int parent_index);
extern int reflist_addref_am(ReflectionList *list, signed int h, signed int k, signed int l, double am);
extern int reflist_addref_am_ph(ReflectionList *list, signed int h, signed int k, signed int l, double am, double ph);
extern int reflist_addref_alpha_parent(ReflectionList *list, signed int h, signed int k, signed int l, double alpha, unsigned int parent_index);
extern int reflist_addref_phase(ReflectionList *list, signed int h, signed int k, signed int l, double phase);
extern int reflist_addref_deltatheta(ReflectionList *list, signed int h, signed int k, signed int l, double delta_theta, signed int multiplier);
extern void reflist_delref(ReflectionList *list, signed int h, signed int k, signed int l);
extern int reflist_inlist(const ReflectionList *list, signed int h, signed int k, signed int l);
extern int reflist_inlist_2d(const ReflectionList *list, signed int h, signed int k);
extern void reflist_set_components(ReflectionList *list, signed int h, signed int k, signed int l, double re, double im);
extern int reflist_addref_am_parent(ReflectionList *list, signed int h, signed int k, signed int l, double am, unsigned int parent_index);

extern ReflectionList *reflist_new_from_array(fftw_complex *array, int width, int height);
extern void reflist_fill_array(fftw_complex *array, const ReflectionList *reflections, int width, int height);

#endif	/* REFLIST_H */