aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/symmetry.c50
-rw-r--r--libcrystfel/src/symmetry.h1
2 files changed, 51 insertions, 0 deletions
diff --git a/libcrystfel/src/symmetry.c b/libcrystfel/src/symmetry.c
index 67298ec1..14b108b7 100644
--- a/libcrystfel/src/symmetry.c
+++ b/libcrystfel/src/symmetry.c
@@ -205,6 +205,56 @@ static void add_symop_v(SymOpList *ops,
}
+/**
+ * get_symop:
+ * @ops: A %SymOpList
+ * @m: A %SymOpMask
+ * @idx: Index of the operation to get
+ *
+ * Returns a pointer to an integer matrix specifying a symmetry operation
+ * contained in the symmetry operator list, and identified by the specified
+ * index.
+ **/
+IntegerMatrix* get_symop(const SymOpList *ops, const SymOpMask *m, int idx)
+{
+ const int n = num_ops(ops);
+
+ if ( m != NULL ) {
+
+ int i, c;
+
+ c = 0;
+ for ( i=0; i<n; i++ ) {
+
+ if ( (c == idx) && m->mask[i] ) {
+ return ops->ops[i];
+ }
+
+ if ( m->mask[i] ) {
+ c++;
+ }
+
+ }
+
+ ERROR("Index %i out of range for point group '%s'\n",
+ idx, symmetry_name(ops));
+
+ return NULL;
+
+ }
+
+ if ( idx >= n ) {
+
+ ERROR("Index %i out of range for point group '%s'\n", idx,
+ symmetry_name(ops));
+
+ return NULL;
+
+ }
+
+ return ops->ops[idx];
+}
+
static signed int *v(signed int h, signed int k, signed int i, signed int l)
{
signed int *vec = malloc(3*sizeof(signed int));
diff --git a/libcrystfel/src/symmetry.h b/libcrystfel/src/symmetry.h
index 145b5473..42cbd9b3 100644
--- a/libcrystfel/src/symmetry.h
+++ b/libcrystfel/src/symmetry.h
@@ -61,6 +61,7 @@ extern "C" {
extern void free_symoplist(SymOpList *ops);
extern SymOpList *get_pointgroup(const char *sym);
+extern IntegerMatrix* get_symop(const SymOpList *ops, const SymOpMask *m, int idx);
extern SymOpMask *new_symopmask(const SymOpList *list);
extern void free_symopmask(SymOpMask *m);