return c->values[idx].f;
}
+/* Returns a pointer to the `double' in the `union value' in C for variable V.
+ The caller is allowed to modify the returned data.
+
+ Case C must be drawn from V's dictionary and must not be shared. */
+double *
+case_num_rw (struct ccase *c, const struct variable *v)
+{
+ assert_variable_matches_case (c, v);
+ assert (!case_is_shared (c));
+ return &c->values[var_get_case_index (v)].f;
+}
+
+/* Returns a pointer to the `double' in the `union value' in C numbered IDX.
+ The caller is allowed to modify the returned data.
+
+ Case C must not be shared. */
+double *
+case_num_rw_idx (struct ccase *c, size_t idx)
+{
+ assert (!case_is_shared (c));
+ return &c->values[idx].f;
+}
+
/* Returns the string value of the `union value' in C for
variable V. Case C must be drawn from V's dictionary. The
caller must not modify the return value.
return c->values[idx].s;
}
+/* Returns a substring for the `union value' in C for variable V. Case C must
+ be drawn from V's dictionary. */
+struct substring
+case_ss (const struct ccase *c, const struct variable *v)
+{
+ assert_variable_matches_case (c, v);
+ return ss_buffer (CHAR_CAST (char *, c->values[var_get_case_index (v)].s),
+ var_get_width (v));
+}
+
+/* Returns a substring for the `union value' in C numbered IDX. WIDTH must be
+ the value's width. */
+struct substring
+case_ss_idx (const struct ccase *c, size_t width, size_t idx)
+{
+ assert (width > 0);
+ assert (idx < c->proto->n_widths);
+ return ss_buffer (CHAR_CAST (char *, c->values[idx].s), width);
+}
+
/* Returns the string value of the `union value' in C for
variable V. Case C must be drawn from V's dictionary. The
caller may modify the return value.
#include <stdlib.h>
#include "libpspp/compiler.h"
+#include "libpspp/str.h"
#include "data/caseproto.h"
struct variable;
double case_num (const struct ccase *, const struct variable *);
double case_num_idx (const struct ccase *, size_t idx);
+double *case_num_rw (struct ccase *, const struct variable *);
+double *case_num_rw_idx (struct ccase *, size_t idx);
const uint8_t *case_str (const struct ccase *, const struct variable *);
const uint8_t *case_str_idx (const struct ccase *, size_t idx);
+struct substring case_ss (const struct ccase *, const struct variable *);
+struct substring case_ss_idx (const struct ccase *, size_t width, size_t idx);
uint8_t *case_str_rw (struct ccase *, const struct variable *);
uint8_t *case_str_rw_idx (struct ccase *, size_t idx);
This function should be used before attempting to modify any
of the data in a case that might be shared, e.g.:
c = case_unshare (c); // Make sure that C is not shared.
- case_data_rw (c, myvar)->f = 1; // Modify data in C.
+ *case_num_rw (c, myvar) = 1; // Modify data in C.
*/
static inline struct ccase *
case_unshare (struct ccase *c)
struct casereader_append_numeric *can = can_;
double new_value = can->func (c, can->n++, can->aux);
c = case_unshare_and_resize (c, can->proto);
- case_data_rw_idx (c, caseproto_get_n_widths (can->proto) - 1)->f = new_value;
+ *case_num_rw_idx (c, caseproto_get_n_widths (can->proto) - 1) = new_value;
return c;
}
{
struct casereader_append_rank *car = car_;
- const double value = case_data (input, car->var)->f;
+ const double value = case_num (input, car->var);
if (car->prev_value != SYSMIS)
{
double weight = 1.0;
if (car->weight)
{
- weight = case_data (input, car->weight)->f;
+ weight = case_num (input, car->weight);
if (car->err && weight < 0)
*car->err |= RANK_ERR_NEGATIVE_WEIGHT;
}
struct ccase *c = casereader_peek (car->clone, car->n + ++k);
if (c == NULL)
break;
- vxx = case_data (c, car->var)->f;
+ vxx = case_num (c, car->var);
if (vxx == value)
{
if (car->weight)
{
- double w = case_data (c, car->weight)->f;
+ double w = case_num (c, car->weight);
if (car->err && w < 0)
*car->err |= RANK_ERR_NEGATIVE_WEIGHT;
car->n++;
input = case_unshare_and_resize (input, car->proto);
- case_data_rw_idx (input, caseproto_get_n_widths (car->proto) - 1)->f
+ *case_num_rw_idx (input, caseproto_get_n_widths (car->proto) - 1)
= car->mean_rank;
car->prev_value = value;
return input;
struct consolidator *cdr = aux;
const union value *current_value = case_data (c, cdr->key);
const int key_width = var_get_width (cdr->key);
- const double weight = cdr->weight ? case_data (c, cdr->weight)->f : 1.0;
+ const double weight = cdr->weight ? case_num (c, cdr->weight) : 1.0;
struct ccase *next_case = casereader_peek (cdr->clone, cdr->n + 1);
int dir = 0;
if (cdr->weight)
{
c = case_unshare (input);
- case_data_rw (c, cdr->weight)->f = cdr->prev_cc;
+ *case_num_rw (c, cdr->weight) = cdr->prev_cc;
}
else
{
c = case_unshare_and_resize (input, cdr->proto);
- case_data_rw_idx (c, caseproto_get_n_widths (cdr->proto) - 1)->f = cdr->prev_cc;
+ *case_num_rw_idx (c, caseproto_get_n_widths (cdr->proto) - 1) = cdr->prev_cc;
}
return c;
struct variable *var = var_;
*cc = case_unshare (*cc);
- case_data_rw (*cc, var)->f = case_num;
+ *case_num_rw (*cc, var) = case_num;
return TRNS_CONTINUE;
}
int width = caseproto_get_width (r->proto, i);
if (width == 0)
- case_data_rw_idx (c, i)->f = read_float (r);
+ *case_num_rw_idx (c, i) = read_float (r);
else
{
uint8_t buf[256];
/* Even if the loop is never entered, set the index
variable to the initial value. */
*c = case_unshare (*c);
- case_data_rw (*c, loop->index_var)->f = loop->cur;
+ *case_num_rw (*c, loop->index_var) = loop->cur;
/* Throw out pathological cases. */
if (!isfinite (loop->cur) || !isfinite (loop->by)
|| (loop->by < 0.0 && loop->cur < loop->last))
goto break_out;
*c = case_unshare (*c);
- case_data_rw (*c, loop->index_var)->f = loop->cur;
+ *case_num_rw (*c, loop->index_var) = loop->cur;
}
if (loop->loop_condition != NULL
{
struct comb_file *file = &proc->files[i];
if (file->in_var != NULL)
- case_data_rw (output, file->in_var)->f = false;
+ *case_num_rw (output, file->in_var) = false;
}
return output;
}
mark_file_used (const struct comb_file *file, struct ccase *output)
{
if (file->in_var != NULL)
- case_data_rw (output, file->in_var)->f = true;
+ *case_num_rw (output, file->in_var) = true;
}
/* Copies the data from FILE's case into output case OUTPUT.
{
new_BY = !subcase_equal_xx (&proc->by_vars, proc->prev_BY, by);
if (proc->last != NULL)
- case_data_rw (proc->buffered_case, proc->last)->f = new_BY;
+ *case_num_rw (proc->buffered_case, proc->last) = new_BY;
casewriter_write (proc->output, proc->buffered_case);
}
else
proc->buffered_case = output;
if (proc->first != NULL)
- case_data_rw (proc->buffered_case, proc->first)->f = new_BY;
+ *case_num_rw (proc->buffered_case, proc->first) = new_BY;
if (new_BY)
{
if (proc->prev_BY != NULL)
{
if (proc->last != NULL)
- case_data_rw (proc->buffered_case, proc->last)->f = 1.0;
+ *case_num_rw (proc->buffered_case, proc->last) = 1.0;
casewriter_write (proc->output, proc->buffered_case);
proc->buffered_case = NULL;
}
/* If there was an END subcommand handle it. */
if (trns->end != NULL)
{
- double *end = &case_data_rw (*c, trns->end)->f;
+ double *end = case_num_rw (*c, trns->end);
if (retval == TRNS_END_FILE)
{
*end = 1.0;
for (col = 0; col < n_vars; ++col)
{
const struct variable *cv = vars [col];
- double x = case_data (c, cv)->f;
+ double x = case_num (c, cv);
assert (col < (*matrix)->size2);
assert (mrow < (*matrix)->size1);
gsl_matrix_set (*matrix, mrow, col, x);
cout = case_create (casewriter_get_proto (iter->writer));
- case_data_rw (cout, iter->subject)->f
- = case_data (input, iter->src)->f;
+ *case_num_rw (cout, iter->subject) = case_num (input, iter->src);
wv = dict_get_case_weight (agr->src_dict, input, NULL);
- case_data_rw (cout, iter->weight)->f = wv;
+ *case_num_rw (cout, iter->weight) = wv;
iter->cc += wv;
size_t hash = value_hash (value, width, 0);
const struct arc_item *item = find_arc_item (spec->items, value, width,
hash);
- case_data_rw (*c, spec->dst)->f = item ? item->to : SYSMIS;
+ *case_num_rw (*c, spec->dst) = item ? item->to : SYSMIS;
}
return TRNS_CONTINUE;
for (; (c = casereader_read (input)); case_unref (c))
{
double case_hits = 0.0;
- const double w = weight ? case_data (c, weight)->f: 1.0;
+ const double w = weight ? case_num (c, weight) : 1.0;
for (v = 0; v < ct->n_vars; ++v)
{
const struct variable *var = ct->vars[v];
const struct dsc_z_score *z;
for (z = t->z_scores; z < t->z_scores + t->z_score_cnt; z++)
- case_data_rw (c, z->z_var)->f = SYSMIS;
+ *case_num_rw (c, z->z_var) = SYSMIS;
}
/* Transformation function to calculate Z-scores. Will return SYSMIS if any of
for (z = t->z_scores; z < t->z_scores + t->z_score_cnt; z++)
{
double input = case_num (*c, z->src_var);
- double *output = &case_data_rw (*c, z->z_var)->f;
+ double *output = case_num_rw (*c, z->z_var);
if (z->mean == SYSMIS || z->std_dev == SYSMIS
|| var_is_num_missing (z->src_var, input, t->exclude))
{
c = case_create (casewriter_get_proto (dsc->z_writer));
z_idx = 0;
- case_data_rw_idx (c, z_idx++)->f = count;
+ *case_num_rw_idx (c, z_idx++) = count;
}
else
c = NULL;
if (dv->z_name && c != NULL)
{
- case_data_rw_idx (c, z_idx++)->f = dv->stats[DSC_MEAN];
- case_data_rw_idx (c, z_idx++)->f = dv->stats[DSC_STDDEV];
+ *case_num_rw_idx (c, z_idx++) = dv->stats[DSC_MEAN];
+ *case_num_rw_idx (c, z_idx++) = dv->stats[DSC_STDDEV];
}
}
{
struct ccase *outcase ;
const struct variable *var = examine->dep_vars[v];
- const double x = case_data (c, var)->f;
+ const double x = case_num (c, var);
if (var_is_value_missing (var, case_data (c, var), examine->dep_excl))
{
/* Save the value and the ID to the writer */
assert (examine->id_idx != -1);
- case_data_rw_idx (outcase, EX_VAL)->f = x;
+ *case_num_rw_idx (outcase, EX_VAL) = x;
value_copy (case_data_rw_idx (outcase, EX_ID),
case_data_idx (c, examine->id_idx), examine->id_width);
- case_data_rw_idx (outcase, EX_WT)->f = weight;
+ *case_num_rw_idx (outcase, EX_WT) = weight;
es[v].cc += weight;
for (reader = casereader_clone (es[v].sorted_reader);
(c = casereader_read (reader)) != NULL; case_unref (c))
{
- const double val = case_data_idx (c, EX_VAL)->f;
- double wt = case_data_idx (c, EX_WT)->f;
+ const double val = case_num_idx (c, EX_VAL);
+ double wt = case_num_idx (c, EX_WT);
wt = var_force_valid_weight (examine->wv, wt, &warn);
moments_pass_two (es[v].mom, val, wt);
flip->error = true;
return NULL;
}
- case_data_rw_idx (c, i + 1)->f = in;
+ *case_num_rw_idx (c, i + 1) = in;
}
flip->cases_read++;
double prev_x = SYSMIS;
int run_length = 0;
- const double w = weight ? case_data (c, weight)->f: 1.0;
+ const double w = weight ? case_num (c, weight) : 1.0;
fr.cc += w;
double weight = dict_get_case_weight (dict, c, &warn_bad_weight);
for (v = 0; v < cmd->n_dep_vars; ++v)
- moments_pass_one (ws.totals, case_data (c, cmd->dep_vars[v])->f,
- weight);
+ moments_pass_one (ws.totals, case_num (c, cmd->dep_vars[v]), weight);
covariance_accumulate_pass1 (cov, c);
}
double weight = dict_get_case_weight (dict, c, &warn_bad_weight);
for (v = 0; v < cmd->n_dep_vars; ++v)
- moments_pass_two (ws.totals, case_data (c, cmd->dep_vars[v])->f,
- weight);
+ moments_pass_two (ws.totals, case_num (c, cmd->dep_vars[v]), weight);
covariance_accumulate_pass2 (cov, c);
}
for (;(c = casereader_read (input)) != NULL; case_unref (c))
{
- const double x = case_data_idx (c, HG_IDX_X)->f;
- const double weight = case_data_idx (c, HG_IDX_WT)->f;
+ const double x = case_num_idx (c, HG_IDX_X);
+ const double weight = case_num_idx (c, HG_IDX_WT);
moments_pass_two (cmd->es[0].mom, x, weight);
histogram_add (histogram, x, weight);
}
{
const double weight = dict_get_case_weight (cmd->dict,c,NULL);
const double x = (cmd->n_dep_vars > 0)
- ? case_data (c, cmd->dep_vars[0])->f : SYSMIS;
+ ? case_num (c, cmd->dep_vars[0]) : SYSMIS;
cc += weight;
struct ccase *outcase = case_create (cmd->gr_proto);
const double weight = dict_get_case_weight (cmd->dict,c,NULL);
if (cmd->chart_type == CT_HISTOGRAM)
- case_data_rw_idx (outcase, HG_IDX_WT)->f = weight;
+ *case_num_rw_idx (outcase, HG_IDX_WT) = weight;
if (cmd->chart_type == CT_SCATTERPLOT && cmd->n_by_vars > 0)
value_copy (case_data_rw_idx (outcase, SP_IDX_BY),
case_data (c, cmd->by_var[0]),
for(int v=0;v<cmd->n_dep_vars;v++)
{
const struct variable *var = cmd->dep_vars[v];
- const double x = case_data (c, var)->f;
+ const double x = case_num (c, var);
if (var_is_value_missing (var, case_data (c, var), cmd->dep_excl))
{
continue;
}
/* Magically v value fits to SP_IDX_X, SP_IDX_Y, HG_IDX_X */
- case_data_rw_idx (outcase, v)->f = x;
+ *case_num_rw_idx (outcase, v) = x;
if (x > cmd->es[v].maximum)
cmd->es[v].maximum = x;
{
struct ccase *c1;
struct casereader *r1 = casereader_clone (grp1->reader);
- double x0 = case_data_idx (c0, 0)->f;
- double cc0 = case_data_idx (c0, 1)->f;
+ double x0 = case_num_idx (c0, 0);
+ double cc0 = case_num_idx (c0, 1);
double w0 = cc0 - prev_cc0;
double prev_cc1 = 0;
for (; (c1 = casereader_read (r1)); case_unref (c1))
{
- double x1 = case_data_idx (c1, 0)->f;
- double cc1 = case_data_idx (c1, 1)->f;
+ double x1 = case_num_idx (c1, 0);
+ double cc1 = case_num_idx (c1, 1);
if (x0 > x1)
{
for (; (c = casereader_read (r)); case_unref (c))
{
- double w = case_data_idx (c, w_idx)->f;
+ double w = case_num_idx (c, w_idx);
for (i = 0; i < n; ++i)
result[i] += f[i] (w);
for (; (c = casereader_read (group)); case_unref (c))
{
struct ccase *c_out = case_create (proto);
- const union value *x = case_data (c, nst->vars[v]);
- case_data_rw_idx (c_out, 0)->f = x->f;
+ *case_num_rw_idx (c_out, 0) = case_num (c, nst->vars[v]);
cc += dict_get_case_weight (dict, c, &warn);
- case_data_rw_idx (c_out, 1)->f = cc;
+ *case_num_rw_idx (c_out, 1) = cc;
casewriter_write (writer, c_out);
}
value_hash (&rank->group, group_var_width, 0));
}
- rank->sum_of_ranks += case_data_idx (c, rank_idx)->f;
+ rank->sum_of_ranks += case_num_idx (c, rank_idx);
rank->n += dict_get_case_weight (dict, c, &warn);
/* If this assertion fires, then either the data wasn't sorted or some other
{
/* Values of the scalar predictor variables */
if (index < n_x)
- return case_data (c, x[index])->f;
+ return case_num (c, x[index]);
/* Coded values of categorical predictor variables (or interactions) */
if (cats && index - n_x < categoricals_df_total (cats))
{
const union value *group = case_data (c, nst->indep_var);
const size_t group_var_width = var_get_width (nst->indep_var);
- const double rank = case_data_idx (c, rank_idx)->f;
+ const double rank = case_num_idx (c, rank_idx);
if (value_equal (group, &nst->val1, group_var_width))
{
NULL);
stat_update *su = cell_spec[means->statistics[stat]].su;
su (cell->stat[stat + v * means->n_statistics], weight,
- case_data (c, dep_var)->f);
+ case_num (c, dep_var));
}
}
}
}
long *n = gsl_vector_long_ptr (kmeans->num_elements_groups, group);
- *n += qc->wv ? case_data (c, qc->wv)->f : 1.0;
+ *n += qc->wv ? case_num (c, qc->wv) : 1.0;
kmeans->n++;
for (j = 0; j < qc->n_vars; ++j)
if (var_is_value_missing (qc->vars[j], val, qc->exclude))
continue;
double *x = gsl_matrix_ptr (kmeans->updated_centers, group, j);
- *x += val->f * (qc->wv ? case_data (c, qc->wv)->f : 1.0);
+ *x += val->f * (qc->wv ? case_num (c, qc->wv) : 1.0);
}
}
}
long *n = gsl_vector_long_ptr (kmeans->num_elements_groups, group);
- *n += qc->wv ? case_data (c, qc->wv)->f : 1.0;
+ *n += qc->wv ? case_num (c, qc->wv) : 1.0;
kmeans->n++;
}
casereader_destroy (cs);
*c = case_unshare (*c);
if (std->CASE_IDX_MEMBERSHIP >= 0)
- case_data_rw (*c, std->membership)->f = case_data_idx (ca, std->CASE_IDX_MEMBERSHIP)->f;
+ *case_num_rw (*c, std->membership) = case_num_idx (ca, std->CASE_IDX_MEMBERSHIP);
if (std->CASE_IDX_DISTANCE >= 0)
- case_data_rw (*c, std->distance)->f = case_data_idx (ca, std->CASE_IDX_DISTANCE)->f;
+ *case_num_rw (*c, std->distance) = case_num_idx (ca, std->CASE_IDX_DISTANCE);
case_unref (ca);
/* Calculate the membership and distance values. */
struct ccase *outc = case_create (proto);
if (qc->save_values & SAVE_MEMBERSHIP)
- case_data_rw_idx (outc, qc->save_trans_data->CASE_IDX_MEMBERSHIP)->f = cluster + 1;
+ *case_num_rw_idx (outc, qc->save_trans_data->CASE_IDX_MEMBERSHIP) = cluster + 1;
if (qc->save_values & SAVE_DISTANCE)
- case_data_rw_idx (outc, qc->save_trans_data->CASE_IDX_DISTANCE)->f
+ *case_num_rw_idx (outc, qc->save_trans_data->CASE_IDX_DISTANCE)
= sqrt (dist_from_case (kmeans, c, qc, clust));
casewriter_write (qc->save_trans_data->writer, outc);
size_t i;
out_case = case_create (casewriter_get_proto (output));
- case_data_rw_idx (out_case, 0)->f = case_num_idx (c, 1);
+ *case_num_rw_idx (out_case, 0) = case_num_idx (c, 1);
for (i = 0; i < cmd->n_rs; ++i)
{
rank_function_t func = rank_func[cmd->rs[i].rfunc];
double rank = func (cmd, tw, cc, cc_1, tie_group, w);
- case_data_rw_idx (out_case, i + 1)->f = rank;
+ *case_num_rw_idx (out_case, i + 1) = rank;
}
casewriter_write (output, out_case);
size_t i;
for (i = 0; i < trns->n_funcs; i++)
- case_data_rw (*c, iv->output_vars[i])->f
+ *case_num_rw (*c, iv->output_vars[i])
= case_num_idx (iv->current, i + 1);
advance_ranking (iv);
break;
{
if (ws->pred_idx != -1)
{
- double pred = case_data_idx (in, ws->extras * k + ws->pred_idx)->f;
- case_data_rw (*c, ws->predvars[k])->f = pred;
+ double pred = case_num_idx (in, ws->extras * k + ws->pred_idx);
+ *case_num_rw (*c, ws->predvars[k]) = pred;
}
if (ws->res_idx != -1)
{
- double resid = case_data_idx (in, ws->extras * k + ws->res_idx)->f;
- case_data_rw (*c, ws->residvars[k])->f = resid;
+ double resid = case_num_idx (in, ws->extras * k + ws->res_idx);
+ *case_num_rw (*c, ws->residvars[k]) = resid;
}
}
case_unref (in);
if (cmd->pred)
{
double pred = linreg_predict (models[k], vals, n_indep);
- case_data_rw_idx (outc, k * ws->extras + ws->pred_idx)->f = pred;
+ *case_num_rw_idx (outc, k * ws->extras + ws->pred_idx) = pred;
}
if (cmd->resid)
{
- double obs = case_data (c, linreg_dep_var (models[k]))->f;
+ double obs = case_num (c, linreg_dep_var (models[k]));
double res = linreg_residual (models[k], obs, vals, n_indep);
- case_data_rw_idx (outc, k * ws->extras + ws->res_idx)->f = res;
+ *case_num_rw_idx (outc, k * ws->extras + ws->res_idx) = res;
}
free (vals);
free (vars);
double sum = 0;
const struct cronbach *s = aux;
- int v;
- for (v = 0 ; v < s->n_items; ++v)
- {
- sum += case_data (c, s->items[v])->f;
- }
+ for (int v = 0 ; v < s->n_items; ++v)
+ sum += case_num (c, s->items[v]);
return sum;
};
struct cronbach *s = &rel->sc[si];
for (i = 0 ; i < s->n_items ; ++i)
- moments1_add (s->m[i], case_data (c, s->items[i])->f, weight);
+ moments1_add (s->m[i], case_num (c, s->items[i]), weight);
- moments1_add (s->total, case_data_idx (c, s->totals_idx)->f, weight);
+ moments1_add (s->total, case_num_idx (c, s->totals_idx), weight);
}
}
casereader_destroy (input);
{
int i;
for (i = 0 ; i < case_get_value_cnt (c); ++i)
- {
- printf ("%g ", case_data_idx (c, i)->f);
- }
+ printf ("%g ", case_num_idx (c, i));
printf ("\n");
}
{
struct cmd_roc *roc = aux;
const struct variable *wv = dict_get_weight (roc->dict);
- const double weight = wv ? case_data (c, wv)->f : 1.0;
+ const double weight = wv ? case_num (c, wv) : 1.0;
const bool positive =
(0 == value_compare_3way (case_data (c, roc->state_var), &roc->state_value,
for (; (cpc = casereader_read (input)); case_unref (cpc))
{
struct ccase *new_case;
- const double cp = case_data_idx (cpc, ROC_CUTPOINT)->f;
+ const double cp = case_num_idx (cpc, ROC_CUTPOINT);
assert (cp != SYSMIS);
new_case = case_clone (cpc);
- if (pos_cond (result, cp))
- case_data_rw_idx (new_case, true_index)->f += weight;
- else
- case_data_rw_idx (new_case, false_index)->f += weight;
+ int index = pos_cond (result, cp) ? true_index : false_index;
+ *case_num_rw_idx (new_case, index) += weight;
prev_cp = cp;
struct ccase *c2;
struct casereader *r2 = casereader_clone (rclone);
- const double weight1 = case_data_idx (c1, weight_idx)->f;
- const double d1 = case_data (c1, var)->f;
+ const double weight1 = case_num_idx (c1, weight_idx);
+ const double d1 = case_num (c1, var);
double n_eq = 0.0;
double n_pred = 0.0;
for (; (c2 = casereader_read (r2)); case_unref (c2))
{
- const double d2 = case_data (c2, var)->f;
- const double weight2 = case_data_idx (c2, weight_idx)->f;
+ const double d2 = case_num (c2, var);
+ const double weight2 = case_num_idx (c2, weight_idx);
if (d1 == d2)
{
}
}
- case_data_rw_idx (new_case, VALUE)->f = d1;
- case_data_rw_idx (new_case, N_EQ)->f = n_eq;
- case_data_rw_idx (new_case, N_PRED)->f = n_pred;
+ *case_num_rw_idx (new_case, VALUE) = d1;
+ *case_num_rw_idx (new_case, N_EQ) = n_eq;
+ *case_num_rw_idx (new_case, N_PRED) = n_pred;
casewriter_write (wtr, new_case);
{
struct ccase *cc = case_create (casewriter_get_proto (writer));
- case_data_rw_idx (cc, ROC_CUTPOINT)->f = cutpoint;
- case_data_rw_idx (cc, ROC_TP)->f = 0;
- case_data_rw_idx (cc, ROC_FN)->f = 0;
- case_data_rw_idx (cc, ROC_TN)->f = 0;
- case_data_rw_idx (cc, ROC_FP)->f = 0;
+ *case_num_rw_idx (cc, ROC_CUTPOINT) = cutpoint;
+ *case_num_rw_idx (cc, ROC_TP) = 0;
+ *case_num_rw_idx (cc, ROC_FN) = 0;
+ *case_num_rw_idx (cc, ROC_TN) = 0;
+ *case_num_rw_idx (cc, ROC_FP) = 0;
casewriter_write (writer, cc);
}
{
struct ccase *pos_case = case_create (n_proto);
struct ccase *cneg;
- const double jpos = case_data_idx (cpos, VALUE)->f;
+ const double jpos = case_num_idx (cpos, VALUE);
while ((cneg = casereader_read (n_neg_reader)))
{
struct ccase *nc = case_create (n_proto);
- const double jneg = case_data_idx (cneg, VALUE)->f;
+ const double jneg = case_num_idx (cneg, VALUE);
- case_data_rw_idx (nc, VALUE)->f = jneg;
- case_data_rw_idx (nc, N_POS_EQ)->f = 0;
+ *case_num_rw_idx (nc, VALUE) = jneg;
+ *case_num_rw_idx (nc, N_POS_EQ) = 0;
- case_data_rw_idx (nc, N_POS_GT)->f = SYSMIS;
+ *case_num_rw_idx (nc, N_POS_GT) = SYSMIS;
*case_data_rw_idx (nc, N_NEG_EQ) = *case_data_idx (cneg, N_EQ);
*case_data_rw_idx (nc, N_NEG_LT) = *case_data_idx (cneg, N_PRED);
break;
}
- case_data_rw_idx (pos_case, VALUE)->f = jpos;
+ *case_num_rw_idx (pos_case, VALUE) = jpos;
*case_data_rw_idx (pos_case, N_POS_EQ) = *case_data_idx (cpos, N_EQ);
*case_data_rw_idx (pos_case, N_POS_GT) = *case_data_idx (cpos, N_PRED);
- case_data_rw_idx (pos_case, N_NEG_EQ)->f = 0;
- case_data_rw_idx (pos_case, N_NEG_LT)->f = SYSMIS;
+ *case_num_rw_idx (pos_case, N_NEG_EQ) = 0;
+ *case_num_rw_idx (pos_case, N_NEG_LT) = SYSMIS;
casewriter_write (w, pos_case);
}
for (; (c = casereader_read (r)); case_unref (c))
{
- double n_pos_gt = case_data_idx (c, N_POS_GT)->f;
+ double n_pos_gt = case_num_idx (c, N_POS_GT);
struct ccase *nc = case_clone (c);
if (n_pos_gt == SYSMIS)
{
n_pos_gt = prev_pos_gt;
- case_data_rw_idx (nc, N_POS_GT)->f = n_pos_gt;
+ *case_num_rw_idx (nc, N_POS_GT) = n_pos_gt;
}
casewriter_write (w, nc);
for (; (c = casereader_read (r)); case_unref (c))
{
- double n_neg_lt = case_data_idx (c, N_NEG_LT)->f;
+ double n_neg_lt = case_num_idx (c, N_NEG_LT);
struct ccase *nc = case_clone (c);
if (n_neg_lt == SYSMIS)
{
n_neg_lt = prev_neg_lt;
- case_data_rw_idx (nc, N_NEG_LT)->f = n_neg_lt;
+ *case_num_rw_idx (nc, N_NEG_LT) = n_neg_lt;
}
casewriter_write (w, nc);
{
struct ccase *next_case = casereader_peek (r, 0);
- const double j = case_data_idx (c, VALUE)->f;
- double n_pos_eq = case_data_idx (c, N_POS_EQ)->f;
- double n_pos_gt = case_data_idx (c, N_POS_GT)->f;
- double n_neg_eq = case_data_idx (c, N_NEG_EQ)->f;
- double n_neg_lt = case_data_idx (c, N_NEG_LT)->f;
+ const double j = case_num_idx (c, VALUE);
+ double n_pos_eq = case_num_idx (c, N_POS_EQ);
+ double n_pos_gt = case_num_idx (c, N_POS_GT);
+ double n_neg_eq = case_num_idx (c, N_NEG_EQ);
+ double n_neg_lt = case_num_idx (c, N_NEG_LT);
- if (prev_case && j == case_data_idx (prev_case, VALUE)->f)
+ if (prev_case && j == case_num_idx (prev_case, VALUE))
{
- if (0 == case_data_idx (c, N_POS_EQ)->f)
+ if (0 == case_num_idx (c, N_POS_EQ))
{
- n_pos_eq = case_data_idx (prev_case, N_POS_EQ)->f;
- n_pos_gt = case_data_idx (prev_case, N_POS_GT)->f;
+ n_pos_eq = case_num_idx (prev_case, N_POS_EQ);
+ n_pos_gt = case_num_idx (prev_case, N_POS_GT);
}
- if (0 == case_data_idx (c, N_NEG_EQ)->f)
+ if (0 == case_num_idx (c, N_NEG_EQ))
{
- n_neg_eq = case_data_idx (prev_case, N_NEG_EQ)->f;
- n_neg_lt = case_data_idx (prev_case, N_NEG_LT)->f;
+ n_neg_eq = case_num_idx (prev_case, N_NEG_EQ);
+ n_neg_lt = case_num_idx (prev_case, N_NEG_LT);
}
}
- if (NULL == next_case || j != case_data_idx (next_case, VALUE)->f)
+ if (NULL == next_case || j != case_num_idx (next_case, VALUE))
{
rs[i].auc += n_pos_gt * n_neg_eq + (n_pos_eq * n_neg_eq) / 2.0;
int coord_idx = 0;
for (; (cc = casereader_read (r)) != NULL; case_unref (cc))
{
- const double se = case_data_idx (cc, ROC_TP)->f /
- (case_data_idx (cc, ROC_TP)->f + case_data_idx (cc, ROC_FN)->f);
+ const double se = case_num_idx (cc, ROC_TP) /
+ (case_num_idx (cc, ROC_TP) + case_num_idx (cc, ROC_FN));
- const double sp = case_data_idx (cc, ROC_TN)->f /
- (case_data_idx (cc, ROC_TN)->f + case_data_idx (cc, ROC_FP)->f);
+ const double sp = case_num_idx (cc, ROC_TN) /
+ (case_num_idx (cc, ROC_TN) + case_num_idx (cc, ROC_FP));
if (coord_idx >= n_coords)
{
struct ccase *c;
for (; (c = casereader_read (group)); case_unref (c))
{
- const double w = weight ? case_data (c, weight)->f: 1.0;
+ const double w = weight ? case_num (c, weight) : 1.0;
const union value *val = case_data (c, var);
if (var_is_value_missing (var, val, exclude))
continue;
for (; (c = casereader_read (reader));)
{
const union value *val = case_data (c, var);
- const double w = weight ? case_data (c, weight)->f: 1.0;
+ const double w = weight ? case_num (c, weight) : 1.0;
if (var_is_value_missing (var, val, exclude))
{
case_unref (c);
struct casereader *reader = casereader_clone (input);
for (; (c = casereader_read (reader)); case_unref (c))
{
- const double w = weight ? case_data (c, weight)->f: 1.0;
+ const double w = weight ? case_num (c, weight) : 1.0;
for (v = 0; v < otp->n_vars; ++v)
{
const struct variable *var = otp->vars[v];
for (; (c = casereader_read (input)); case_unref (c))
{
- const double w = weight ? case_data (c, weight)->f: 1.0;
+ const double w = weight ? case_num (c, weight) : 1.0;
for (v = 0; v < otp->n_vars; ++v)
{
{
const variable_pair *vp = aux;
- return case_data (c, (*vp)[0])->f - case_data (c, (*vp)[1])->f;
+ return case_num (c, (*vp)[0]) - case_num (c, (*vp)[1]);
}
static void show_ranks_box (const struct wilcoxon_state *,
double d = append_difference (c, 0, vp);
if (d > 0)
- {
- case_data_rw (output, ws[i].sign)->f = 1.0;
-
- }
+ *case_num_rw (output, ws[i].sign) = 1.0;
else if (d < 0)
- {
- case_data_rw (output, ws[i].sign)->f = -1.0;
- }
+ *case_num_rw (output, ws[i].sign) = -1.0;
else
{
double w = 1.0;
if (weight)
- w = case_data (c, weight)->f;
+ w = case_num (c, weight);
/* Central point values should be dropped */
ws[i].n_zeros += w;
continue;
}
- case_data_rw (output, ws[i].absdiff)->f = fabs (d);
+ *case_num_rw (output, ws[i].absdiff) = fabs (d);
if (weight)
- case_data_rw (output, weightx)->f = case_data (c, weight)->f;
+ *case_num_rw (output, weightx) = case_num (c, weight);
casewriter_write (writer, output);
}
for (; (c = casereader_read (rr)) != NULL; case_unref (c))
{
- double sign = case_data (c, ws[i].sign)->f;
- double rank = case_data_idx (c, weight ? 3 : 2)->f;
- double w = 1.0;
- if (weight)
- w = case_data (c, weightx)->f;
+ double sign = case_num (c, ws[i].sign);
+ double rank = case_num_idx (c, weight ? 3 : 2);
+ double w = weight ? case_num (c, weightx) : 1.0;
if (sign > 0)
{
|| expr_evaluate_num (compute->test, *c, case_num) == 1.0)
{
*c = case_unshare (*c);
- case_data_rw (*c, compute->variable)->f
+ *case_num_rw (*c, compute->variable)
= expr_evaluate_num (compute->rvalue, *c, case_num);
}
}
*c = case_unshare (*c);
- case_data_rw (*c, vector_get_var (compute->vector, rindx - 1))->f
+ *case_num_rw (*c, vector_get_var (compute->vector, rindx - 1))
= expr_evaluate_num (compute->rvalue, *c, case_num);
}
counter += count_numeric (crit, *c);
else
counter += count_string (crit, *c);
- case_data_rw (*c, dv->var)->f = counter;
+ *case_num_rw (*c, dv->var) = counter;
}
return TRNS_CONTINUE;
}
if (trns->dst_type == VAL_NUMERIC)
{
- double *dst = &case_data_rw (*c, dst_var)->f;
+ double *dst = case_num_rw (*c, dst_var);
if (out != NULL)
*dst = !out->copy_input ? out->value.f : case_num (*c, src_var);
else if (trns->src_vars != trns->dst_vars)
{
ds_put_format (&o->label,
"%ld",
- (casenumber) case_data_idx (cx, bw->id_idx)->f);
+ (casenumber) case_num_idx (cx, bw->id_idx));
}
ll_push_head (&bw->outliers, &o->ll);
assert (!cat->cat_to_iact);
double weight;
- weight = cat->wv ? case_data (c, cat->wv)->f : 1.0;
+ weight = cat->wv ? case_num (c, cat->wv) : 1.0;
weight = var_force_valid_weight (cat->wv, weight, NULL);
/* Update the frequency table for each variable. */
covariance_accumulate_pass1 (struct covariance *cov, const struct ccase *c)
{
size_t i, j, m;
- const double weight = cov->wv ? case_data (c, cov->wv)->f : 1.0;
+ const double weight = cov->wv ? case_num (c, cov->wv) : 1.0;
assert (cov->passes == 2);
if (!cov->pass_one_first_case_seen)
covariance_accumulate_pass2 (struct covariance *cov, const struct ccase *c)
{
size_t i, j;
- const double weight = cov->wv ? case_data (c, cov->wv)->f : 1.0;
+ const double weight = cov->wv ? case_num (c, cov->wv) : 1.0;
assert (cov->passes == 2);
assert (cov->state >= 1);
covariance_accumulate (struct covariance *cov, const struct ccase *c)
{
size_t i, j, m;
- const double weight = cov->wv ? case_data (c, cov->wv)->f : 1.0;
+ const double weight = cov->wv ? case_num (c, cov->wv) : 1.0;
assert (cov->passes == 1);
minimize (&np->y_min, y);
cp = case_create (casewriter_get_proto (np->writer));
- case_data_rw_idx (cp, NP_IDX_Y)->f = y;
- case_data_rw_idx (cp, NP_IDX_NS)->f = ns;
- case_data_rw_idx (cp, NP_IDX_DNS)->f = dns;
+ *case_num_rw_idx (cp, NP_IDX_Y) = y;
+ *case_num_rw_idx (cp, NP_IDX_NS) = ns;
+ *case_num_rw_idx (cp, NP_IDX_DNS) = dns;
casewriter_write (np->writer, cp);
np->prev_cc = cc;
for (; (cx = casereader_read (reader)) != NULL; case_unref (cx))
{
- const double weight = (wt_idx == -1) ? 1.0 : case_data_idx (cx, wt_idx)->f;
- const double this_value = case_data_idx (cx, val_idx)->f;
+ const double weight = wt_idx == -1 ? 1.0 : case_num_idx (cx, wt_idx);
+ const double this_value = case_num_idx (cx, val_idx);
/* The casereader MUST be sorted */
assert (this_value >= prev_value);
data = casereader_clone (npp->data);
for (; (c = casereader_read (data)) != NULL; case_unref (c))
xrchart_datum (cr, geom, 0,
- case_data_idx (c, NP_IDX_Y)->f,
- case_data_idx (c, NP_IDX_NS)->f);
+ case_num_idx (c, NP_IDX_Y),
+ case_num_idx (c, NP_IDX_NS));
casereader_destroy (data);
xrchart_line (cr, geom, npp->slope, npp->intercept,
data = casereader_clone (dnpp->data);
for (; (c = casereader_read (data)) != NULL; case_unref (c))
- xrchart_datum (cr, geom, 0, case_data_idx (c, NP_IDX_Y)->f,
- case_data_idx (c, NP_IDX_DNS)->f);
+ xrchart_datum (cr, geom, 0, case_num_idx (c, NP_IDX_Y),
+ case_num_idx (c, NP_IDX_DNS));
casereader_destroy (data);
xrchart_line (cr, geom, 0, 0, dnpp->y_min, dnpp->y_max, XRCHART_DIM_X);
xrchart_vector_start (cr, geom, rv->name);
for (; (cc = casereader_read (r)) != NULL; case_unref (cc))
{
- double se = case_data_idx (cc, ROC_TP)->f;
- double sp = case_data_idx (cc, ROC_TN)->f;
+ double se = case_num_idx (cc, ROC_TP);
+ double sp = case_num_idx (cc, ROC_TN);
- se /= case_data_idx (cc, ROC_FN)->f + case_data_idx (cc, ROC_TP)->f ;
- sp /= case_data_idx (cc, ROC_TN)->f + case_data_idx (cc, ROC_FP)->f ;
+ se /= case_num_idx (cc, ROC_FN) + case_num_idx (cc, ROC_TP);
+ sp /= case_num_idx (cc, ROC_TN) + case_num_idx (cc, ROC_FP);
xrchart_vector (cr, geom, 1 - sp, se);
}
colour->blue / 255.0);
xrchart_datum (cr, geom, 0,
- case_data_idx (c, SP_IDX_X)->f,
- case_data_idx (c, SP_IDX_Y)->f);
+ case_num_idx (c, SP_IDX_X),
+ case_num_idx (c, SP_IDX_Y));
}
casereader_destroy (data);
cairo_restore (cr);