Package uk.ac.starlink.dpac.math
Class FuncUtils
- java.lang.Object
-
- uk.ac.starlink.dpac.math.FuncUtils
-
public class FuncUtils extends java.lang.Object
Utility methods associated with functions. This class contains only static methods.- Since:
- 15 Mar 2018
- Author:
- Mark Taylor
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
findValueMonotonic(Function f, double xlo, double xhi, double y0, double ytol)
Locates the X value where a supplied monotonically non-decreasing function is within a specified tolerance of a given Y value.static Function
interpolateLinear(NumericFunction nf)
Returns a function which represents an interpolated representation of the given sample set, using linear interpolation.static Function
interpolateQuadratic(NumericFunction nf)
Returns a function which represents an interpolated representation of the given sample set, using quadratic interpolation with Legendre polynomials.static Function
interpolateSpline(NumericFunction nf)
Returns a function which represents an interpolated representation of the given sample set, using splines.
-
-
-
Method Detail
-
interpolateQuadratic
public static Function interpolateQuadratic(NumericFunction nf)
Returns a function which represents an interpolated representation of the given sample set, using quadratic interpolation with Legendre polynomials.- Parameters:
nf
- input numeric function- Returns:
- interpolated version of function
-
interpolateSpline
public static Function interpolateSpline(NumericFunction nf)
Returns a function which represents an interpolated representation of the given sample set, using splines.- Parameters:
nf
- input numeric function- Returns:
- interpolated version of function
-
interpolateLinear
public static Function interpolateLinear(NumericFunction nf)
Returns a function which represents an interpolated representation of the given sample set, using linear interpolation.- Parameters:
nf
- input numeric function- Returns:
- interpolated version of function
-
findValueMonotonic
public static double findValueMonotonic(Function f, double xlo, double xhi, double y0, double ytol)
Locates the X value where a supplied monotonically non-decreasing function is within a specified tolerance of a given Y value. The bisection method is used. Behaviour is undefined if the supplied function is not monotonic.- Parameters:
f
- monotonic functionxlo
- lowest X value to considerxhi
- highest X value to considery0
- required Y valueytol
- tolerance in Y- Returns:
- X value corresonding to
y0
, or NaN if it's not in range
-
-