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/dvomisc.c

    r7680 r16040  
    3333
    3434}
    35 
    36 /* values are ave[i].R, ave[i].D, ave[i].M */
    37 void sortave (Average *ave, int N) {
    38 
    39   int l,j,ir,i;
    40   Average tmp;
    41 
    42   if (N < 2) return;
    43   l = N >> 1;
    44   ir = N - 1;
    45   for (;;) {
    46     if (l > 0) {
    47       l--;
    48       tmp = ave[l];
    49     }
    50     else {
    51       tmp = ave[ir];
    52       ave[ir] = ave[0];
    53       if (--ir == 0) {
    54         ave[0] = tmp;
    55         return;
    56       }
    57     }
    58     i = l;
    59     j = (l << 1) + 1;
    60     while (j <= ir) {
    61       if (j < ir && ave[j].R < ave[j+1].R) j++;
    62       if (tmp.R < ave[j].R) {
    63         ave[i] = ave[j];
    64         j += (i=j) + 1;
    65       }
    66       else j = ir + 1;
    67     }
    68     ave[i] = tmp;
    69   }
    70 }
    71 
    72 /** this does not seem to be used at the moment */
    73 /* values are ave[i].R, ave[i].D, ave[i].M */
    74 void sort_images (Image *image, int N) {
    75 
    76   int l,j,ir,i;
    77   Image tmp;
    78 
    79   if (N < 2) return;
    80   l = N >> 1;
    81   ir = N - 1;
    82   for (;;) {
    83     if (l > 0) {
    84       l--;
    85       tmp = image[l];
    86     }
    87     else {
    88       tmp = image[ir];
    89       image[ir] = image[0];
    90       if (--ir == 0) {
    91         image[0] = tmp;
    92         return;
    93       }
    94     }
    95     i = l;
    96     j = (l << 1) + 1;
    97     while (j <= ir) {
    98       if (j < ir && image[j].tzero < image[j+1].tzero) j++;
    99       if (tmp.tzero < image[j].tzero) {
    100         image[i] = image[j];
    101         j += (i=j) + 1;
    102       }
    103       else j = ir + 1;
    104     }
    105     image[i] = tmp;
    106   }
    107 }
    108 
    109 /* sort subset by image[subset[i]].tzero */
    110 void sort_image_subset (Image *image, int *subset, int N) {
    111 
    112   int l, j, ir, i, tmp;
    113 
    114   if (N < 2) return;
    115   l = N >> 1;
    116   ir = N - 1;
    117   for (;;) {
    118     if (l > 0) {
    119       l--;
    120       tmp = subset[l];
    121     }
    122     else {
    123       tmp = subset[ir];
    124       subset[ir] = subset[0];
    125       if (--ir == 0) {
    126         subset[0] = tmp;
    127         return;
    128       }
    129     }
    130     i = l;
    131     j = (l << 1) + 1;
    132     while (j <= ir) {
    133       if (j < ir && image[subset[j]].tzero < image[subset[j+1]].tzero) j++;
    134       if (image[tmp].tzero < image[subset[j]].tzero) {
    135         subset[i] = subset[j];
    136         j += (i=j) + 1;
    137       }
    138       else j = ir + 1;
    139     }
    140     subset[i] = tmp;
    141   }
    142 }
Note: See TracChangeset for help on using the changeset viewer.