aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/reference/CrystFEL-docs.sgml1
-rw-r--r--doc/reference/CrystFEL-sections.txt17
-rw-r--r--src/symmetry.c203
-rw-r--r--src/symmetry.h16
-rw-r--r--src/utils.c171
-rw-r--r--src/utils.h33
6 files changed, 199 insertions, 242 deletions
diff --git a/doc/reference/CrystFEL-docs.sgml b/doc/reference/CrystFEL-docs.sgml
index 74fa1580..c27ec740 100644
--- a/doc/reference/CrystFEL-docs.sgml
+++ b/doc/reference/CrystFEL-docs.sgml
@@ -29,7 +29,6 @@
<abstract>There are three main reflection list thingies.</abstract>
<xi:include href="xml/reflist.xml"/>
<xi:include href="xml/reflist-utils.xml"/>
- <xi:include href="xml/reflitemlist.xml"/>
</chapter>
<chapter>
diff --git a/doc/reference/CrystFEL-sections.txt b/doc/reference/CrystFEL-sections.txt
index af517540..ac5392df 100644
--- a/doc/reference/CrystFEL-sections.txt
+++ b/doc/reference/CrystFEL-sections.txt
@@ -55,23 +55,6 @@ asymmetric_indices
</SECTION>
<SECTION>
-<FILE>reflitemlist</FILE>
-ReflItemList
-<SUBSECTION>
-new_items
-add_item
-add_item_with_op
-clear_items
-delete_items
-find_item
-num_items
-union_items
-union_op_items
-intersection_items
-get_item
-</SECTION>
-
-<SECTION>
<FILE>unitcell</FILE>
UnitCell
<SUBSECTION>
diff --git a/src/symmetry.c b/src/symmetry.c
index a066ca47..3a9d505e 100644
--- a/src/symmetry.c
+++ b/src/symmetry.c
@@ -16,10 +16,13 @@
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <math.h>
+#include "symmetry.h"
#include "utils.h"
+
#ifdef DEBUG
#define SYM_DEBUG STATUS
#else /* DEBUG */
@@ -39,6 +42,181 @@
*/
+struct sym_op {
+ signed int h;
+ signed int k;
+ signed int l;
+ int op;
+};
+
+
+/**
+ * SECTION:symoplist
+ * @short_description: A list of point symmetry operations
+ * @title: SymOpList
+ * @section_id:
+ * @see_also:
+ * @include: "symmetry.h"
+ * @Image:
+ *
+ * Wibble
+ */
+
+struct _symoplist {
+ struct sym_op *items;
+ int n_ops;
+ int max_ops;
+};
+
+
+
+static void alloc_items(SymOpList *items)
+{
+ items->items = realloc(items->items,
+ items->max_ops*sizeof(struct sym_op));
+}
+
+
+/**
+ * new_items:
+ *
+ * Creates a new %SymOpList.
+ *
+ * Returns: The new list, or NULL.
+ **/
+SymOpList *new_items()
+{
+ SymOpList *new;
+ new = malloc(sizeof(SymOpList));
+ if ( new == NULL ) return NULL;
+ new->max_ops = 1024;
+ new->n_ops = 0;
+ new->items = NULL;
+ alloc_items(new);
+ return new;
+}
+
+
+void delete_items(SymOpList *items)
+{
+ if ( items == NULL ) return;
+ if ( items->items != NULL ) free(items->items);
+ free(items);
+}
+
+
+void add_item_with_op(SymOpList *items, signed int h, signed int k,
+ signed int l, int op)
+{
+ if ( items->n_ops == items->max_ops ) {
+ items->max_ops += 1024;
+ alloc_items(items);
+ }
+
+ items->items[items->n_ops].h = h;
+ items->items[items->n_ops].k = k;
+ items->items[items->n_ops].l = l;
+ items->items[items->n_ops].op = op;
+ items->n_ops++;
+}
+
+
+void add_item(SymOpList *items, signed int h, signed int k, signed int l)
+{
+ add_item_with_op(items, h, k, l, 0);
+}
+
+
+int find_item(SymOpList *items,
+ signed int h, signed int k, signed int l)
+{
+ int i;
+
+ for ( i=0; i<items->n_ops; i++ ) {
+ if ( items->items[i].h != h ) continue;
+ if ( items->items[i].k != k ) continue;
+ if ( items->items[i].l != l ) continue;
+ return 1;
+ }
+ return 0;
+}
+
+
+static int find_op(SymOpList *items, int op)
+{
+ int i;
+
+ for ( i=0; i<items->n_ops; i++ ) {
+ if ( items->items[i].op == op ) return 1;
+ }
+ return 0;
+}
+
+
+struct sym_op *get_item(SymOpList *items, int i)
+{
+ if ( i >= items->n_ops ) return NULL;
+ return &items->items[i];
+}
+
+
+int num_items(const SymOpList *items)
+{
+ return items->n_ops;
+}
+
+
+void union_op_items(SymOpList *items, SymOpList *newi)
+{
+ int n, i;
+
+ n = num_items(newi);
+ for ( i=0; i<n; i++ ) {
+
+ struct sym_op *r = get_item(newi, i);
+ if ( find_op(items, r->op) ) continue;
+
+ add_item_with_op(items, r->h, r->k, r->l, r->op);
+
+ }
+}
+
+
+void union_ops(SymOpList *items, SymOpList *newi)
+{
+ int n, i;
+
+ n = num_items(newi);
+ for ( i=0; i<n; i++ ) {
+
+ struct sym_op *r = get_item(newi, i);
+ if ( find_item(items, r->h, r->k, r->l) ) continue;
+
+ add_item_with_op(items, r->h, r->k, r->l, r->op);
+
+ }
+}
+
+
+SymOpList *intersection_ops(SymOpList *i1, SymOpList *i2)
+{
+ int n, i;
+ SymOpList *res = new_items();
+
+ n = num_items(i1);
+ for ( i=0; i<n; i++ ) {
+
+ struct sym_op *r = get_item(i1, i);
+ if ( find_item(i2, r->h, r->k, r->l) ) {
+ add_item_with_op(res, r->h, r->k, r->l, r->op);
+ }
+
+ }
+
+ return res;
+}
+
+
/* Check if a reflection is in the asymmetric unit cell */
static int check_cond(signed int h, signed int k, signed int l, const char *sym)
{
@@ -294,7 +472,7 @@ static int special_position(signed int hs, signed int ks, signed int ls,
{
int n_general;
int i;
- ReflItemList *equivs;
+ SymOpList *equivs;
int n_equivs = 0;
if ( idx == 0 ) {
@@ -374,13 +552,13 @@ void get_asymm(signed int h, signed int k, signed int l,
*
* To count the number of possibilities, use num_items() on the result.
*/
-static ReflItemList *coset_decomp(signed int hs, signed int ks, signed int ls,
- const char *holo, const char *mero)
+static SymOpList *coset_decomp(signed int hs, signed int ks, signed int ls,
+ const char *holo, const char *mero)
{
int n_mero, n_holo;
int i;
signed int h, k, l;
- ReflItemList *twins = new_items();
+ SymOpList *twins = new_items();
/* Start by putting the given reflection into the asymmetric cell
* for its (probably merohedral) point group. */
@@ -422,11 +600,12 @@ static ReflItemList *coset_decomp(signed int hs, signed int ks, signed int ls,
* To use the result, call get_general_equiv() on each reflection using
* the holohedral point group (use get_holohedral() for this), and for "idx"
* give each "op" field from the list returned by this function. */
-ReflItemList *get_twins(ReflItemList *items, const char *holo, const char *mero)
+SymOpList *get_twins(const char *holo, const char *mero)
{
int i;
- ReflItemList *ops = new_items();
+ SymOpList *ops = new_items();
int expected, actual;
+ SymOpList *items;
/* Run the coset decomposition for every reflection in the "pattern",
* and see which gives the highest number of possibilities. This
@@ -435,8 +614,8 @@ ReflItemList *get_twins(ReflItemList *items, const char *holo, const char *mero)
for ( i=0; i<num_items(items); i++ ) {
signed int h, k, l;
- struct refl_item *item;
- ReflItemList *new_ops;
+ struct sym_op *item;
+ SymOpList *new_ops;
item = get_item(items, i);
@@ -466,7 +645,7 @@ ReflItemList *get_twins(ReflItemList *items, const char *holo, const char *mero)
}
-int find_unique_equiv(ReflItemList *items, signed int h, signed int k,
+int find_unique_equiv(SymOpList *items, signed int h, signed int k,
signed int l, const char *mero, signed int *hu,
signed int *ku, signed int *lu)
{
@@ -612,21 +791,21 @@ int has_bisecting_mirror_or_diad(const char *sym)
}
-int check_symmetry(ReflItemList *items, const char *sym)
+int check_symmetry(SymOpList *items, const char *sym)
{
int i;
unsigned char *flags;
flags = new_list_flag();
for ( i=0; i<num_items(items); i++ ) {
- struct refl_item *it = get_item(items, i);
+ struct sym_op *it = get_item(items, i);
set_flag(flags, it->h, it->k, it->l, 1);
}
for ( i=0; i<num_items(items); i++ ) {
int j;
- struct refl_item *it = get_item(items, i);
+ struct sym_op *it = get_item(items, i);
int found = 0;
for ( j=0; j<num_equivs(it->h, it->k, it->l, sym); j++ ) {
diff --git a/src/symmetry.h b/src/symmetry.h
index 485913a0..fbb80d26 100644
--- a/src/symmetry.h
+++ b/src/symmetry.h
@@ -17,6 +17,13 @@
#include <config.h>
#endif
+/**
+ * SymOpList
+ *
+ * Opaque type.
+ **/
+typedef struct _symoplist SymOpList;
+
extern void get_asymm(signed int h, signed int k, signed int l,
signed int *hp, signed int *kp, signed int *lp,
@@ -35,14 +42,7 @@ 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 ReflItemList *get_twins(ReflItemList *items,
- const char *holo, const char *mero);
-
-extern int find_unique_equiv(ReflItemList *items, signed int h, signed int k,
- signed int l, const char *mero, signed int *hu,
- signed int *ku, signed int *lu);
-
-extern int check_symmetry(ReflItemList *items, const char *sym);
+extern SymOpList *get_twins(const char *holo, const char *mero);
/* Properties of point groups */
extern int is_polyhedral(const char *sym);
diff --git a/src/utils.c b/src/utils.c
index d10f0f42..4b4bfb51 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -392,177 +392,6 @@ int assplode(const char *a, const char *delims, char ***pbits,
return n;
}
-/**
- * SECTION:reflitemlist
- * @short_description: The index list and indexed arrays
- * @title: ReflItemList
- * @section_id:
- * @see_also:
- * @include: "utils.h"
- * @Image:
- *
- * Wibble
- */
-
-struct _reflitemlist {
- struct refl_item *items;
- int n_items;
- int max_items;
-};
-
-
-void clear_items(ReflItemList *items)
-{
- items->n_items = 0;
-}
-
-
-static void alloc_items(ReflItemList *items)
-{
- items->items = realloc(items->items,
- items->max_items*sizeof(struct refl_item));
-}
-
-
-/**
- * new_items:
- *
- * Creates a new %ReflItemList.
- *
- * Returns: The new list, or NULL.
- **/
-ReflItemList *new_items()
-{
- ReflItemList *new;
- new = malloc(sizeof(ReflItemList));
- if ( new == NULL ) return NULL;
- new->max_items = 1024;
- new->n_items = 0;
- new->items = NULL;
- alloc_items(new);
- return new;
-}
-
-
-void delete_items(ReflItemList *items)
-{
- if ( items == NULL ) return;
- if ( items->items != NULL ) free(items->items);
- free(items);
-}
-
-
-void add_item_with_op(ReflItemList *items, signed int h, signed int k,
- signed int l, int op)
-{
- if ( items->n_items == items->max_items ) {
- items->max_items += 1024;
- alloc_items(items);
- }
-
- items->items[items->n_items].h = h;
- items->items[items->n_items].k = k;
- items->items[items->n_items].l = l;
- items->items[items->n_items].op = op;
- items->n_items++;
-}
-
-
-void add_item(ReflItemList *items, signed int h, signed int k, signed int l)
-{
- add_item_with_op(items, h, k, l, 0);
-}
-
-
-int find_item(ReflItemList *items,
- signed int h, signed int k, signed int l)
-{
- int i;
-
- for ( i=0; i<items->n_items; i++ ) {
- if ( items->items[i].h != h ) continue;
- if ( items->items[i].k != k ) continue;
- if ( items->items[i].l != l ) continue;
- return 1;
- }
- return 0;
-}
-
-
-static int find_op(ReflItemList *items, int op)
-{
- int i;
-
- for ( i=0; i<items->n_items; i++ ) {
- if ( items->items[i].op == op ) return 1;
- }
- return 0;
-}
-
-
-struct refl_item *get_item(ReflItemList *items, int i)
-{
- if ( i >= items->n_items ) return NULL;
- return &items->items[i];
-}
-
-
-int num_items(const ReflItemList *items)
-{
- return items->n_items;
-}
-
-
-void union_op_items(ReflItemList *items, ReflItemList *newi)
-{
- int n, i;
-
- n = num_items(newi);
- for ( i=0; i<n; i++ ) {
-
- struct refl_item *r = get_item(newi, i);
- if ( find_op(items, r->op) ) continue;
-
- add_item_with_op(items, r->h, r->k, r->l, r->op);
-
- }
-}
-
-
-void union_items(ReflItemList *items, ReflItemList *newi)
-{
- int n, i;
-
- n = num_items(newi);
- for ( i=0; i<n; i++ ) {
-
- struct refl_item *r = get_item(newi, i);
- if ( find_item(items, r->h, r->k, r->l) ) continue;
-
- add_item_with_op(items, r->h, r->k, r->l, r->op);
-
- }
-}
-
-
-ReflItemList *intersection_items(ReflItemList *i1, ReflItemList *i2)
-{
- int n, i;
- ReflItemList *res = new_items();
-
- n = num_items(i1);
- for ( i=0; i<n; i++ ) {
-
- struct refl_item *r = get_item(i1, i);
- if ( find_item(i2, r->h, r->k, r->l) ) {
- add_item_with_op(res, r->h, r->k, r->l, r->op);
- }
-
- }
-
- return res;
-}
-
char *check_prefix(char *prefix)
{
diff --git a/src/utils.h b/src/utils.h
index 66299867..5e05a7f3 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -200,39 +200,6 @@ static inline int within_tolerance(double a, double b, double percent)
#include "list_tmp.h"
-/* ----------- Reflection lists indexed by sequence (not indices) ----------- */
-
-/**
- * ReflItemList
- *
- * Opaque type.
- **/
-typedef struct _reflitemlist ReflItemList;
-
-struct refl_item {
- signed int h;
- signed int k;
- signed int l;
- int op;
-};
-
-extern void clear_items(ReflItemList *items);
-extern ReflItemList *new_items(void);
-extern void delete_items(ReflItemList *items);
-extern void add_item(ReflItemList *items,
- signed int h, signed int k, signed int l);
-extern void add_item_with_op(ReflItemList *items,
- signed int h, signed int k, signed int l, int op);
-extern int find_item(ReflItemList *items,
- signed int h, signed int k, signed int l);
-extern struct refl_item *get_item(ReflItemList *items, int i);
-extern int num_items(const ReflItemList *items);
-extern unsigned int *items_to_counts(ReflItemList *items);
-extern void union_op_items(ReflItemList *items, ReflItemList *newi);
-extern void union_items(ReflItemList *items, ReflItemList *newi);
-extern ReflItemList *intersection_items(ReflItemList *i1, ReflItemList *i2);
-
-
/* ------------------------------ Message macros ---------------------------- */
extern pthread_mutex_t stderr_lock;