New functions to return the sum and weights associated with categorical variables
[pspp-builds.git] / src / math / categoricals.c
index 19b6e3f11907dec4f8e92a43d38d1c8dc7c7182f..d0762831a9b22e8c2766fbbd0010105be5601136 100644 (file)
@@ -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