feat(examples): extend hello with a second translation unit and a test

Gives the archive more than one member and gives meowc test something to run.
This commit is contained in:
milner committed 2022-06-28 01:49:34 +00:00
1 parent d71c538eef
commit a845c628e3
3 files changed
+51

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
#include "mathx.h"
#include <math.h>
double stats_mean(const double *a, size_t n) {
if (n == 0) return 0.0;
double sum = 0.0;
for (size_t i = 0; i < n; i++) sum += a[i];
return sum / (double)n;
}
double stats_stddev(const double *a, size_t n) {
if (n < 2) return 0.0;
double m = stats_mean(a, n);
double acc = 0.0;
for (size_t i = 0; i < n; i++) acc += (a[i] - m) * (a[i] - m);
return sqrt(acc / (double)(n - 1));
}