- casewriter_write (iter->writer, cout);
- }
- break;
- case SD:
- moments1_add (iter->moments, v->f, weight);
- break;
- case MAX:
- iter->dbl[0] = MAX (iter->dbl[0], v->f);
- iter->int1 = 1;
- break;
- case MAX | FSTRING:
- /* Need to do some kind of Unicode collation thingy here */
- if (memcmp (iter->string, v->s, src_width) < 0)
- memcpy (iter->string, v->s, src_width);
- iter->int1 = 1;
- break;
- case MIN:
- iter->dbl[0] = MIN (iter->dbl[0], v->f);
- iter->int1 = 1;
- break;
- case MIN | FSTRING:
- if (memcmp (iter->string, v->s, src_width) > 0)
- memcpy (iter->string, v->s, src_width);
- iter->int1 = 1;
- break;
- case FGT:
- case PGT:
- if (v->f > iter->arg[0].f)
- iter->dbl[0] += weight;
- iter->dbl[1] += weight;
- break;
- case FGT | FSTRING:
- case PGT | FSTRING:
- if (memcmp (iter->arg[0].c, v->s, src_width) < 0)
- iter->dbl[0] += weight;
- iter->dbl[1] += weight;
- break;
- case FLT:
- case PLT:
- if (v->f < iter->arg[0].f)
- iter->dbl[0] += weight;
- iter->dbl[1] += weight;
- break;
- case FLT | FSTRING:
- case PLT | FSTRING:
- if (memcmp (iter->arg[0].c, v->s, src_width) > 0)
- iter->dbl[0] += weight;
- iter->dbl[1] += weight;
- break;
- case FIN:
- case PIN:
- if (iter->arg[0].f <= v->f && v->f <= iter->arg[1].f)
- iter->dbl[0] += weight;
- iter->dbl[1] += weight;
- break;
- case FIN | FSTRING:
- case PIN | FSTRING:
- if (memcmp (iter->arg[0].c, v->s, src_width) <= 0
- && memcmp (iter->arg[1].c, v->s, src_width) >= 0)
- iter->dbl[0] += weight;
- iter->dbl[1] += weight;
- break;
- case FOUT:
- case POUT:
- if (iter->arg[0].f > v->f || v->f > iter->arg[1].f)
- iter->dbl[0] += weight;
- iter->dbl[1] += weight;
- break;
- case FOUT | FSTRING:
- case POUT | FSTRING:
- if (memcmp (iter->arg[0].c, v->s, src_width) > 0
- || memcmp (iter->arg[1].c, v->s, src_width) < 0)
- iter->dbl[0] += weight;
- iter->dbl[1] += weight;
- break;
- case N:
- case N | FSTRING:
- iter->dbl[0] += weight;
- break;
- case NU:
- case NU | FSTRING:
- iter->int1++;
- break;
- case FIRST:
- if (iter->int1 == 0)
- {
- iter->dbl[0] = v->f;
- iter->int1 = 1;
- }
- break;
- case FIRST | FSTRING:
- if (iter->int1 == 0)
- {
- memcpy (iter->string, v->s, src_width);
- iter->int1 = 1;
- }
- break;
- case LAST:
- iter->dbl[0] = v->f;
- iter->int1 = 1;
- break;
- case LAST | FSTRING:
- memcpy (iter->string, v->s, src_width);
- iter->int1 = 1;
- break;
- case NMISS:
- case NMISS | FSTRING:
- case NUMISS:
- case NUMISS | FSTRING:
- /* Our value is not missing or it would have been
- caught earlier. Nothing to do. */
- break;
- default:
- NOT_REACHED ();
- }
- } else {
- switch (iter->function)
- {
- case N:
- iter->dbl[0] += weight;
- break;
- case NU:
- iter->int1++;
- break;
- default:
- NOT_REACHED ();
- }
+ /* This is horrible. There are too many possibilities. */
+ switch (av->function)
+ {
+ case SUM:
+ av->dbl[0] += v->f * weight;
+ av->int1 = 1;
+ break;
+ case MEAN:
+ av->dbl[0] += v->f * weight;
+ av->dbl[1] += weight;
+ break;
+ case MEDIAN:
+ {
+ double wv ;
+ struct ccase *cout;
+
+ cout = case_create (casewriter_get_proto (av->writer));
+
+ *case_num_rw (cout, av->subject) = case_num (input, av->src);
+
+ wv = dict_get_case_weight (agr->src_dict, input, NULL);
+
+ *case_num_rw (cout, av->weight) = wv;
+
+ av->cc += wv;
+
+ casewriter_write (av->writer, cout);
+ }
+ break;
+ case SD:
+ moments1_add (av->moments, v->f, weight);
+ break;
+ case MAX:
+ av->dbl[0] = MAX (av->dbl[0], v->f);
+ av->int1 = 1;
+ break;
+ case MAX | FSTRING:
+ /* Need to do some kind of Unicode collation thingy here */
+ if (memcmp (av->string, v->s, src_width) < 0)
+ memcpy (av->string, v->s, src_width);
+ av->int1 = 1;
+ break;
+ case MIN:
+ av->dbl[0] = MIN (av->dbl[0], v->f);
+ av->int1 = 1;
+ break;
+ case MIN | FSTRING:
+ if (memcmp (av->string, v->s, src_width) > 0)
+ memcpy (av->string, v->s, src_width);
+ av->int1 = 1;
+ break;
+ case FGT:
+ case PGT:
+ if (v->f > av->arg[0].f)
+ av->dbl[0] += weight;
+ av->dbl[1] += 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;
+ break;
+ case FLT:
+ case PLT:
+ if (v->f < av->arg[0].f)
+ av->dbl[0] += weight;
+ av->dbl[1] += 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;
+ 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;
+ 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;
+ 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;
+ 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;
+ break;
+ case N:
+ case N | FSTRING:
+ av->dbl[0] += weight;
+ break;
+ case NU:
+ case NU | FSTRING:
+ av->int1++;
+ break;
+ case FIRST:
+ if (av->int1 == 0)
+ {
+ av->dbl[0] = v->f;
+ av->int1 = 1;
+ }
+ break;
+ case FIRST | FSTRING:
+ if (av->int1 == 0)
+ {
+ memcpy (av->string, v->s, src_width);
+ av->int1 = 1;
+ }
+ break;
+ case LAST:
+ av->dbl[0] = v->f;
+ av->int1 = 1;
+ break;
+ case LAST | FSTRING:
+ memcpy (av->string, v->s, src_width);
+ av->int1 = 1;
+ break;
+ case NMISS:
+ case NMISS | FSTRING:
+ case NUMISS:
+ case NUMISS | FSTRING:
+ /* Our value is not missing or it would have been
+ caught earlier. Nothing to do. */
+ break;
+ default:
+ NOT_REACHED ();
+ }
+ }
+ else
+ {
+ switch (av->function)
+ {
+ case N:
+ av->dbl[0] += weight;
+ break;
+ case NU:
+ av->int1++;
+ break;
+ default:
+ NOT_REACHED ();
+ }
+ }