From: Ben Pfaff Date: Thu, 7 Dec 2006 05:16:33 +0000 (+0000) Subject: Compare variable pointers instead of variable indexes. X-Git-Tag: v0.6.0~666 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c4b7cfcec922cf6d1e92a607f23f00d26e7324e;p=pspp-builds.git Compare variable pointers instead of variable indexes. --- diff --git a/src/language/stats/ChangeLog b/src/language/stats/ChangeLog index 2dfc70b6..c0c9708a 100644 --- a/src/language/stats/ChangeLog +++ b/src/language/stats/ChangeLog @@ -1,3 +1,8 @@ +Wed Dec 6 21:14:26 2006 Ben Pfaff + + * regression.q (reg_inserted): Compare variable pointers instead + of variable indexes. + Mon Dec 4 22:33:46 2006 Ben Pfaff * crosstabs.q (insert_summary): Use var_to_string for labeling. diff --git a/src/language/stats/regression.q b/src/language/stats/regression.q index 7068d7f6..77f577a5 100644 --- a/src/language/stats/regression.q +++ b/src/language/stats/regression.q @@ -722,7 +722,7 @@ reg_inserted (const struct variable *v, struct variable **varlist, int n_vars) for (i = 0; i < n_vars; i++) { - if (v->index == varlist[i]->index) + if (v == varlist[i]) { return 1; } diff --git a/src/math/ChangeLog b/src/math/ChangeLog index 5b05c817..3b01849f 100644 --- a/src/math/ChangeLog +++ b/src/math/ChangeLog @@ -1,3 +1,15 @@ +Wed Dec 6 21:14:59 2006 Ben Pfaff + + * coefficient.c: (pspp_coeff_get_value) Compare variable pointers + instead of variable indexes. + (pspp_linreg_get_coeff) Ditto. + (design_matrix_col_to_var_index) Removed. + (design_matrix_col_to_var) Compare variable pointers + instead of variable indexes. + (cmp_dm_var_index) Ditto. + (design_matrix_var_to_column) Ditto. + (dm_var_to_last_column) Ditto. + Sun Nov 5 08:30:32 WST 2006 John Darrington * levene.c levene.h Changed to use the new casefilter structure. diff --git a/src/math/coefficient.c b/src/math/coefficient.c index f59c3645..e3d9aee1 100644 --- a/src/math/coefficient.c +++ b/src/math/coefficient.c @@ -169,7 +169,7 @@ pspp_coeff_get_value (struct pspp_coeff *c, while (i < c->n_vars) { candidate = pspp_coeff_get_var (c, i); - if (v->index == candidate->index) + if (v == candidate) { return (c->v_info + i)->val; } @@ -201,7 +201,7 @@ pspp_linreg_get_coeff (const pspp_linreg_cache * c, result = c->coeff[i]; tmp = pspp_coeff_get_var (result, 0); - while (tmp->index != v->index && i < c->n_coeffs) + while (tmp != v && i < c->n_coeffs) { result = c->coeff[i]; tmp = pspp_coeff_get_var (result, 0); @@ -221,7 +221,7 @@ pspp_linreg_get_coeff (const pspp_linreg_cache * c, If v is categorical, we need to ensure the coefficient matches the VAL. */ - while (tmp->index != v->index && i < c->n_coeffs + while (tmp != v && i < c->n_coeffs && compare_values (pspp_coeff_get_value (result, tmp), val, var_get_width (v))) { /* FIX THIS */ diff --git a/src/math/design-matrix.c b/src/math/design-matrix.c index 310a2f56..01fdb085 100644 --- a/src/math/design-matrix.c +++ b/src/math/design-matrix.c @@ -146,8 +146,8 @@ design_matrix_destroy (struct design_matrix *dm) Return the index of the variable for the given column. */ -static size_t -design_matrix_col_to_var_index (const struct design_matrix *dm, size_t col) +struct variable * +design_matrix_col_to_var (const struct design_matrix *dm, size_t col) { size_t i; struct design_matrix_var v; @@ -156,42 +156,11 @@ design_matrix_col_to_var_index (const struct design_matrix *dm, size_t col) { v = dm->vars[i]; if (v.first_column <= col && col <= v.last_column) - return (v.v)->index; - } - return DM_INDEX_NOT_FOUND; -} - -/* - Return a pointer to the variable whose values - are stored in column col. - */ -struct variable * -design_matrix_col_to_var (const struct design_matrix *dm, size_t col) -{ - size_t index; - size_t i; - struct design_matrix_var dmv; - - index = design_matrix_col_to_var_index (dm, col); - for (i = 0; i < dm->n_vars; i++) - { - dmv = dm->vars[i]; - if ((dmv.v)->index == index) - { - return (struct variable *) dmv.v; - } + return (struct variable *) v.v; } return NULL; } -static size_t -cmp_dm_var_index (const struct design_matrix_var *dmv, size_t index) -{ - if (dmv->v->index == index) - return 1; - return 0; -} - /* Return the number of the first column which holds the values for variable v. @@ -206,7 +175,7 @@ design_matrix_var_to_column (const struct design_matrix * dm, for (i = 0; i < dm->n_vars; i++) { tmp = dm->vars[i]; - if (cmp_dm_var_index (&tmp, v->index)) + if (tmp.v == v) { return tmp.first_column; } @@ -225,7 +194,7 @@ dm_var_to_last_column (const struct design_matrix *dm, for (i = 0; i < dm->n_vars; i++) { tmp = dm->vars[i]; - if (cmp_dm_var_index (&tmp, v->index)) + if (tmp.v == v) { return tmp.last_column; } diff --git a/src/math/linreg/ChangeLog b/src/math/linreg/ChangeLog index d5cf40fc..0d6b6881 100644 --- a/src/math/linreg/ChangeLog +++ b/src/math/linreg/ChangeLog @@ -1,3 +1,8 @@ +Wed Dec 6 21:16:22 2006 Ben Pfaff + + * linreg.c: (pspp_linreg_get_vars) Compare variable pointers + instead of variable indexes. + 2006-05-19 Jason Stover * coefficient.c: Moved to src/math. diff --git a/src/math/linreg/linreg.c b/src/math/linreg/linreg.c index c717e4ad..6bbd94c5 100644 --- a/src/math/linreg/linreg.c +++ b/src/math/linreg/linreg.c @@ -123,7 +123,7 @@ pspp_linreg_get_vars (const void *c_, struct variable **v) /* Repeated variables are likely to bunch together, at the end of the array. */ i = result - 1; - while (i >= 0 && (v[i]->index != tmp->index)) + while (i >= 0 && v[i] != tmp) { i--; }