X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvar.h;h=d7756fce2830ffb134963f9ef51e4cf91f5fcd15;hb=4a529f3eb33c87fa4cf40b9e9464a581312d8e60;hp=277bfde8ad3ccd1f3afda2aa01c2077633f85fe6;hpb=ccf2f45c091ce1555b4e2a36186c501675c18a59;p=pspp diff --git a/src/var.h b/src/var.h index 277bfde8ad..d7756fce28 100644 --- a/src/var.h +++ b/src/var.h @@ -22,7 +22,7 @@ #include #include "format.h" -#include "t-test.h" +#include "group_proc.h" #include "val.h" /* Frequency tables. */ @@ -115,55 +115,12 @@ struct list_proc int vert; /* Whether to print the varname vertically. */ }; -/* DESCRIPTIVES private data. Note that the DESCRIPTIVES procedure also - has a transformation, descriptives_trns. */ -enum - { - /* As these are used as bit indexes, there must be 32 or fewer. - Be very careful in adjusting these, see the structure below - and the table in descriptives.q. */ - dsc_mean = 0, dsc_semean, dsc_stddev, dsc_variance, dsc_kurt, - dsc_sekurt, dsc_skew, dsc_seskew, dsc_range, dsc_min, - dsc_max, dsc_sum, dsc_n_stats - }; - -struct descriptives_proc - { - /* Miscellaneous. */ - int dup; /* Finds duplicates in list of - variables. */ - char zname[10]; /* Name for z-score variable. */ - - /* Counts. */ - double valid, miss; /* Valid, missing--general. */ - - /* Mean, moments about the mean. */ - double X_bar, M2, M3, M4; - double min, max; - - /* Statistics. */ - double stats[dsc_n_stats]; /* Everything glommed together. */ - }; - /* GET private data. */ struct get_proc { int fv, nv; /* First, # of values. */ }; -/* Sort order. */ -enum - { - SRT_ASCEND, /* A, B, C, ..., X, Y, Z. */ - SRT_DESCEND /* Z, Y, X, ..., C, B, A. */ - }; - -/* SORT CASES private data. */ -struct sort_cases_proc - { - int order; /* SRT_ASCEND or SRT_DESCEND. */ - }; - /* MEANS private data. */ struct means_proc { @@ -234,8 +191,6 @@ struct variable int index; /* Index into its dictionary's var[]. */ int type; /* NUMERIC or ALPHA. */ - /* Also important but parse_variables() doesn't need it. Still, - check before reordering. */ int width; /* Size of string variables in chars. */ int fv, nv; /* Index into `value's, number of values. */ unsigned init : 1; /* 1=VFM must init and possibly reinit. */ @@ -250,7 +205,7 @@ struct variable struct fmt_spec write; /* Default format for WRITE. */ /* Labels. */ - struct val_labs *val_labs; + struct val_labs *val_labs; /* Value labels. */ char *label; /* Variable label. */ /* Per-procedure info. */ @@ -259,14 +214,12 @@ struct variable union { struct crosstab_proc crs; - struct descriptives_proc dsc; struct frequencies_proc frq; struct list_proc lst; struct means_proc mns; - struct sort_cases_proc srt; struct matrix_data_proc mxd; struct match_files_proc mtf; - struct t_test_proc t_t; + struct group_proc grp_data; } p; }; @@ -294,15 +247,6 @@ struct vector int cnt; /* Number of variables. */ }; -/* Cases. */ - -/* A single case. (This doesn't need to be a struct anymore, but it - remains so for hysterical raisins.) */ -struct ccase - { - union value data[1]; - }; - /* Dictionary. */ /* Complete dictionary state. */ @@ -340,8 +284,10 @@ int dict_rename_vars (struct dictionary *, struct variable **, char **new_names, size_t count, char **err_name); +struct ccase; struct variable *dict_get_weight (const struct dictionary *); -double dict_get_case_weight (const struct dictionary *, const struct ccase *); +double dict_get_case_weight (const struct dictionary *, + const struct ccase *, int *); void dict_set_weight (struct dictionary *, struct variable *); struct variable *dict_get_filter (const struct dictionary *); @@ -352,7 +298,10 @@ void dict_set_case_limit (struct dictionary *, int); int dict_get_next_value_idx (const struct dictionary *); size_t dict_get_case_size (const struct dictionary *); + void dict_compact_values (struct dictionary *); +size_t dict_get_compacted_value_cnt (const struct dictionary *); +int *dict_get_compacted_idx_to_fv (const struct dictionary *); struct variable *const *dict_get_split_vars (const struct dictionary *); size_t dict_get_split_cnt (const struct dictionary *); @@ -412,6 +361,7 @@ void cancel_temporary (void); /* Functions. */ void dump_split_vars (const struct ccase *); +typedef int (* is_missing_func )(const union value *, const struct variable *); int is_num_user_missing (double, const struct variable *); int is_str_user_missing (const unsigned char[], const struct variable *); @@ -422,17 +372,16 @@ void copy_missing_values (struct variable *dest, const struct variable *src); /* Transformations. */ +struct trns_header; +typedef int trns_proc_func (struct trns_header *, struct ccase *, int); +typedef void trns_free_func (struct trns_header *); + /* Header for all transformations. */ struct trns_header { - /* Index into t_trns[]. */ - int index; - - /* Transformation proc. */ - int (*proc) (struct trns_header *, struct ccase *); - - /* Garbage collector proc. */ - void (*free) (struct trns_header *); + int index; /* Index into t_trns[]. */ + trns_proc_func *proc; /* Transformation proc. */ + trns_free_func *free; /* Garbage collector proc. */ }; /* Array of transformations */ @@ -450,14 +399,15 @@ void cancel_transformations (void); struct var_set; -struct var_set *var_set_create_from_dict (struct dictionary *d); -struct var_set *var_set_create_from_array (struct variable **var, size_t); +struct var_set *var_set_create_from_dict (const struct dictionary *d); +struct var_set *var_set_create_from_array (struct variable *const *var, + size_t); -size_t var_set_get_cnt (struct var_set *vs); -struct variable *var_set_get_var (struct var_set *vs, size_t idx); -struct variable *var_set_lookup_var (struct var_set *vs, const char *name); +size_t var_set_get_cnt (const struct var_set *vs); +struct variable *var_set_get_var (const struct var_set *vs, size_t idx); +struct variable *var_set_lookup_var (const struct var_set *vs, + const char *name); void var_set_destroy (struct var_set *vs); - /* Variable parsers. */ @@ -471,16 +421,25 @@ enum PV_NUMERIC = 0020, /* Vars must be numeric. */ PV_STRING = 0040, /* Vars must be string. */ PV_SAME_TYPE = 00100, /* All vars must be the same type. */ - PV_NO_SCRATCH = 00200, /* Disallow scratch variables. */ + PV_NO_SCRATCH = 00200 /* Disallow scratch variables. */ }; struct variable *parse_variable (void); -struct variable *parse_dict_variable (struct dictionary *); -int parse_variables (struct dictionary *, struct variable ***, int *, +struct variable *parse_dict_variable (const struct dictionary *); +int parse_variables (const struct dictionary *, struct variable ***, int *, int opts); -int parse_var_set_vars (struct var_set *, struct variable ***, int *, +int parse_var_set_vars (const struct var_set *, struct variable ***, int *, int opts); int parse_DATA_LIST_vars (char ***names, int *cnt, int opts); int parse_mixed_vars (char ***names, int *cnt, int opts); + + +/* Return a string representing this variable, in the form most + appropriate from a human factors perspective. + (IE: the label if it has one, otherwise the name ) +*/ +const char * var_to_string(const struct variable *var); + + #endif /* !var_h */