static void
ctables_summary_add (union ctables_summary *s,
const struct ctables_summary_spec *ss,
- const struct variable *var, const union value *value,
+ const union value *value,
bool is_scale, bool is_scale_missing,
bool is_missing, bool is_included,
double weight)
case CTSF_RANGE:
if (!is_scale_missing)
{
- assert (!var_is_alpha (var)); /* XXX? */
if (s->min == SYSMIS || value->f < s->min)
s->min = value->f;
if (s->max == SYSMIS || value->f > s->max)
return 0;
}
-/* Algorithm:
-
- For each row:
- For each ctables_table:
- For each combination of row vars:
- For each combination of column vars:
- For each combination of layer vars:
- Add entry
- Make a table of row values:
- Sort entries by row values
- Assign a 0-based index to each actual value
- Construct a dimension
- Make a table of column values
- Make a table of layer values
- For each entry:
- Fill the table entry using the indexes from before.
- */
-
static struct ctables_area *
ctables_area_insert (struct ctables_section *s, struct ctables_cell *cell,
enum ctables_area_type area)
static struct ctables_cell *
ctables_cell_insert__ (struct ctables_section *s, const struct ccase *c,
- const struct ctables_category *cats[PIVOT_N_AXES][10])
+ const struct ctables_category **cats[PIVOT_N_AXES])
{
size_t hash = 0;
enum ctables_summary_variant sv = CSV_CELL;
static void
ctables_cell_add__ (struct ctables_section *s, const struct ccase *c,
- const struct ctables_category *cats[PIVOT_N_AXES][10],
+ const struct ctables_category **cats[PIVOT_N_AXES],
bool is_included, double weight[N_CTWS])
{
struct ctables_cell *cell = ctables_cell_insert__ (s, c, cats);
bool scale_missing = specs->is_scale && (is_missing || is_listwise_missing (specs, c));
for (size_t i = 0; i < specs->n; i++)
- ctables_summary_add (&cell->summaries[i], &specs->specs[i],
- specs->var, value, specs->is_scale,
- scale_missing, is_missing, is_included,
- weight[specs->specs[i].weighting]);
+ ctables_summary_add (&cell->summaries[i], &specs->specs[i], value,
+ specs->is_scale, scale_missing, is_missing,
+ is_included, weight[specs->specs[i].weighting]);
for (enum ctables_area_type at = 0; at < N_CTATS; at++)
if (!(cell->omit_areas && (1u << at)))
{
static void
recurse_totals (struct ctables_section *s, const struct ccase *c,
- const struct ctables_category *cats[PIVOT_N_AXES][10],
+ const struct ctables_category **cats[PIVOT_N_AXES],
bool is_included, double weight[N_CTWS],
enum pivot_axis_type start_axis, size_t start_nest)
{
static void
recurse_subtotals (struct ctables_section *s, const struct ccase *c,
- const struct ctables_category *cats[PIVOT_N_AXES][10],
+ const struct ctables_category **cats[PIVOT_N_AXES],
bool is_included, double weight[N_CTWS],
enum pivot_axis_type start_axis, size_t start_nest)
{
ctables_cell_insert (struct ctables_section *s, const struct ccase *c,
double weight[N_CTWS])
{
- const struct ctables_category *cats[PIVOT_N_AXES][10]; /* XXX */
+ const struct ctables_category *layer_cats[s->nests[PIVOT_AXIS_LAYER]->n];
+ const struct ctables_category *row_cats[s->nests[PIVOT_AXIS_ROW]->n];
+ const struct ctables_category *column_cats[s->nests[PIVOT_AXIS_COLUMN]->n];
+ const struct ctables_category **cats[PIVOT_N_AXES] =
+ {
+ [PIVOT_AXIS_LAYER] = layer_cats,
+ [PIVOT_AXIS_ROW] = row_cats,
+ [PIVOT_AXIS_COLUMN] = column_cats,
+ };
bool is_included = true;
static void
ctables_section_recurse_add_empty_categories (
struct ctables_section *s,
- const struct ctables_category *cats[PIVOT_N_AXES][10], struct ccase *c,
+ const struct ctables_category **cats[PIVOT_N_AXES], struct ccase *c,
enum pivot_axis_type a, size_t a_idx)
{
if (a >= PIVOT_N_AXES)
if (!show_empty)
return;
- const struct ctables_category *cats[PIVOT_N_AXES][10]; /* XXX */
+ const struct ctables_category *layer_cats[s->nests[PIVOT_AXIS_LAYER]->n];
+ const struct ctables_category *row_cats[s->nests[PIVOT_AXIS_ROW]->n];
+ const struct ctables_category *column_cats[s->nests[PIVOT_AXIS_COLUMN]->n];
+ const struct ctables_category **cats[PIVOT_N_AXES] =
+ {
+ [PIVOT_AXIS_LAYER] = layer_cats,
+ [PIVOT_AXIS_ROW] = row_cats,
+ [PIVOT_AXIS_COLUMN] = column_cats,
+ };
struct ccase *c = case_create (dict_get_proto (s->table->ctables->dict));
ctables_section_recurse_add_empty_categories (s, cats, c, 0, 0);
case_unref (c);