33 static double **data = NULL;
34 static long last_n = 0;
42 data = (
double **)
zarray_2d(
sizeof(**data), n, 2);
46 for (i = 0; i < n; i++) {
53 *value = data[n / 2][0];
69 static double **data = NULL;
70 static long last_n = 0;
75 if (percentile < 0 || percentile > 100)
80 data = (
double **)
zarray_2d(
sizeof(**data), n, 2);
84 for (i = 0; i < n; i++) {
91 *value = data[(long)((n - 1) * (percentile / 100.0))][0];
92 i = data[(long)((n - 1) * (percentile / 100.0))][1];
107 static double **data = NULL;
108 static long last_n = 0;
111 if (index < 0 && n <= 0)
117 data = (
double **)
zarray_2d(
sizeof(**data), n, 2);
121 for (i = 0; i < n; i++) {
122 data[i][0] = x[i][index];
126 qsort((
void *)data, n,
sizeof(*data),
row_compare);
128 *value = data[n / 2][0];
143 double sum, min_dist, dist;
149 for (i = sum = 0; i < n; i++)
155 for (i = 0; i < n; i++)
156 if ((dist = fabs(data[i] - sum)) < min_dist) {
173 double target, min_dist, dist, min, max;
181 target = (min + max) / 2;
185 for (i = 0; i < n; i++)
186 if ((dist = fabs(data[i] - target)) < min_dist) {
void ** zarray_2d(uint64_t size, uint64_t n1, uint64_t n2)
Allocates a 2D array with specified dimensions.
int free_zarray_2d(void **array, uint64_t n1, uint64_t n2)
Frees a 2D array and its associated memory.
int find_min_max(double *min, double *max, double *list, int64_t n)
Finds the minimum and maximum values in a list of doubles.
void set_up_row_sort(int sort_by_column, size_t n_columns, size_t element_size, int(*compare)(const void *a, const void *b))
Set up parameters for row-based sorting.
int double_cmpasc(const void *a, const void *b)
Compare two doubles in ascending order.
int row_compare(const void *av, const void *bv)
Compare two rows based on the previously set sorting parameters.