X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Fcategoricals.h;h=5e49b4504ab1b9338c19fe089b861fa8d82a328f;hb=142f8f8814423f76523825f8df060e2fa9d2a2b6;hp=d5a8b0df9519b2fbf5f2911a7704bb6a40a6c486;hpb=259b5c32c06fd93964720f4a0e7844b5a24c55db;p=pspp diff --git a/src/math/categoricals.h b/src/math/categoricals.h index d5a8b0df95..5e49b4504a 100644 --- a/src/math/categoricals.h +++ b/src/math/categoricals.h @@ -22,11 +22,10 @@ #include "data/missing-values.h" struct categoricals; -struct variable; struct ccase; struct interaction; - -union value ; +struct variable; +union value; /* Categoricals. @@ -52,17 +51,18 @@ union value ; */ /* Creating and destroying categoricals. */ -struct categoricals *categoricals_create (struct interaction *const*, size_t n_int, - const struct variable *wv, - enum mv_class fctr_excl); +struct categoricals *categoricals_create (struct interaction *const *, + size_t n, + const struct variable *wv, + enum mv_class fctr_excl); void categoricals_destroy (struct categoricals *); /* Updating categoricals. */ -void categoricals_update (struct categoricals *cat, const struct ccase *c); -void categoricals_done (const struct categoricals *cat); -bool categoricals_is_complete (const struct categoricals *cat); +void categoricals_update (struct categoricals *, const struct ccase *); +void categoricals_done (const struct categoricals *); +bool categoricals_is_complete (const struct categoricals *); -/* Counting categories. +/* Categories. A variable's number of categories is the number of unique values observed in the data passed to categoricals_update(). @@ -73,9 +73,11 @@ bool categoricals_is_complete (const struct categoricals *cat); A categorical object's number of categories is the sum of its interactions' categories. */ -/* Return the number of categories (distinct values) for variable N */ -size_t categoricals_n_count (const struct categoricals *cat, size_t n); -size_t categoricals_n_total (const struct categoricals *cat); +size_t categoricals_n_count (const struct categoricals *, size_t idx); +size_t categoricals_n_total (const struct categoricals *); + +union value *categoricals_get_var_values (const struct categoricals *, + const struct variable *, size_t *n); /* Degrees of freedom. @@ -87,10 +89,8 @@ size_t categoricals_n_total (const struct categoricals *cat); A categorical object's degrees of freedom is the sum of its interactions' degrees of freedom. */ -size_t categoricals_df (const struct categoricals *cat, size_t n); -size_t categoricals_df_total (const struct categoricals *cat); - -size_t categoricals_get_n_variables (const struct categoricals *cat); +size_t categoricals_df (const struct categoricals *, size_t idx); +size_t categoricals_df_total (const struct categoricals *); /* Sanity. */ bool categoricals_sane (const struct categoricals *cat); @@ -112,16 +112,18 @@ bool categoricals_sane (const struct categoricals *cat); These functions may be used on an object only after calling categoricals_done(). */ -double categoricals_get_weight_by_subscript (const struct categoricals *cat, int subscript); -const struct interaction *categoricals_get_interaction_by_subscript (const struct categoricals *cat, int subscript); - -double categoricals_get_sum_by_subscript (const struct categoricals *cat, int subscript); -double -categoricals_get_dummy_code_for_case (const struct categoricals *cat, int subscript, - const struct ccase *c); -double -categoricals_get_effects_code_for_case (const struct categoricals *cat, int subscript, - const struct ccase *c); +double categoricals_get_weight_by_subscript (const struct categoricals *, + int subscript); +const struct interaction *categoricals_get_interaction_by_subscript ( + const struct categoricals *, int subscript); +double categoricals_get_sum_by_subscript (const struct categoricals *, + int subscript); +double categoricals_get_dummy_code_for_case (const struct categoricals *, + int subscript, + const struct ccase *); +double categoricals_get_effects_code_for_case (const struct categoricals *, + int subscript, + const struct ccase *); /* "Long map". @@ -138,23 +140,30 @@ categoricals_get_effects_code_for_case (const struct categoricals *cat, int subs These functions may be used on an object only after calling categoricals_done(). */ -const struct ccase * -categoricals_get_case_by_category_real (const struct categoricals *cat, int iact, int n); -void * -categoricals_get_user_data_by_category_real (const struct categoricals *cat, int iact, int n); -void * categoricals_get_user_data_by_category (const struct categoricals *cat, int category); -const struct ccase * categoricals_get_case_by_category (const struct categoricals *cat, int subscript); +const struct ccase *categoricals_get_case_by_category_real ( + const struct categoricals *, int iact, int n); +void *categoricals_get_user_data_by_category_real ( + const struct categoricals *, int iact, int n); -struct payload -{ - void* (*create) (const void *aux1, void *aux2); - void (*update) (const void *aux1, void *aux2, void *user_data, const struct ccase *, double weight); - void (*calculate) (const void *aux1, void *aux2, void *user_data); - void (*destroy) (const void *aux1, void *aux2, void *user_data); -}; +int categoricals_get_value_index_by_category_real ( + const struct categoricals *, int iact_idx, int cat_idx, int var_idx); -void categoricals_set_payload (struct categoricals *cats, const struct payload *p, const void *aux1, void *aux2); +void *categoricals_get_user_data_by_category (const struct categoricals *, + int category); +const struct ccase *categoricals_get_case_by_category ( + const struct categoricals *cat, int subscript); -bool categoricals_isbalanced (const struct categoricals *cat); +struct payload + { + void *(*create) (const void *aux1, void *aux2); + void (*update) (const void *aux1, void *aux2, void *user_data, + const struct ccase *, double weight); + void (*calculate) (const void *aux1, void *aux2, void *user_data); + void (*destroy) (const void *aux1, void *aux2, void *user_data); + }; + +void categoricals_set_payload (struct categoricals *, const struct payload *, + const void *aux1, void *aux2); +bool categoricals_isbalanced (const struct categoricals *); #endif