diff options
author | Kenneth Beyerlein <kenneth.beyerlein@desy.de> | 2014-06-25 14:57:15 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2014-06-26 10:17:52 +0200 |
commit | 2a795e8605e20f0fa3e20fed094f0c906b147628 (patch) | |
tree | 76a21ba6d61cc1b93cb3e9d6415135d5567d1235 /libcrystfel | |
parent | cf34597c5f8583f68eaad22d85c849e1050c922b (diff) |
Add get_symop
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/symmetry.c | 50 | ||||
-rw-r--r-- | libcrystfel/src/symmetry.h | 1 |
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); |