Fixed incorrect behaviour of REGRESSION when multiple dependent variables are entered
[pspp] / src / language / stats / oneway.c
index a30026e8b4c38c283fcc74a7524fdec9d8caed3b..f9476d5c951bc4b732c09f10613af0de3a96838c 100644 (file)
@@ -815,6 +815,7 @@ run_oneway (const struct oneway_spec *cmd,
 
   for (v = 0; v < cmd->n_vars; ++v)
     {
+      const gsl_matrix *ucm;
       gsl_matrix *cm;
       struct per_var_ws *pvw = &ws.vws[v];
       const struct categoricals *cats = covariance_get_categoricals (pvw->cov);
@@ -828,7 +829,10 @@ run_oneway (const struct oneway_spec *cmd,
          continue;
        }
 
-      cm = covariance_calculate_unnormalized (pvw->cov);
+      ucm = covariance_calculate_unnormalized (pvw->cov);
+
+      cm = gsl_matrix_alloc (ucm->size1, ucm->size2);
+      gsl_matrix_memcpy (cm, ucm);
 
       moments1_calculate (ws.dd_total[v]->mom, &pvw->n, NULL, NULL, NULL, NULL);
 
@@ -843,8 +847,6 @@ run_oneway (const struct oneway_spec *cmd,
       pvw->n_groups = categoricals_n_total (cats);
 
       pvw->mse = (pvw->sst - pvw->ssa) / (pvw->n - pvw->n_groups);
-
-      gsl_matrix_free (cm);
     }
 
   for (v = 0; v < cmd->n_vars; ++v)