IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 26, 2007, 5:35:47 PM (19 years ago)
Author:
eugene
Message:

various cleanups of I/O operations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotSortBySN.c

    r13006 r15040  
    1 # include "psphotInternal.h"
    21
    3 
    4 // sort by SN (descending)
    5 int pmPeakSortBySN (const void **a, const void **b)
    6 {
    7     pmPeak *A = *(pmPeak **)a;
    8     pmPeak *B = *(pmPeak **)b;
    9 
    10     psF32 fA = A->SN;
    11     psF32 fB = B->SN;
    12     if (isnan (fA)) fA = 0;
    13     if (isnan (fB)) fB = 0;
    14 
    15     psF32 diff = fA - fB;
    16     if (diff > FLT_EPSILON) return (-1);
    17     if (diff < FLT_EPSILON) return (+1);
    18     return (0);
    19 }
    20 
    21 // sort by Y (ascending)
    22 int pmPeakSortByY (const void **a, const void **b)
    23 {
    24     pmPeak *A = *(pmPeak **)a;
    25     pmPeak *B = *(pmPeak **)b;
    26 
    27     psF32 fA = A->y;
    28     psF32 fB = B->y;
    29 
    30     psF32 diff = fA - fB;
    31     if (diff > FLT_EPSILON) return (+1);
    32     if (diff < FLT_EPSILON) return (-1);
    33     return (0);
    34 }
    35 
    36 // sort by SN (descending)
    37 int pmSourceSortBySN (const void **a, const void **b)
    38 {
    39     pmSource *A = *(pmSource **)a;
    40     pmSource *B = *(pmSource **)b;
    41 
    42     psF32 fA = (A->peak == NULL) ? 0 : A->peak->SN;
    43     psF32 fB = (B->peak == NULL) ? 0 : B->peak->SN;
    44     if (isnan (fA)) fA = 0;
    45     if (isnan (fB)) fB = 0;
    46 
    47     psF32 diff = fA - fB;
    48     if (diff > FLT_EPSILON) return (-1);
    49     if (diff < FLT_EPSILON) return (+1);
    50     return (0);
    51 }
    52 
    53 // sort by Y (ascending)
    54 int pmSourceSortByY (const void **a, const void **b)
    55 {
    56     pmSource *A = *(pmSource **)a;
    57     pmSource *B = *(pmSource **)b;
    58 
    59     psF32 fA = (A->peak == NULL) ? 0 : A->peak->y;
    60     psF32 fB = (B->peak == NULL) ? 0 : B->peak->y;
    61 
    62     psF32 diff = fA - fB;
    63     if (diff > FLT_EPSILON) return (+1);
    64     if (diff < FLT_EPSILON) return (-1);
    65     return (0);
    66 }
    67 
Note: See TracChangeset for help on using the changeset viewer.