554 |
|
int n, imax; |
555 |
|
int wl; |
556 |
|
double wl0, wlstep; |
557 |
+ |
double boxpos, boxstep; |
558 |
|
/* check bounds */ |
559 |
|
if (wlmax <= C_CMINWL | wlmax <= wlmin | wlmin >= C_CMAXWL) |
560 |
|
return(MG_EILL); |
567 |
|
wlmax -= wlstep; |
568 |
|
ac--; |
569 |
|
} |
569 |
– |
if (ac < 2) |
570 |
– |
return(MG_EILL); |
570 |
|
imax = ac; /* box filter if necessary */ |
571 |
+ |
boxpos = 0; |
572 |
+ |
boxstep = 1; |
573 |
|
if (wlstep < C_CWLI) { |
574 |
+ |
imax = (wlmax - wlmin)/C_CWLI + (1-FTINY); |
575 |
+ |
boxpos = (wlmin - C_CMINWL)/C_CWLI; |
576 |
+ |
boxstep = wlstep/C_CWLI; |
577 |
|
wlstep = C_CWLI; |
574 |
– |
imax = (wlmax - wlmin)/wlstep; |
578 |
|
} |
579 |
|
scale = 0.; /* get values and maximum */ |
580 |
|
pos = 0; |
581 |
|
for (i = 0; i < imax; i++) { |
582 |
|
va[i] = 0.; n = 0; |
583 |
< |
while (pos < (i+.5)*ac/imax) { |
583 |
> |
while (boxpos < i+.5 && pos < ac) { |
584 |
|
if (!isflt(av[pos])) |
585 |
|
return(MG_ETYPE); |
586 |
|
va[i] += atof(av[pos++]); |
587 |
|
n++; |
588 |
+ |
boxpos += boxstep; |
589 |
|
} |
590 |
|
if (n > 1) |
591 |
|
va[i] /= (double)n; |
594 |
|
if (va[i] > scale) |
595 |
|
scale = va[i]; |
596 |
|
} |
597 |
< |
if (scale == 0.) |
597 |
> |
if (scale <= FTINY) |
598 |
|
return(MG_EILL); |
599 |
|
scale = C_CMAXV / scale; |
600 |
|
clr->ssum = 0; /* convert to our spacing */ |