- Timestamp:
- May 3, 2010, 8:45:22 AM (16 years ago)
- Location:
- branches/simmosaic_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simmosaic_branches
- Property svn:mergeinfo changed
-
branches/simmosaic_branches/Ohana
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/Ohana merged eligible /branches/eam_branches/Ohana.20100407 27635-27772 /branches/pap_delete/Ohana 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simmosaic_branches/Ohana/src/addstar/src/build_links.c
r17192 r27839 1 1 # include "addstar.h" 2 3 /* 4 5 There are two modes for the measure table: sorted and unsorted. 6 7 In sorted mode, all measures associated with a given average are in a single block. The block 8 is pointed to by average->measureOffset and the range is average->Nmeasure 9 10 In unsorted mode, it is not possible to go directly from average to measure without scanning. 11 In this case, it is necessary to use the value measure->averef to find the corresponding 12 average entry. 13 14 Note that average->measureOffset and measure->averef are only valid for a given load of the 15 data: they refer to the sequence number in the data blocks. 16 17 next_meas is a list of the equivalent sequence of the measure block as if it were sorted. 18 19 to find the sequence of measurements for a given average: 20 n_0 = average->measureOffset 21 n_1 = next_meas[n_0] 22 n_i = next_meas[n_i-1] 23 24 */ 2 25 3 26 /* build the initial links assuming the table is sorted, 4 27 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;28 off_t *init_measure_links (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure) { 29 30 off_t i, j, N; 31 off_t *next_meas; 9 32 10 33 N = 0; 11 34 12 ALLOCATE (next , int, Nmeasure);35 ALLOCATE (next_meas, off_t, Nmeasure); 13 36 for (i = 0; i < Naverage; i++, N++) { 14 37 for (j = 0; j < average[i].Nmeasure - 1; j++, N++) { 15 next [N] = N + 1;38 next_meas[N] = N + 1; 16 39 if (N >= Nmeasure) { 17 40 fprintf (stderr, "WARNING: N out of bounds (1)\n"); 18 41 } 19 42 } 20 next [N] = -1;43 next_meas[N] = -1; 21 44 if (N >= Nmeasure) { 22 45 fprintf (stderr, "WARNING: N out of bounds (2)\n"); … … 28 51 } 29 52 } 30 return (next); 31 } 32 33 /* 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; 38 39 N = 0; 40 41 ALLOCATE (next, int, Nmissing); 42 for (i = 0; i < Naverage; i++) { 43 for (j = 0; j < average[i].Nmissing - 1; j++, N++) { 44 next[N] = N + 1; 45 } 46 if (average[i].Nmissing > 0) { 47 next[N] = -1; 48 if (N >= Nmissing) { 49 fprintf (stderr, "overflow in init_missing_links"); 50 abort (); 51 } 52 N++; 53 } 54 55 } 56 return (next); 57 } 58 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; 95 96 /* there may be 0 Nmiss; this is not true for Nmeas */ 97 if (average[0].Nmissing < 1) { 98 average[0].missingOffset = Nmissing; 99 next[Nmissing] = -1; 100 return (TRUE); 101 } 102 103 m = average[0].missingOffset; 104 for (k = 0; k < average[0].Nmissing - 1; k++) m = next[m]; 105 /* set up references */ 106 next[Nmissing] = -1; 107 next[m] = Nmissing; 108 return (TRUE); 53 return (next_meas); 109 54 } 110 55 … … 116 61 */ 117 62 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);63 off_t *build_measure_links (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure) { 64 65 off_t i, m, k, Nm, averef; 66 off_t *next_meas; 67 68 ALLOCATE (next_meas, off_t, Nmeasure); 124 69 125 70 /* reset the Nm, offset values for average */ … … 132 77 averef = measure[Nm].averef; 133 78 m = average[averef].measureOffset; 134 next [Nm] = -1;79 next_meas[Nm] = -1; 135 80 136 81 if (m == -1) { /* no links yet for source */ … … 140 85 } 141 86 142 for (k = 0; next [m] != -1; k++) {143 m = next [m];87 for (k = 0; next_meas[m] != -1; k++) { 88 m = next_meas[m]; 144 89 if (m >= Nmeasure) { 145 90 fprintf (stderr, "WARNING: m out of bounds (1)\n"); … … 148 93 149 94 average[averef].Nmeasure = k + 2; 150 next [m] = Nm;95 next_meas[m] = Nm; 151 96 if (m >= Nmeasure) { 152 97 fprintf (stderr, "WARNING: m out of bounds (2)\n"); 153 98 } 154 99 } 155 return (next); 100 return (next_meas); 101 } 102 103 /* average[].measureOffset, average[].Nmeasure are valid within an addstar run */ 104 off_t add_meas_link (Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE) { 105 106 off_t k, m; 107 108 /* if we have trouble, check validity of next_meas[m] : m < Nmeasure */ 109 m = average[0].measureOffset; 110 111 for (k = 0; k < average[0].Nmeasure - 1; k++) { 112 m = next_meas[m]; 113 if (m >= NMEASURE) { 114 fprintf (stderr, "WARNING: m out of bounds (3)\n"); 115 } 116 } 117 118 /* set up references */ 119 next_meas[Nmeasure] = -1; 120 if (Nmeasure >= NMEASURE) { 121 fprintf (stderr, "WARNING: Nmeasure out of bounds (1)\n"); 122 } 123 124 if (m == -1) { 125 average[0].measureOffset = Nmeasure; 126 } else { 127 next_meas[m] = Nmeasure; 128 if (m >= NMEASURE) { 129 fprintf (stderr, "WARNING: m out of bounds (4)\n"); 130 } 131 } 132 133 return (TRUE); 156 134 } 157 135 … … 159 137 we must always save the missing table, if it exists */ 160 138 161 Measure *sort_measure (Average *average, int Naverage, Measure *measure, int Nmeasure, int *next) {162 163 int i, k, n, N;139 Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next_meas) { 140 141 off_t i, k, n, N; 164 142 Measure *tmpmeasure; 165 143 … … 171 149 average[i].measureOffset = N; 172 150 for (k = 0; k < average[i].Nmeasure; k++, N++) { 151 if (n == -1) abort(); 173 152 tmpmeasure[N] = measure[n]; 153 if (measure[n].averef != i) abort(); 174 154 tmpmeasure[N].averef = i; 175 n = next [n];155 n = next_meas[n]; 176 156 } 177 157 } … … 180 160 } 181 161 182 Missing *sort_missing (Average *average, int Naverage, Missing *missing, int Nmissing, int *next) { 183 184 int i, k, n, N; 162 /* build the initial links assuming the table is sorted */ 163 off_t *init_missing_links (Average *average, off_t Naverage, Missing *missing, off_t Nmissing) { 164 165 off_t i, j, N; 166 off_t *next_miss; 167 168 N = 0; 169 170 ALLOCATE (next_miss, off_t, Nmissing); 171 for (i = 0; i < Naverage; i++) { 172 for (j = 0; j < average[i].Nmissing - 1; j++, N++) { 173 next_miss[N] = N + 1; 174 } 175 if (average[i].Nmissing > 0) { 176 next_miss[N] = -1; 177 if (N >= Nmissing) { 178 fprintf (stderr, "overflow in init_missing_links"); 179 abort (); 180 } 181 N++; 182 } 183 184 } 185 return (next_miss); 186 } 187 188 off_t add_miss_link (Average *average, off_t *next_miss, off_t Nmissing) { 189 190 off_t k, m; 191 192 /* there may be 0 Nmiss; this is not true for Nmeas */ 193 if (average[0].Nmissing < 1) { 194 average[0].missingOffset = Nmissing; 195 next_miss[Nmissing] = -1; 196 return (TRUE); 197 } 198 199 m = average[0].missingOffset; 200 for (k = 0; k < average[0].Nmissing - 1; k++) m = next_miss[m]; 201 /* set up references */ 202 next_miss[Nmissing] = -1; 203 next_miss[m] = Nmissing; 204 return (TRUE); 205 } 206 207 Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss) { 208 209 off_t i, k, n, N; 185 210 Missing *tmpmissing; 186 211 … … 193 218 for (k = 0; k < average[i].Nmissing; k++, N++) { 194 219 tmpmissing[N] = missing[n]; 195 n = next [n];220 n = next_miss[n]; 196 221 } 197 222 } … … 199 224 return (tmpmissing); 200 225 } 226
Note:
See TracChangeset
for help on using the changeset viewer.
