Partially revert -r314. The existing tests were more robust in the

face of round-off error.

  Preserve unconditional "snap to last" feature of function uniquify()
  for the time being.
This commit is contained in:
Bård Skaflestad 2009-08-14 12:50:21 +00:00
parent 756454f0fc
commit 6c6b1aa0c8

View File

@ -90,14 +90,20 @@ static int uniquify(int n, double *list, double tolerance)
double val = list[pos++];/* Keep first value */
for (i=1; i<n; ++i){
if (list [i] - val > tolerance){
if (val + tolerance < list [i]){
val = list[i];
list[pos++] = val;
}
}
/* Keep last value (one way or the other...) */
list[pos-1] = list[n-1];
#if 0
if (val + tolerance < list[n-1]){
list[pos-1] = list[n-1];
}
#else
list[pos-1] = list[n-1];
#endif
return pos;
}
@ -139,12 +145,12 @@ static int assignPointNumbers(int begin,
}
/* Find next k such that zlist[k] < z[i] < zlist[k+1] */
while ((k < end) && (z[i] - zlist[k] > tolerance)){
while ((k < end) && (zlist[k] + tolerance < z[i])){
k++;
}
/* assert (k < len && z[i] - zlist[k] <= tolerance) */
if ((k == end) || ( z[i] - zlist[k] > tolerance)){
if ((k == end) || ( zlist[k] + tolerance < z[i])){
fprintf(stderr, "Cannot associate zcorn values with given list\n");
fprintf(stderr, "of z-coordinates to given tolerance\n");
return 0;