GLM: Add unimplemented subcommands, and add a test.
[pspp] / src / math / covariance.c
index 446ee6621a1e11881c37e5dba04d8d645c1610a8..adad3439e056e0baad8c35b515972c89747b8ac0 100644 (file)
@@ -731,3 +731,28 @@ covariance_destroy (struct covariance *cov)
   free (cov->cm);
   free (cov);
 }
+
+size_t
+covariance_dim (const struct covariance * cov)
+{
+  return (cov->dim);
+}
+
+/*
+  Returns an array of variables corresponding to rows of the covariance matrix.
+  In other words, element i of the array is the variable corresponding to 
+  row (and column) i of the covariance matrix.
+ */
+void
+covariance_get_var_indices (const struct covariance *cov, const struct variable **vars)
+{
+  int i;
+  for (i = 0; i < cov->n_vars; i++)
+    {
+      vars[i] = cov->vars[i];
+    }
+  for (i = cov->n_vars; i < cov->dim; i++)
+    {
+      vars[i] = categoricals_get_variable_by_subscript (cov->categoricals, i - cov->n_vars);
+    }
+}