+/*
+ Compute the covariance matrix in a single data-pass. Cases with
+ missing values are dropped listwise. In other words, if one of the
+ values for any variable in a case is missing, the entire case is
+ skipped.
+
+ The caller must use a casefilter to remove the cases with missing
+ values before calling covariance_accumulate_listwise. This function
+ assumes that CCASE has already passed through this filter, and
+ contains no missing values.
+
+ Do not call this function directly. Call it through the struct
+ covariance_matrix ACCUMULATE member function, for example,
+ cov->accumulate (cov, ccase).
+ */
+static void
+covariance_accumulate_listwise (struct covariance_matrix *cov,
+ const struct ccase *ccase)
+{
+ size_t i;
+ size_t j;
+ const union value *val1;
+ const union value *val2;
+ const struct variable **v_variables;
+
+ assert (cov != NULL);
+ assert (ccase != NULL);
+
+ v_variables = get_covariance_variables (cov);
+ assert (v_variables != NULL);
+
+ for (i = 0; i < cov->n_variables; ++i)
+ {
+ val1 = case_data (ccase, v_variables[i]);
+ cat_value_update (v_variables[i], val1);
+ if (var_is_alpha (v_variables[i]))
+ cov->update_moments (cov, i, val1->f);
+
+ for (j = i; j < cov->n_variables; j++)
+ {
+ val2 = case_data (ccase, v_variables[j]);
+ update_hash_entry (cov->ca, v_variables[i], v_variables[j],
+ val1, val2);
+ if (j != i)
+ update_hash_entry (cov->ca, v_variables[j], v_variables[i],
+ val2, val1);
+ }
+ }
+}
+
+/*
+ Call this function during the data pass. Each case will be added to
+ a hash containing all values of the covariance matrix. After the
+ data have been passed, call covariance_matrix_compute to put the
+ values in the struct covariance_matrix.
+ */
+void
+covariance_matrix_accumulate (struct covariance_matrix *cov,
+ const struct ccase *ccase)
+{
+ cov->accumulate (cov, ccase);
+}
+
+static void
+covariance_matrix_insert (struct design_matrix *cov,
+ const struct variable *v1,
+ const struct variable *v2, const union value *val1,