Package ffx.numerics.integrate
Class FunctionDataCurve
java.lang.Object
ffx.numerics.integrate.FunctionDataCurve
- All Implemented Interfaces:
DataSet
- Direct Known Subclasses:
CompositeCurve
,CosineWave
,PolynomialCurve
,SinWave
A FunctionDataCurve represents a set of points along a 1-dimensional, analytically integrable
function.
- Author:
- Jacob M. Litman
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
If ends should have 1/2 regular separation.protected double
Lower bound.protected double[]
Function values.protected double
Upper bound.protected double[]
Input points. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
Evaluates the functions analytical integral over the entire range of points.double
analyticalIntegral
(double lb, double ub) Evaluates the function's analytical integral over a range.static boolean
approxEquals
(double x1, double x2) Checks for equality to +/- 10 ulp.static boolean
approxEquals
(double x1, double x2, double ulpMultiple) Compare two doubles to machine precision.protected final void
Used to check that x array is composed of equally-spaced points from lb to ub.double
binWidth()
Separation between points along x; should be uniform.abstract double
fX
(double x) Evaluates the function at x.double[]
Returns copy of the array of points f(x) to integrate (y-axis).double
getFxPoint
(int index) Point f(x) at index.double[]
getX()
Returns copy of the array of points x (x-axis).boolean
Does this data set have half-width start/end bins.abstract double
integralAt
(double x) Analytical integral at a point.double
Lower bound of the points along x.int
Number of points along x.toString()
double
Upper bound of the points along x.
-
Field Details
-
lb
protected double lbLower bound. -
ub
protected double ubUpper bound. -
points
protected double[] pointsFunction values. -
x
protected double[] xInput points. -
halfWidthEnd
protected boolean halfWidthEndIf ends should have 1/2 regular separation.
-
-
Constructor Details
-
FunctionDataCurve
public FunctionDataCurve()Constructor.
-
-
Method Details
-
approxEquals
public static boolean approxEquals(double x1, double x2) Checks for equality to +/- 10 ulp.- Parameters:
x1
- a double.x2
- a double.- Returns:
- a boolean.
-
approxEquals
public static boolean approxEquals(double x1, double x2, double ulpMultiple) Compare two doubles to machine precision.- Parameters:
x1
- The first point.x2
- The second point.ulpMultiple
- A multiple to apply to the ULP of the larger of the two values.- Returns:
- True if the two values are within the specified ULPs of each other.
-
analyticalIntegral
public double analyticalIntegral()Evaluates the functions analytical integral over the entire range of points.- Returns:
- Exact finite integral
-
analyticalIntegral
public double analyticalIntegral(double lb, double ub) Evaluates the function's analytical integral over a range.- Parameters:
lb
- Lower integration boundub
- Upper integration bound- Returns:
- Exact finite integral of range
-
binWidth
public double binWidth()Separation between points along x; should be uniform. -
fX
public abstract double fX(double x) Evaluates the function at x.- Parameters:
x
- x- Returns:
- f(x)
-
getAllFxPoints
public double[] getAllFxPoints()Returns copy of the array of points f(x) to integrate (y-axis).- Specified by:
getAllFxPoints
in interfaceDataSet
- Returns:
- an array of
invalid reference
double
-
getFxPoint
public double getFxPoint(int index) Point f(x) at index.- Specified by:
getFxPoint
in interfaceDataSet
- Parameters:
index
- the index of the point to return.- Returns:
- a double.
-
getX
public double[] getX()Returns copy of the array of points x (x-axis). -
halfWidthEnds
public boolean halfWidthEnds()Does this data set have half-width start/end bins. Intended for OST, where the first and last bins are half the regular width.- Specified by:
halfWidthEnds
in interfaceDataSet
- Returns:
- a boolean.
-
integralAt
public abstract double integralAt(double x) Analytical integral at a point.- Parameters:
x
- Point- Returns:
- Exact finite integral of 0 to this point
-
lowerBound
public double lowerBound()Lower bound of the points along x.- Specified by:
lowerBound
in interfaceDataSet
- Returns:
- a double.
-
numPoints
public int numPoints()Number of points along x. -
toString
-
upperBound
public double upperBound()Upper bound of the points along x.- Specified by:
upperBound
in interfaceDataSet
- Returns:
- a double.
-
assertXIntegrity
protected final void assertXIntegrity()Used to check that x array is composed of equally-spaced points from lb to ub.
-