aboutsummaryrefslogtreecommitdiff
path: root/src/symmetry.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-06-29 17:27:43 +0200
committerThomas White <taw@physics.org>2012-02-22 15:26:51 +0100
commit5bc4a6971f6ed08bc63f685cf39994d836af19d3 (patch)
treee89421bda0042292633adf1d06589ce965c01a9b /src/symmetry.c
parente27c9f1e9cc53c335910ee0d195910e9d4aa6ad6 (diff)
process_hkl: Merge with symmetry
Diffstat (limited to 'src/symmetry.c')
-rw-r--r--src/symmetry.c75
1 files changed, 74 insertions, 1 deletions
diff --git a/src/symmetry.c b/src/symmetry.c
index 7a6a5ed6..913e887f 100644
--- a/src/symmetry.c
+++ b/src/symmetry.c
@@ -18,6 +18,79 @@
#include <stdio.h>
#include <math.h>
-void apply_symmetry(double ref, unsigned int *counts, const char *sym)
+#include "utils.h"
+
+
+/* Conditions for a reflection to be in the asymmetric unit cell */
+#define COND_1(h, k, l) (1)
+#define COND_6MMM(h, k, i, l) ( (h>=0) && (k>=0) && (l>=0) && ((h>k)||((h==0)&&(k==0))) )
+
+
+/* Macros for checking the above conditions and returning if satisfied */
+#define CHECK_COND_FOURIDX(h, k, i, l, cond) \
+ if ( COND_##cond((h), (k), (i), (l)) ) { \
+ *hp = (h); *kp = (k); *lp = (l); \
+ return; \
+ }
+
+#define CHECK_COND_THREEIDX(h, k, l, cond) \
+ if ( COND_##cond((h), (k), (l)) ) { \
+ *hp = (h); *kp = (k); *lp = (l); \
+ return; \
+ }
+
+
+/* Abort macro if no match found */
+#define SYM_ABORT \
+ ERROR("No match in %s for %i %i %i\n", sym, h, k, l); \
+ abort();
+
+
+void get_asymm(signed int h, signed int k, signed int l,
+ signed int *hp, signed int *kp, signed int *lp,
+ const char *sym)
{
+ if ( strcmp(sym, "1") == 0 ) {
+ CHECK_COND_THREEIDX(h, k, l, 1);
+ SYM_ABORT;
+ }
+
+ if ( strcmp(sym, "6/mmm") == 0 ) {
+
+ const signed int i = h+k;
+
+ CHECK_COND_FOURIDX(h, k, i, l, 6MMM);
+ CHECK_COND_FOURIDX(h, i, k, l, 6MMM);
+ CHECK_COND_FOURIDX(k, h, i, l, 6MMM);
+ CHECK_COND_FOURIDX(k, i, h, l, 6MMM);
+ CHECK_COND_FOURIDX(i, h, k, l, 6MMM);
+ CHECK_COND_FOURIDX(i, k, h, l, 6MMM);
+
+ CHECK_COND_FOURIDX(h, k, i, -l, 6MMM);
+ CHECK_COND_FOURIDX(h, i, k, -l, 6MMM);
+ CHECK_COND_FOURIDX(k, h, i, -l, 6MMM);
+ CHECK_COND_FOURIDX(k, i, h, -l, 6MMM);
+ CHECK_COND_FOURIDX(i, h, k, -l, 6MMM);
+ CHECK_COND_FOURIDX(i, k, h, -l, 6MMM);
+
+ CHECK_COND_FOURIDX(-h, -k, -i, l, 6MMM);
+ CHECK_COND_FOURIDX(-h, -i, -k, l, 6MMM);
+ CHECK_COND_FOURIDX(-k, -h, -i, l, 6MMM);
+ CHECK_COND_FOURIDX(-k, -i, -h, l, 6MMM);
+ CHECK_COND_FOURIDX(-i, -h, -k, l, 6MMM);
+ CHECK_COND_FOURIDX(-i, -k, -h, l, 6MMM);
+
+ CHECK_COND_FOURIDX(-h, -k, -i, -l, 6MMM);
+ CHECK_COND_FOURIDX(-h, -i, -k, -l, 6MMM);
+ CHECK_COND_FOURIDX(-k, -h, -i, -l, 6MMM);
+ CHECK_COND_FOURIDX(-k, -i, -h, -l, 6MMM);
+ CHECK_COND_FOURIDX(-i, -h, -k, -l, 6MMM);
+ CHECK_COND_FOURIDX(-i, -k, -h, -l, 6MMM);
+
+ SYM_ABORT; /* Should never reach here */
+
+ }
+
+ ERROR("Unknown point group '%s'\n", sym);
+ abort();
}