Class ArrayTableFunctionFast
java.lang.Object
com.amalgamasimulation.utils.tablefunction.ArrayTableFunctionFast
- All Implemented Interfaces:
ITableFunction,Serializable
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionArrayTableFunctionFast(double[] arguments, double[] values, double step) ArrayTableFunctionFast(List<Pair<Double, Double>> argumentsAndValues, double step) Creates a new instance of interval table function with specified arguments and values.ArrayTableFunctionFast(List<Double> arguments, List<Double> values, double step) Creates a new instance of interval table function with specified arguments and values. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInterval(double beginArgInclusive, double endArgExclusive, double value) Adds a new interval to the interval table function.doubleget(double arg) Returns value by argumentgetAdjacentValues(double arg) Returns two values closest to argument, first is left-sided, second is right-sidedReturns all cumulative argument-value pairsReturns all argument-value pairsdoublegetAverageSum(double beginArgInclusive, double endArgExclusive, double argWindow, double argStep) Returns average sum value between the specified argumentsgetCopy()doublegetCumulative(double arg) doublegetInterpolated(double arg) doubleReturns minimal argument with non-zero value.doublegetMaxNonZeroArgumentBetween(double beginArgument, double endArgument) doublegetMaxSum(double beginArgInclusive, double endArgExclusive, double argWindow, double argStep) Returns maximum value between the specified argumentsdoubleReturns minimal argument with non-zero valuedoublegetMinNonZeroArgumentBetween(double beginArgument, double endArgument) doublegetMinSum(double beginArgInclusive, double endArgExclusive, double argWindow, double argStep) Returns minimum value between the specified argumentsdoublegetPeriod(double beginArgInclusive, double cumulativeValueLimit) Returns the argument with cumulative value summ equal tocumulativeValueLimitdoublegetSumBetween(double beginArgInclusive, double endArgExclusive) Retruns square under the line of the plot between the specified values (definite integral of the function frombeginArgInclusivetoendArgExclusive).voidmultiply(double factor)
-
Constructor Details
-
ArrayTableFunctionFast
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.
-
ArrayTableFunctionFast
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.
-
ArrayTableFunctionFast
public ArrayTableFunctionFast(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 thanbeginArgInclusiveso 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 frombeginArgInclusivetoendArgExclusive).- Specified by:
getSumBetweenin interfaceITableFunction- Parameters:
beginArgInclusive- - begin argument of the interval. NaNs and infinities are not allowed.endArgExclusive- - end argument of the interval, should be greater thanbeginArgInclusiveso 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 tocumulativeValueLimit- Specified by:
getPeriodin interfaceITableFunction- 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:
getMaxSumin interfaceITableFunction- Parameters:
beginArgInclusive- - begin argument of the interval. NaNs and infinities are not allowed.endArgExclusive- - end argument of the interval, should be greater thanbeginArgInclusiveso that interval has non-zero length. NaNs and infinities are not allowed.argWindow- - argument windowargStep- - 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:
getAverageSumin interfaceITableFunction- Parameters:
beginArgInclusive- - begin argument of the interval. NaNs and infinities are not allowed.endArgExclusive- - end argument of the interval, should be greater thanbeginArgInclusiveso that interval has non-zero length. NaNs and infinities are not allowed.argWindow- - argument windowargStep- - 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:
getMinSumin interfaceITableFunction- Parameters:
beginArgInclusive- - begin argument of the interval. NaNs and infinities are not allowed.endArgExclusive- - end argument of the interval, should be greater thanbeginArgInclusiveso that interval has non-zero length. NaNs and infinities are not allowed.argWindow- - argument windowargStep- - step between the arguments- Returns:
- Minimum argument between the specified values
-
get
public double get(double arg) Returns value by argument- Specified by:
getin interfaceITableFunction- Parameters:
arg- - argument- Returns:
- Value by argument
-
getInterpolated
public double getInterpolated(double arg) - Specified by:
getInterpolatedin interfaceITableFunction
-
getMinNonZeroArgument
public double getMinNonZeroArgument()Returns minimal argument with non-zero value- Specified by:
getMinNonZeroArgumentin interfaceITableFunction- 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:
getMinNonZeroArgumentBetweenin interfaceITableFunction
-
getMaxNonZeroArgument
public double getMaxNonZeroArgument()Description copied from interface:ITableFunctionReturns minimal argument with non-zero value.- Specified by:
getMaxNonZeroArgumentin interfaceITableFunction- 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:
getMaxNonZeroArgumentBetweenin interfaceITableFunction
-
getAdjacentValues
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
Returns all argument-value pairs- Specified by:
getArgumentValuePairsin interfaceITableFunction- Returns:
- All argument-value pairs
-
getArgumentCumulativeValuePairs
Returns all cumulative argument-value pairs- Returns:
- All cumulative argument-value pairs
-
getCopy
- Specified by:
getCopyin interfaceITableFunction
-
multiply
public void multiply(double factor)
-