# Class StepFunction

All Implemented Interfaces:
Function<Vector,Double>, RealScalarFunction, UnivariateRealFunction, OrderedPairs

public class StepFunction extends AbstractUnivariateRealFunction implements OrderedPairs
A step function (or staircase function) is a finite linear combination of indicator functions of intervals. Informally speaking, a step function is a piecewise constant function having only finitely many pieces.

Note: this function is mutable for convenience. It allows dynamically adding more points to the function. It is handy when, e.g., merging two sets of points.

## Nested classes/interfaces inherited from interface dev.nm.analysis.function.Function

Function.EvaluationException
• ## Constructor Summary

Constructors
Constructor
Description
StepFunction(double epsilon)
Construct an empty step function.
StepFunction(OrderedPairs f)
Construct a step function from a collection ordered pairs.
StepFunction(OrderedPairs f, double epsilon)
Construct a step function from a collection ordered pairs.
• ## Method Summary

Modifier and Type
Method
Description
void
add(OrderedPairs f)
Dynamically add points to the step function.
double
evaluate(double x)
Evaluate y = f(x).
double
maxDomain()
Get the biggest abscissae.
double
minDomain()
Get the smallest abscissae.
int
size()
Get the number of points.
double[]
x()
Get the abscissae.
double[]
y()
Get the ordinates.

### Methods inherited from class dev.nm.analysis.function.rn2r1.univariate.AbstractUnivariateRealFunction

evaluate

### Methods inherited from class dev.nm.analysis.function.rn2r1.AbstractRealScalarFunction

dimensionOfDomain, dimensionOfRange

### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

### Methods inherited from interface dev.nm.analysis.function.Function

dimensionOfDomain, dimensionOfRange
• ## Constructor Details

• ### StepFunction

public StepFunction(double epsilon)
Construct an empty step function.
Parameters:
epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0
• ### StepFunction

public StepFunction(OrderedPairs f, double epsilon)
Construct a step function from a collection ordered pairs.
Parameters:
f - a collection of ordered pairs
epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0
• ### StepFunction

public StepFunction(OrderedPairs f)
Construct a step function from a collection ordered pairs.
Parameters:
f - a collection of ordered pairs
• ## Method Details

Dynamically add points to the step function.
Parameters:
f - a collection of ordered pairs
• ### x

public double[] x()
Description copied from interface: OrderedPairs
Get the abscissae.
Specified by:
x in interface OrderedPairs
Returns:
the abscissae
• ### y

public double[] y()
Description copied from interface: OrderedPairs
Get the ordinates.
Specified by:
y in interface OrderedPairs
Returns:
the ordinates
• ### minDomain

public double minDomain()
Get the smallest abscissae.
Returns:
the smallest abscissae
• ### maxDomain

public double maxDomain()
Get the biggest abscissae.
Returns:
the biggest abscissae
• ### size

public int size()
Description copied from interface: OrderedPairs
Get the number of points.
Specified by:
size in interface OrderedPairs
Returns:
the number of points
• ### evaluate

public double evaluate(double x)
Description copied from interface: UnivariateRealFunction
Evaluate y = f(x).
Specified by:
evaluate in interface UnivariateRealFunction
Parameters:
x - x
Returns:
f(x)