aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-07-27 12:16:39 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:34 +0100
commit0ca816fdeae85779ef4a8100cdc25ec16fc9d735 (patch)
treec9f5d1d21a4030b4c53f755791f660f163b5af3d /src
parent645edae8173996f28686315b05253d4d4db94ccb (diff)
Don't use an array in check_list_symmetry()
Diffstat (limited to 'src')
-rw-r--r--src/reflist-utils.c16
-rw-r--r--src/reflist.c8
2 files changed, 14 insertions, 10 deletions
diff --git a/src/reflist-utils.c b/src/reflist-utils.c
index 3991600d..af43b1ff 100644
--- a/src/reflist-utils.c
+++ b/src/reflist-utils.c
@@ -106,12 +106,10 @@ unsigned char *flags_from_list(RefList *list)
int check_list_symmetry(RefList *list, const SymOpList *sym)
{
- unsigned char *flags;
Reflection *refl;
RefListIterator *iter;
SymOpMask *mask;
- flags = flags_from_list(list);
mask = new_symopmask(sym);
if ( mask == NULL ) {
ERROR("Couldn't create mask for list symmetry check.\n");
@@ -135,26 +133,24 @@ int check_list_symmetry(RefList *list, const SymOpList *sym)
for ( j=0; j<n; j++ ) {
signed int he, ke, le;
- get_equiv(sym, mask, j, h, k, l, &he, &ke, &le);
+ Reflection *f;
- if ( abs(he) > INDMAX ) continue;
- if ( abs(le) > INDMAX ) continue;
- if ( abs(ke) > INDMAX ) continue;
+ get_equiv(sym, mask, j, h, k, l, &he, &ke, &le);
- found += lookup_flag(flags, he, ke, le);
+ f = find_refl(list, he, ke, le);
+ if ( f != NULL ) found++;
}
+ assert(found != 0); /* That'd just be silly */
if ( found > 1 ) {
- free(flags);
free_symopmask(mask);
- STATUS("Found %i %i %i twice\n", h, k, l);
+ STATUS("Found %i %i %i: %i times\n", h, k, l, found);
return 1; /* Symmetry is wrong! */
}
}
- free(flags);
free_symopmask(mask);
return 0;
diff --git a/src/reflist.c b/src/reflist.c
index aefbf4e2..45cd132e 100644
--- a/src/reflist.c
+++ b/src/reflist.c
@@ -212,6 +212,14 @@ Reflection *find_refl(const RefList *list,
if ( list->head == NULL ) return NULL;
+ /* Indices greater than or equal to 256 are filtered out when
+ * reflections are added, so don't even bother looking.
+ * (also, looking for such reflections causes trouble because the search
+ * serial number would be invalid) */
+ if ( abs(h) >= 256 ) return NULL;
+ if ( abs(k) >= 256 ) return NULL;
+ if ( abs(l) >= 256 ) return NULL;
+
refl = list->head;
while ( refl != NULL ) {