| 61 |
|
register PACKHEAD *clist; |
| 62 |
|
int nents; |
| 63 |
|
{ |
| 64 |
+ |
int oldnr; |
| 65 |
|
register int i, n; |
| 66 |
< |
|
| 66 |
> |
/* look for common members */ |
| 67 |
> |
for (n = 0; n < nents; n++) { |
| 68 |
> |
for (i = 0; i < complen; i++) |
| 69 |
> |
if (clist[n].bi == complist[i].bi && |
| 70 |
> |
clist[n].hd == complist[i].hd) { |
| 71 |
> |
oldnr = complist[i].nr; |
| 72 |
> |
clist[n].nc = complist[i].nc; |
| 73 |
> |
switch (op) { |
| 74 |
> |
case BS_ADD: /* add to count */ |
| 75 |
> |
complist[i].nr += clist[n].nr; |
| 76 |
> |
clist[n].nr = 0; |
| 77 |
> |
break; |
| 78 |
> |
case BS_ADJ: /* reset count */ |
| 79 |
> |
complist[i].nr = clist[n].nr; |
| 80 |
> |
clist[n].nr = 0; |
| 81 |
> |
break; |
| 82 |
> |
case BS_DEL: /* delete count */ |
| 83 |
> |
if (clist[n].nr == 0 || |
| 84 |
> |
clist[n].nr >= complist[i].nr) |
| 85 |
> |
complist[i].nr = 0; |
| 86 |
> |
else |
| 87 |
> |
complist[i].nr -= clist[n].nr; |
| 88 |
> |
break; |
| 89 |
> |
} |
| 90 |
> |
if (complist[i].nr != oldnr) |
| 91 |
> |
lastin = -1; /* flag sort */ |
| 92 |
> |
break; |
| 93 |
> |
} |
| 94 |
> |
if (i >= complen) |
| 95 |
> |
clist[n].nc = bnrays(hdlist[clist[n].hd], clist[n].bi); |
| 96 |
> |
} |
| 97 |
> |
/* complete list operations */ |
| 98 |
|
switch (op) { |
| 99 |
|
case BS_NEW: /* new computation set */ |
| 100 |
< |
if (complen) |
| 100 |
> |
listpos = 0; |
| 101 |
> |
lastin = -1; |
| 102 |
> |
if (complen) /* free old list */ |
| 103 |
|
free((char *)complist); |
| 104 |
< |
if (nents <= 0) { |
| 105 |
< |
complist = NULL; |
| 72 |
< |
listpos = complen = 0; |
| 73 |
< |
lastin = -1; |
| 104 |
> |
complist = NULL; |
| 105 |
> |
if (!(complen = nents)) |
| 106 |
|
return; |
| 75 |
– |
} |
| 107 |
|
complist = (PACKHEAD *)malloc(nents*sizeof(PACKHEAD)); |
| 108 |
|
if (complist == NULL) |
| 109 |
|
goto memerr; |
| 110 |
|
bcopy((char *)clist, (char *)complist, nents*sizeof(PACKHEAD)); |
| 80 |
– |
complen = nents; /* finish initialization below */ |
| 111 |
|
break; |
| 112 |
|
case BS_ADD: /* add to computation set */ |
| 113 |
|
case BS_ADJ: /* adjust set quantities */ |
| 114 |
|
if (nents <= 0) |
| 115 |
|
return; |
| 116 |
< |
/* merge any common members */ |
| 87 |
< |
for (n = 0; n < nents; n++) { |
| 88 |
< |
for (i = 0; i < complen; i++) |
| 89 |
< |
if (clist[n].bi == complist[i].bi && |
| 90 |
< |
clist[n].hd == complist[i].hd) { |
| 91 |
< |
int oldnr = complist[i].nr; |
| 92 |
< |
if (op == BS_ADD) |
| 93 |
< |
complist[i].nr += clist[n].nr; |
| 94 |
< |
else /* op == BS_ADJ */ |
| 95 |
< |
complist[i].nr = clist[n].nr; |
| 96 |
< |
clist[n].nr = 0; |
| 97 |
< |
clist[n].nc = complist[i].nc; |
| 98 |
< |
if (complist[i].nr != oldnr) |
| 99 |
< |
lastin = -1; /* flag sort */ |
| 100 |
< |
break; |
| 101 |
< |
} |
| 102 |
< |
if (i >= complen) |
| 103 |
< |
clist[n].nc = bnrays(hdlist[clist[n].hd], |
| 104 |
< |
clist[n].bi); |
| 105 |
< |
} |
| 106 |
< |
/* sort updated list */ |
| 107 |
< |
sortcomplist(); |
| 108 |
< |
/* sort new entries */ |
| 116 |
> |
sortcomplist(); /* sort updated list & new entries */ |
| 117 |
|
qsort((char *)clist, nents, sizeof(PACKHEAD), beamcmp); |
| 118 |
|
/* what can't we satisfy? */ |
| 119 |
|
for (n = 0; n < nents && clist[n].nr > clist[n].nc; n++) |
| 137 |
|
lastin = complen-1; /* list is now sorted */ |
| 138 |
|
break; |
| 139 |
|
case BS_DEL: /* delete from computation set */ |
| 140 |
< |
if (nents <= 0) |
| 133 |
< |
return; |
| 134 |
< |
/* find each member */ |
| 135 |
< |
for (i = 0; i < complen; i++) |
| 136 |
< |
for (n = 0; n < nents; n++) |
| 137 |
< |
if (clist[n].bi == complist[i].bi && |
| 138 |
< |
clist[n].hd == complist[i].hd) { |
| 139 |
< |
if (clist[n].nr == 0 || |
| 140 |
< |
clist[n].nr >= complist[i].nr) |
| 141 |
< |
complist[i].nr = 0; |
| 142 |
< |
else |
| 143 |
< |
complist[i].nr -= clist[n].nr; |
| 144 |
< |
lastin = -1; /* flag full sort */ |
| 145 |
< |
break; |
| 146 |
< |
} |
| 147 |
< |
return; /* no display */ |
| 140 |
> |
return; /* already done */ |
| 141 |
|
default: |
| 142 |
|
error(CONSISTENCY, "bundle_set called with unknown operation"); |
| 143 |
|
} |
| 152 |
|
hdloadbeams(hb, nents, dispbeam); |
| 153 |
|
free((char *)hb); |
| 154 |
|
} |
| 162 |
– |
if (op == BS_NEW) { |
| 163 |
– |
done_packets(flush_queue()); /* empty queue, so we can... */ |
| 164 |
– |
for (i = 0; i < complen; i++) /* ...get number computed */ |
| 165 |
– |
complist[i].nc = bnrays(hdlist[complist[i].hd], |
| 166 |
– |
complist[i].bi); |
| 167 |
– |
listpos = 0; |
| 168 |
– |
lastin = -1; /* flag for initial sort */ |
| 169 |
– |
} |
| 155 |
|
return; |
| 156 |
|
memerr: |
| 157 |
|
error(SYSTEM, "out of memory in bundle_set"); |
| 212 |
|
/* compute beam weights */ |
| 213 |
|
k = 0; |
| 214 |
|
for (j = 0; hdlist[j] != NULL; j++) { |
| 215 |
< |
frac = 512. * hdlist[j]->wg[0] * |
| 216 |
< |
hdlist[j]->wg[1] * hdlist[j]->wg[2]; |
| 217 |
< |
if (frac < 0.) frac = -frac; |
| 215 |
> |
frac = 512. * VLEN(hdlist[j]->wg[0]) * |
| 216 |
> |
VLEN(hdlist[j]->wg[1]) * |
| 217 |
> |
VLEN(hdlist[j]->wg[2]); |
| 218 |
|
for (i = nbeams(hdlist[j]); i > 0; i--) { |
| 219 |
|
complist[k].hd = j; |
| 220 |
|
complist[k].bi = i; |