X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fchisquare.c;h=d1d81bab39dcc26e422aa32e96354c5c16a808d5;hb=3f3b74c2dd0e8468e11b0bb22366f6081ba0d459;hp=ffb75dd3e0ce95ad85b3732db35b6a21cfe40447;hpb=9420449c40bb1307f6c31e50b61ba03825680e3a;p=pspp diff --git a/src/language/stats/chisquare.c b/src/language/stats/chisquare.c index ffb75dd3e0..d1d81bab39 100644 --- a/src/language/stats/chisquare.c +++ b/src/language/stats/chisquare.c @@ -70,7 +70,7 @@ create_freq_hash_with_range (const struct dictionary *dict, /* Populate the hash with zero entries */ entries = xnmalloc (hi - lo + 1, sizeof *entries); - for (i_d = lo; i_d <= hi; i_d += 1.0 ) + for (i_d = lo; i_d <= hi; i_d += 1.0) { size_t ofs = i_d - lo; union value value = { i_d }; @@ -141,16 +141,16 @@ chisquare_execute (const struct dataset *ds, struct one_sample_test *ost = &cst->parent; double total_expected = 0.0; - double *df = xzalloc (sizeof (*df) * ost->n_vars); - double *xsq = xzalloc (sizeof (*df) * ost->n_vars); + double *df = XCALLOC (ost->n_vars, double); + double *xsq = XCALLOC (ost->n_vars, double); bool ok; - for ( i = 0 ; i < cst->n_expected ; ++i ) + for (i = 0 ; i < cst->n_expected ; ++i) total_expected += cst->expected[i]; - if ( cst->ranged == false ) + if (cst->ranged == false) { - for ( v = 0 ; v < ost->n_vars ; ++v ) + for (v = 0 ; v < ost->n_vars ; ++v) { const struct variable *var = ost->vars[v]; @@ -244,19 +244,19 @@ chisquare_execute (const struct dataset *ds, struct pivot_dimension *var_dim = pivot_dimension_create (table, PIVOT_AXIS_COLUMN, N_("Variable")); - for ( size_t i = 0 ; i < ost->n_vars ; ++i ) + for (size_t i = 0 ; i < ost->n_vars ; ++i) pivot_category_create_leaf (var_dim->root, pivot_value_new_variable (ost->vars[i])); struct pivot_dimension *category_dim = pivot_dimension_create (table, PIVOT_AXIS_ROW, N_("Category")); size_t n_cells = cst->hi - cst->lo + 1; - for (size_t i = 0 ; i < n_cells; ++i ) + for (size_t i = 0 ; i < n_cells; ++i) pivot_category_create_leaf (category_dim->root, pivot_value_new_integer (i + 1)); pivot_category_create_leaves (category_dim->root, N_("Total")); - for ( size_t v = 0 ; v < ost->n_vars ; ++v ) + for (size_t v = 0 ; v < ost->n_vars ; ++v) { const struct variable *var = ost->vars[v]; struct casereader *reader = @@ -274,11 +274,11 @@ chisquare_execute (const struct dataset *ds, struct freq **ff = freq_hmap_sort (&freq_hash, var_get_width (var)); double total_obs = 0.0; - for ( size_t i = 0 ; i < hmap_count (&freq_hash) ; ++i ) + for (size_t i = 0 ; i < hmap_count (&freq_hash) ; ++i) total_obs += ff[i]->count; xsq[v] = 0.0; - for ( size_t i = 0 ; i < hmap_count (&freq_hash) ; ++i ) + for (size_t i = 0 ; i < hmap_count (&freq_hash) ; ++i) { /* Category. */ pivot_table_put3 (table, 0, v, i, @@ -327,7 +327,7 @@ chisquare_execute (const struct dataset *ds, struct pivot_dimension *variables = pivot_dimension_create ( table, PIVOT_AXIS_ROW, N_("Variable")); - for ( size_t v = 0 ; v < ost->n_vars ; ++v ) + for (size_t v = 0 ; v < ost->n_vars ; ++v) { const struct variable *var = ost->vars[v];