Markus:
> The problem is the non-linear increase here, I guess: If I
> would check for 1000 GDD in above example, I have the input
> 
> ...
> 193,997.8
> 194,1008.4
> ...
> 
> but get
> EPSILON = 1e-6
> > abs(997 - 1000) < EPSILON * 1000
> [1] FALSE
> > abs(1008.4 - 1000) < EPSILON * 1000
> [1] FALSE
> 
> and still won't find it.

the correct output here is "194", yes? ie the first day to cross that
threshold? Can you guarantee that the input data array is sorted?

why worry about EPSILON at all? If sorted:

for(i=0; i < data.n; i++)
{
   if ( data.val[i] > threshold )
      return data.day[i];
}


If not sorted just run through the whole loop and

first_day=366;
for (day)
{
 if ((val > thresh) && (day < first_day))
    first_day = day;
}
return first_day;


?
Hamish



      

_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to