363 |
|
tms->hbrmin = tms->hbrmax = ls[i]; |
364 |
|
oldlen = 0; |
365 |
|
} else { |
366 |
< |
oldorig = (tms->hbrmin-MINBRT)/HISTEP; |
367 |
< |
oldlen = (tms->hbrmax-MINBRT)/HISTEP + 1 - oldorig; |
366 |
> |
oldorig = HISTI(tms->hbrmin); |
367 |
> |
oldlen = HISTI(tms->hbrmax) + 1 - oldorig; |
368 |
|
} |
369 |
|
for (i = len; i--; ) { |
370 |
|
if ((j = ls[i]) < MINBRT) |
374 |
|
else if (j > tms->hbrmax) |
375 |
|
tms->hbrmax = j; |
376 |
|
} |
377 |
< |
horig = (tms->hbrmin-MINBRT)/HISTEP; |
378 |
< |
hlen = (tms->hbrmax-MINBRT)/HISTEP + 1 - horig; |
377 |
> |
horig = HISTI(tms->hbrmin); |
378 |
> |
hlen = HISTI(tms->hbrmax) + 1 - horig; |
379 |
|
if (hlen > oldlen) { /* (re)allocate histogram */ |
380 |
|
int *newhist = (int *)calloc(hlen, sizeof(int)); |
381 |
|
if (newhist == NULL) |
391 |
|
returnOK; |
392 |
|
for (i = len; i--; ) /* add in new counts */ |
393 |
|
if (ls[i] >= MINBRT) |
394 |
< |
tms->histo[ (ls[i]-MINBRT)/HISTEP - horig ] += wt; |
394 |
> |
tms->histo[ HISTI(ls[i]) - horig ] += wt; |
395 |
|
returnOK; |
396 |
|
} |
397 |
|
|
496 |
|
Ldmin = Ldmax/Lddyn; |
497 |
|
logLddyn = log(Lddyn); |
498 |
|
Ldavg = sqrt(Ldmax*Ldmin); |
499 |
< |
i = (tms->hbrmin-MINBRT)/HISTEP; |
500 |
< |
brt0 = MINBRT + HISTEP/2 + i*HISTEP; |
501 |
< |
histlen = (tms->hbrmax-MINBRT)/HISTEP + 1 - i; |
499 |
> |
i = HISTI(tms->hbrmin); |
500 |
> |
brt0 = HISTV(i); |
501 |
> |
histlen = HISTI(tms->hbrmax) + 1 - i; |
502 |
|
/* histogram total and mean */ |
503 |
|
histot = 0; sum = 0; |
504 |
|
j = brt0 + histlen*HISTEP; |
633 |
|
return(NULL); |
634 |
|
*tmnew = *tms; /* copy everything */ |
635 |
|
if (tmnew->histo != NULL) { /* duplicate histogram */ |
636 |
< |
len = (tmnew->hbrmax-MINBRT)/HISTEP + 1 - |
637 |
< |
(tmnew->hbrmin-MINBRT)/HISTEP; |
636 |
> |
len = HISTI(tmnew->hbrmax) + 1 - HISTI(tmnew->hbrmin); |
637 |
|
tmnew->histo = (int *)malloc(len*sizeof(int)); |
638 |
|
if (tmnew->histo != NULL) |
639 |
|
for (i = len; i--; ) |