{
struct ccase *c;
const gsl_matrix *var_matrix, *samples_matrix, *mean_matrix;
- const gsl_matrix *cov_matrix;
+ gsl_matrix *cov_matrix;
gsl_matrix *corr_matrix;
struct covariance *cov = covariance_2pass_create (corr->n_vars_total, corr->vars,
NULL,
covariance_destroy (cov);
gsl_matrix_free (corr_matrix);
+ gsl_matrix_free (cov_matrix);
}
int
/* Intermediate values used in calculation */
const gsl_matrix *corr ; /* The correlation matrix */
- const gsl_matrix *cov ; /* The covariance matrix */
+ gsl_matrix *cov ; /* The covariance matrix */
const gsl_matrix *n ; /* Matrix of number of samples */
gsl_vector *eval ; /* The eigenvalues */
gsl_vector_free (id->msr);
gsl_vector_free (id->eval);
gsl_matrix_free (id->evec);
+ if (id->cov != NULL)
+ gsl_matrix_free (id->cov);
free (id);
}
reg_sweep (cm, 0);
dump_matrix (cm);
+
+ gsl_matrix_free (cm);
}
if (!taint_has_tainted_successor (taint))
pvw->n_groups = categoricals_total (cats);
pvw->mse = (pvw->sst - pvw->ssa) / (n - pvw->n_groups);
+
+ gsl_matrix_free (cm);
}
for (v = 0; v < cmd->n_vars; ++v)
size_t dep_subscript;
size_t *rows;
const gsl_matrix *ssizes;
- const gsl_matrix *cm;
+ gsl_matrix *cm;
const gsl_matrix *mean_matrix;
const gsl_matrix *ssize_matrix;
double result = 0.0;
/* PSPP - a program for statistical analysis.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
}
-static const gsl_matrix *
+static gsl_matrix *
covariance_calculate_double_pass (struct covariance *cov)
{
size_t i, j;
return cm_to_gsl (cov);
}
-static const gsl_matrix *
+static gsl_matrix *
covariance_calculate_single_pass (struct covariance *cov)
{
size_t i, j;
}
-/*
- Return a pointer to gsl_matrix containing the pairwise covariances.
- The matrix remains owned by the COV object, and must not be freed.
- Call this function only after all data have been accumulated.
-*/
-const gsl_matrix *
+/* Return a pointer to gsl_matrix containing the pairwise covariances. The
+ caller owns the returned matrix and must free it when it is no longer
+ needed.
+
+ Call this function only after all data have been accumulated. */
+gsl_matrix *
covariance_calculate (struct covariance *cov)
{
if ( cov->state <= 0 )
/*
Covariance computed without dividing by the sample size.
*/
-static const gsl_matrix *
+static gsl_matrix *
covariance_calculate_double_pass_unnormalized (struct covariance *cov)
{
size_t i, j;
return cm_to_gsl (cov);
}
-static const gsl_matrix *
+static gsl_matrix *
covariance_calculate_single_pass_unnormalized (struct covariance *cov)
{
size_t i, j;
}
-/*
- Return a pointer to gsl_matrix containing the pairwise covariances.
- The matrix remains owned by the COV object, and must not be freed.
- Call this function only after all data have been accumulated.
-*/
-const gsl_matrix *
+/* Return a pointer to gsl_matrix containing the pairwise covariances. The
+ caller owns the returned matrix and must free it when it is no longer
+ needed.
+
+ Call this function only after all data have been accumulated. */
+gsl_matrix *
covariance_calculate_unnormalized (struct covariance *cov)
{
if ( cov->state <= 0 )
/* PSPP - a program for statistical analysis.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
void covariance_accumulate_pass1 (struct covariance *, const struct ccase *);
void covariance_accumulate_pass2 (struct covariance *, const struct ccase *);
-const gsl_matrix * covariance_calculate (struct covariance *cov);
-const gsl_matrix * covariance_calculate_unnormalized (struct covariance *);
+gsl_matrix * covariance_calculate (struct covariance *);
+gsl_matrix * covariance_calculate_unnormalized (struct covariance *);
void covariance_destroy (struct covariance *cov);