From: John Darrington Date: Sat, 24 Oct 2009 14:20:10 +0000 (+0200) Subject: New functions to return the sum and weights associated with categorical variables X-Git-Tag: sid-i386-build97^0 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=15ad18b01e1d7519be521c31b2a02dc123a1ff69;p=pspp-builds.git New functions to return the sum and weights associated with categorical variables --- 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