IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 3, 2010, 8:41:49 AM (16 years ago)
Author:
eugene
Message:

updates from trunk

Location:
branches/tap_branches
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/tap_branches

  • branches/tap_branches/Ohana

  • branches/tap_branches/Ohana/src/dvomerge/src/build_links.c

    r24745 r27838  
    33/* build the initial links assuming the table is sorted,
    44   not partial, and has a correct set of average[].measureOffset,Nmeasure values */
    5 int *init_measure_links (Average *average, int Naverage, Measure *measure, int Nmeasure) {
    6 
    7   int i, j, N;
    8   int *next;
     5off_t *init_measure_links (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure) {
     6
     7  off_t i, j, N;
     8  off_t *next;
    99
    1010  N = 0;
    1111
    12   ALLOCATE (next, int, Nmeasure);
     12  ALLOCATE (next, off_t, Nmeasure);
    1313  for (i = 0; i < Naverage; i++, N++) {
    1414    for (j = 0; j < average[i].Nmeasure - 1; j++, N++) {
     
    3131}
    3232
     33/* average[].measureOffset, average[].Nmeasure are valid within an addstar run */
     34int add_meas_link (Average *average, off_t *next, off_t Nmeasure, off_t NMEASURE) {
     35
     36  off_t k, m;
     37
     38  /* if we have trouble, check validity of next[m] : m < Nmeasure */
     39  m = average[0].measureOffset; 
     40
     41  for (k = 0; k < average[0].Nmeasure - 1; k++)  {
     42    m = next[m];
     43    if (m >= NMEASURE) {
     44      fprintf (stderr, "WARNING: m out of bounds (3)\n");
     45    }
     46  }
     47
     48  /* set up references */
     49  next[Nmeasure] = -1;
     50  if (Nmeasure >= NMEASURE) {
     51    fprintf (stderr, "WARNING: Nmeasure out of bounds (1)\n");
     52  }
     53
     54  if (m == -1) {
     55    average[0].measureOffset = Nmeasure;
     56  } else {
     57    next[m] = Nmeasure;
     58    if (m >= NMEASURE) {
     59      fprintf (stderr, "WARNING: m out of bounds (4)\n");
     60    }
     61  }
     62
     63  return (TRUE);
     64}
     65
     66Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next) {
     67
     68  off_t i, k, n, N;
     69  Measure *tmpmeasure;
     70
     71  /* fix order of Measure (memory intensive, but fast) */
     72  N = 0;
     73  ALLOCATE (tmpmeasure, Measure, Nmeasure);
     74  for (i = 0; i < Naverage; i++) {
     75    n = average[i].measureOffset;
     76    average[i].measureOffset = N;
     77    for (k = 0; k < average[i].Nmeasure; k++, N++) {
     78      tmpmeasure[N] = measure[n];
     79      tmpmeasure[N].averef = i;
     80      n = next[n];
     81    }
     82  }
     83  free (measure);
     84  return (tmpmeasure);
     85}
     86
     87/* construct measure links which are valid FOR THIS LOAD
     88 * - if we have a full load, we will get links which can
     89 *   be used by other programs (eg, relphot, etc)
     90 * - if we have a partial load, the links are only valid
     91 *   for that partial load
     92 */
     93
     94off_t *build_measure_links (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure) {
     95
     96  off_t i, m, k, Nm, averef;
     97  off_t *next;
     98
     99  ALLOCATE (next, off_t, Nmeasure);
     100
     101  /* reset the Nm, offset values for average */
     102  for (i = 0; i < Naverage; i++) {
     103    average[i].measureOffset = -1;
     104    average[i].Nmeasure     =  0;
     105  }
     106
     107  for (Nm = 0; Nm < Nmeasure; Nm++) {
     108    averef = measure[Nm].averef;
     109    m = average[averef].measureOffset; 
     110    next[Nm] = -1;
     111
     112    if (m == -1) { /* no links yet for source */
     113      average[averef].measureOffset = Nm;
     114      average[averef].Nmeasure     = 1;
     115      continue;
     116    }
     117
     118    for (k = 0; next[m] != -1; k++) {
     119      m = next[m];
     120      if (m >= Nmeasure) {
     121        fprintf (stderr, "WARNING: m out of bounds (1)\n");
     122      }
     123    }
     124
     125    average[averef].Nmeasure = k + 2;
     126    next[m] = Nm;
     127    if (m >= Nmeasure) {
     128      fprintf (stderr, "WARNING: m out of bounds (2)\n");
     129    }
     130  }
     131  return (next);
     132}
     133
    33134/* build the initial links assuming the table is sorted */
    34 int *init_missing_links (Average *average, int Naverage, Missing *missing, int Nmissing) {
    35 
    36   int i, j, N;
    37   int *next;
     135off_t *init_missing_links (Average *average, off_t Naverage, Missing *missing, off_t Nmissing) {
     136
     137  off_t i, j, N;
     138  off_t *next;
    38139
    39140  N = 0;
    40141
    41   ALLOCATE (next, int, Nmissing);
     142  ALLOCATE (next, off_t, Nmissing);
    42143  for (i = 0; i < Naverage; i++) {
    43144    for (j = 0; j < average[i].Nmissing - 1; j++, N++) {
     
    57158}
    58159
    59 /* average[].measureOffset, average[].Nmeasure are valid within an addstar run */
    60 int add_meas_link (Average *average, int *next, int Nmeasure, int NMEASURE) {
    61 
    62   int k, m;
    63 
    64   /* if we have trouble, check validity of next[m] : m < Nmeasure */
    65   m = average[0].measureOffset; 
    66 
    67   for (k = 0; k < average[0].Nmeasure - 1; k++)  {
    68     m = next[m];
    69     if (m >= NMEASURE) {
    70       fprintf (stderr, "WARNING: m out of bounds (3)\n");
    71     }
    72   }
    73 
    74   /* set up references */
    75   next[Nmeasure] = -1;
    76   if (Nmeasure >= NMEASURE) {
    77     fprintf (stderr, "WARNING: Nmeasure out of bounds (1)\n");
    78   }
    79 
    80   if (m == -1) {
    81     average[0].measureOffset = Nmeasure;
    82   } else {
    83     next[m] = Nmeasure;
    84     if (m >= NMEASURE) {
    85       fprintf (stderr, "WARNING: m out of bounds (4)\n");
    86     }
    87   }
    88 
    89   return (TRUE);
    90 }
    91 
    92 int add_miss_link (Average *average, int *next, int Nmissing) {
    93 
    94   int k, m;
     160int add_miss_link (Average *average, off_t *next, off_t Nmissing) {
     161
     162  off_t k, m;
    95163
    96164  /* there may be 0 Nmiss; this is not true for Nmeas */
     
    109177}
    110178
    111 /* construct measure links which are valid FOR THIS LOAD
    112  * - if we have a full load, we will get links which can
    113  *   be used by other programs (eg, relphot, etc)
    114  * - if we have a partial load, the links are only valid
    115  *   for that partial load
    116  */
    117 
    118 int *build_measure_links (Average *average, int Naverage, Measure *measure, int Nmeasure) {
    119 
    120   int i, m, k, Nm, averef;
    121   int *next;
    122 
    123   ALLOCATE (next, int, Nmeasure);
    124 
    125   /* reset the Nm, offset values for average */
    126   for (i = 0; i < Naverage; i++) {
    127     average[i].measureOffset = -1;
    128     average[i].Nmeasure     =  0;
    129   }
    130 
    131   for (Nm = 0; Nm < Nmeasure; Nm++) {
    132     averef = measure[Nm].averef;
    133     m = average[averef].measureOffset; 
    134     next[Nm] = -1;
    135 
    136     if (m == -1) { /* no links yet for source */
    137       average[averef].measureOffset = Nm;
    138       average[averef].Nmeasure     = 1;
    139       continue;
    140     }
    141 
    142     for (k = 0; next[m] != -1; k++) {
    143       m = next[m];
    144       if (m >= Nmeasure) {
    145         fprintf (stderr, "WARNING: m out of bounds (1)\n");
    146       }
    147     }
    148 
    149     average[averef].Nmeasure = k + 2;
    150     next[m] = Nm;
    151     if (m >= Nmeasure) {
    152       fprintf (stderr, "WARNING: m out of bounds (2)\n");
    153     }
    154   }
    155   return (next);
    156 }
    157 
    158179/* Missing does not carry enough information to reconstruct the links
    159180   we must always save the missing table, if it exists */
    160181
    161 Measure *sort_measure (Average *average, int Naverage, Measure *measure, int Nmeasure, int *next) {
    162 
    163   int i, k, n, N;
    164   Measure *tmpmeasure;
    165 
    166   /* fix order of Measure (memory intensive, but fast) */
    167   N = 0;
    168   ALLOCATE (tmpmeasure, Measure, Nmeasure);
    169   for (i = 0; i < Naverage; i++) {
    170     n = average[i].measureOffset;
    171     average[i].measureOffset = N;
    172     for (k = 0; k < average[i].Nmeasure; k++, N++) {
    173       tmpmeasure[N] = measure[n];
    174       tmpmeasure[N].averef = i;
    175       n = next[n];
    176     }
    177   }
    178   free (measure);
    179   return (tmpmeasure);
    180 }
    181 
    182 Missing *sort_missing (Average *average, int Naverage, Missing *missing, int Nmissing, int *next) {
    183 
    184   int i, k, n, N;
     182Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next) {
     183
     184  off_t i, k, n, N;
    185185  Missing *tmpmissing;
    186186
Note: See TracChangeset for help on using the changeset viewer.