math: Coding style updates in some order-stat implementations.
[pspp] / src / math / trimmed-mean.c
index 4840fd2d66e0375a6114e3585fc5795b9acf60d7..d44131a53b4c4eebf18efff5815f7723287f8348 100644 (file)
@@ -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)
 {