diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 83d03e1d9..63df40a1a 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -54,6 +54,11 @@ If the output is not quite correct, check for invisible trailing spaces! + + Add getXmax(), getXmin(), getYmax(), getYmin() to bicubic interpolating function. + These can be useful to manage an OutOfRangeException without the need to access + the original x and y arrays. + Added mapping functions to MathArrays. These methods allow to map any univariate or bivariate functions to arrays. diff --git a/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java b/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java index b89a51778..f1c10f80f 100644 --- a/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java +++ b/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java @@ -184,6 +184,38 @@ public class BicubicInterpolatingFunction } } + /** + * Returns the minimum value of the first coordinate + * @return xval[0]. + */ + public double getXmin() { + return xval[0]; + } + + /** + * Returns the maximum value of the second coordinate + * @return xval[xval.length - 1]. + */ + public double getXmax() { + return xval[xval.length - 1]; + } + + /** + * Returns the minimum value of the second coordinate + * @return yval[0]. + */ + public double getYmin() { + return yval[0]; + } + + /** + * Returns the maximum value of the second coordinate + * @return yval[yval.length - 1]. + */ + public double getYmax() { + return yval[yval.length - 1]; + } + /** * @param c Coordinate. * @param val Coordinate samples. diff --git a/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java b/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java index 0ec77aa42..b54c7503d 100644 --- a/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java +++ b/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java @@ -160,7 +160,12 @@ public final class BicubicInterpolatingFunctionTest { try { bcf.value(x, y); Assert.fail("OutOfRangeException expected"); - } catch (OutOfRangeException expected) {} + } catch (OutOfRangeException expected) { + Assert.assertEquals(xMin, bcf.getXmin(), 1.0e-15); + Assert.assertEquals(xMax, bcf.getXmax(), 1.0e-15); + Assert.assertEquals(yMin, bcf.getYmin(), 1.0e-15); + Assert.assertEquals(yMax, bcf.getYmax(), 1.0e-15); + } x = xMin; y = yMax + small; @@ -169,7 +174,12 @@ public final class BicubicInterpolatingFunctionTest { try { bcf.value(x, y); Assert.fail("OutOfRangeException expected"); - } catch (OutOfRangeException expected) {} + } catch (OutOfRangeException expected) { + Assert.assertEquals(xMin, bcf.getXmin(), 1.0e-15); + Assert.assertEquals(xMax, bcf.getXmax(), 1.0e-15); + Assert.assertEquals(yMin, bcf.getYmin(), 1.0e-15); + Assert.assertEquals(yMax, bcf.getYmax(), 1.0e-15); + } } /**