size_t *domains[N_CTDTS];
size_t n_domains[N_CTDTS];
- struct ctables_summary_spec_set cell_summaries;
- struct ctables_summary_spec_set total_summaries;
+ struct ctables_summary_spec_set cell_sss;
+ struct ctables_summary_spec_set total_sss;
};
struct var_array2
{
struct ctables_var var;
bool scale;
- struct ctables_summary_spec_set cell_summaries;
- struct ctables_summary_spec_set total_summaries;
+ struct ctables_summary_spec_set cell_sss;
+ struct ctables_summary_spec_set total_sss;
};
/* Nonterminals. */
switch (axis->op)
{
case CTAO_VAR:
- ctables_summary_spec_set_uninit (&axis->cell_summaries);
- ctables_summary_spec_set_uninit (&axis->total_summaries);
+ ctables_summary_spec_set_uninit (&axis->cell_sss);
+ ctables_summary_spec_set_uninit (&axis->total_sss);
break;
case CTAO_STACK:
break;
}
- struct ctables_summary_spec_set *set = (totals ? &axis->total_summaries
- : &axis->cell_summaries);
+ struct ctables_summary_spec_set *set = (totals ? &axis->total_sss
+ : &axis->cell_sss);
if (set->n >= set->allocated)
set->summaries = x2nrealloc (set->summaries, &set->allocated,
sizeof *set->summaries);
{
if (!lex_force_match (ctx->lexer, T_LBRACK))
goto error;
+ totals = true;
}
}
else if (lex_force_match (ctx->lexer, T_RBRACK))
if (!axis)
return NULL;
else if (axis->op == CTAO_VAR)
- return !axis->scale && axis->cell_summaries.n ? axis : NULL;
+ return !axis->scale && axis->cell_sss.n ? axis : NULL;
else
{
for (size_t i = 0; i < 2; i++)
assert (n == allocate);
const struct var_array *summary_src;
- if (!a->cell_summaries.var)
+ if (!a->cell_sss.var)
summary_src = b;
- else if (!b->cell_summaries.var)
+ else if (!b->cell_sss.var)
summary_src = a;
else
NOT_REACHED ();
: b->scale_idx != SIZE_MAX ? a->n + b->scale_idx
: SIZE_MAX),
.n = n,
- .cell_summaries = summary_src->cell_summaries,
- .total_summaries = summary_src->total_summaries,
+ .cell_sss = summary_src->cell_sss,
+ .total_sss = summary_src->total_sss,
};
}
var_array2_uninit (&va0);
.n = 1,
.scale_idx = a->scale ? 0 : SIZE_MAX,
};
- if (a->cell_summaries.n || a->scale)
+ if (a->cell_sss.n || a->scale)
{
- va->cell_summaries = a->cell_summaries;
- va->total_summaries = a->total_summaries;
- va->cell_summaries.var = a->var.var;
- va->total_summaries.var = a->var.var;
+ va->cell_sss = a->cell_sss;
+ va->total_sss = a->total_sss;
+ va->cell_sss.var = a->var.var;
+ va->total_sss.var = a->var.var;
}
return (struct var_array2) { .vas = va, .n = 1 };
}
{
- const struct ctables_summary_spec_set *sss = &ss->cell_summaries;
+ const struct ctables_summary_spec_set *sss
+ = (cell->total ? &ss->total_sss : &ss->cell_sss);
cell->summaries = xmalloc (sss->n * sizeof *cell->summaries);
for (size_t i = 0; i < sss->n; i++)
ctables_summary_init (&cell->summaries[i], &sss->summaries[i]);
hmap_insert (&t->cells, &cell->node, hash);
summarize: ;
- const struct ctables_summary_spec_set *sss = &ss->cell_summaries;
+ const struct ctables_summary_spec_set *sss
+ = (cell->total ? &ss->total_sss : &ss->cell_sss);
for (size_t i = 0; i < sss->n; i++)
ctables_summary_add (&cell->summaries[i], &sss->summaries[i], sss->var,
case_data (c, sss->var), weight);
for (size_t i = 0; i < t->vaas[t->summary_axis].n; i++)
{
struct var_array *va = &t->vaas[t->summary_axis].vas[i];
- if (!va->cell_summaries.n)
+ if (!va->cell_sss.n)
{
- struct ctables_summary_spec_set *css = &va->cell_summaries;
+ struct ctables_summary_spec_set *css = &va->cell_sss;
css->summaries = xmalloc (sizeof *css->summaries);
css->n = 1;
if (!css->var)
css->var = va->vars[0];
- va->total_summaries = va->cell_summaries;
+ va->total_sss = va->cell_sss;
}
+ else if (!va->total_sss.n)
+ va->total_sss = va->cell_sss;
}
}
{
if (label)
parent = pivot_category_create_group__ (parent, label);
- for (size_t m = 0; m < va->cell_summaries.n; m++)
+ const struct ctables_summary_spec_set *sss
+ = cell->total ? &va->total_sss : &va->cell_sss;
+ for (size_t m = 0; m < sss->n; m++)
{
int leaf = pivot_category_create_leaf (
- parent, pivot_value_new_text (va->cell_summaries.summaries[m].label));
+ parent, pivot_value_new_text (sss->summaries[m].label));
if (m == 0)
prev_leaf = leaf;
}
if (cell->hide)
continue;
- const struct ctables_summary_spec_set *sss = &t->vaas[t->summary_axis].vas[cell->axes[t->summary_axis].vaa_idx].cell_summaries;
+ const struct var_array *va = &t->vaas[t->summary_axis].vas[cell->axes[t->summary_axis].vaa_idx];
+ const struct ctables_summary_spec_set *sss = cell->total ? &va->total_sss : &va->cell_sss;
for (size_t j = 0; j < sss->n; j++)
{
size_t dindexes[3];