BicubicInterpolatingFunction implements BivariateFunction { public boolean isValidPoint(double x, double y) { if (x < xval[0] || x > xval[xval.length - 1] || y < yval[0] || y > yval[yval.length - 1]) { return false; } else { return true; } } BicubicInterpolatingFunction(double[] x,
                                        double[] y,
                                        double[][] f,
                                        double[][] dFdX,
                                        double[][] dFdY,
                                        double[][] d2FdXdY); double value(double x, double y); boolean isValidPoint(double x, double y);  }
@Test public void testIsValidPoint() { final double xMin = -12; final double xMax = 34; final double yMin = 5; final double yMax = 67; final double[] xval = new double[] { xMin, xMax }; final double[] yval = new double[] { yMin, yMax }; final double[][] f = new double[][] { { 1, 2 }, { 3, 4 } }; final double[][] dFdX = f; final double[][] dFdY = f; final double[][] dFdXdY = f; final BicubicInterpolatingFunction bcf = new BicubicInterpolatingFunction(xval, yval, f, dFdX, dFdY, dFdXdY); double x, y; x = xMin; y = yMin; Assert.assertTrue(bcf.isValidPoint(x, y)); bcf.value(x, y); x = xMax; y = yMax; Assert.assertTrue(bcf.isValidPoint(x, y)); bcf.value(x, y); final double xRange = xMax - xMin; final double yRange = yMax - yMin; x = xMin + xRange / 3.4; y = yMin + yRange / 1.2; Assert.assertTrue(bcf.isValidPoint(x, y)); bcf.value(x, y); final double small = 1e-8; x = xMin - small; y = yMax; Assert.assertFalse(bcf.isValidPoint(x, y)); try { bcf.value(x, y); Assert.fail("OutOfRangeException expected"); } catch (OutOfRangeException expected) {} x = xMin; y = yMax + small; Assert.assertFalse(bcf.isValidPoint(x, y)); try { bcf.value(x, y); Assert.fail("OutOfRangeException expected"); } catch (OutOfRangeException expected) {} }