X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fexamine.q;h=f72a80248b96049ba113aa3dfb09582a84c57539;hb=e7d0a9f16192ceeff9243f0ede8e399ee1ef0d44;hp=aad3baa10fd4380e68b0faddede7d834480b6966;hpb=8444d8d47de5e5f8d076b6f43f73c2c29494031e;p=pspp-builds.git diff --git a/src/language/stats/examine.q b/src/language/stats/examine.q index aad3baa1..f72a8024 100644 --- a/src/language/stats/examine.q +++ b/src/language/stats/examine.q @@ -19,33 +19,36 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include + #include #include +#include #include #include -#include -#include -#include + #include +#include #include +#include +#include +#include #include -#include +#include #include -#include +#include +#include +#include #include +#include #include -#include -#include -#include -#include -#include -#include -#include +#include #include #include #include #include #include +#include +#include #include "gettext.h" #define _(msgid) gettext (msgid) @@ -61,9 +64,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *^variables=custom; +total=custom; +nototal=custom; - +missing=miss:pairwise/!listwise, - rep:report/!noreport, - incl:include/!exclude; + missing=miss:pairwise/!listwise, + rep:report/!noreport, + incl:include/!exclude; +compare=cmp:variables/!groups; +percentiles=custom; +id=var; @@ -107,7 +110,7 @@ static struct factor *factors=0; static struct metrics *totals=0; /* Parse the clause specifying the factors */ -static int examine_parse_independent_vars(struct cmd_examine *cmd); +static int examine_parse_independent_vars (const struct dictionary *dict, struct cmd_examine *cmd); @@ -148,7 +151,8 @@ void box_plot_variables(const struct factor *fctr, /* Per Split function */ -static bool run_examine(const struct casefile *cf, void *cmd_); +static bool run_examine (const struct ccase *, + const struct casefile *cf, void *cmd_, const struct dataset *); static void output_examine(void); @@ -187,14 +191,14 @@ static short sbc_percentile; int -cmd_examine(void) +cmd_examine (struct dataset *ds) { bool ok; subc_list_double_create(&percentile_list); percentile_algorithm = PC_HAVERAGE; - if ( !parse_examine(&cmd) ) + if ( !parse_examine (ds, &cmd, NULL) ) return CMD_FAILURE; /* If /MISSING=INCLUDE is set, then user missing values are ignored */ @@ -218,7 +222,7 @@ cmd_examine(void) subc_list_double_push(&percentile_list, 75); } - ok = multipass_procedure_with_splits (run_examine, &cmd); + ok = multipass_procedure_with_splits (ds, run_examine, &cmd); if ( totals ) { @@ -285,12 +289,13 @@ output_examine(void) { if ( cmd.cmp == XMN_GROUPS ) { - box_plot_group(0, dependent_vars, n_dependent_vars, - cmd.v_id); + box_plot_group (0, (const struct variable **) dependent_vars, + n_dependent_vars, cmd.v_id); } else - box_plot_variables(0, dependent_vars, n_dependent_vars, - cmd.v_id); + box_plot_variables (0, + (const struct variable **) dependent_vars, + n_dependent_vars, cmd.v_id); } if ( cmd.a_plot[XMN_PLT_HISTOGRAM] ) @@ -342,11 +347,13 @@ output_examine(void) if ( cmd.a_plot[XMN_PLT_BOXPLOT] ) { if ( cmd.cmp == XMN_VARIABLES ) - box_plot_variables(fctr, dependent_vars, n_dependent_vars, - cmd.v_id); + box_plot_variables (fctr, + (const struct variable **) dependent_vars, + n_dependent_vars, cmd.v_id); else - box_plot_group(fctr, dependent_vars, n_dependent_vars, - cmd.v_id); + box_plot_group (fctr, + (const struct variable **) dependent_vars, + n_dependent_vars, cmd.v_id); } for ( v = 0 ; v < n_dependent_vars; ++v ) @@ -416,7 +423,8 @@ list_to_ptile_hash(const subc_list_double *l) /* Parse the PERCENTILES subcommand */ static int -xmn_custom_percentiles(struct cmd_examine *p UNUSED) +xmn_custom_percentiles(struct dataset *ds UNUSED, + struct cmd_examine *p UNUSED, void *aux UNUSED) { sbc_percentile = 1; @@ -426,7 +434,7 @@ xmn_custom_percentiles(struct cmd_examine *p UNUSED) while ( lex_is_number() ) { - subc_list_double_push(&percentile_list,lex_number()); + subc_list_double_push (&percentile_list, lex_number()); lex_get(); @@ -457,13 +465,13 @@ xmn_custom_percentiles(struct cmd_examine *p UNUSED) if ( 0 == subc_list_double_count(&percentile_list)) { - subc_list_double_push(&percentile_list, 5); - subc_list_double_push(&percentile_list, 10); - subc_list_double_push(&percentile_list, 25); - subc_list_double_push(&percentile_list, 50); - subc_list_double_push(&percentile_list, 75); - subc_list_double_push(&percentile_list, 90); - subc_list_double_push(&percentile_list, 95); + subc_list_double_push (&percentile_list, 5); + subc_list_double_push (&percentile_list, 10); + subc_list_double_push (&percentile_list, 25); + subc_list_double_push (&percentile_list, 50); + subc_list_double_push (&percentile_list, 75); + subc_list_double_push (&percentile_list, 90); + subc_list_double_push (&percentile_list, 95); } return 1; @@ -471,7 +479,7 @@ xmn_custom_percentiles(struct cmd_examine *p UNUSED) /* TOTAL and NOTOTAL are simple, mutually exclusive flags */ static int -xmn_custom_total(struct cmd_examine *p) +xmn_custom_total (struct dataset *ds UNUSED, struct cmd_examine *p, void *aux UNUSED) { if ( p->sbc_nototal ) { @@ -483,7 +491,8 @@ xmn_custom_total(struct cmd_examine *p) } static int -xmn_custom_nototal(struct cmd_examine *p) +xmn_custom_nototal (struct dataset *ds UNUSED, + struct cmd_examine *p, void *aux UNUSED) { if ( p->sbc_total ) { @@ -499,17 +508,18 @@ xmn_custom_nototal(struct cmd_examine *p) /* Parser for the variables sub command Returns 1 on success */ static int -xmn_custom_variables(struct cmd_examine *cmd ) +xmn_custom_variables(struct dataset *ds, struct cmd_examine *cmd, void *aux UNUSED) { + const struct dictionary *dict = dataset_dict (ds); lex_match('='); - if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL) + if ((token != T_ID || dict_lookup_var (dict, tokid) == NULL) && token != T_ALL) { return 2; } - if (!parse_variables (default_dict, &dependent_vars, &n_dependent_vars, + if (!parse_variables (dict, &dependent_vars, &n_dependent_vars, PV_NO_DUPLICATE | PV_NUMERIC | PV_NO_SCRATCH) ) { free (dependent_vars); @@ -523,7 +533,7 @@ xmn_custom_variables(struct cmd_examine *cmd ) if ( lex_match(T_BY)) { int success ; - success = examine_parse_independent_vars(cmd); + success = examine_parse_independent_vars (dict, cmd); if ( success != 1 ) { free (dependent_vars); free (totals) ; @@ -538,12 +548,12 @@ xmn_custom_variables(struct cmd_examine *cmd ) /* Parse the clause specifying the factors */ static int -examine_parse_independent_vars(struct cmd_examine *cmd) +examine_parse_independent_vars (const struct dictionary *dict, struct cmd_examine *cmd) { int success; struct factor *sf = xmalloc (sizeof *sf); - if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL) + if ((token != T_ID || dict_lookup_var (dict, tokid) == NULL) && token != T_ALL) { free ( sf ) ; @@ -551,7 +561,7 @@ examine_parse_independent_vars(struct cmd_examine *cmd) } - sf->indep_var[0] = parse_variable(); + sf->indep_var[0] = parse_variable (dict); sf->indep_var[1] = 0; if ( token == T_BY ) @@ -559,14 +569,14 @@ examine_parse_independent_vars(struct cmd_examine *cmd) lex_match(T_BY); - if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL) + if ((token != T_ID || dict_lookup_var (dict, tokid) == NULL) && token != T_ALL) { free ( sf ) ; return 2; } - sf->indep_var[1] = parse_variable(); + sf->indep_var[1] = parse_variable (dict); } @@ -585,7 +595,7 @@ examine_parse_independent_vars(struct cmd_examine *cmd) if ( token == '.' || token == '/' ) return 1; - success = examine_parse_independent_vars(cmd); + success = examine_parse_independent_vars (dict, cmd); if ( success != 1 ) free ( sf ) ; @@ -611,7 +621,7 @@ void populate_summary(struct tab_table *t, int col, int row, -static int bad_weight_warn = 1; +static bool bad_weight_warn = true; /* Perform calculations for the sub factors */ @@ -671,17 +681,23 @@ factor_calc(struct ccase *c, int case_no, double weight, int case_missing) } static bool -run_examine(const struct casefile *cf, void *cmd_ ) +run_examine(const struct ccase *first, const struct casefile *cf, + void *cmd_, const struct dataset *ds) { + struct dictionary *dict = dataset_dict (ds); struct casereader *r; struct ccase c; int v; const struct cmd_examine *cmd = (struct cmd_examine *) cmd_; + struct factor *fctr; + + output_split_file_values (ds, first); + /* Make sure we haven't got rubbish left over from a previous split */ - struct factor *fctr = factors; + fctr = factors; while (fctr) { struct factor *next = fctr->next; @@ -693,8 +709,6 @@ run_examine(const struct casefile *cf, void *cmd_ ) fctr = next; } - - for ( v = 0 ; v < n_dependent_vars ; ++v ) metrics_precalc(&totals[v]); @@ -706,7 +720,7 @@ run_examine(const struct casefile *cf, void *cmd_ ) const int case_no = casereader_cnum(r); const double weight = - dict_get_case_weight(default_dict, &c, &bad_weight_warn); + dict_get_case_weight(dict, &c, &bad_weight_warn); if ( cmd->miss == XMN_LISTWISE ) {