case: Introduce new functions for numbers and substrings in cases.
authorBen Pfaff <blp@cs.stanford.edu>
Fri, 3 Sep 2021 02:59:23 +0000 (19:59 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Fri, 3 Sep 2021 03:02:10 +0000 (20:02 -0700)
Use the case_num_*() functions everywhere in the tree for clarity and
brevity.

41 files changed:
src/data/case.c
src/data/case.h
src/data/casereader-translator.c
src/data/dataset.c
src/data/por-file-reader.c
src/language/control/loop.c
src/language/data-io/combine-files.c
src/language/data-io/data-list.c
src/language/data-io/matrix-reader.c
src/language/stats/aggregate.c
src/language/stats/autorecode.c
src/language/stats/cochran.c
src/language/stats/descriptives.c
src/language/stats/examine.c
src/language/stats/flip.c
src/language/stats/friedman.c
src/language/stats/glm.c
src/language/stats/graph.c
src/language/stats/jonckheere-terpstra.c
src/language/stats/kruskal-wallis.c
src/language/stats/logistic.c
src/language/stats/mann-whitney.c
src/language/stats/means.c
src/language/stats/quick-cluster.c
src/language/stats/rank.c
src/language/stats/regression.c
src/language/stats/reliability.c
src/language/stats/roc.c
src/language/stats/runs.c
src/language/stats/wilcoxon.c
src/language/xforms/compute.c
src/language/xforms/count.c
src/language/xforms/recode.c
src/math/box-whisker.c
src/math/categoricals.c
src/math/covariance.c
src/math/np.c
src/math/order-stats.c
src/output/charts/np-plot-cairo.c
src/output/charts/roc-chart-cairo.c
src/output/charts/scatterplot-cairo.c

index 70c1b44075355d45310232203923af4867b6962b..742d1f0f22ca46e6743f0c0a6d808b6fd28250a6 100644 (file)
@@ -323,6 +323,29 @@ case_num_idx (const struct ccase *c, size_t idx)
   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.
@@ -348,6 +371,26 @@ case_str_idx (const struct ccase *c, size_t idx)
   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.
index 4b20d477d6a2b66b1e6cf98a99ed820dc547e3f4..45fdf52c9b993f7829885e01f4422fbe32b89f2a 100644 (file)
@@ -23,6 +23,7 @@
 #include <stdlib.h>
 
 #include "libpspp/compiler.h"
+#include "libpspp/str.h"
 #include "data/caseproto.h"
 
 struct variable;
@@ -94,9 +95,13 @@ union value *case_data_rw_idx (struct ccase *, size_t idx);
 
 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);
 
@@ -121,7 +126,7 @@ void case_unref__ (struct ccase *);
    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)
index cab13fe31dd98a2f5280af5dd406a7b6b485ada4..a6508502b7348115b9ded5b8ee7fc66c7c116f95 100644 (file)
@@ -264,7 +264,7 @@ can_translate (struct ccase *c, void *can_)
   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;
 }
 
@@ -405,7 +405,7 @@ car_translate (struct ccase *input, void *car_)
 {
   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)
     {
@@ -420,7 +420,7 @@ car_translate (struct ccase *input, void *car_)
       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;
        }
@@ -430,13 +430,13 @@ car_translate (struct ccase *input, void *car_)
          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;
@@ -462,7 +462,7 @@ car_translate (struct ccase *input, void *car_)
   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;
@@ -490,7 +490,7 @@ uniquify (const struct ccase *c, void *aux)
   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;
 
@@ -530,12 +530,12 @@ consolodate_weight (struct ccase *input, void *aux)
   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;
index b94a3675c6668ac4ce4ae6362c7db145d58846f3..f966b63af96ab807d6c927d3a34f8053210b99fe 100644 (file)
@@ -818,7 +818,7 @@ store_case_num (void *var_, struct ccase **cc, casenumber case_num)
   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;
 }
