Class FunctionDataCurve

java.lang.Object
ffx.numerics.integrate.FunctionDataCurve
All Implemented Interfaces:
DataSet
Direct Known Subclasses:
CompositeCurve, CosineWave, PolynomialCurve, SinWave

public abstract class FunctionDataCurve extends Object implements DataSet
A FunctionDataCurve represents a set of points along a 1-dimensional, analytically integrable function.
Author:
Jacob M. Litman
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected 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

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    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
    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[]
    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.
    double
    Upper bound of the points along x.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • lb

      protected double lb
      Lower bound.
    • ub

      protected double ub
      Upper bound.
    • points

      protected double[] points
      Function values.
    • x

      protected double[] x
      Input points.
    • halfWidthEnd

      protected boolean halfWidthEnd
      If 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 bound
      ub - Upper integration bound
      Returns:
      Exact finite integral of range
    • binWidth

      public double binWidth()
      Separation between points along x; should be uniform.
      Specified by:
      binWidth in interface DataSet
      Returns:
      a double.
    • 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 interface DataSet
      Returns:
      an array of
      invalid reference
      double
      objects.
    • getFxPoint

      public double getFxPoint(int index)
      Point f(x) at index.
      Specified by:
      getFxPoint in interface DataSet
      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).
      Specified by:
      getX in interface DataSet
      Returns:
      an array of
      invalid reference
      double
      objects.
    • 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 interface DataSet
      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 interface DataSet
      Returns:
      a double.
    • numPoints

      public int numPoints()
      Number of points along x.
      Specified by:
      numPoints in interface DataSet
      Returns:
      the number of points.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • upperBound

      public double upperBound()
      Upper bound of the points along x.
      Specified by:
      upperBound in interface DataSet
      Returns:
      a double.
    • assertXIntegrity

      protected final void assertXIntegrity()
      Used to check that x array is composed of equally-spaced points from lb to ub.