X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Ftrimmed-mean.c;fp=src%2Fmath%2Ftrimmed-mean.c;h=d44131a53b4c4eebf18efff5815f7723287f8348;hb=71f9b6d6c14525cd41ba77c9fd50aa13d0da830c;hp=4840fd2d66e0375a6114e3585fc5795b9acf60d7;hpb=feb269112e14589474c0a75e96cd5a892d9aaeef;p=pspp diff --git a/src/math/trimmed-mean.c b/src/math/trimmed-mean.c index 4840fd2d66..d44131a53b 100644 --- a/src/math/trimmed-mean.c +++ b/src/math/trimmed-mean.c @@ -50,30 +50,28 @@ destroy (struct statistic *s) struct trimmed_mean * trimmed_mean_create (double W, double tail) { - struct trimmed_mean *tm = XZALLOC (struct trimmed_mean); - struct order_stats *os = &tm->parent; - struct statistic *stat = &os->parent; - - os->n_k = 2; - os->k = tm->k; - assert (tail >= 0); assert (tail <= 1); - os->k[0].tc = tail * W; - os->k[1].tc = W * (1 - tail); - - stat->accumulate = acc; - stat->destroy = destroy; - - tm->cyk1p1 = SYSMIS; - tm->w = W; - tm->tail = tail; - + struct trimmed_mean *tm = xmalloc (sizeof *tm); + *tm = (struct trimmed_mean) { + .parent = { + .parent = { + .accumulate = acc, + .destroy = destroy, + }, + .k = tm->k, + .n_k = 2, + }, + .k[0] = { .tc = tail * W }, + .k[1] = { .tc = W * (1 - tail) }, + .cyk1p1 = SYSMIS, + .w = W, + .tail = tail, + }; return tm; } - double trimmed_mean_calculate (const struct trimmed_mean *tm) {