- int val_width = 1;
- char *val;
-
- result = xmalloc (sizeof (*result));
- result->intr = var;
- n_vars = interaction_get_n_vars (var);
- value_init (&result->val, val_width);
- val = value_str_rw (&result->val, val_width);
- val[0] = '\0';
- result->f = 1.0;
- for (i = 0; i < n_vars; i++)
- {
- member = interaction_get_member (var, i);
-
- if (var_is_value_missing (member, vals[i], MV_ANY))
- {
- value_set_missing (&result->val, MAX_SHORT_STRING);
- result->f = SYSMIS;
- break;
- }
- else
- {
- if (var_is_alpha (var->members[i]))
- {
- int w = var_get_width (var->members[i]);
- value_resize (result, val_width, val_width + w);
- strncat (val, value_str (vals[i], w), w);
- val = value_str_rw (&result->val, val_width);
- }
- else if (var_is_numeric (var->members[i]))
- {
- result->f *= vals[i]->f;
- }
- }
- }
- if (interaction_get_n_alpha (var) == 0)
- {
- /*
- If there are no categorical variables, then the
- interaction consists of only numeric data. In this case,
- code that uses this interaction_value will see the union
- member as the numeric value. If we were to store that
- numeric value in result->f as well, the calling code may
- inadvertently square this value by multiplying by
- result->val->f. Such multiplication would be correct for an
- interaction consisting of both categorical and numeric
- data, but a mistake for purely numerical interactions. To
- avoid the error, we set result->f to 1.0 for numeric
- interactions.
- */
- result->val.f = result->f;
- result->f = 1.0;
- }