+ return val2->f;
+ }
+ else
+ {
+ return 0.0;
+ }
+}
+static double
+update_sum (const struct variable *var, const union value *val, double weight)
+{
+ assert (var != NULL);
+ assert (val != NULL);
+ if (var_is_alpha (var))
+ {
+ return weight;
+ }
+ return val->f;
+}
+static struct covariance_accumulator *
+get_new_covariance_accumulator (const struct variable *v1,
+ const struct variable *v2,
+ const union value *val1,
+ const union value *val2)
+{
+ if ((v1 != NULL) && (v2 != NULL) && (val1 != NULL) && (val2 != NULL))
+ {
+ struct covariance_accumulator *ca;
+ ca = xmalloc (sizeof (*ca));
+ ca->v1 = v1;
+ ca->v2 = v2;
+ ca->val1 = val1;
+ ca->val2 = val2;
+ return ca;
+ }
+ return NULL;
+}
+
+static const struct variable **
+get_covariance_variables (const struct covariance_matrix *cov)
+{
+ return cov->v_variables;
+}
+
+static void
+update_hash_entry_intr (struct hsh_table *c,
+ const struct variable *v1,
+ const struct variable *v2,
+ const union value *val1, const union value *val2,
+ const struct interaction_value *i_val1,
+ const struct interaction_value *i_val2)
+{
+ struct covariance_accumulator *ca;
+ struct covariance_accumulator *new_entry;
+ double iv_f1;
+ double iv_f2;
+
+ iv_f1 = interaction_value_get_nonzero_entry (i_val1);
+ iv_f2 = interaction_value_get_nonzero_entry (i_val2);
+ ca = get_new_covariance_accumulator (v1, v2, val1, val2);
+ ca->dot_product = update_product (ca->v1, ca->v2, ca->val1, ca->val2);
+ ca->dot_product *= iv_f1 * iv_f2;
+ ca->sum1 = update_sum (ca->v1, ca->val1, iv_f1);
+ ca->sum2 = update_sum (ca->v2, ca->val2, iv_f2);
+ ca->ssize = 1.0;
+ new_entry = hsh_insert (c, ca);
+
+ if (new_entry != NULL)
+ {
+ new_entry->dot_product += ca->dot_product;
+ new_entry->ssize += 1.0;
+ new_entry->sum1 += ca->sum1;
+ new_entry->sum2 += ca->sum2;
+ /*
+ If DOT_PRODUCT is null, CA was not already in the hash
+ hable, so we don't free it because it was just inserted.
+ If DOT_PRODUCT was not null, CA is already in the hash table.
+ Unnecessary now, it must be freed here.
+ */
+ free (ca);