#include <maths.h>
#include <smalloc.h>
#include <vec.h>
+#include <assert.h>
#include <indexutil.h>
#include <poscalc.h>
_gmx_sel_evaluate_arithmetic(gmx_sel_evaluate_t *data, t_selelem *sel,
gmx_ana_index_t *g)
{
- t_selelem *left, *right;
int n, i, i1, i2;
real lval, rval=0., val=0.;
int rc;
+ gmx_bool bArithNeg;
- left = sel->child;
- right = left->next;
+ t_selelem *const left = sel->child;
+ t_selelem *const right = left->next;
if (left->mempool)
{
n = (sel->flags & SEL_SINGLEVAL) ? 1 : g->isize;
sel->v.nr = n;
+
+ bArithNeg = (sel->u.arith.type == ARITH_NEG);
+ assert(right || bArithNeg);
for (i = i1 = i2 = 0; i < n; ++i)
{
lval = left->v.u.r[i1];
- if (sel->u.arith.type != ARITH_NEG)
+ if (!bArithNeg)
{
rval = right->v.u.r[i2];
}
{
++i1;
}
- if (sel->u.arith.type != ARITH_NEG && !(right->flags & SEL_SINGLEVAL))
+ if (!bArithNeg && !(right->flags & SEL_SINGLEVAL))
{
++i2;
}