From 05d31510f4ea311cb5d8db7edff5fedc416a5bb5 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 25 Jul 2011 17:33:02 +0200 Subject: Fix num_equivs() and get_equiv() --- src/symmetry.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/symmetry.c b/src/symmetry.c index b727a921..87088c80 100644 --- a/src/symmetry.c +++ b/src/symmetry.c @@ -239,7 +239,18 @@ static void add_copied_op(SymOpList *ops, struct sym_op *copyme) **/ int num_equivs(const SymOpList *ops, const SymOpMask *m) { - return num_ops(ops); + int n = num_ops(ops); + int i; + int c; + + if ( m == NULL ) return n; + + c = 0; + for ( i=0; imask[i] ) c++; + } + + return c; } @@ -886,20 +897,49 @@ void get_equiv(const SymOpList *ops, const SymOpMask *m, int idx, signed int h, signed int k, signed int l, signed int *he, signed int *ke, signed int *le) { - int i, n; + const int n = num_ops(ops); + + if ( m != NULL ) { + + int i, c; + + c = 0; + for ( i=0; imask[i] ) { + do_op(&ops->ops[i], h, k, l, he, ke, le); + return; + } + + if ( m->mask[i] ) { + c++; + } - n = num_ops(ops); - for ( i=idx; imask[i] ) { - do_op(&ops->ops[i], h, k, l, he, ke, le); - return; } + + ERROR("Index %i out of range for point group '%s' with" + " reflection %i %i %i\n", + idx, symmetry_name(ops), h, k, l); + + *he = 0; *ke = 0; *le = 0; + + return; + } - ERROR("Index %i out of range for point group '%s'\n", idx, - symmetry_name(ops)); - *he = 0; *ke = 0; *le = 0; + + if ( idx >= n ) { + + ERROR("Index %i out of range for point group '%s'\n", idx, + symmetry_name(ops)); + + *he = 0; *ke = 0; *le = 0; + return; + + } + + do_op(&ops->ops[idx], h, k, l, he, ke, le); } -- cgit v1.2.3