#include <stddef.h>
#include "format.h"
#include "t-test.h"
+#include "val.h"
-/* Values. */
-
-/* Max length of a short string value, generally 8 chars. */
-#define MAX_SHORT_STRING ((SIZEOF_DOUBLE)>=8 ? ((SIZEOF_DOUBLE)+1)/2*2 : 8)
-#define MIN_LONG_STRING (MAX_SHORT_STRING+1)
-
-/* Max string length. */
-#define MAX_STRING 255
-
-/* FYI: It is a bad situation if sizeof(flt64) < MAX_SHORT_STRING:
- then short string missing values can be truncated in system files
- because there's only room for as many characters as can fit in a
- flt64. */
-#if MAX_SHORT_STRING > 8
-#error MAX_SHORT_STRING must be less than 8.
-#endif
-
-/* Special values. */
-#define SYSMIS (-DBL_MAX)
-#define LOWEST second_lowest_value
-#define HIGHEST DBL_MAX
-
-/* Describes one value, which is either a floating-point number or a
- short string. */
-union value
- {
- /* A numeric value. */
- double f;
-
- /* A short-string value. */
- unsigned char s[MAX_SHORT_STRING];
-
- /* Used by evaluate_expression() to return a string result.
- As currently implemented, it's a pointer to a dynamic
- buffer in the appropriate expression.
-
- Also used by the AGGREGATE procedure in handling string
- values. */
- unsigned char *c;
- };
-
-/* Maximum number of `union value's in a single number or string
- value. */
-#define MAX_ELEMS_PER_VALUE (MAX_STRING / sizeof (union value) + 1)
-
-int compare_values (union value *a, union value *b, int width);
-\f
/* Frequency tables. */
/* Frequency table entry. */
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
{
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. */
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;
{
union value data[1];
};
+
+/* Linked list of cases. */
+struct case_list
+ {
+ struct case_list *next;
+ struct ccase c;
+ };
\f
/* Dictionary. */
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 *);
/* 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 *);
\f
/* 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 */
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);
void var_set_destroy (struct var_set *vs);
-
\f
/* Variable parsers. */
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);