pico-scale
util.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2022 Daniel Robertson
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #ifndef UTIL_H_916DF5EE_2C2B_4D3C_A484_A64B176F8D96
24 #define UTIL_H_916DF5EE_2C2B_4D3C_A484_A64B176F8D96
25 
26 #include <assert.h>
27 #include <stddef.h>
28 #include <stdint.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
41 void util_average(
42  const int32_t* const arr,
43  const size_t len,
44  double* const avg);
45 
53 void util_median(
54  int32_t* const arr,
55  const size_t len,
56  double* const med);
57 
59  const void* a,
60  const void* b);
61 
62 #ifdef __cplusplus
63 }
64 #endif
65 
66 #endif
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.
Definition: util.c:46
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.
Definition: util.c:27
int util__median_compare_func(const void *a, const void *b)
Definition: util.c:78