union agr_argument arg[2]; /* Arguments. */
/* Accumulated during AGGREGATE execution. */
- double dbl[3];
+ double dbl;
+ double W; /* Total non-missing weight. */
int int1;
char *string;
bool saw_missing;
{
case NMISS:
case NMISS | FSTRING:
- av->dbl[0] += weight;
+ av->dbl += weight;
break;
case NUMISS:
case NUMISS | FSTRING:
}
/* This is horrible. There are too many possibilities. */
+ av->W += weight;
switch (av->function)
{
case SUM:
- av->dbl[0] += v->f * weight;
+ av->dbl += v->f * weight;
av->int1 = 1;
break;
case MEAN:
- av->dbl[0] += v->f * weight;
- av->dbl[1] += weight;
+ av->dbl += v->f * weight;
break;
case MEDIAN:
{
moments1_add (av->moments, v->f, weight);
break;
case MAX:
- av->dbl[0] = MAX (av->dbl[0], v->f);
+ av->dbl = MAX (av->dbl, v->f);
av->int1 = 1;
break;
case MAX | FSTRING:
av->int1 = 1;
break;
case MIN:
- av->dbl[0] = MIN (av->dbl[0], v->f);
+ av->dbl = MIN (av->dbl, v->f);
av->int1 = 1;
break;
case MIN | FSTRING:
case FGT:
case PGT:
if (v->f > av->arg[0].f)
- av->dbl[0] += weight;
- av->dbl[1] += weight;
+ av->dbl += weight;
break;
case FGT | FSTRING:
case PGT | FSTRING:
if (memcmp (av->arg[0].c, v->s, src_width) < 0)
- av->dbl[0] += weight;
- av->dbl[1] += weight;
+ av->dbl += weight;
break;
case FLT:
case PLT:
if (v->f < av->arg[0].f)
- av->dbl[0] += weight;
- av->dbl[1] += weight;
+ av->dbl += weight;
break;
case FLT | FSTRING:
case PLT | FSTRING:
if (memcmp (av->arg[0].c, v->s, src_width) > 0)
- av->dbl[0] += weight;
- av->dbl[1] += weight;
+ av->dbl += weight;
break;
case FIN:
case PIN:
if (av->arg[0].f <= v->f && v->f <= av->arg[1].f)
- av->dbl[0] += weight;
- av->dbl[1] += weight;
+ av->dbl += weight;
break;
case FIN | FSTRING:
case PIN | FSTRING:
if (memcmp (av->arg[0].c, v->s, src_width) <= 0
&& memcmp (av->arg[1].c, v->s, src_width) >= 0)
- av->dbl[0] += weight;
- av->dbl[1] += weight;
+ av->dbl += weight;
break;
case FOUT:
case POUT:
if (av->arg[0].f > v->f || v->f > av->arg[1].f)
- av->dbl[0] += weight;
- av->dbl[1] += weight;
+ av->dbl += weight;
break;
case FOUT | FSTRING:
case POUT | FSTRING:
if (memcmp (av->arg[0].c, v->s, src_width) > 0
|| memcmp (av->arg[1].c, v->s, src_width) < 0)
- av->dbl[0] += weight;
- av->dbl[1] += weight;
+ av->dbl += weight;
break;
case N:
case N | FSTRING:
- av->dbl[0] += weight;
+ av->dbl += weight;
break;
case NU:
case NU | FSTRING:
case FIRST:
if (av->int1 == 0)
{
- av->dbl[0] = v->f;
+ av->dbl = v->f;
av->int1 = 1;
}
break;
}
break;
case LAST:
- av->dbl[0] = v->f;
+ av->dbl = v->f;
av->int1 = 1;
break;
case LAST | FSTRING:
switch (av->function)
{
case N:
- av->dbl[0] += weight;
+ av->dbl += weight;
break;
case NU:
av->int1++;
switch (av->function)
{
case SUM:
- v->f = av->int1 ? av->dbl[0] : SYSMIS;
+ v->f = av->int1 ? av->dbl : SYSMIS;
break;
case MEAN:
- v->f = av->dbl[1] != 0.0 ? av->dbl[0] / av->dbl[1] : SYSMIS;
+ v->f = av->W != 0.0 ? av->dbl / av->W : SYSMIS;
break;
case MEDIAN:
{
av->weight,
av->subject,
av->exclude);
- av->dbl[0] = percentile_calculate (median, PC_HAVERAGE);
+ av->dbl = percentile_calculate (median, PC_HAVERAGE);
statistic_destroy (&median->parent.parent);
}
- v->f = av->dbl[0];
+ v->f = av->dbl;
}
break;
case SD:
break;
case MAX:
case MIN:
- v->f = av->int1 ? av->dbl[0] : SYSMIS;
+ v->f = av->int1 ? av->dbl : SYSMIS;
break;
case MAX | FSTRING:
case MIN | FSTRING:
case FIN | FSTRING:
case FOUT:
case FOUT | FSTRING:
- v->f = av->dbl[1] ? av->dbl[0] / av->dbl[1] : SYSMIS;
+ v->f = av->W ? av->dbl / av->W : SYSMIS;
break;
case PGT:
case PGT | FSTRING:
case PIN | FSTRING:
case POUT:
case POUT | FSTRING:
- v->f = av->dbl[1] ? av->dbl[0] / av->dbl[1] * 100.0 : SYSMIS;
+ v->f = av->W ? av->dbl / av->W * 100.0 : SYSMIS;
break;
case N:
case N | FSTRING:
- v->f = av->dbl[0];
+ v->f = av->dbl;
break;
case NU:
case NU | FSTRING:
break;
case FIRST:
case LAST:
- v->f = av->int1 ? av->dbl[0] : SYSMIS;
+ v->f = av->int1 ? av->dbl : SYSMIS;
break;
case FIRST | FSTRING:
case LAST | FSTRING:
break;
case NMISS:
case NMISS | FSTRING:
- v->f = av->dbl[0];
+ v->f = av->dbl;
break;
case NUMISS:
case NUMISS | FSTRING:
{
struct agr_var *av = &agr->agr_vars[i];
av->saw_missing = false;
- av->dbl[0] = av->dbl[1] = av->dbl[2] = 0.0;
+ av->dbl = av->W = 0.0;
av->int1 = 0;
switch (av->function)
{
case MIN:
- av->dbl[0] = DBL_MAX;
+ av->dbl = DBL_MAX;
break;
case MIN | FSTRING:
memset (av->string, 255, var_get_width (av->src));
break;
case MAX:
- av->dbl[0] = -DBL_MAX;
+ av->dbl = -DBL_MAX;
break;
case MAX | FSTRING:
memset (av->string, 0, var_get_width (av->src));