rc->v = v;
rc->n_categories = 0;
rc->n_allocated_categories = N_INITIAL_CATEGORIES;
- rc->vals = xmalloc (N_INITIAL_CATEGORIES * sizeof (*rc->vals));
+ rc->vals = xnmalloc (N_INITIAL_CATEGORIES, sizeof *rc->vals);
return rc;
}
struct recoded_categorical_array *ca;
struct variable *v;
- ca = (struct recoded_categorical_array *) xmalloc (sizeof (*ca));
+ ca = xmalloc (sizeof *ca);
for (i = 0; i < n_variables; i++)
{
v = v_variables[i];
}
}
ca->n_vars = n_categoricals;
- ca->a = xmalloc (n_categoricals * sizeof (*(ca->a)));
+ ca->a = xnmalloc (n_categoricals, sizeof *ca->a);
for (i = 0; i < n_categoricals; i++)
{
*(ca->a + i) = cr_recoded_categorical_create (v_variables[i]);
if (rc->n_categories >= rc->n_allocated_categories)
{
rc->n_allocated_categories *= 2;
- rc->vals = xrealloc (rc->vals, rc->n_allocated_categories
- * sizeof (*(rc->vals)));
+ rc->vals = xnrealloc (rc->vals,
+ rc->n_allocated_categories, sizeof *rc->vals);
}
rc->vals[rc->n_categories] = *v;
rc->n_categories++;
size_t n_cols = 0;
size_t col;
- dm = xmalloc (sizeof (*dm));
- dm->vars = xmalloc (n_variables * sizeof (struct variable *));
+ dm = xmalloc (sizeof *dm);
+ dm->vars = xnmalloc (n_variables, sizeof *dm->vars);
dm->n_vars = n_variables;
for (i = 0; i < n_variables; i++)
}
}
dm->m = gsl_matrix_calloc (n_data, n_cols);
- dm->vars = xmalloc (dm->n_vars * sizeof (*(dm->vars)));
+ dm->vars = xnmalloc (dm->n_vars, sizeof *dm->vars);
assert (dm->vars != NULL);
col = 0;
tmp = &(dm->vars[col]);
tmp->v = v;
tmp->first_column = col;
+ tmp->last_column = col;
col++;
}
else if (v->type == ALPHA)
/*
Return a pointer to the variable whose values
- are stored in column col.
+ are stored in column col. BUG IN HERE
*/
struct variable *
design_matrix_col_to_var (const struct design_matrix *dm, size_t col)