pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: var_create_internal again


From: Ben Pfaff
Subject: Re: var_create_internal again
Date: Sun, 14 Jun 2009 20:11:40 -0700
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Jason Stover <address@hidden> writes:

> How about this: For now, patch var_create_internal to allow for a
> width argument. That will let me finish an initial version of the
> interaction/covariance matrix code and an initial glm.q. Then everyone
> can review it and suggest changes, possibly major ones such as dropping
> the need to look up columns based on particular variables.

This sounds reasonable to me, and since John agrees I pushed the
following change to master:

commit 04c88b897db0d2281faa2829ed57b0f344395b8a
Author: Ben Pfaff <address@hidden>
Date:   Sun Jun 14 20:09:42 2009 -0700

    Allow variables created by var_create_internal to have any width.
    
    Until now, var_create_internal has always created a numeric variable.
    In the long run we wish to phase out the use of internal variables
    entirely, but this change should help Jason get some work done in the
    short term.

diff --git a/src/data/variable.c b/src/data/variable.c
index c0767d7..8d85b51 100644
--- a/src/data/variable.c
+++ b/src/data/variable.c
@@ -149,13 +149,13 @@ var_clone (const struct variable *old_var)
   return new_var;
 }
 
-/* Create a variable to be used for internal calculations only.
-   The variable is assigned a unique dictionary index and a case
-   index of CASE_IDX. */
+/* Create a variable of the specified WIDTH to be used for
+   internal calculations only.  The variable is assigned a unique
+   dictionary index and a case index of CASE_IDX. */
 struct variable *
-var_create_internal (int case_idx)
+var_create_internal (int case_idx, int width)
 {
-  struct variable *v = var_create ("$internal", 0);
+  struct variable *v = var_create ("$internal", width);
   struct vardict_info vdi;
   static int counter = INT_MAX / 2;
 
diff --git a/src/data/variable.h b/src/data/variable.h
index 2752aeb..5d28d5b 100644
--- a/src/data/variable.h
+++ b/src/data/variable.h
@@ -32,7 +32,7 @@ union value;
 struct variable *var_create (const char *name, int width);
 struct variable *var_clone (const struct variable *);
 void var_destroy (struct variable *);
-struct variable *var_create_internal (int case_idx);
+struct variable *var_create_internal (int case_idx, int width);
 
 
 /* Variable names. */
diff --git a/src/language/stats/aggregate.c b/src/language/stats/aggregate.c
index 0d181bd..08d2f5e 100644
--- a/src/language/stats/aggregate.c
+++ b/src/language/stats/aggregate.c
@@ -1105,10 +1105,10 @@ initialize_aggregate_info (struct agr_proc *agr, const 
struct ccase *input)
             proto = caseproto_add_width (proto, 0);
 
            if ( ! iter->subject)
-             iter->subject = var_create_internal (0);
+             iter->subject = var_create_internal (0, 0);
 
            if ( ! iter->weight)
-             iter->weight = var_create_internal (1);
+             iter->weight = var_create_internal (1, 0);
 
             subcase_init_var (&ordering, iter->subject, SC_ASCEND);
            iter->writer = sort_create_writer (&ordering, proto);
diff --git a/src/language/stats/wilcoxon.c b/src/language/stats/wilcoxon.c
index 37d2b19..03a307f 100644
--- a/src/language/stats/wilcoxon.c
+++ b/src/language/stats/wilcoxon.c
@@ -88,7 +88,7 @@ wilcoxon_execute (const struct dataset *ds,
 
   struct wilcoxon_state *ws = xcalloc (sizeof (*ws), t2s->n_pairs);
   const struct variable *weight = dict_get_weight (dict);
-  struct variable *weightx = var_create_internal (WEIGHT_IDX);
+  struct variable *weightx = var_create_internal (WEIGHT_IDX, 0);
   struct caseproto *proto;
 
   input =
@@ -108,8 +108,8 @@ wilcoxon_execute (const struct dataset *ds,
       struct subcase ordering;
       variable_pair *vp = &t2s->pairs[i];
 
-      ws[i].sign = var_create_internal (0);
-      ws[i].absdiff = var_create_internal (1);
+      ws[i].sign = var_create_internal (0, 0);
+      ws[i].absdiff = var_create_internal (1, 0);
 
       r = casereader_create_filter_missing (r, *vp, 2,
                                            exclude,
diff --git a/src/math/interaction.c b/src/math/interaction.c
index c8795ed..133d7d7 100644
--- a/src/math/interaction.c
+++ b/src/math/interaction.c
@@ -83,7 +83,7 @@ interaction_variable_create (const struct variable **vars, 
int n_vars)
            }
        }
     }
-  result->intr = var_create_internal (0);
+  result->intr = var_create_internal (0, 0);
 
   return result;
 }

-- 
Ben Pfaff 
http://benpfaff.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]