25 #include "../include/util.h"
28 const int32_t*
const arr,
36 long long int total = 0;
38 for(
size_t i = 0; i < len; ++i) {
42 *avg = (double)total / len;
67 *med = (arr[(len / 2) - 1] + arr[len / 2]) / 2.0;
70 *med = (double)arr[(len / 2) + 1];
73 *med = (double)arr[0];
85 const int32_t* restrict
const pA = (
const int32_t*
const)a;
86 const int32_t* restrict
const pB = (
const int32_t*
const)b;
89 return (*pA < *pB) ? -1 : (*pA > *pB);
void util_median(int32_t *const arr, const size_t len, double *const med)
Calculates the median value from an array of signed 32-bit integers.
void util_average(const int32_t *const arr, const size_t len, double *const avg)
Calculates the average value from an array of signed 32-bit integers.
int util__median_compare_func(const void *a, const void *b)