Package ffx.numerics.switching
Class SquaredTrigSwitch
java.lang.Object
ffx.numerics.switching.SquaredTrigSwitch
- All Implemented Interfaces:
UnivariateDiffFunction
,UnivariateSwitchingFunction
A SquaredTrigSwitch implements a 0-1 switch of form f(x) = sin^2(ax) or of form f(x) = cos^2(ax).
Cosine implementation is achieved by phase-shifting a sine wave.
- Author:
- Jacob M. Litman, Michael J. Schnieders
-
Constructor Summary
ConstructorDescriptionSquaredTrigSwitch
(boolean cosine) Default constructor, creating a switch sin^2(pi*x/2), or cos^2 if flag set.SquaredTrigSwitch
(double coefficient, boolean cosine) Constructor permitting a custom frequency "a" in the form sin^2(a*x) or cos^2(a*x). -
Method Summary
Modifier and TypeMethodDescriptionboolean
Remains 0 below the lower bound, and 1 above the upper bound (i.e. a multiplicative switch).double
firstDerivative
(double x) First derivative at a point.int
The highest-order derivative that is zero at the bounds.double
Gets the one bound, where f(x) becomes one.double
Get the repeating period of this switch.double
Gets the zero bound, where f(x) becomes zero.boolean
isCosine()
Return true if a cos^2(ax) transform, false if a sin^2(ax) transform.double
nthDerivative
(double x, int order) N'th order derivative at a point.double
secondDerivative
(double x) Second derivative at a point.boolean
True if f(lb + delta) + f(ub - delta) = 1 for all delta between 0 and (ub - lb).toString()
boolean
Remains in the range 0-1 outside the bounds.double
valueAt
(double x) Value at a pointMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ffx.numerics.switching.UnivariateSwitchingFunction
highestOrderZeroDerivativeAtZeroBound
-
Constructor Details
-
SquaredTrigSwitch
public SquaredTrigSwitch(boolean cosine) Default constructor, creating a switch sin^2(pi*x/2), or cos^2 if flag set. The sine form will switch 0-1, and the cosine form switch 1-0.- Parameters:
cosine
- Use a cos^2(pi*x/2) transform instead of sin^2(pi*x/2).
-
SquaredTrigSwitch
public SquaredTrigSwitch(double coefficient, boolean cosine) Constructor permitting a custom frequency "a" in the form sin^2(a*x) or cos^2(a*x). The sine form will switch 0-1, and the cosine form switch 1-0.- Parameters:
coefficient
- Value of acosine
- Use a cos^2(ax) transform instead of sin^2(ax).
-
-
Method Details
-
constantOutsideBounds
public boolean constantOutsideBounds()Remains 0 below the lower bound, and 1 above the upper bound (i.e. a multiplicative switch).- Specified by:
constantOutsideBounds
in interfaceUnivariateSwitchingFunction
- Returns:
- df(x)/dx is zero outside range lb-ub.
-
firstDerivative
First derivative at a point.- Specified by:
firstDerivative
in interfaceUnivariateDiffFunction
- Parameters:
x
- a double.- Returns:
- f'(x)
- Throws:
IllegalArgumentException
- If f'(x) is undefined at x.
-
getHighestOrderZeroDerivative
public int getHighestOrderZeroDerivative()The highest-order derivative that is zero at the bounds.- Specified by:
getHighestOrderZeroDerivative
in interfaceUnivariateSwitchingFunction
- Returns:
- Maximum order zero derivative at bounds.
-
getOneBound
public double getOneBound()Gets the one bound, where f(x) becomes one.- Specified by:
getOneBound
in interfaceUnivariateSwitchingFunction
- Returns:
- One bound
-
getPeriod
public double getPeriod()Get the repeating period of this switch.- Returns:
- Period
-
getZeroBound
public double getZeroBound()Gets the zero bound, where f(x) becomes zero.- Specified by:
getZeroBound
in interfaceUnivariateSwitchingFunction
- Returns:
- Zero bound
-
isCosine
public boolean isCosine()Return true if a cos^2(ax) transform, false if a sin^2(ax) transform.- Returns:
- a boolean.
-
nthDerivative
N'th order derivative at a point. Should be relatively optional for any order above 2.- Specified by:
nthDerivative
in interfaceUnivariateDiffFunction
- Parameters:
x
- a double.order
- Derivative order (>= 1)- Returns:
- d^nf(x)/dx^n
- Throws:
IllegalArgumentException
- If derivative undefined at x.
-
secondDerivative
Second derivative at a point.- Specified by:
secondDerivative
in interfaceUnivariateDiffFunction
- Parameters:
x
- a double.- Returns:
- f''(x)
- Throws:
IllegalArgumentException
- If f''(x) is undefined at x.
-
symmetricToUnity
public boolean symmetricToUnity()True if f(lb + delta) + f(ub - delta) = 1 for all delta between 0 and (ub - lb). For example, a power switch with beta 1 is symmetric to unity, as f(l) + f(1-l) = 1, but beta 2 produces a non-unity result, where f(0.5) + f(0.5) = 0.5.- Specified by:
symmetricToUnity
in interfaceUnivariateSwitchingFunction
- Returns:
- If symmetry produces unity result.
-
toString
-
validOutsideBounds
public boolean validOutsideBounds()Remains in the range 0-1 outside the bounds. Implied to be true if constantOutsideBounds is true.- Specified by:
validOutsideBounds
in interfaceUnivariateSwitchingFunction
- Returns:
- min(f ( x)) = 0 and max(f(x)) = 1.
-
valueAt
Value at a point- Specified by:
valueAt
in interfaceUnivariateDiffFunction
- Parameters:
x
- a double.- Returns:
- f(x)
- Throws:
IllegalArgumentException
- If f(x) is undefined at x.
-