## Class PiecewiseContantDoubleUnaryOperator

• All Implemented Interfaces:
DoubleUnaryOperator, Function<Double,​Double>

public class PiecewiseContantDoubleUnaryOperator
extends Object
implements DoubleUnaryOperator, Function<Double,​Double>
A piecewise constant DoubleUnaryOperator $$f : \mathbb{R} \rightarrow \mathbb{R}$$ with exact calculation of the integral $$\int_{a}^{b} f(x) dx$$ for given bounds $$a, b$$. The summation uses Kahan error correction. For convenience the class can act as DoubleUnaryOperator specialization and as Function.
Author:
Christian Fries
• ### Constructor Summary

Constructors
Constructor Description
PiecewiseContantDoubleUnaryOperator​(double[] intervalRightPoints, double[] values)
Construct a piecewise constant DoubleUnaryOperator $$f : \mathbb{R} \rightarrow \mathbb{R}$$.
PiecewiseContantDoubleUnaryOperator​(List<Double> intervalRightPoints, List<Double> values)
Construct a piecewise constant DoubleUnaryOperator $$f : \mathbb{R} \rightarrow \mathbb{R}$$.
• ### Method Summary

All Methods
Modifier and Type Method Description
Double apply​(Double value)
Get the value of this function $$f$$ at the given argument.
double applyAsDouble​(double operand)
Get the value of this unary operator $$f$$ at the given argument.
double getIntegral​(double lowerBound, double upperBound)
Get the integral $$\int_{a}^{b} f(x) dx$$ of this function $$f$$ for given bounds $$a, b$$.
double getIntegral​(double lowerBound, double upperBound, DoubleUnaryOperator operator)
Get the integral $$\int_{a}^{b} g(f(x)) dx$$ of this function $$f$$ plugged into a given function $$g$$ for given bounds $$a, b$$.
double getIntegral​(double lowerBound, double upperBound, Function<Double,​Double> operator)
Get the integral $$\int_{a}^{b} g(f(x)) dx$$ of this function $$f$$ plugged into a given function $$g$$ for given bounds $$a, b$$.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Methods inherited from interface java.util.function.DoubleUnaryOperator

andThen, compose
• ### Methods inherited from interface java.util.function.Function

andThen, compose
• ### Constructor Detail

• #### PiecewiseContantDoubleUnaryOperator

public PiecewiseContantDoubleUnaryOperator​(double[] intervalRightPoints,
double[] values)
Construct a piecewise constant DoubleUnaryOperator $$f : \mathbb{R} \rightarrow \mathbb{R}$$.
Parameters:
intervalRightPoints - Array of length $$n$$ with the right hand points $$x_{i}$$ of the intervals $$(x_{i-1},x_{i}]$$ on which we have values.
values - Array of length $$n+1$$ with the values $$f_{i}$$ on the intervals $$(x_{i-1},x_{i}]$$ where:
• the first value $$f_{0}$$ in this array corresponds to the value on $$(-\infty,x_{0}]$$
• the last value $$f_{n}$$ in this array corresponds to the value on $$(x_{n-1},\infty)$$
• #### PiecewiseContantDoubleUnaryOperator

public PiecewiseContantDoubleUnaryOperator​(List<Double> intervalRightPoints,
List<Double> values)
Construct a piecewise constant DoubleUnaryOperator $$f : \mathbb{R} \rightarrow \mathbb{R}$$.
Parameters:
intervalRightPoints - List of length $$n$$ with the right hand points $$x_{i}$$ of the intervals $$(x_{i-1},x_{i}]$$ on which we have values.
values - List of length $$n+1$$ with the values $$f_{i}$$ on the intervals $$(x_{i-1},x_{i}]$$ where:
• the first value $$f_{0}$$ in this array corresponds to the value on $$(-\infty,x_{0}]$$
• the last value $$f_{n}$$ in this array corresponds to the value on $$(x_{n-1},\infty)$$
• ### Method Detail

• #### getIntegral

public double getIntegral​(double lowerBound,
double upperBound,
DoubleUnaryOperator operator)
Get the integral $$\int_{a}^{b} g(f(x)) dx$$ of this function $$f$$ plugged into a given function $$g$$ for given bounds $$a, b$$.
Parameters:
lowerBound - The lower bound a.
upperBound - The upper bound b.
operator - The given function g.
Returns:
The integral $$\int_{a}^{b} g(f(x)) dx$$.
• #### getIntegral

public double getIntegral​(double lowerBound,
double upperBound,
Function<Double,​Double> operator)
Get the integral $$\int_{a}^{b} g(f(x)) dx$$ of this function $$f$$ plugged into a given function $$g$$ for given bounds $$a, b$$.
Parameters:
lowerBound - The lower bound a.
upperBound - The upper bound b.
operator - The given function g.
Returns:
The integral $$\int_{a}^{b} g(f(x)) dx$$.
• #### getIntegral

public double getIntegral​(double lowerBound,
double upperBound)
Get the integral $$\int_{a}^{b} f(x) dx$$ of this function $$f$$ for given bounds $$a, b$$.
Parameters:
lowerBound - The lower bound a.
upperBound - The upper bound b.
Returns:
The integral $$\int_{a}^{b} f(x) dx$$.
• #### applyAsDouble

public double applyAsDouble​(double operand)
Get the value of this unary operator $$f$$ at the given argument.
Specified by:
applyAsDouble in interface DoubleUnaryOperator
Parameters:
operand - The given argument.
Returns:
The value $$f(x)$$.
• #### apply

public Double apply​(Double value)
Get the value of this function $$f$$ at the given argument.
Specified by:
apply in interface Function<Double,​Double>
Parameters:
value - The given argument.
Returns:
The value $$f(x)$$.