math/np.c: Change np_create to take 3 doubles rather than a struct moment1*
authorJohn Darrington <john@darrington.wattle.id.au>
Tue, 13 Mar 2012 09:40:51 +0000 (10:40 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 14 Mar 2012 19:30:55 +0000 (20:30 +0100)
src/language/stats/examine.q
src/math/np.c
src/math/np.h

index e225f3343d4e5850afc43628d43f7add913aee89..8bf913e92a5e2feaaf472259ff41eb76e947c138 100644 (file)
@@ -902,7 +902,11 @@ examine_group (struct cmd_examine *cmd, struct casereader *reader, int level,
 
         if ( cmd->a_plot[XMN_PLT_NPPLOT] )
            {
-             metric->np = np_create (metric->moments);
+              double n, mean, var;
+              moments1_calculate (metric->moments,
+                                  &n, &mean, &var, NULL,  NULL);
+
+             metric->np = np_create (n, mean, var);
              n_os ++;
            }
 
index ccaa51e22d24a0e96a91996f7f597df547d3c6ce..598c05e84b22ce1536d0e98051031518158779e4 100644 (file)
@@ -72,9 +72,8 @@ acc (struct statistic *s, const struct ccase *cx UNUSED,
 }
 
 struct np *
-np_create (const struct moments1 *m)
+np_create (double n, double mean, double var)
 {
-  double variance;
   struct np *np = xzalloc (sizeof (*np));
   struct order_stats *os = &np->parent;
   struct statistic *stat = &os->parent;
@@ -83,9 +82,10 @@ np_create (const struct moments1 *m)
 
   np->prev_cc = 0;
 
-  moments1_calculate (m, &np->n, &np->mean, &variance, NULL, NULL);
+  np->n = n;
+  np->mean = mean;
 
-  np->stddev = sqrt (variance);
+  np->stddev = sqrt (var);
 
   np->y_min = np->ns_min = np->dns_min = DBL_MAX;
   np->y_max = np->ns_max = np->dns_max = -DBL_MAX;
index b5265bd41f72c57d5b895a578a428971957fb61a..2fa009f90aa8b2a6465a0435adc356ac2e6d018b 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "order-stats.h"
 
-struct moments1;
 struct casewriter;
 
 enum
@@ -38,7 +37,6 @@ struct np
   double mean;
   double stddev;
 
-
   double prev_cc;
 
   double ns_min;
@@ -54,6 +52,6 @@ struct np
 };
 
 
-struct np * np_create (const struct moments1 *);
+struct np * np_create (double n, double mean, double var);
 
 #endif