+
+
+
+static int
+compare_var_name (const void *a_, const void *b_, void *v_ unused)
+{
+ const struct variable *a = a_;
+ const struct variable *b = b_;
+
+ return strcmp(a->name,b->name);
+}
+
+static unsigned
+hash_var_name (const void *a_, void *v_ unused)
+{
+ const struct variable *a = a_;
+
+ return hsh_hash_bytes (a->name, strlen(a->name));
+}
+
+
+static void
+paired_precalc (void)
+{
+ int i;
+ for(i=0; i < n_pairs ; ++i )
+ pairs[i].correlation=0;
+}
+
+static int
+paired_calc (struct ccase *c)
+{
+ int i;
+
+ for(i=0; i < n_pairs ; ++i )
+ {
+ struct variable *v0 = pairs[i].v[0];
+ struct variable *v1 = pairs[i].v[1];
+
+ union value *val0 = &c->data[v0->fv];
+ union value *val1 = &c->data[v1->fv];
+
+ pairs[i].correlation += ( val0->f - pairs[i].v[0]->p.t_t.mean )
+ *
+ ( val1->f - pairs[i].v[1]->p.t_t.mean );
+ }
+
+
+ return 0;
+}
+
+static void
+paired_postcalc (void)
+{
+ int i;
+
+ for(i=0; i < n_pairs ; ++i )
+ {
+
+ pairs[i].correlation /= pairs[i].v[0]->p.t_t.std_dev *
+ pairs[i].v[1]->p.t_t.std_dev ;
+
+ pairs[i].correlation /= pairs[i].v[0]->p.t_t.n -1;
+ }
+}