{
struct hmap_node node;
- const struct ctables_freq *example;
+ const struct ctables_cell *example;
double valid;
double missing;
};
-struct ctables_freq
+struct ctables_cell
{
- /* In struct ctables's 'ft' hmap. Indexed by all the values in all the
+ /* In struct ctables's 'cells' hmap. Indexed by all the values in all the
axes (except the scalar variable, if any). */
struct hmap_node node;
struct ctables_axis *axes[PIVOT_N_AXES];
struct var_array2 vaas[PIVOT_N_AXES];
enum pivot_axis_type summary_axis;
- struct hmap ft;
+ struct hmap cells;
struct hmap domains[N_CTDTS];
enum pivot_axis_type slabels_position;
}
static double
-ctables_summary_value (const struct ctables_freq *f,
+ctables_summary_value (const struct ctables_cell *f,
union ctables_summary *s,
const struct ctables_summary_spec *ss)
{
NOT_REACHED ();
}
-struct ctables_freq_sort_aux
+struct ctables_cell_sort_aux
{
const struct ctables_table *t;
enum pivot_axis_type a;
};
static int
-ctables_freq_compare_3way (const void *a_, const void *b_, const void *aux_)
+ctables_cell_compare_3way (const void *a_, const void *b_, const void *aux_)
{
- const struct ctables_freq_sort_aux *aux = aux_;
- struct ctables_freq *const *ap = a_;
- struct ctables_freq *const *bp = b_;
- const struct ctables_freq *a = *ap;
- const struct ctables_freq *b = *bp;
+ const struct ctables_cell_sort_aux *aux = aux_;
+ struct ctables_cell *const *ap = a_;
+ struct ctables_cell *const *bp = b_;
+ const struct ctables_cell *a = *ap;
+ const struct ctables_cell *b = *bp;
size_t a_idx = a->axes[aux->a].vaa_idx;
size_t b_idx = b->axes[aux->a].vaa_idx;
*/
static struct ctables_domain *
-ctables_domain_insert (struct ctables_table *t, struct ctables_freq *f,
+ctables_domain_insert (struct ctables_table *t, struct ctables_cell *f,
enum ctables_domain_type domain)
{
size_t hash = 0;
struct ctables_domain *d;
HMAP_FOR_EACH_WITH_HASH (d, struct ctables_domain, node, hash, &t->domains[domain])
{
- const struct ctables_freq *df = d->example;
+ const struct ctables_cell *df = d->example;
for (enum pivot_axis_type a = 0; a < PIVOT_N_AXES; a++)
{
size_t idx = f->axes[a].vaa_idx;
}
static void
-ctables_freqtab_insert (struct ctables_table *t,
- const struct ccase *c,
- size_t ir, size_t ic, size_t il,
- double weight)
+ctables_cell_insert (struct ctables_table *t,
+ const struct ccase *c,
+ size_t ir, size_t ic, size_t il,
+ double weight)
{
size_t ix[PIVOT_N_AXES] = {
[PIVOT_AXIS_ROW] = ir,
var_get_width (va->vars[i]), hash);
}
- struct ctables_freq *f;
- HMAP_FOR_EACH_WITH_HASH (f, struct ctables_freq, node, hash, &t->ft)
+ struct ctables_cell *f;
+ HMAP_FOR_EACH_WITH_HASH (f, struct ctables_cell, node, hash, &t->cells)
{
for (enum pivot_axis_type a = 0; a < PIVOT_N_AXES; a++)
{
ctables_summary_init (&f->summaries[i], &ss->summaries[i]);
for (enum ctables_domain_type dt = 0; dt < N_CTDTS; dt++)
f->domains[dt] = ctables_domain_insert (t, f, dt);
- hmap_insert (&t->ft, &f->node, hash);
+ hmap_insert (&t->cells, &f->node, hash);
summarize:
for (size_t i = 0; i < ss->n_summaries; i++)
for (size_t ir = 0; ir < t->vaas[PIVOT_AXIS_ROW].n; ir++)
for (size_t ic = 0; ic < t->vaas[PIVOT_AXIS_COLUMN].n; ic++)
for (size_t il = 0; il < t->vaas[PIVOT_AXIS_LAYER].n; il++)
- ctables_freqtab_insert (t, c, ir, ic, il, weight);
+ ctables_cell_insert (t, c, ir, ic, il, weight);
}
}
casereader_destroy (input);
assert (t->axes[a]);
- struct ctables_freq **sorted = xnmalloc (t->ft.count, sizeof *sorted);
+ struct ctables_cell **sorted = xnmalloc (t->cells.count, sizeof *sorted);
- struct ctables_freq *f;
+ struct ctables_cell *f;
size_t n = 0;
- HMAP_FOR_EACH (f, struct ctables_freq, node, &t->ft)
+ HMAP_FOR_EACH (f, struct ctables_cell, node, &t->cells)
sorted[n++] = f;
- assert (n == t->ft.count);
+ assert (n == t->cells.count);
- struct ctables_freq_sort_aux aux = { .t = t, .a = a };
- sort (sorted, n, sizeof *sorted, ctables_freq_compare_3way, &aux);
+ struct ctables_cell_sort_aux aux = { .t = t, .a = a };
+ sort (sorted, n, sizeof *sorted, ctables_cell_compare_3way, &aux);
size_t max_depth = 0;
for (size_t j = 0; j < t->vaas[a].n; j++)
int prev_leaf = 0;
for (size_t j = 0; j < n; j++)
{
- struct ctables_freq *f = sorted[j];
+ struct ctables_cell *f = sorted[j];
const struct var_array *va = &t->vaas[a].vas[f->axes[a].vaa_idx];
size_t n_common = 0;
bool new_subtable = false;
if (j > 0)
{
- struct ctables_freq *prev = sorted[j - 1];
+ struct ctables_cell *prev = sorted[j - 1];
if (prev->axes[a].vaa_idx == f->axes[a].vaa_idx)
{
for (; n_common < va->n; n_common++)
free (sorted);
free (groups);
}
- struct ctables_freq *f;
- HMAP_FOR_EACH (f, struct ctables_freq, node, &t->ft)
+ struct ctables_cell *f;
+ HMAP_FOR_EACH (f, struct ctables_cell, node, &t->cells)
{
const struct var_array *ss = &t->vaas[t->summary_axis].vas[f->axes[t->summary_axis].vaa_idx];
for (size_t j = 0; j < ss->n_summaries; j++)
pivot_table_submit (pt);
}
-#if 0
- for (size_t i = 0; i < ct->n_tables; i++)
- {
- struct ctables_table *t = ct->tables[i];
-
- for (size_t j = 0; j < t->n_fts; j++)
- {
- struct ctables_freqtab *ft = t->fts[j];
- struct ctables_freq *f, *next;
- HMAP_FOR_EACH_SAFE (f, next, struct ctables_freq, node, &ft->data)
- {
- hmap_delete (&ft->data, &f->node);
- for (size_t k = 0; k < ft->n_summaries; k++)
- ctables_summary_uninit (&f->summaries[k], &ft->summaries[k]);
- free (f->summaries);
- for (size_t k = 0; k < ft->vars.n; k++)
- {
- const struct variable *var = ft->vars.vars[k];
- value_destroy (&f->values[k], var_get_width (var));
- }
- free (f);
- }
- hmap_destroy (&ft->data);
- var_array_uninit (&ft->vars);
- free (ft);
- }
- free (t->fts);
- }
-#endif
-
return proc_commit (ds);
}
struct ctables_table *t = xmalloc (sizeof *t);
*t = (struct ctables_table) {
- .ft = HMAP_INITIALIZER (t->ft),
+ .cells = HMAP_INITIALIZER (t->cells),
.slabels_position = PIVOT_AXIS_COLUMN,
.slabels_visible = true,
.row_labels = CTLP_NORMAL,