X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fcorrelations.c;h=6af8ba32ffd54cc32f8e84baa8f77ee0192eee1d;hb=758bb90bac15899ca7f18a55dc4f90e1345c7179;hp=c575205ccf2e8b8858e06383854e13f340baaf98;hpb=8b71948cd57dbd2787cb4c50525b957e9be8a62b;p=pspp diff --git a/src/language/stats/correlations.c b/src/language/stats/correlations.c index c575205ccf..6af8ba32ff 100644 --- a/src/language/stats/correlations.c +++ b/src/language/stats/correlations.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -30,8 +29,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -96,7 +94,6 @@ output_descriptives (const struct corr *corr, const gsl_matrix *means, struct tab_table *t = tab_create (nc, nr); tab_title (t, _("Descriptive Statistics")); - tab_dim (t, tab_natural_dimensions, NULL, NULL); tab_headers (t, heading_columns, 0, heading_rows, 0); @@ -191,7 +188,6 @@ output_correlation (const struct corr *corr, const struct corr_opts *opts, t = tab_create (nc, nr); tab_title (t, _("Correlations")); - tab_dim (t, tab_natural_dimensions, NULL, NULL); tab_headers (t, heading_columns, 0, heading_rows, 0); @@ -284,16 +280,25 @@ run_corr (struct casereader *r, const struct corr_opts *opts, const struct corr const gsl_matrix *var_matrix, *samples_matrix, *mean_matrix; const gsl_matrix *cov_matrix; gsl_matrix *corr_matrix; - struct covariance *cov = covariance_create (corr->n_vars_total, corr->vars, - opts->wv, opts->exclude); + struct covariance *cov = covariance_2pass_create (corr->n_vars_total, corr->vars, + NULL, + opts->wv, opts->exclude); + struct casereader *rc = casereader_clone (r); for ( ; (c = casereader_read (r) ); case_unref (c)) { - covariance_accumulate (cov, c); + covariance_accumulate_pass1 (cov, c); + } + + for ( ; (c = casereader_read (rc) ); case_unref (c)) + { + covariance_accumulate_pass2 (cov, c); } cov_matrix = covariance_calculate (cov); + casereader_destroy (rc); + samples_matrix = covariance_moments (cov, MOMENT_NONE); var_matrix = covariance_moments (cov, MOMENT_VARIANCE); mean_matrix = covariance_moments (cov, MOMENT_MEAN); @@ -493,10 +498,13 @@ cmd_correlation (struct lexer *lexer, struct dataset *ds) /* Done. */ + free (corr->vars); free (corr); + return ok ? CMD_SUCCESS : CMD_CASCADING_FAILURE; error: + free (corr->vars); free (corr); return CMD_FAILURE; }