aboutsummaryrefslogtreecommitdiff
path: root/src/symmetry.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-07-18 18:43:09 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:33 +0100
commit012073a3be1bb523588b83d8be0589a5d00676aa (patch)
tree3ceb925d33c3f6b0111f34d3ad1b46752c601ecd /src/symmetry.c
parent16e0de817a51d58e01df75ab90081d6201b3bb43 (diff)
Don't recalcaulate num_equivs all the time
Diffstat (limited to 'src/symmetry.c')
-rw-r--r--src/symmetry.c46
1 files changed, 28 insertions, 18 deletions
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; i<n; i++ ) {
+ tot *= ops->ops[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; i<ops->n_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; i<n; i++ ) {
- tot *= ops->ops[i].order;
- }
-
- return tot;
+ return ops->num_equivs;
}