Class ArrayTableFunction
java.lang.Object
com.amalgamasimulation.utils.tablefunction.ArrayTableFunction
- All Implemented Interfaces:
ITableFunction
,Serializable
- See Also:
-
Constructor Summary
ConstructorDescriptionArrayTableFunction
(double[] arguments, double[] values, double step) ArrayTableFunction
(List<Pair<Double, Double>> argumentsAndValues, double step) Creates a new instance of interval table function with specified arguments and values.ArrayTableFunction
(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 TypeMethodDescriptionvoid
addInterval
(double beginArgInclusive, double endArgExclusive, double value) Adds a new interval to the interval table function.double
get
(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 pairsdouble
getAverageSum
(double beginArgInclusive, double endArgExclusive, double argWindow, double argStep) Returns average sum value between the specified argumentsgetCopy()
double
getCumulative
(double arg) double
getInterpolated
(double arg) double
Returns minimal argument with non-zero value.double
getMaxNonZeroArgumentBetween
(double beginArgument, double endArgument) double
getMaxSum
(double beginArgInclusive, double endArgExclusive, double argWindow, double argStep) Returns maximum value between the specified argumentsdouble
Returns minimal argument with non-zero valuedouble
getMinNonZeroArgumentBetween
(double beginArgument, double endArgument) double
getMinSum
(double beginArgInclusive, double endArgExclusive, double argWindow, double argStep) Returns minimum value between the specified argumentsdouble
getPeriod
(double beginArgInclusive, double cumulativeValueLimit) Returns the argument with cumulative value summ equal tocumulativeValueLimit
double
getSumBetween
(double beginArgInclusive, double endArgExclusive) Retruns square under the line of the plot between the specified values (definite integral of the function frombeginArgInclusive
toendArgExclusive
).void
multiply
(double factor)
-
Constructor Details
-
ArrayTableFunction
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
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 thanbeginArgInclusive
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 frombeginArgInclusive
toendArgExclusive
).- Specified by:
getSumBetween
in interfaceITableFunction
- Parameters:
beginArgInclusive
- - begin argument of the interval. NaNs and infinities are not allowed.endArgExclusive
- - end argument of the interval, should be greater thanbeginArgInclusive
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 tocumulativeValueLimit
- Specified by:
getPeriod
in 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:
getMaxSum
in interfaceITableFunction
- Parameters:
beginArgInclusive
- - begin argument of the interval. NaNs and infinities are not allowed.endArgExclusive
- - end argument of the interval, should be greater thanbeginArgInclusive
so 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:
getAverageSum
in interfaceITableFunction
- Parameters:
beginArgInclusive
- - begin argument of the interval. NaNs and infinities are not allowed.endArgExclusive
- - end argument of the interval, should be greater thanbeginArgInclusive
so 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:
getMinSum
in interfaceITableFunction
- Parameters:
beginArgInclusive
- - begin argument of the interval. NaNs and infinities are not allowed.endArgExclusive
- - end argument of the interval, should be greater thanbeginArgInclusive
so 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:
get
in interfaceITableFunction
- Parameters:
arg
- - argument- Returns:
- Value by argument
-
getInterpolated
public double getInterpolated(double arg) - Specified by:
getInterpolated
in interfaceITableFunction
-
getMinNonZeroArgument
public double getMinNonZeroArgument()Returns minimal argument with non-zero value- Specified by:
getMinNonZeroArgument
in 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:
getMinNonZeroArgumentBetween
in interfaceITableFunction
-
getMaxNonZeroArgument
public double getMaxNonZeroArgument()Description copied from interface:ITableFunction
Returns minimal argument with non-zero value.- Specified by:
getMaxNonZeroArgument
in 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:
getMaxNonZeroArgumentBetween
in 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:
getArgumentValuePairs
in interfaceITableFunction
- Returns:
- All argument-value pairs
-
getArgumentCumulativeValuePairs
Returns all cumulative argument-value pairs- Returns:
- All cumulative argument-value pairs
-
getCopy
- Specified by:
getCopy
in interfaceITableFunction
-
multiply
public void multiply(double factor)
-