+struct interaction;
+struct variable;
+union value;
+
+/* Categoricals.
+
+ A categorical variable has a finite and usually small number of possible
+ values. The categoricals data structure organizes an array of interactions
+ maong categorical variables, that is, a set of sets of categorical
+ variables. (Both levels of "set" are ordered.)
+
+ The life cycle of a categoricals object looks like this:
+
+ 1. Create it with categoricals_create(). This fixes the set of interactions
+ and other parameters.
+
+ 2. Pass all of the desired cases through the object with
+ categoricals_update().
+
+ 3. Finalize the object with categoricals_done(). Only at this point may
+ most of the categoricals query functions be called.
+
+ 4. Use the categoricals object as desired.
+
+ 5. Destroy the object with categoricals_destroy().
+*/
+
+/* Creating and destroying categoricals. */
+struct categoricals *categoricals_create (struct interaction *const *,
+ size_t n,
+ const struct variable *wv,
+ enum mv_class fctr_excl);
+void categoricals_destroy (struct categoricals *);
+
+/* Updating categoricals. */
+void categoricals_update (struct categoricals *, const struct ccase *);
+void categoricals_done (const struct categoricals *);
+bool categoricals_is_complete (const struct categoricals *);
+
+/* Categories.
+
+ A variable's number of categories is the number of unique values observed in
+ the data passed to categoricals_update().
+
+ An interaction's number of categories is the number of observed unique
+ values of its variables, which will often be less than the product of its
+ variables' numbers of categories.
+
+ A categorical object's number of categories is the sum of its interactions'
+ categories. */
+size_t categoricals_n_count (const struct categoricals *, size_t idx);
+size_t categoricals_n_total (const struct categoricals *);
+
+union value *categoricals_get_var_values (const struct categoricals *,
+ const struct variable *, size_t *n);
+
+/* Degrees of freedom.
+
+ A categorical variable with N_CATS categories has N_CATS - 1 degrees of
+ freedom.
+
+ An interaction's degrees of freedom is the product of its variables' degrees
+ of freedom.
+
+ A categorical object's degrees of freedom is the sum of its interactions'
+ degrees of freedom. */
+size_t categoricals_df (const struct categoricals *, size_t idx);
+size_t categoricals_df_total (const struct categoricals *);
+
+/* Sanity. */
+bool categoricals_sane (const struct categoricals *cat);
+
+/* "Short map".
+
+ These look up an interaction within a categoricals object on the basis of a
+ "subscript". Interaction 0 with DF_0 degrees of freedom is assigned
+ subscripts [0, DF_0 - 1], interaction 1 with DF_1 degrees of freedom is
+ assigned subscripts [DF_0, DF_0 + DF_1 - 1], and so on. The subscripts
+ passed in must be in the range [0, DF_SUM - 1] where DF_SUM is the total
+ number of degrees of freedom for the object, as returned by
+ categoricals_df_total().
+
+ These functions are intended for covariance matrix routines, where normally
+ 1 less than the total number of distinct values of each categorical variable
+ should be considered.
+
+ These functions may be used on an object only after calling
+ categoricals_done().
+*/
+double categoricals_get_weight_by_subscript (const struct categoricals *,
+ int subscript);
+const struct interaction *categoricals_get_interaction_by_subscript (
+ const struct categoricals *, int subscript);
+double categoricals_get_sum_by_subscript (const struct categoricals *,
+ int subscript);
+double categoricals_get_dummy_code_for_case (const struct categoricals *,
+ int subscript,
+ const struct ccase *);
+double categoricals_get_effects_code_for_case (const struct categoricals *,
+ int subscript,
+ const struct ccase *);
+