From b7940a312616b5fd6af8aa91fc292571bfda2d9e Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 22 Jun 2021 20:39:51 -0700 Subject: [PATCH] remove ascending parameter to vector_sort_int The only calls to this uses ascending, so having this configurable was adding unnecessary maintenance burden. --- lib/mingle/ink.c | 2 +- lib/sparse/general.c | 21 ++------------------- lib/sparse/general.h | 6 ++---- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/lib/mingle/ink.c b/lib/mingle/ink.c index 1f9a07c52..00e19fdd5 100644 --- a/lib/mingle/ink.c +++ b/lib/mingle/ink.c @@ -240,7 +240,7 @@ double ink(pedge* edges, int numEdges, int *pick, double *ink0, point_t *meet1, *ink0 = 0; /* canonicalize so that edges 1,2,3 and 3,2,1 gives the same optimal ink */ - if (pick) vector_sort_int(numEdges, pick, TRUE); + if (pick) vector_sort_int(numEdges, pick); begin = end = Origin; for (i = 0; i < numEdges; i++) { diff --git a/lib/sparse/general.c b/lib/sparse/general.c index 7da126b88..e6ba34121 100644 --- a/lib/sparse/general.c +++ b/lib/sparse/general.c @@ -165,19 +165,6 @@ static int comp_ascend(const void *s1, const void *s2){ return 0; } -static int comp_descend_int(const void *s1, const void *s2){ - const int *ss1, *ss2; - ss1 = (const int*) s1; - ss2 = (const int*) s2; - - if ((ss1)[0] > (ss2)[0]){ - return -1; - } else if ((ss1)[0] < (ss2)[0]){ - return 1; - } - return 0; -} - static int comp_ascend_int(const void *s1, const void *s2){ const int *ss1, *ss2; ss1 = (const int*) s1; @@ -214,12 +201,8 @@ void vector_ordering(int n, real *v, int **p){ } -void vector_sort_int(int n, int *v, int ascending){ - if (ascending){ - qsort(v, n, sizeof(int), comp_ascend_int); - } else { - qsort(v, n, sizeof(int), comp_descend_int); - } +void vector_sort_int(int n, int *v){ + qsort(v, n, sizeof(int), comp_ascend_int); } int excute_system_command3(char *s1, char *s2, char *s3){ diff --git a/lib/sparse/general.h b/lib/sparse/general.h index ba8e917ef..ef88f2947 100644 --- a/lib/sparse/general.h +++ b/lib/sparse/general.h @@ -99,13 +99,11 @@ real* vector_saxpy2(int n, real *x, real *y, real beta);/* x = x+beta*y */ void vector_take(int n, real *v, int m, int *p, real **u); void vector_float_take(int n, float *v, int m, int *p, float **u); -/* give the position of the lagest, second largest etc in vector v if ascending = TRUE - or - give the position of the smallest, second smallest etc in vector v if ascending = TRUE. +/* give the position of the smallest, second smallest etc in vector v. results in p. If *p == NULL, p is assigned. */ void vector_ordering(int n, real *v, int **p); -void vector_sort_int(int n, int *v, int ascending); +void vector_sort_int(int n, int *v); real vector_median(int n, real *x); real vector_percentile(int n, real *x, real y);/* find the value such that y% of element of vector x is <= that value.*/ -- 2.40.0