aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/symmetry.c16
-rw-r--r--src/utils.c27
-rw-r--r--src/utils.h2
3 files changed, 34 insertions, 11 deletions
diff --git a/src/symmetry.c b/src/symmetry.c
index bca06b48..055d7d60 100644
--- a/src/symmetry.c
+++ b/src/symmetry.c
@@ -311,8 +311,7 @@ static ReflItemList *coset_decomp(signed int hs, signed int ks, signed int ls,
ReflItemList *get_twins(ReflItemList *items, const char *sym)
{
int i;
- int n_twins = 1;
- ReflItemList *max_ops = NULL;
+ ReflItemList *ops = new_items();;
/* Run the coset decomposition for every reflection in the "pattern",
* and see which gives the highest number of possibilities. This
@@ -322,7 +321,7 @@ ReflItemList *get_twins(ReflItemList *items, const char *sym)
signed int h, k, l;
struct refl_item *item;
- ReflItemList *ops;
+ ReflItemList *new_ops;
item = get_item(items, i);
@@ -330,14 +329,11 @@ ReflItemList *get_twins(ReflItemList *items, const char *sym)
k = item->k;
l = item->l;
- ops = coset_decomp(h, k, l, sym);
- if ( num_items(ops) > n_twins ) {
- n_twins = num_items(ops);
- delete_items(max_ops);
- max_ops = ops;
- }
+ new_ops = coset_decomp(h, k, l, sym);
+ union_op_items(ops, new_ops);
+ delete_items(new_ops);
}
- return max_ops;
+ return ops;
}
diff --git a/src/utils.c b/src/utils.c
index 1e54f923..21ba882f 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -363,6 +363,17 @@ int find_item(ReflItemList *items,
}
+static int find_op(ReflItemList *items, int op)
+{
+ int i;
+
+ for ( i=0; i<items->n_items; i++ ) {
+ if ( items->items[i].op == op ) return 1;
+ }
+ return 0;
+}
+
+
struct refl_item *get_item(ReflItemList *items, int i)
{
if ( i >= items->n_items ) return NULL;
@@ -391,3 +402,19 @@ unsigned int *items_to_counts(ReflItemList *items)
return c;
}
+
+
+void union_op_items(ReflItemList *items, ReflItemList *newi)
+{
+ int n, i;
+
+ n = num_items(newi);
+ for ( i=0; i<n; i++ ) {
+
+ struct refl_item *r = get_item(newi, i);
+ if ( find_op(items, r->op) ) continue;
+
+ add_item_with_op(items, r->h, r->k, r->l, r->op);
+
+ }
+}
diff --git a/src/utils.h b/src/utils.h
index 46ce51a6..a7433d28 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -199,7 +199,7 @@ extern int find_item(ReflItemList *items,
extern struct refl_item *get_item(ReflItemList *items, int i);
extern int num_items(const ReflItemList *items);
extern unsigned int *items_to_counts(ReflItemList *items);
-
+extern void union_op_items(ReflItemList *items, ReflItemList *newi);
/* ------------------------------ Message macros ---------------------------- */