X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Foneway.q;h=2c1c19e8d8d77a19b8c1827143207053b90ca069;hb=3542b2c285a83fb43a4b7031c477ab938eaf7c1c;hp=40107f77c877205af42c9555ac1c329f29b39d47;hpb=14aac9fe7a7efbb6c9bded2ed5969a643cb76645;p=pspp-builds.git diff --git a/src/language/stats/oneway.q b/src/language/stats/oneway.q index 40107f77..2c1c19e8 100644 --- a/src/language/stats/oneway.q +++ b/src/language/stats/oneway.q @@ -261,7 +261,7 @@ show_anova_table (void) t = tab_create (n_cols, n_rows, 0); tab_headers (t, 2, 0, 1, 0); - tab_dim (t, tab_natural_dimensions); + tab_dim (t, tab_natural_dimensions, NULL); tab_box (t, @@ -372,7 +372,7 @@ show_descriptives (const struct dictionary *dict) t = tab_create (n_cols, n_rows, 0); tab_headers (t, 2, 0, 2, 0); - tab_dim (t, tab_natural_dimensions); + tab_dim (t, tab_natural_dimensions, NULL); /* Put a frame around the entire box, and vertical lines inside */ @@ -518,7 +518,7 @@ show_homogeneity (void) t = tab_create (n_cols, n_rows, 0); tab_headers (t, 1, 0, 1, 0); - tab_dim (t, tab_natural_dimensions); + tab_dim (t, tab_natural_dimensions, NULL); /* Put a frame around the entire box, and vertical lines inside */ tab_box (t, @@ -571,7 +571,6 @@ show_contrast_coeffs (short *bad_contrast) { int n_cols = 2 + ostensible_number_of_groups; int n_rows = 2 + cmd.sbc_contrast; - union value *group_value; int count = 0; void *const *group_values; @@ -579,7 +578,7 @@ show_contrast_coeffs (short *bad_contrast) t = tab_create (n_cols, n_rows, 0); tab_headers (t, 2, 0, 2, 0); - tab_dim (t, tab_natural_dimensions); + tab_dim (t, tab_natural_dimensions, NULL); /* Put a frame around the entire box, and vertical lines inside */ tab_box (t, @@ -618,13 +617,16 @@ show_contrast_coeffs (short *bad_contrast) count < hsh_count (global_group_hash); ++count) { + double *group_value_p; + union value group_value; int i; struct string vstr; - group_value = group_values[count]; ds_init_empty (&vstr); - var_append_value_name (indep_var, group_value, &vstr); + group_value_p = group_values[count]; + group_value.f = *group_value_p; + var_append_value_name (indep_var, &group_value, &vstr); tab_text (t, count + 2, 1, TAB_CENTER | TAT_TITLE, ds_cstr (&vstr)); @@ -661,7 +663,7 @@ show_contrast_tests (short *bad_contrast) t = tab_create (n_cols, n_rows, 0); tab_headers (t, 3, 0, 1, 0); - tab_dim (t, tab_natural_dimensions); + tab_dim (t, tab_natural_dimensions, NULL); /* Put a frame around the entire box, and vertical lines inside */ tab_box (t, @@ -878,10 +880,25 @@ precalc (struct cmd_oneway *cmd UNUSED) } } +static int +compare_double_3way (const void *a_, const void *b_, const void *aux UNUSED) +{ + const double *a = a_; + const double *b = b_; + return *a < *b ? -1 : *a > *b; +} + +static unsigned +do_hash_double (const void *value_, const void *aux UNUSED) +{ + const double *value = value_; + return hash_double (*value, 0); +} + static void -free_value (void *value_, const void *aux UNUSED) +free_double (void *value_, const void *aux UNUSED) { - union value *value = value_; + double *value = value_; free (value); } @@ -908,9 +925,9 @@ run_oneway (struct cmd_oneway *cmd, taint = taint_clone (casereader_get_taint (input)); global_group_hash = hsh_create (4, - compare_values_short, - hash_value_short, - free_value, + compare_double_3way, + do_hash_double, + free_double, indep_var); precalc (cmd); @@ -931,9 +948,12 @@ run_oneway (struct cmd_oneway *cmd, const double weight = dict_get_case_weight (dict, c, NULL); const union value *indep_val = case_data (c, indep_var); - void **p = hsh_probe (global_group_hash, indep_val); + void **p = hsh_probe (global_group_hash, &indep_val->f); if (*p == NULL) - *p = value_dup (indep_val, var_get_width (indep_var)); + { + double *value = *p = xmalloc (sizeof *value); + *value = indep_val->f; + } for (i = 0; i < n_vars; ++i) {