Class ArrayTableFunction

java.lang.Object
com.amalgamasimulation.utils.tablefunction.ArrayTableFunction
All Implemented Interfaces:
ITableFunction, Serializable

public class ArrayTableFunction extends Object implements ITableFunction
See Also:
  • Constructor Details

    • ArrayTableFunction

      public ArrayTableFunction(List<Double> arguments, List<Double> values, double step)
      Creates a new instance of interval table function with specified arguments and values. Number of arguments should be equal to number of values. Arguments and values should all be finite numbers. If arguments are sorted in ascending order and there are no repeating arguments, a new instance will be created fast, otherwise additional calculations will be made to sort arguments and group values for repeating arguments.
      Parameters:
      arguments - - list of arguments. NaNs and infinities are not allowed.
      values - - list of values. NaNs and infinities are not allowed.
    • ArrayTableFunction

      public ArrayTableFunction(List<Pair<Double,Double>> argumentsAndValues, double step)
      Creates a new instance of interval table function with specified arguments and values. Arguments and values should all be finite numbers. If arguments are sorted in ascending order and there are no repeating arguments, a new instance will be created fast, otherwise additional calculations will be made to sort arguments and group values for repeating arguments.
      Parameters:
      argumentsAndValues - - list of (argument, value) pairs. NaNs and infinities are not allowed.
    • ArrayTableFunction

      public ArrayTableFunction(double[] arguments, double[] values, double step)
  • Method Details

    • addInterval

      public void addInterval(double beginArgInclusive, double endArgExclusive, double value)
      Adds a new interval to the interval table function. The interval partially cover or overlap several existing intervals.
      Parameters:
      beginArgInclusive - - begin argument of the interval. NaNs and infinities are not allowed.
      endArgExclusive - - end argument of the interval, should be greater than beginArgInclusive so that interval has non-zero length. NaNs and infinities are not allowed.
      value - - value added to the specified interval. NaNs and infinities are not allowed.
    • getSumBetween

      public double getSumBetween(double beginArgInclusive, double endArgExclusive)
      Retruns square under the line of the plot between the specified values (definite integral of the function from beginArgInclusive to endArgExclusive).
      Specified by:
      getSumBetween in interface ITableFunction
      Parameters:
      beginArgInclusive - - begin argument of the interval. NaNs and infinities are not allowed.
      endArgExclusive - - end argument of the interval, should be greater than beginArgInclusive so that interval has non-zero length. NaNs and infinities are not allowed.
      Returns:
      Square under the line of the plot between the specified values.
    • getPeriod

      public double getPeriod(double beginArgInclusive, double cumulativeValueLimit)
      Returns the argument with cumulative value summ equal to cumulativeValueLimit
      Specified by:
      getPeriod in interface ITableFunction
      Parameters:
      beginArgInclusive - - begin argument of the interval. NaNs and infinities are not allowed.
      cumulativeValueLimit - - cumulative values limit. NaNs and infinities are not allowed.
      Returns:
      The argument with cumulative value summ equal to cumulativeValueLimit
    • getCumulative

      public double getCumulative(double arg)
    • getMaxSum

      public double getMaxSum(double beginArgInclusive, double endArgExclusive, double argWindow, double argStep)
      Returns maximum value between the specified arguments
      Specified by:
      getMaxSum in interface ITableFunction
      Parameters:
      beginArgInclusive - - begin argument of the interval. NaNs and infinities are not allowed.
      endArgExclusive - - end argument of the interval, should be greater than beginArgInclusive so that interval has non-zero length. NaNs and infinities are not allowed.
      argWindow - - argument window
      argStep - - step between the arguments
      Returns:
      Maximum argument between the specified values
    • getAverageSum

      public double getAverageSum(double beginArgInclusive, double endArgExclusive, double argWindow, double argStep)
      Returns average sum value between the specified arguments
      Specified by:
      getAverageSum in interface ITableFunction
      Parameters:
      beginArgInclusive - - begin argument of the interval. NaNs and infinities are not allowed.
      endArgExclusive - - end argument of the interval, should be greater than beginArgInclusive so that interval has non-zero length. NaNs and infinities are not allowed.
      argWindow - - argument window
      argStep - - step between the arguments
      Returns:
      Average sum value between the specified arguments
    • getMinSum

      public double getMinSum(double beginArgInclusive, double endArgExclusive, double argWindow, double argStep)
      Returns minimum value between the specified arguments
      Specified by:
      getMinSum in interface ITableFunction
      Parameters:
      beginArgInclusive - - begin argument of the interval. NaNs and infinities are not allowed.
      endArgExclusive - - end argument of the interval, should be greater than beginArgInclusive so that interval has non-zero length. NaNs and infinities are not allowed.
      argWindow - - argument window
      argStep - - step between the arguments
      Returns:
      Minimum argument between the specified values
    • get

      public double get(double arg)
      Returns value by argument
      Specified by:
      get in interface ITableFunction
      Parameters:
      arg - - argument
      Returns:
      Value by argument
    • getInterpolated

      public double getInterpolated(double arg)
      Specified by:
      getInterpolated in interface ITableFunction
    • getMinNonZeroArgument

      public double getMinNonZeroArgument()
      Returns minimal argument with non-zero value
      Specified by:
      getMinNonZeroArgument in interface ITableFunction
      Returns:
      Minimal argument with non-zero value, or Double.POSITIVE_INFINITY if there are no non-zero values in the table function
    • getMinNonZeroArgumentBetween

      public double getMinNonZeroArgumentBetween(double beginArgument, double endArgument)
      Specified by:
      getMinNonZeroArgumentBetween in interface ITableFunction
    • getMaxNonZeroArgument

      public double getMaxNonZeroArgument()
      Description copied from interface: ITableFunction
      Returns minimal argument with non-zero value.
      Specified by:
      getMaxNonZeroArgument in interface ITableFunction
      Returns:
      Minimal argument with non-zero value, or Double.NEGATIVE_INFINITY if there are no non-zero values in the table function
    • getMaxNonZeroArgumentBetween

      public double getMaxNonZeroArgumentBetween(double beginArgument, double endArgument)
      Specified by:
      getMaxNonZeroArgumentBetween in interface ITableFunction
    • getAdjacentValues

      public Pair<Double,Double> getAdjacentValues(double arg)
      Returns two values closest to argument, first is left-sided, second is right-sided
      Parameters:
      arg - - argument
      Returns:
      Two values closest to argument, first is left-sided, second is right-sided
    • getArgumentValuePairs

      public List<Pair<Double,Double>> getArgumentValuePairs()
      Returns all argument-value pairs
      Specified by:
      getArgumentValuePairs in interface ITableFunction
      Returns:
      All argument-value pairs
    • getArgumentCumulativeValuePairs

      public List<Pair<Double,Double>> getArgumentCumulativeValuePairs()
      Returns all cumulative argument-value pairs
      Returns:
      All cumulative argument-value pairs
    • getCopy

      public ITableFunction getCopy()
      Specified by:
      getCopy in interface ITableFunction
    • multiply

      public void multiply(double factor)