projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Avoid warnings about adjustments with non-zero page sizes
[pspp-builds.git]
/
src
/
math
/
interaction.c
diff --git
a/src/math/interaction.c
b/src/math/interaction.c
index cd151097d6242408c93a31dc877e4f6faffc8345..7fc9f0f63d2c5efee0098f06fe921d50758425e6 100644
(file)
--- a/
src/math/interaction.c
+++ b/
src/math/interaction.c
@@
-15,7
+15,7
@@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/*
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/*
- An interaction is a
gsl_vector
containing a "product" of other
+ An interaction is a
structure
containing a "product" of other
variables. The variables can be either categorical or numeric.
If the variables are all numeric, the interaction is just the
scalar product. If any of the variables are categorical, their
variables. The variables can be either categorical or numeric.
If the variables are all numeric, the interaction is just the
scalar product. If any of the variables are categorical, their
@@
-31,10
+31,9
@@
#include <config.h>
#include <assert.h>
#include <config.h>
#include <assert.h>
-#include <gsl/gsl_math.h>
-#include <gsl/gsl_vector.h>
#include <data/value.h>
#include <data/variable.h>
#include <data/value.h>
#include <data/variable.h>
+#include <gl/unistr.h>
#include <math/interaction.h>
#include <string.h>
#include <xalloc.h>
#include <math/interaction.h>
#include <string.h>
#include <xalloc.h>
@@
-67,10
+66,11
@@
interaction_variable_create (const struct variable **vars, int n_vars)
{
struct interaction_variable *result = NULL;
size_t i;
{
struct interaction_variable *result = NULL;
size_t i;
- int width = 0;
if (n_vars > 0)
{
if (n_vars > 0)
{
+ int width = 0;
+
result = xmalloc (sizeof (*result));
result->n_alpha = 0;
result->members = xnmalloc (n_vars, sizeof (*result->members));
result = xmalloc (sizeof (*result));
result->n_alpha = 0;
result->members = xnmalloc (n_vars, sizeof (*result->members));
@@
-81,11
+81,11
@@
interaction_variable_create (const struct variable **vars, int n_vars)
if (var_is_alpha (vars[i]))
{
result->n_alpha++;
if (var_is_alpha (vars[i]))
{
result->n_alpha++;
- width
= 1
;
+ width
+= var_get_width (vars[i])
;
}
}
}
}
+ result->intr = var_create_internal (0, width);
}
}
- result->intr = var_create_internal (0, width);
return result;
}
return result;
}
@@
-142,29
+142,27
@@
struct interaction_value *
interaction_value_create (const struct interaction_variable *var, const union value **vals)
{
struct interaction_value *result = NULL;
interaction_value_create (const struct interaction_variable *var, const union value **vals)
{
struct interaction_value *result = NULL;
- const struct variable *member;
- size_t i;
- size_t n_vars;
if (var != NULL)
{
if (var != NULL)
{
- int val_width = 1;
- uint8_t *val;
+ size_t i;
+ int val_width = var_get_width (interaction_get_variable (var));
+ int offset = 0;
+ size_t n_vars = interaction_get_n_vars (var);
result = xmalloc (sizeof (*result));
result->intr = var;
result = xmalloc (sizeof (*result));
result->intr = var;
- n_vars = interaction_get_n_vars (var);
+
value_init (&result->val, val_width);
value_init (&result->val, val_width);
- val = value_str_rw (&result->val, val_width);
- val[0] = '\0';
+
result->f = 1.0;
for (i = 0; i < n_vars; i++)
{
result->f = 1.0;
for (i = 0; i < n_vars; i++)
{
- member = interaction_get_member (var, i);
+
const struct variable *
member = interaction_get_member (var, i);
if (var_is_value_missing (member, vals[i], MV_ANY))
{
if (var_is_value_missing (member, vals[i], MV_ANY))
{
- value_set_missing (&result->val,
MAX_SHORT_STRING
);
+ value_set_missing (&result->val,
val_width
);
result->f = SYSMIS;
break;
}
result->f = SYSMIS;
break;
}
@@
-172,10
+170,10
@@
interaction_value_create (const struct interaction_variable *var, const union va
{
if (var_is_alpha (var->members[i]))
{
{
if (var_is_alpha (var->members[i]))
{
+ uint8_t *val = value_str_rw (&result->val, val_width);
int w = var_get_width (var->members[i]);
int w = var_get_width (var->members[i]);
- value_resize (result, val_width, val_width + w);
- strncat (val, value_str (vals[i], w), w);
- val = value_str_rw (&result->val, val_width);
+ u8_cpy (val + offset, value_str (vals[i], w), w);
+ offset += w;
}
else if (var_is_numeric (var->members[i]))
{
}
else if (var_is_numeric (var->members[i]))
{
@@
-214,7
+212,7
@@
interaction_value_get (const struct interaction_value *val)
/*
Returns the numeric value of the non-zero entry for the vector
corresponding to this interaction. Do not use this function to get
/*
Returns the numeric value of the non-zero entry for the vector
corresponding to this interaction. Do not use this function to get
- the numeric value of a pur
le
y numeric interaction. Instead, use the
+ the numeric value of a pur
el
y numeric interaction. Instead, use the
union value * returned by interaction_value_get.
*/
double
union value * returned by interaction_value_get.
*/
double
@@
-230,8
+228,7
@@
interaction_value_destroy (struct interaction_value *val)
{
if (val != NULL)
{
{
if (val != NULL)
{
- size_t n_vars = interaction_get_n_vars (val->intr);
- int val_width = n_vars * MAX_SHORT_STRING + 1;
+ int val_width = var_get_width (interaction_get_variable (val->intr));
value_destroy (&val->val, val_width);
free (val);
value_destroy (&val->val, val_width);
free (val);
@@
-246,12
+243,10
@@
interaction_case_data (const struct ccase *ccase, const struct interaction_varia
{
size_t i;
size_t n_vars;
{
size_t i;
size_t n_vars;
- const struct variable *intr;
const struct variable *member;
const union value **vals = NULL;
n_vars = interaction_get_n_vars (iv);
const struct variable *member;
const union value **vals = NULL;
n_vars = interaction_get_n_vars (iv);
- intr = interaction_get_variable (iv);
vals = xnmalloc (n_vars, sizeof (*vals));
for (i = 0; i < n_vars; i++)
vals = xnmalloc (n_vars, sizeof (*vals));
for (i = 0; i < n_vars; i++)