IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 18, 2019, 5:02:59 PM (7 years ago)
Author:
eugene
Message:

cleanup opihi sort functions; add deimos fitobj function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/sort.c

    r40398 r40642  
    11# include "data.h"
    2 
    3 void fsortindex (opihi_flt *X, int *IDX, int N) {
    4 
    5 # define SWAPFUNC(A,B){ opihi_flt tmp; int itmp;        \
    6   tmp = X[A]; X[A] = X[B]; X[B] = tmp; \
    7   itmp = IDX[A]; IDX[A] = IDX[B]; IDX[B] = itmp; \
    8 }
    9 
    10 // # define COMPARE(A,B)(X[A] < X[B])
    11 # define COMPARE(A,B)((!isfinite(X[A]) && isfinite(X[B])) || (X[A] < X[B]))
    12 
    13   OHANA_SORT (N, COMPARE, SWAPFUNC);
    14 
    15 # undef SWAPFUNC
    16 # undef COMPARE
    17 
    18 }
    19 
    20 void isortindex (opihi_int *X, int *IDX, int N) {
    21 
    22 # define SWAPFUNC(A,B){ opihi_int tmp; int itmp;        \
    23   tmp = X[A]; X[A] = X[B]; X[B] = tmp; \
    24   itmp = IDX[A]; IDX[A] = IDX[B]; IDX[B] = itmp; \
    25 }
    26 
    27 # define COMPARE(A,B)(X[A] < X[B])
    28 // # define COMPARE(A,B)((!isfinite(X[A]) && isfinite(X[B])) || (X[A] < X[B]))
    29 
    30   OHANA_SORT (N, COMPARE, SWAPFUNC);
    31 
    32 # undef SWAPFUNC
    33 # undef COMPARE
    34 
    35 }
    362
    373// XXX add an option to NOT sort, but return an index instead?
     
    7844  /* sort key & index */
    7945  if (vec[0][0].type == OPIHI_FLT) {
    80     fsortindex (vec[0][0].elements.Flt, index, Nval);
     46    sort_opihi_flt_index (vec[0][0].elements.Flt, index, Nval);
    8147  } else {
    82     isortindex (vec[0][0].elements.Int, index, Nval);
     48    sort_int_index (vec[0][0].elements.Int, index, Nval);
    8349  }
    8450
Note: See TracChangeset for help on using the changeset viewer.