* update for the UE localization functions

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6502 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
Navid Nikaein
2015-02-10 12:21:18 +00:00
parent 5f3e26524b
commit 376619babb
9 changed files with 126 additions and 54 deletions
+13 -10
View File
@@ -304,10 +304,11 @@ del(struct list* z) {
struct node* cur;
struct node* x = z->head;
while(x) {
while((x != NULL) && (z->size > 0)) {
cur = x;
x = x->next;
free(cur);
z->size--;
}
z->head = NULL;
@@ -410,14 +411,16 @@ int compare (const void * a, const void * b)
*/
int32_t calculate_median(struct list *loc_list) {
int32_t median = 0;
double* table = (double*) malloc(loc_list->size * sizeof(double));
totable(table, loc_list);
/// sort the table in ascending way
qsort (table, loc_list->size, sizeof(double), &compare);
/// median is the value at middle the sorted table
/// Q1 is the value at 1/4 the sorted table
/// Q3 is the value at 3/4 the sorted table
median = table[loc_list->size/2];
free(table);
if (loc_list->size > 0) {
double* table = (double*) malloc(loc_list->size * sizeof(double));
totable(table, loc_list);
/// sort the table in ascending way
qsort (table, loc_list->size, sizeof(double), &compare);
/// median is the value at middle the sorted table
/// Q1 is the value at 1/4 the sorted table
/// Q3 is the value at 3/4 the sorted table
median = table[loc_list->size/2];
free(table);
}
return median;
}