New functions to return the sum and weights associated with categorical variables fc11-i386-build28 fc11-x64-build25 lenny-x64-build49 sid-i386-build97
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 24 Oct 2009 14:20:10 +0000 (16:20 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 24 Oct 2009 14:20:10 +0000 (16:20 +0200)
src/math/categoricals.c
src/math/categoricals.h

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
index 2cec0b45cd3822ebbc6d7aff70ec34bf4b7ca530..9e58f59eb0c2890bc6260089a1369b4cf9cb5629 100644 (file)
@@ -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