aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-10-22 10:52:50 +0200
committerThomas White <taw@physics.org>2019-10-22 10:52:50 +0200
commit883e26767fb61d6af5381cbecf8fb2ff33210be7 (patch)
treefa6a76b877673d58d76d7dd462d56e9b5c74a56a /libcrystfel
parent10371502d7993866e5820a206e64a2664337c8c5 (diff)
reduce_g6: Fix sign criterion for step 3
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/cell-utils.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/libcrystfel/src/cell-utils.c b/libcrystfel/src/cell-utils.c
index f86a2108..f96554dd 100644
--- a/libcrystfel/src/cell-utils.c
+++ b/libcrystfel/src/cell-utils.c
@@ -1787,9 +1787,36 @@ static int UNUSED is_niggli(struct g6 g, double eps)
}
-static signed int eps_sign(double v, double eps)
+static int DEF_positive(struct g6 g, double eps)
{
- return GT(v, 0.0) ? +1 : -1;
+ int n_zero = 0;
+ int n_positive = 0;
+
+ if ( LT(0.0, g.D) ) {
+ n_positive++;
+ } else {
+ if ( !LT(g.D, 0.0) ) {
+ n_zero++;
+ }
+ }
+
+ if ( LT(0.0, g.E) ) {
+ n_positive++;
+ } else {
+ if ( !LT(g.E, 0.0) ) {
+ n_zero++;
+ }
+ }
+
+ if ( LT(0.0, g.F) ) {
+ n_positive++;
+ } else {
+ if ( !LT(g.F, 0.0) ) {
+ n_zero++;
+ }
+ }
+
+ return (n_positive==3) || ((n_zero==0) && (n_positive==1));
}
@@ -1899,8 +1926,7 @@ IntegerMatrix *reduce_g6(struct g6 g, double epsrel)
finished = 0;
- /* K-G paper says g3*g4*g3, which I assume is a misprint */
- if ( eps_sign(g.D, eps) * eps_sign(g.E, eps) * eps_sign(g.F, eps) > 0 ) {
+ if ( DEF_positive(g, eps) ) {
intmat_zero(M);
intmat_set(M, 0, 0, LT(g.D, 0.0) ? -1 : 1);