index 8d008b1dd610a30574be726f7edc74ff54c80b39..b5cc35b825ba73c27ae015971fd249afdf9e749e 100644 (file)
@@ -901,7 +901,7 @@ por_file_casereader_read (struct casereader *reader, void *r_)
       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];
index 765d21314793e0165e235ec7c9ae3a0917a6048f..156e647ea0e617ac16446a8c8a38d84814b47071 100644 (file)
@@ -315,7 +315,7 @@ loop_trns_proc (void *loop_, struct ccase **c, casenumber case_num)
       /* 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)
@@ -374,7 +374,7 @@ end_loop_trns_proc (void *loop_, struct ccase **c, casenumber case_num UNUSED)
           || (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
index c63901d3dc3ba40115120ce32bdc4cbf2aee9116..c51f04aaa947d422a9b504d69e66dc13ef5c0161 100644 (file)
@@ -835,7 +835,7 @@ create_output_case (const struct comb_proc *proc)
     {
       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;
 }
@@ -844,7 +844,7 @@ static void
 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.
@@ -913,7 +913,7 @@ output_case (struct comb_proc *proc, struct ccase *output, union value by[])
         {
           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
@@ -921,7 +921,7 @@ output_case (struct comb_proc *proc, struct ccase *output, union value by[])
 
       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)
         {
@@ -946,7 +946,7 @@ output_buffered_case (struct comb_proc *proc)
   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;
     }
index f689c99711d0626143f2026fc230d468d75beed0..b6dc078985258011561bace4ddfcd59e91aff9c3 100644 (file)
@@ -527,7 +527,7 @@ data_list_trns_proc (void *trns_, struct ccase **c, casenumber case_num UNUSED)
   /* 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;
index eac86744af9a5685e9715ad2625096be2418411a..a7db15e029d8b9feac1d9111a8297edb87c6540b 100644 (file)
@@ -182,7 +182,7 @@ matrix_fill_row (gsl_matrix **matrix,
   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);
index 9f0b271533888cc195c68637b9f569451d56e490..565e26d93808b4b8b92037c2a348375f0a3c12c3 100644 (file)
@@ -789,12 +789,11 @@ accumulate_aggregate_info (struct agr_proc *agr, const struct ccase *input)
 
               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;
 
index 005ba7622a818602c477b90682c9245d545bf56e..6481a263268f84fc43fe8cb000e23230a51038b5 100644 (file)
@@ -568,7 +568,7 @@ autorecode_trns_proc (void *arc_, struct ccase **c,
       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;
index 4b881f393c7318e06c41501bc4038d74b6992082..935d612b5e94e7e7d18b9572ce7a2814fb09c1f0 100644 (file)
@@ -80,7 +80,7 @@ cochran_execute (const struct dataset *ds,
   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];
index 0cee83e06b79b018feeeb4834e46af87fabc1f89..eefd0598e31a6dca612c84ebd5339a77ef7eb05b 100644 (file)
@@ -606,7 +606,7 @@ descriptives_set_all_sysmis_zscores (const struct dsc_trns *t, struct ccase *c)
   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
@@ -684,7 +684,7 @@ descriptives_trns_proc (void *trns_, struct ccase **c,
   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))
@@ -904,7 +904,7 @@ calc_descriptives (struct dsc_proc *dsc, struct casereader *group,
     {
       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;
@@ -945,8 +945,8 @@ calc_descriptives (struct dsc_proc *dsc, struct casereader *group,
 
       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];
         }
     }
 
index ad8a9baa767d525fdf645c1a8ec07d3dba312885..00fb801fce273283fc737fc91b2c23aa3531b352 100644 (file)
@@ -1068,7 +1068,7 @@ update_n (const void *aux1, void *aux2 UNUSED, void *user_data,
     {
       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))
         {
@@ -1090,11 +1090,11 @@ update_n (const void *aux1, void *aux2 UNUSED, void *user_data,
 
       /* 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;
 
@@ -1148,8 +1148,8 @@ calculate_n (const void *aux1, void *aux2 UNUSED, void *user_data)
       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);
index 216c9d7921c78a15a9a4a06af201178592bae075..993f8975a629d6beae47ba95b7fed7f0c0cf2747 100644 (file)
@@ -440,7 +440,7 @@ flip_casereader_read (struct casereader *reader, void *flip_)
           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++;
index 5d476fab2c080e88d234f8f9e865334d478cf330..55e42489f4e3a420790c7184c432b1968d5f17af 100644 (file)
@@ -123,7 +123,7 @@ friedman_execute (const struct dataset *ds,
       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;
 
index a6898502708506e7ebc5be5ca76254a4424d8a73..2766279f2ed9fbcaad9c80531a7c0752fb63ccde 100644 (file)
@@ -618,8 +618,7 @@ run_glm (struct glm_spec *cmd, struct casereader *input,
       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);
     }
@@ -636,8 +635,7 @@ run_glm (struct glm_spec *cmd, struct casereader *input,
       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);
     }
index 147d654ac484d392f263c8ebbb323e7a95bd97d8..425fd241574d76227d7cb2830dd11aa832307900 100644 (file)
@@ -355,8 +355,8 @@ show_histogr (const struct graph *cmd, struct casereader *input)
 
   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);
     }
@@ -489,7 +489,7 @@ run_barchart (struct graph *cmd, struct casereader *input)
        {
          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;
 
@@ -609,7 +609,7 @@ run_graph (struct graph *cmd, struct casereader *input)
       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]),
@@ -617,7 +617,7 @@ run_graph (struct graph *cmd, struct casereader *input)
       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))
            {
@@ -625,7 +625,7 @@ run_graph (struct graph *cmd, struct casereader *input)
              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;
index bc5c76f58e909848c087c199e91bdd7ccbce507b..7d654bbecbff4ef86155abbdb354578c09366ef4 100644 (file)
@@ -101,16 +101,16 @@ u (const struct group_data *grp0, const struct group_data *grp1)
     {
       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)
             {
@@ -203,7 +203,7 @@ void variance_calculation (struct casereader *ir, const struct variable *var,
 
   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);
@@ -295,12 +295,11 @@ jonckheere_terpstra_execute (const struct dataset *ds,
         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);
           }
 
index 061857d30e600daa46946bc7ca121324fe7ec805..62c49e48482cd05b5b0d09d7e0f5f231b4a6a4c8 100644 (file)
@@ -192,7 +192,7 @@ kruskal_wallis_execute (const struct dataset *ds,
                           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
index dbf54c6b0b483093d7b6a2de692801accd987581..d62390644da7264925cd5bd44a140c411f1731f6 100644 (file)
@@ -227,7 +227,7 @@ predictor_value (const struct ccase *c,
 {
   /* 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))
index b45f8f910edcfa608a17431afe508d74b94eb1c5..2301cd13c53ed207643e4314408c19fc4cb88171 100644 (file)
@@ -127,7 +127,7 @@ mann_whitney_execute (const struct dataset *ds,
        {
          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))
            {
index bb1cf59926fb8eccc3ee3149609271fd1f929594..2235433fb92021600e4d380f2003135a6ab78053 100644 (file)
@@ -939,7 +939,7 @@ service_cell_map (const struct means *means, const struct mtable *mt,
                                                               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));
                 }
             }
         }
index 8b2432ac455fec61a7fe8a56043ba035e5991c3d..e3bb76e42257362387c0077c2f4fb7f3a047ab64 100644 (file)
@@ -482,7 +482,7 @@ kmeans_cluster (struct Kmeans *kmeans, struct casereader *reader,
                }
 
              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)
@@ -491,7 +491,7 @@ kmeans_cluster (struct Kmeans *kmeans, struct casereader *reader,
                  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);
                }
            }
 
@@ -537,7 +537,7 @@ kmeans_cluster (struct Kmeans *kmeans, struct casereader *reader,
              }
 
            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);
@@ -621,10 +621,10 @@ save_trans_func (void *aux, struct ccase **c, casenumber x UNUSED)
   *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);
 
@@ -708,10 +708,10 @@ quick_cluster_show_membership (struct Kmeans *kmeans,
        /* 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);
index fe277c7de3824fd9e6287d513ae6223de1deb5cb..dc40a0954a02e20b2377c19f3e4ec9eb33007256 100644 (file)
@@ -573,12 +573,12 @@ rank_sorted_file (struct casereader *input,
           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);
@@ -928,7 +928,7 @@ rank_trns_proc (void *trns_, struct ccase **c, casenumber case_idx UNUSED)
             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;
index 6fa114338eb344daca89cd15bf0a1041491548ef..7c98dba047b94ca3d278890e68885d08fa48fb71 100644 (file)
@@ -175,14 +175,14 @@ save_trans_func (void *aux, struct ccase **c, casenumber x UNUSED)
         {
           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);
@@ -827,14 +827,14 @@ run_regression (const struct regression *cmd,
               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);
index 615e108a78c61b9cdc1ce2084faf132d31526f1c..86c1add760eb2faad211df850d53fadd020c28ab 100644 (file)
@@ -426,11 +426,8 @@ append_sum (const struct ccase *c, casenumber n UNUSED, void *aux)
   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;
 };
@@ -495,9 +492,9 @@ do_reliability (struct casereader *input, struct dataset *ds,
          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);
index b3f8e91e47da59645d04f83cfa75ae66a4f3ff88..1a4fcba65783c7e590e47cb67345e9641cff1c7f 100644 (file)
@@ -336,9 +336,7 @@ dump_casereader (struct casereader *reader)
     {
       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");
     }
 
@@ -358,7 +356,7 @@ match_positives (const struct ccase *c, void *aux)
 {
   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,
@@ -428,7 +426,7 @@ accumulate_counts (struct casereader *input,
   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);
 
@@ -438,10 +436,8 @@ accumulate_counts (struct casereader *input,
 
       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;
 
@@ -509,8 +505,8 @@ process_group (const struct variable *var, struct casereader *reader,
       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;
 
@@ -522,8 +518,8 @@ process_group (const struct variable *var, struct casereader *reader,
 
       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)
            {
@@ -536,9 +532,9 @@ process_group (const struct variable *var, struct casereader *reader,
            }
        }
 
-      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);
 
@@ -624,11 +620,11 @@ append_cutpoint (struct casewriter *writer, double cutpoint)
 {
   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);
 }
@@ -791,18 +787,18 @@ do_roc (struct cmd_roc *roc, struct casereader *reader, struct dictionary *dict)
        {
          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);
@@ -814,11 +810,11 @@ do_roc (struct cmd_roc *roc, struct casereader *reader, struct dictionary *dict)
                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);
        }
@@ -840,13 +836,13 @@ do_roc (struct cmd_roc *roc, struct casereader *reader, struct dictionary *dict)
 
        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);
@@ -865,13 +861,13 @@ do_roc (struct cmd_roc *roc, struct casereader *reader, struct dictionary *dict)
 
        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);
@@ -888,28 +884,28 @@ do_roc (struct cmd_roc *roc, struct casereader *reader, struct dictionary *dict)
          {
            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;
 
@@ -1087,11 +1083,11 @@ show_coords (struct roc_state *rs, const struct cmd_roc *roc)
       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)
             {
index d12bd0d2b52a7239c5d4866bc726edc941e5f6a2..9ef4c64add1f601303ce894a6c2805d63293db39 100644 (file)
@@ -143,7 +143,7 @@ runs_execute (const struct dataset *ds,
                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;
@@ -191,7 +191,7 @@ runs_execute (const struct dataset *ds,
            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);
@@ -224,7 +224,7 @@ runs_execute (const struct dataset *ds,
        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];
@@ -260,7 +260,7 @@ runs_execute (const struct dataset *ds,
 
   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)
        {
index 622db2292edc4b0a6cc8f19e44a0c5875ba9315a..775e63ef4adbe582c517a26da453d4d1a15c334b 100644 (file)
@@ -49,7 +49,7 @@ append_difference (const struct ccase *c, casenumber n UNUSED, void *aux)
 {
   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 *,
@@ -124,19 +124,14 @@ wilcoxon_execute (const struct dataset *ds,
          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;
@@ -144,10 +139,10 @@ wilcoxon_execute (const struct dataset *ds,
               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);
        }
@@ -169,11 +164,9 @@ wilcoxon_execute (const struct dataset *ds,
 
       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)
            {
index aa81729827bc35046bc5a129560a541efa125c83..8e0ce85d61e08ddfe121ba3682eb95cfddea748a 100644 (file)
@@ -133,7 +133,7 @@ compute_num (void *compute_, struct ccase **c, casenumber case_num)
       || 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);
     }
 
@@ -170,7 +170,7 @@ compute_num_vec (void *compute_, struct ccase **c, casenumber 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);
     }
 
index bf3c9e9ac5ad87cc39f1452998357e1a8b0988e2..1f35045290cfc0f879db4cfa17d4eaa2bd0ce779 100644 (file)
@@ -356,7 +356,7 @@ count_trns_proc (void *trns_, struct ccase **c,
          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;
 }
index b5e0e3fcdec34f8ffb4e0f4575aaea939ea30f75..f1834cc8a5fb09daffa0a1eb68b4070e781d084e 100644 (file)
@@ -710,7 +710,7 @@ recode_trns_proc (void *trns_, struct ccase **c, casenumber case_idx UNUSED)
 
       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)
index 3e501ccaeb7501da327eb145337290786b6ef7b9..344561a6fd24a0cdcd694778ba06733932427309 100644 (file)
@@ -105,7 +105,7 @@ acc (struct statistic *s, const struct ccase *cx,
     {
       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);
index 4e6d8dad7ad942c633c7dc79820b93bc43d01ea6..28d51a9dd704f5bc3a8937b496f05ac0e9cda94c 100644 (file)
@@ -367,7 +367,7 @@ categoricals_update (struct categoricals *cat, const struct ccase *c)
   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. */
