diff options
author | Thomas White <taw@physics.org> | 2011-07-26 18:02:53 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:34 +0100 |
commit | 645edae8173996f28686315b05253d4d4db94ccb (patch) | |
tree | 6cdb856235376d34c9ac786def64c5999ab0f21f /src | |
parent | 7bac028af325feebe706072441cfc0e672ffca45 (diff) |
Fix get_asymm() (again)
Diffstat (limited to 'src')
-rw-r--r-- | src/symmetry.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/symmetry.c b/src/symmetry.c index 70820db2..8f88b69d 100644 --- a/src/symmetry.c +++ b/src/symmetry.c @@ -999,6 +999,15 @@ void special_position(const SymOpList *ops, SymOpMask *m, } +static int any_negative(signed int h, signed int k, signed int l) +{ + if ( h < 0 ) return 1; + if ( k < 0 ) return 1; + if ( l < 0 ) return 1; + return 0; +} + + /** * get_asymm: * @ops: A %SymOpList, usually corresponding to a point group @@ -1027,26 +1036,46 @@ void get_asymm(const SymOpList *ops, int nequiv; int p; signed int best_h, best_k, best_l; + int have_negs; nequiv = num_equivs(ops, NULL); best_h = h; best_k = k; best_l = l; + have_negs = any_negative(best_h, best_k, best_l); for ( p=0; p<nequiv; p++ ) { + int will_have_negs; + get_equiv(ops, NULL, p, h, k, l, hp, kp, lp); + will_have_negs = any_negative(*hp, *kp, *lp); + + /* Don't lose "no negs" status */ + if ( !have_negs && will_have_negs ) continue; + + if ( have_negs && !will_have_negs ) { + best_h = *hp; best_k = *kp; best_l = *lp; + have_negs = 0; + continue; + } + if ( *hp > best_h ) { best_h = *hp; best_k = *kp; best_l = *lp; + have_negs = any_negative(best_h, best_k, best_l); continue; } + if ( *hp < best_h ) continue; if ( *kp > best_k ) { best_h = *hp; best_k = *kp; best_l = *lp; + have_negs = any_negative(best_h, best_k, best_l); continue; } + if ( *kp < best_k ) continue; if ( *lp > best_l ) { best_h = *hp; best_k = *kp; best_l = *lp; + have_negs = any_negative(best_h, best_k, best_l); continue; } |