(double x, double[] xpoints, double[] ypoints, int len, double min, double max)
| 62 | } |
| 63 | |
| 64 | public static int findNearestXIndex(double x, double[] xpoints, double[] ypoints, int len, double min, |
| 65 | double max) { |
| 66 | |
| 67 | x = Math.min(max, Math.max(min, x)); |
| 68 | |
| 69 | int imin = -1; |
| 70 | double dxmin = Double.MAX_VALUE; |
| 71 | for (int i = 0; i < len; i++) { |
| 72 | if (Double.isNaN(ypoints[i])) |
| 73 | continue; |
| 74 | double dx = Math.abs(x - xpoints[i]); |
| 75 | if (dx < dxmin) { |
| 76 | dxmin = dx; |
| 77 | imin = i; |
| 78 | } |
| 79 | } |
| 80 | if (xpoints[imin] < min) |
| 81 | imin++; |
| 82 | if (imin == len || xpoints[imin] > max) |
| 83 | imin = len - 1; |
| 84 | return imin; |
| 85 | } |
| 86 | |
| 87 | public static int findNearestXIndex0(double x, double[] xpoints, double[] ypoints, int len, double min, double max) { |
| 88 |
no test coverage detected