From 15ad18b01e1d7519be521c31b2a02dc123a1ff69 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 24 Oct 2009 16:20:10 +0200 Subject: [PATCH] New functions to return the sum and weights associated with categorical variables --- src/math/categoricals.c | 21 +++++++++++++++++++++ src/math/categoricals.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/src/math/categoricals.c b/src/math/categoricals.c index 19b6e3f1..d0762831 100644 --- a/src/math/categoricals.c +++ b/src/math/categoricals.c @@ -317,6 +317,27 @@ categoricals_get_value_by_subscript (const struct categoricals *cat, int subscri return &vn->value; } + +double +categoricals_get_weight_by_subscript (const struct categoricals *cat, int subscript) +{ + int vindex = cat->reverse_variable_map[subscript]; + const struct var_params *vp = &cat->vp[vindex]; + + return vp->cc; +} + +double +categoricals_get_sum_by_subscript (const struct categoricals *cat, int subscript) +{ + int vindex = cat->reverse_variable_map[subscript]; + const struct var_params *vp = &cat->vp[vindex]; + + const struct value_node *vn = vp->reverse_value_map [subscript - vp->base_subscript]; + return vn->cc; +} + + /* Returns unity if the value in case C at SUBSCRIPT is equal to the category for that subscript */ double diff --git a/src/math/categoricals.h b/src/math/categoricals.h index 2cec0b45..9e58f59e 100644 --- a/src/math/categoricals.h +++ b/src/math/categoricals.h @@ -51,8 +51,14 @@ const struct variable * categoricals_get_variable_by_subscript (const struct cat const union value * categoricals_get_value_by_subscript (const struct categoricals *cat, int subscript); +double categoricals_get_weight_by_subscript (const struct categoricals *cat, int subscript); + +double categoricals_get_sum_by_subscript (const struct categoricals *cat, int subscript); + double categoricals_get_binary_by_subscript (const struct categoricals *cat, int subscript, const struct ccase *c); + + #endif -- 2.30.2