Package org.djutils.math.functions
Interface MathFunction
- All Superinterfaces:
Comparable<MathFunction>,Function<Double,Double>
- All Known Implementing Classes:
ArcSine,ArcTangent,Concatenation,Constant,Exponential,Logarithm,Nan,Power,Product,Quotient,Sine,Sum
MathFunction interface.
Copyright (c) 2024-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordWrapper for one domain and function value pair. -
Method Summary
Modifier and TypeMethodDescriptiondefault intcompareChains(MathFunction chain1, MathFunction chain2) Compare chains for sorting.default intcompareTo(MathFunction other) intcompareWithinSubType(MathFunction other) Determine sorting order among instances of a particular sub type ofMathFunction.Returns the derivative of the data with respect to fractional length.getKnotReport(Interval<?> interval) Report what is known about knots of thisMathFunctionin someInterval.Report all knots of thisMathFunctionin someInterval.default doublegetScale()Get the scale factor of this MathFunction.default MathFunctionmergeAdd(MathFunction other) This MathFunction is added to another; try to replace both by a combinedMathFunction.default MathFunctionmergeDivide(MathFunction other) This MathFunction is divided by another; try to replace both by a combined MathFunction.default MathFunctionmergeMultiply(MathFunction other) This MathFunction is multiplied by another; try to replace both by a combined MathFunction.default StringprintValue(double value) Format a numerical value.scaleBy(double factor) Incorporate a multiplication factor to this MathFunction.default MathFunctionsimplify()Attempts to find a simplified version of this MathFunction (e.g. replace1 - 5by-4).intSorting priority of this type of MathFunction (low values shall sort before higher).
-
Method Details
-
getDerivative
MathFunction getDerivative()Returns the derivative of the data with respect to fractional length.- Returns:
- derivative of this MathFunction
-
simplify
Attempts to find a simplified version of this MathFunction (e.g. replace1 - 5by-4).- Returns:
this, or a simplified version thereof
-
getScale
default double getScale()Get the scale factor of this MathFunction.- Returns:
- the scale factor of this MathFunction
-
scaleBy
Incorporate a multiplication factor to this MathFunction.- Parameters:
factor- the factor to incorporate- Returns:
- a new MathFunction that yields the same result as the original function multiplied by the
factor
-
printValue
Format a numerical value. If the value is integer, format it without decimal point. If the value is not integer, use a reasonable format.- Parameters:
value- the value to format- Returns:
- the formatted value
-
compareChains
Compare chains for sorting.- Parameters:
chain1- chainMathFunctionof firstMathFunction(may benull)chain2- chainMathFunctionof secondMathFunction(may benull)- Returns:
- int
< 0whenchain1sorts beforechain2;> 0whenchain1sorts afterchain2;0whenchain1is equal tochain2
-
sortPriority
int sortPriority()Sorting priority of this type of MathFunction (low values shall sort before higher).- Returns:
- sorting priority of this type of MathFunction
-
compareWithinSubType
Determine sorting order among instances of a particular sub type ofMathFunction. The sorting order should sortMathFunctions that may be combined next to one another. BecauseMathFunctions are also used inSortedSets, this comparator may return 0 if and only if this and other are entirely equal!- Parameters:
other- the otherMathFunctionthat must be of the same type- Returns:
- int; < 0 when this sorts before other; > 0 when this sorts after other; 0 when this and other are identical
-
mergeAdd
This MathFunction is added to another; try to replace both by a combinedMathFunction.- Parameters:
other- the otherMathFunction- Returns:
- combined MathFunction, or null when the two could not be combined
-
mergeMultiply
This MathFunction is multiplied by another; try to replace both by a combined MathFunction.- Parameters:
other- the other MathFunction- Returns:
- combined MathFunction, or null when the two could not be combined
-
mergeDivide
This MathFunction is divided by another; try to replace both by a combined MathFunction.- Parameters:
other- the other MathFunction- Returns:
- combined MathFunction, or null when the two could not be combined
-
compareTo
- Specified by:
compareToin interfaceComparable<MathFunction>
-
getKnotReport
Report what is known about knots of thisMathFunctionin someInterval. The report does not take chained functions into account.- Parameters:
interval- theIntervalon which knowledge of knots is requested- Returns:
- summary of what is known about knots in the Interval
-
getKnots
Report all knots of thisMathFunctionin someInterval. ThrowsIllegalStateExceptionwhen the number of knots in theIntervalis not known, or infinite.- Parameters:
interval- theIntervalover which the knots must be reported- Returns:
- all the knots of this
MathFunctionin the requestedInterval - Throws:
UnsupportedOperationException- when the number of knots cannot be returned in a set because it is not known, or infinite
-