@Test public void testClosestToUpperBound() { assertEquals(1.3, SpikeInterpolation.getUpperValue(useAr, 1.3), 1e-8); assertEquals(2, SpikeInterpolation.getUpperValue(useAr, 1.9), 1e-8); assertEquals(2.9, SpikeInterpolation.getUpperValue(useAr, 2.7), 1e-8); assertEquals(2.9, SpikeInterpolation.getUpperValue(useAr, 2.9), 1e-8); }
static double getUpperValue(double[] doubles, double val) { double lowestUpper = Double.MAX_VALUE; for (double current : doubles) { if (current >= val && current <= lowestUpper) { lowestUpper = current; } } if (lowestUpper == Double.MAX_VALUE) { throw new IllegalArgumentException("Can't find the closest max value of " + val); } return lowestUpper; }
SpikeInterpolation { static double getUpperValue(double[] doubles, double val) { double lowestUpper = Double.MAX_VALUE; for (double current : doubles) { if (current >= val && current <= lowestUpper) { lowestUpper = current; } } if (lowestUpper == Double.MAX_VALUE) { throw new IllegalArgumentException("Can't find the closest max value of " + val); } return lowestUpper; } }
SpikeInterpolation { static double getUpperValue(double[] doubles, double val) { double lowestUpper = Double.MAX_VALUE; for (double current : doubles) { if (current >= val && current <= lowestUpper) { lowestUpper = current; } } if (lowestUpper == Double.MAX_VALUE) { throw new IllegalArgumentException("Can't find the closest max value of " + val); } return lowestUpper; }  }
SpikeInterpolation { static double getUpperValue(double[] doubles, double val) { double lowestUpper = Double.MAX_VALUE; for (double current : doubles) { if (current >= val && current <= lowestUpper) { lowestUpper = current; } } if (lowestUpper == Double.MAX_VALUE) { throw new IllegalArgumentException("Can't find the closest max value of " + val); } return lowestUpper; }   }
SpikeInterpolation { static double getUpperValue(double[] doubles, double val) { double lowestUpper = Double.MAX_VALUE; for (double current : doubles) { if (current >= val && current <= lowestUpper) { lowestUpper = current; } } if (lowestUpper == Double.MAX_VALUE) { throw new IllegalArgumentException("Can't find the closest max value of " + val); } return lowestUpper; }    }