IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 8, 2008, 12:50:52 PM (19 years ago)
Author:
eugene
Message:

replaced sort functions drived from press with sort macros derived from gsl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/dvo/fitsed.c

    r14401 r16040  
    436436SEDtableRow **sort_SEDtable (SEDtableRow *raw, int N) {
    437437
    438   int l,j,ir,i;
    439   SEDtableRow **value, *temp;
     438  int i;
     439  SEDtableRow **value;
    440440 
    441441  if (N <= 0) return (NULL);
     
    445445    value[i] = &raw[i];
    446446  }
    447   if (N < 2) return (value);
    448 
    449   l = N >> 1;
    450   ir = N - 1;
    451   for (;;) {
    452     if (l > 0) {
    453       l--;
    454       temp = value[l];
    455     }
    456     else {
    457       temp = value[ir];
    458       value[ir] = value[0];
    459       if (--ir == 0) {
    460         value[0] = temp;
    461         return (value);
    462       }
    463     }
    464     i = l;
    465     j = (l << 1) + 1;
    466     while (j <= ir) {
    467       if (j < ir && value[j][0].color < value[j+1][0].color) ++j;
    468       if (temp[0].color < value[j][0].color) {
    469         value[i] = value[j];
    470         j += (i=j) + 1;
    471       }
    472       else j = ir + 1;
    473     }
    474     value[i] = temp;
    475   }
     447
     448# define SWAPFUNC(A,B){ SEDtableRow *temp = value[A]; value[A] = value[B]; value[B] = temp; }
     449# define COMPARE(A,B)(value[A][0].color < value[B][0].color)
     450
     451  OHANA_SORT (N, COMPARE, SWAPFUNC);
     452
     453# undef SWAPFUNC
     454# undef COMPARE
    476455
    477456  return (value);
Note: See TracChangeset for help on using the changeset viewer.