Record Class PiecewiseFunction.FunctionSegment
java.lang.Object
java.lang.Record
com.amalgamasimulation.core.piecewise.PiecewiseFunction.FunctionSegment
- Enclosing class:
PiecewiseFunction
public static record PiecewiseFunction.FunctionSegment(Interval argumentInterval, double beforeBeginValue, double beginValue, double endValue, double rate)
extends Record
A function segment is a section between breakpoints where the function
behaves linearly or has a constant rate.
Each segment is defined by:
- An argument interval that specifies the range of the segment.
- The value of the function at the start and end of the interval.
- The rate of change (slope) of the function within the interval.
A function segment always includes any step change at its beginning, allowing it to reflect abrupt value transitions, but excludes any step change that may occur at its end, ensuring continuity with subsequent segments.
-
Constructor Summary
ConstructorsConstructorDescriptionFunctionSegment(Interval argumentInterval, double beforeBeginValue, double beginValue, double endValue, double rate) Creates an instance of aFunctionSegmentrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theargumentIntervalrecord component.doubleReturns the value of thebeforeBeginValuerecord component.doubleReturns the value of thebeginValuerecord component.doubleendValue()Returns the value of theendValuerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.doublemax()Returns the maximum value of the function within this segment.doublemaxByAbs()Returns the value within this segment that has the greatest absolute value.doublemin()Returns the minimum value of the function within this segment.doublerate()Returns the value of theraterecord component.doubleReturns the signed square of the segment, representing the area under the segment (with sign depending on the value).final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
FunctionSegment
public FunctionSegment(Interval argumentInterval, double beforeBeginValue, double beginValue, double endValue, double rate) Creates an instance of aFunctionSegmentrecord class.- Parameters:
argumentInterval- the value for theargumentIntervalrecord componentbeforeBeginValue- the value for thebeforeBeginValuerecord componentbeginValue- the value for thebeginValuerecord componentendValue- the value for theendValuerecord componentrate- the value for theraterecord component
-
-
Method Details
-
signedSquare
public double signedSquare()Returns the signed square of the segment, representing the area under the segment (with sign depending on the value).- Returns:
- the signed square (area) of the segment
-
min
public double min()Returns the minimum value of the function within this segment. Does not consider possible step change at the end of the segment- Returns:
- the minimum value of the segment.
-
maxByAbs
public double maxByAbs()Returns the value within this segment that has the greatest absolute value. If the maximum and minimum values have equal absolute values, the maximum (positive) value is returned.Does not consider a possible step change at the end of the segment.
- Returns:
- the value with the greatest absolute magnitude in this segment, preserving the original sign
-
max
public double max()Returns the maximum value of the function within this segment. Does not consider possible step change at the end of the segment- Returns:
- the maximum value of the segment.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
argumentInterval
Returns the value of theargumentIntervalrecord component.- Returns:
- the value of the
argumentIntervalrecord component
-
beforeBeginValue
public double beforeBeginValue()Returns the value of thebeforeBeginValuerecord component.- Returns:
- the value of the
beforeBeginValuerecord component
-
beginValue
public double beginValue()Returns the value of thebeginValuerecord component.- Returns:
- the value of the
beginValuerecord component
-
endValue
public double endValue()Returns the value of theendValuerecord component.- Returns:
- the value of the
endValuerecord component
-
rate
public double rate()Returns the value of theraterecord component.- Returns:
- the value of the
raterecord component
-