From 012073a3be1bb523588b83d8be0589a5d00676aa Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 18 Jul 2011 18:43:09 +0200 Subject: Don't recalcaulate num_equivs all the time --- src/symmetry.c | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'src/symmetry.c') diff --git a/src/symmetry.c b/src/symmetry.c index 95fdc408..19daf0ec 100644 --- a/src/symmetry.c +++ b/src/symmetry.c @@ -80,6 +80,7 @@ struct _symoplist int max_ops; char *name; int *divisors; + int num_equivs; }; @@ -101,6 +102,7 @@ static SymOpList *new_symoplist() new->n_ops = 0; new->ops = NULL; new->name = NULL; + new->num_equivs = 1; alloc_ops(new); return new; } @@ -180,6 +182,29 @@ static int order_of_op(signed int *hin, signed int *kin, signed int *lin) } +/* This returns the number of operations in "ops". To get the number of + * symmetric equivalents this generates, use num_equivs() instead. */ +static int num_ops(const SymOpList *ops) +{ + return ops->n_ops; +} + + +static void update_num_equivs(SymOpList *ops) +{ + int i, n, tot; + + n = num_ops(ops); + tot = 1; + + for ( i=0; iops[i].order; + } + + ops->num_equivs = tot; +} + + /* Add a operation to a SymOpList */ static void add_symop(SymOpList *ops, signed int *h, signed int *k, signed int *l) @@ -203,6 +228,8 @@ static void add_symop(SymOpList *ops, for ( i=1; in_ops; i++ ) { ops->divisors[i] = ops->divisors[i-1]*ops->ops[i].order; } + + update_num_equivs(ops); } @@ -219,14 +246,6 @@ static void add_copied_symop(SymOpList *ops, struct sym_op *copyme) } -/* This returns the number of operations in "ops". To get the number of - * symmetric equivalents this generates, use num_equivs() instead. */ -static int num_ops(const SymOpList *ops) -{ - return ops->n_ops; -} - - /** * num_equivs: * @@ -235,16 +254,7 @@ static int num_ops(const SymOpList *ops) **/ int num_equivs(const SymOpList *ops) { - int i, n, tot; - - n = num_ops(ops); - tot = 1; - - for ( i=0; iops[i].order; - } - - return tot; + return ops->num_equivs; } -- cgit v1.2.3