- java.lang.Object
-
- org.ojalgo.function.series.PeriodicFunction
-
- All Implemented Interfaces:
java.util.function.DoubleUnaryOperator,java.util.function.Function<java.lang.Double,java.lang.Double>,java.util.function.UnaryOperator<java.lang.Double>,BasicFunction,PrimitiveFunction.Unary,UnaryFunction<java.lang.Double>
public final class PeriodicFunction extends java.lang.Object implements PrimitiveFunction.Unary
A periodic function is a function that repeats its values in regular intervals or periods. The most important examples are the trigonometric functions, which repeat over intervals of length 2π radians.This class allows you to create a periodic function from any other function. The base function only needs to be defined over the interval specified in this class, The resulting function will repeat the base function in regular periods. The default period is 2π, but it's possible to specify any other period. The default origin is zero, but it's possible to specify any other origin.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ojalgo.function.BasicFunction
BasicFunction.Differentiable<N extends java.lang.Comparable<N>,F extends BasicFunction>, BasicFunction.Integratable<N extends java.lang.Comparable<N>,F extends BasicFunction>, BasicFunction.PlainUnary<T,R>
-
-
Field Summary
Fields Modifier and Type Field Description private doublemyOriginprivate doublemyPeriodprivate java.util.function.DoubleUnaryOperatormyShapestatic PeriodicFunctionSAWTOOTHhttps://en.wikipedia.org/wiki/Sawtooth_wavestatic PeriodicFunctionSINEhttps://en.wikipedia.org/wiki/Sine_wavestatic PeriodicFunctionSQUAREhttps://en.wikipedia.org/wiki/Square_wavestatic PeriodicFunctionTRIANGLEhttps://en.wikipedia.org/wiki/Triangle_wave
-
Constructor Summary
Constructors Constructor Description PeriodicFunction(double origin, java.util.function.DoubleUnaryOperator shape, double period)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PrimitiveFunction.SampleDomaingetSampleDomain(int nbSamples)doubleinvoke(double arg)static PeriodicFunctionof(double origin, java.util.function.DoubleUnaryOperator shape)static PeriodicFunctionof(java.util.function.DoubleUnaryOperator shape)Origin at zero, and period 2π [0, 2π).static java.util.function.DoubleUnaryOperatorof(java.util.function.DoubleUnaryOperator shape, double period)static PeriodicFunctionofCentered(java.util.function.DoubleUnaryOperator shape)Origin at -π, and period 2π [-π, π).PeriodicFunctionwithInterval(double origin, double period)interval = [origin, origin+period)PeriodicFunctionwithOrigin(double origin)interval = [origin, origin+period)PeriodicFunctionwithPeriod(double period)interval = [origin, origin+period)PeriodicFunctionwithShape(java.util.function.DoubleUnaryOperator shape)The shape is the function that is repeated in regular intervals.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ojalgo.function.PrimitiveFunction.Unary
invoke
-
Methods inherited from interface org.ojalgo.function.UnaryFunction
andThen, apply, applyAsDouble, compose, invoke, invoke, invoke, invoke, invoke
-
-
-
-
Field Detail
-
SAWTOOTH
public static final PeriodicFunction SAWTOOTH
https://en.wikipedia.org/wiki/Sawtooth_waveDomain: (-∞, ∞) by repeating/shifting the definition interval [0, 2π).
Range: [-1, 1].
-
SINE
public static final PeriodicFunction SINE
https://en.wikipedia.org/wiki/Sine_waveDomain: (-∞, ∞) by repeating/shifting the definition interval [0, 2π).
Range: [-1, 1].
-
SQUARE
public static final PeriodicFunction SQUARE
https://en.wikipedia.org/wiki/Square_waveDomain: (-∞, ∞) by repeating/shifting the definition interval [0, 2π).
Range: [-1, 1].
-
TRIANGLE
public static final PeriodicFunction TRIANGLE
https://en.wikipedia.org/wiki/Triangle_waveDomain: (-∞, ∞) by repeating/shifting the definition interval [0, 2π).
Range: [-1, 1].
-
myOrigin
private final double myOrigin
-
myPeriod
private final double myPeriod
-
myShape
private final java.util.function.DoubleUnaryOperator myShape
-
-
Method Detail
-
of
public static PeriodicFunction of(double origin, java.util.function.DoubleUnaryOperator shape)
-
of
public static PeriodicFunction of(java.util.function.DoubleUnaryOperator shape)
Origin at zero, and period 2π [0, 2π).
-
of
public static java.util.function.DoubleUnaryOperator of(java.util.function.DoubleUnaryOperator shape, double period)
-
ofCentered
public static PeriodicFunction ofCentered(java.util.function.DoubleUnaryOperator shape)
Origin at -π, and period 2π [-π, π).
-
getSampleDomain
public PrimitiveFunction.SampleDomain getSampleDomain(int nbSamples)
-
invoke
public double invoke(double arg)
- Specified by:
invokein interfaceUnaryFunction<java.lang.Double>
-
withInterval
public PeriodicFunction withInterval(double origin, double period)
interval = [origin, origin+period)
-
withOrigin
public PeriodicFunction withOrigin(double origin)
interval = [origin, origin+period)
-
withPeriod
public PeriodicFunction withPeriod(double period)
interval = [origin, origin+period)
-
withShape
public PeriodicFunction withShape(java.util.function.DoubleUnaryOperator shape)
The shape is the function that is repeated in regular intervals.
-
-