index cd8ec2ffd1e68b24f783f2ea3c9ce42b7598fae5..44787c679a2a107acd5ef4eb1f7888c12ffbf366 100644 (file)
@@ -301,7 +301,7 @@ void
 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)
@@ -346,7 +346,7 @@ void
 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);
@@ -464,7 +464,7 @@ void
 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);
 
index dd197f9c6d392c9eb13886f21471bcd3cd0b2ac3..8b7d09e7d378a0639765801e55cbece47f116455 100644 (file)
@@ -63,9 +63,9 @@ acc (struct statistic *s, const struct ccase *cx UNUSED,
   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;
index 59edc92fc80fe28af97237893ae89f39d344e1a3..1a4aef891ae173d84147ddc27d014b7e22618222 100644 (file)
@@ -125,8 +125,8 @@ order_stats_accumulate_idx (struct order_stats **os, size_t nos,
 
   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);
index ae866831f65d62ee34795d64048fb554d1bf6bee..f74572d0c8a57f0f6804e6bab42ca479df67bd53 100644 (file)
@@ -48,8 +48,8 @@ np_plot_chart_draw (const struct chart *chart, cairo_t *cr,
   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,
@@ -74,8 +74,8 @@ dnp_plot_chart_draw (const struct chart *chart, cairo_t *cr,
 
   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);
index 910d6152f0a7f64140b67cae932aa60a9bc7a652..04e37405f1e36e30ae15023843526e25b16a798c 100644 (file)
@@ -58,11 +58,11 @@ xrchart_draw_roc (const struct chart *chart, cairo_t *cr,
       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);
        }
index 17307497c783f7b2c4d5bea00634170d955f05b9..f03d33bc169101174934598f1c56833b3c458a58 100644 (file)
@@ -101,8 +101,8 @@ xrchart_draw_scatterplot (const struct chart *chart, cairo_t *cr,
                             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);