From: John Darrington Date: Tue, 13 Mar 2012 09:40:51 +0000 (+0100) Subject: math/np.c: Change np_create to take 3 doubles rather than a struct moment1* X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa699d5ccbfef21d9c97e09d99a4bfa8243407f7;p=pspp math/np.c: Change np_create to take 3 doubles rather than a struct moment1* --- diff --git a/src/language/stats/examine.q b/src/language/stats/examine.q index e225f3343d..8bf913e92a 100644 --- a/src/language/stats/examine.q +++ b/src/language/stats/examine.q @@ -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 ++; } diff --git a/src/math/np.c b/src/math/np.c index ccaa51e22d..598c05e84b 100644 --- a/src/math/np.c +++ b/src/math/np.c @@ -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; diff --git a/src/math/np.h b/src/math/np.h index b5265bd41f..2fa009f90a 100644 --- a/src/math/np.h +++ b/src/math/np.h @@ -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