+ const double df = iap->df_prod[v] / dfp;
+
+ /* Translate the subscript into an index for the individual variable */
+ const int index = ((subscript - base_index) % iap->df_prod[v] ) / dfp;
+ dfp = iap->df_prod [v];
+
+#if EFFECTS_CODING
+ if ( valn->index == df )
+ bin = -1.0;
+ else
+#endif
+ if ( valn->index != index )
+ bin = 0;
+
+ result *= bin;
+ }
+
+ return result;
+}
+
+
+size_t
+categoricals_get_n_variables (const struct categoricals *cat)
+{
+ printf ("%s\n", __FUNCTION__);
+ return cat->n_vars;
+}
+
+
+/* Return a case containing the set of values corresponding to
+ the Nth Category of the IACTth interaction */
+const struct ccase *
+categoricals_get_case_by_category_real (const struct categoricals *cat, int iact, int n)
+{
+ const struct interact_params *vp = &cat->iap[iact];
+ const struct interaction_value *vn = vp->reverse_interaction_value_map [n];
+
+ return vn->ccase;
+}
+
+/* Return a the user data corresponding to the Nth Category of the IACTth interaction. */
+void *
+categoricals_get_user_data_by_category_real (const struct categoricals *cat, int iact, int n)
+{
+ const struct interact_params *vp = &cat->iap[iact];
+ const struct interaction_value *iv = vp->reverse_interaction_value_map [n];
+
+ return iv->user_data;
+}
+
+
+
+/* Return a case containing the set of values corresponding to SUBSCRIPT */
+const struct ccase *
+categoricals_get_case_by_category (const struct categoricals *cat, int subscript)
+{
+ int vindex = reverse_variable_lookup_long (cat, subscript);
+ const struct interact_params *vp = &cat->iap[vindex];
+ const struct interaction_value *vn = vp->reverse_interaction_value_map [subscript - vp->base_subscript_long];
+
+ return vn->ccase;
+}
+
+void *
+categoricals_get_user_data_by_category (const struct categoricals *cat, int subscript)
+{
+ int vindex = reverse_variable_lookup_long (cat, subscript);
+ const struct interact_params *vp = &cat->iap[vindex];
+
+ const struct interaction_value *iv = vp->reverse_interaction_value_map [subscript - vp->base_subscript_long];
+ return iv->user_data;
+}
+
+
+\f
+
+void
+categoricals_set_payload (struct categoricals *cat, const struct payload *p,
+ const void *aux1, void *aux2)
+{
+ cat->payload = p;
+ cat->aux1 = aux1;
+ cat->aux2 = aux2;