joptima.functions
Class Cosine
- java.lang.Object
-
- joptima.functions.ConstrainableFunction
-
- joptima.functions.Cosine
-
- All Implemented Interfaces:
- Function
public class Cosine extends ConstrainableFunction
Function amplitude * cos(2 * pi * frequency * (x - offset)). A concrete implementation of joptima.Function that calculates a cosine.
-
-
Field Summary
Fields Modifier and Type Field and Description doublem_amplitudedoublem_frequencydoublem_xoffset
-
Constructor Summary
Constructors Constructor and Description Cosine()Default constructor: amplitude = 1, frequency = 1, xoffset = 0.Cosine(double amplitude, double frequency, double xoffset)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublecalculate(double x)Calculates the value of the function at the given point using the preset parameters.voidconstrain(java.lang.String parametername)Removes the given parameter from the parameter list.doublegetAmplitude()doublegetAngularFrequency()doublegetFrequency()java.lang.StringgetName()Gets the (user-settable) name of this function.Parameter[]getParameters()Lists all the mutable parameters to this function.doublegetXoffset()voidsetAmplitude(double amplitude)voidsetAngularFrequency(double omega)voidsetFrequency(double frequency)voidsetName(java.lang.String newname)Overrides the default function name.voidsetXoffset(double xoffset)-
Methods inherited from class joptima.functions.ConstrainableFunction
constrain, constrain
-
-
-
-
Field Detail
-
m_amplitude
public double m_amplitude
-
m_frequency
public double m_frequency
-
m_xoffset
public double m_xoffset
-
-
Constructor Detail
-
Cosine
public Cosine()
Default constructor: amplitude = 1, frequency = 1, xoffset = 0.
-
Cosine
public Cosine(double amplitude, double frequency, double xoffset)Constructor.
-
-
Method Detail
-
getParameters
public Parameter[] getParameters()
Description copied from interface:FunctionLists all the mutable parameters to this function.- Returns:
- a
Parameter[] of delegates that access the proper member variables.
-
constrain
public void constrain(java.lang.String parametername)
Description copied from class:ConstrainableFunctionRemoves the given parameter from the parameter list. This constraint is mandatory to implement.- Specified by:
constrainin classConstrainableFunction
-
getName
public java.lang.String getName()
Description copied from interface:FunctionGets the (user-settable) name of this function.- Returns:
- the name of the function
-
setName
public void setName(java.lang.String newname)
Description copied from interface:FunctionOverrides the default function name.- Parameters:
newname- the new name for the function
-
calculate
public double calculate(double x)
Description copied from interface:FunctionCalculates the value of the function at the given point using the preset parameters.- Parameters:
x- the x coordinate to calculate the function at- Returns:
- the value of the function at the given coordinate
-
setAngularFrequency
public void setAngularFrequency(double omega)
-
getAngularFrequency
public double getAngularFrequency()
-
getAmplitude
public double getAmplitude()
-
setAmplitude
public void setAmplitude(double amplitude)
-
getFrequency
public double getFrequency()
-
setFrequency
public void setFrequency(double frequency)
-
getXoffset
public double getXoffset()
-
setXoffset
public void setXoffset(double xoffset)
-
-
DMelt 3.0 © DataMelt by jWork.ORG