power_method(L, L->n, 1, seed, maxit, tol, &v, &eigv);
}
- vector_ordering(n, v, p, TRUE);
+ vector_ordering(n, v, p);
if (Verbose)
fprintf(stderr, "cpu time for spectral ordering (before greedy) = %f\n", (real) (clock() - start)/(CLOCKS_PER_SEC));
/* find the median value in a list of real */
int *p = NULL;
real res;
- vector_ordering(n, x, &p, TRUE);
+ vector_ordering(n, x, &p);
if ((n/2)*2 == n){
res = 0.5*(x[p[n/2-1]] + x[p[n/2]]);
*/
int *p = NULL, i;
real res;
- vector_ordering(n, x, &p, TRUE);
+ vector_ordering(n, x, &p);
y = MIN(y, 1);
return 0;
}
-
-void vector_ordering(int n, real *v, int **p, int ascending){
- /* give the position of the lagest, second largest etc in vector v if ascending = FALSE
-
- or
-
- give the position of the smallest, second smallest etc in vector v if ascending = TRUE.
+void vector_ordering(int n, real *v, int **p){
+ /* give the position of the smallest, second smallest etc in vector v.
results in p. If *p == NULL, p is assigned.
-
- ascending: TRUE if v[p] is from small to large.
*/
real *u;
u[2*i] = v[i];
}
- if (ascending){
- qsort(u, n, sizeof(real)*2, comp_ascend);
- } else {
- qsort(u, n, sizeof(real)*2, comp_descend);
- }
+ qsort(u, n, sizeof(real)*2, comp_ascend);
for (i = 0; i < n; i++) (*p)[i] = (int) u[2*i+1];
FREE(u);
give the position of the smallest, second smallest etc in vector v if ascending = TRUE.
results in p. If *p == NULL, p is assigned.
*/
-void vector_ordering(int n, real *v, int **p, int ascending);
+void vector_ordering(int n, real *v, int **p);
void vector_sort_real(int n, real *v, int ascending);
void vector_sort_int(int n, int *v, int ascending);
real vector_median(int n, real *x);