Jason Stover <[EMAIL PROTECTED]> writes:

> I have added the following two pieces of information
> to the variable structure:
>
>     /* Values of a categorical variable which are in the active
>        file. Procedures need vectors with binary entries, so any
>        variable of type ALPHA will have its values stored here. */
>     struct cat_vals *obs_vals;
>     bool values_stored; /* True if a variables' values are encoded in
>                            obs_vals.  A procedure may create
>                            obs_vals, then another procedure may
>                            destroy it. If values_stored is true, the
>                            procedure that needs the encoding does not
>                            need to pass the data again to find the
>                            encoding. If values_stored is false, the
>                            procedure must make an extra data pass.
>                         */
>
> This makes the binary encoding MUCH easier for
> any modeling procedure. It allowed me to simplify cat.c. I was
> going to keep a more complicated data structure inside the
> variable struct, as described in earlier email, but that seems
> to be overly complex overkill at this time. 

Seems okay to me.

Is it necessary to have two members?  Seems to me that just
obs_vals by itself would be enough.  If it's null, there are no
values.

> In addition to adding the above information to a variable 
> structure in var.h, I need to add two lines like this:
>
>       v->obs_vals = NULL;
>       v->values_stored = false;
>
> anywhere a variable struct * v is created. Where are the variables
> allocated, and may I add such information without stepping an anyone's
> toes?

dict_create_var() and dict_delete_var() are the main places that
variables are created and destroyed.  There might be other spots
but I think I've killed all of those by now.

> Those two modifications (the first to var.h, the second to the place
> where variables are allocated) are the only changes I need to make.
>
> Transformations that alter categorical variables can drop this info
> by just setting v->values_stored to false and destroying v->obs_vals.

I'd add a function for doing that and put a call to it in
dict_delete_var().
-- 
Ben Pfaff 
email: [EMAIL PROTECTED]
web: http://benpfaff.org


_______________________________________________
pspp-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/pspp-dev

Reply via email to