[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: case_data_rw()
From: |
Jason Stover |
Subject: |
Re: case_data_rw() |
Date: |
Sat, 15 Apr 2006 12:09:27 -0400 |
User-agent: |
Mutt/1.5.10i |
On Fri, Apr 14, 2006 at 10:36:37AM -0700, Ben Pfaff wrote:
> > The LIST command shows nothing but missing values for the new
> > variable. And gdb doesn't follow the program in the casereading
> > loop, so it's hard to see what's going on. (But I can see
> > *lc->residual returns the correct doubles.)
>
> I think there must be some other subtlety that is causing a
> problem. Perhaps you can post the file diff or otherwise
> describe the larger context.
Here's the diff between my copy of regression.q the version currently in CVS.
508,509c508
< int case_num;
< double residual;
---
> unsigned long case_num;
511a511,512
> union value *w_val = NULL;
> struct variable *residuals = NULL;
520a522
> residuals = dict_create_var_assert (default_dict, "residuals", 0);
528c530,531
< for (i = 0; i < n_variables; ++i)
---
> i = 0;
> while (i < n_variables)
533a537
> i = n_variables;
534a539
> i++;
536c541,543
< residual = (*lc->residual) ((const struct variable **)
v_variables,
---
> w_val = case_data_rw (&c, residuals->fv);
> assert (w_val);
> w_val->f = (*lc->residual) ((const struct variable **)
> v_variables,
Here is the syntax I ran:
data list list / v0 to v2.
begin data
0.65377128 7.735648 -23.97588
-0.13087553 6.142625 -19.63854
0.34880368 7.651430 -25.26557
0.69249021 6.125125 -16.57090
-0.07368178 8.245789 -25.80001
-0.34404919 6.031540 -17.56743
0.75981559 9.832291 -28.35977
-0.46958313 5.343832 -16.79548
-0.06108490 8.838262 -29.25689
0.56154863 6.200189 -18.58219
end data
regression /variables=v0 v1 v2 /statistics defaults /dependent=v2
/method=enter /save=residuals.
list.
And here is the listing (without the regression results):
v0 v1 v2 residuals
-------- -------- -------- ---------
.65 7.74 -23.98 .00
-.13 6.14 -19.64 .
.35 7.65 -25.27 .
.69 6.13 -16.57 .
-.07 8.25 -25.80 .
-.34 6.03 -17.57 .
.76 9.83 -28.36 .
-.47 5.34 -16.80 .
-.06 8.84 -29.26 .
.56 6.20 -18.58 .
printf("%f\n",w_val->f) just after the assignment w_val->f = ... shows
the correct value in w_val, but after that it's lost.
It's hard to see what's happening in gdb because case_data_rw() and
case_num() are inline. gdb doesn't follow the source well, and tells
me w_val isn't a symbol, etc. I #define'd DEBUGGING 1 in case.h, but
then dictionary.o would not link. Is it necessary to have the functions
in case.c as inline, given the hassle it causes while debugging?
-Jason