- result = xmalloc (sizeof (*result));
- result->intr = var;
- n_vars = interaction_get_n_vars (var);
- result->val = value_create (n_vars * MAX_SHORT_STRING + 1);
- result->f = 1.0;
- for (i = 0; i < n_vars; i++)
- {
- member = interaction_variable_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]))
- {
- strncat (result->val->s, vals[i]->s, MAX_SHORT_STRING);
- }
- 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;
- }