Class ConstantCurve
- java.lang.Object
-
- com.opengamma.strata.market.curve.ConstantCurve
-
- All Implemented Interfaces:
Curve,ParameterizedData,Serializable,org.joda.beans.Bean,org.joda.beans.ImmutableBean
public final class ConstantCurve extends Object implements Curve, org.joda.beans.ImmutableBean, Serializable
A curve based on a single constant value.This class defines a curve in terms of a single parameter, the constant value. When queried,
yValue(double)always returns the constant value. The sensitivity is 1 and the first derivative is 0.The curve has one parameter, the value of the constant.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConstantCurve.MetaThe meta-bean forConstantCurve.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)doublefirstDerivative(double x)Computes the first derivative of the curve.CurveMetadatagetMetadata()Gets the curve metadata.doublegetParameter(int parameterIndex)Gets the value of the parameter at the specified index.intgetParameterCount()Gets the number of parameters.doublegetYValue()Gets the single y-value.inthashCode()static ConstantCurve.Metameta()The meta-bean forConstantCurve.ConstantCurve.MetametaBean()static ConstantCurveof(CurveMetadata metadata, double yValue)Creates a constant curve with a specific value.static ConstantCurveof(CurveName name, double yValue)Creates a constant curve with a specific value.static ConstantCurveof(String name, double yValue)Creates a constant curve with a specific value.StringtoString()ConstantCurvewithMetadata(CurveMetadata metadata)Returns a new curve with the specified metadata.ConstantCurvewithParameter(int parameterIndex, double newValue)Returns a copy of the data with the value at the specified index altered.ConstantCurvewithPerturbation(ParameterPerturbation perturbation)Returns a perturbed copy of the data.doubleyValue(double x)Computes the y-value for the specified x-value.UnitParameterSensitivityyValueParameterSensitivity(double x)Computes the sensitivity of the y-value with respect to the curve parameters.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.market.curve.Curve
createParameterSensitivity, createParameterSensitivity, findParameterIndex, getName, getParameterMetadata, split, withUnderlyingCurve
-
-
-
-
Method Detail
-
of
public static ConstantCurve of(String name, double yValue)
Creates a constant curve with a specific value.- Parameters:
name- the curve nameyValue- the constant y-value- Returns:
- the curve
-
of
public static ConstantCurve of(CurveName name, double yValue)
Creates a constant curve with a specific value.- Parameters:
name- the curve nameyValue- the constant y-value- Returns:
- the curve
-
of
public static ConstantCurve of(CurveMetadata metadata, double yValue)
Creates a constant curve with a specific value.- Parameters:
metadata- the curve metadatayValue- the constant y-value- Returns:
- the curve
-
getParameterCount
public int getParameterCount()
Description copied from interface:ParameterizedDataGets the number of parameters.This returns the number of parameters, which can be used to create a loop to access the other methods on this interface.
- Specified by:
getParameterCountin interfaceParameterizedData- Returns:
- the number of parameters
-
getParameter
public double getParameter(int parameterIndex)
Description copied from interface:ParameterizedDataGets the value of the parameter at the specified index.- Specified by:
getParameterin interfaceParameterizedData- Parameters:
parameterIndex- the zero-based index of the parameter to get- Returns:
- the value of the parameter
-
withParameter
public ConstantCurve withParameter(int parameterIndex, double newValue)
Description copied from interface:ParameterizedDataReturns a copy of the data with the value at the specified index altered.This instance is immutable and unaffected by this method call.
- Specified by:
withParameterin interfaceCurve- Specified by:
withParameterin interfaceParameterizedData- Parameters:
parameterIndex- the zero-based index of the parameter to getnewValue- the new value for the specified parameter- Returns:
- a parameterized data instance based on this with the specified parameter altered
-
withPerturbation
public ConstantCurve withPerturbation(ParameterPerturbation perturbation)
Description copied from interface:ParameterizedDataReturns a perturbed copy of the data.The perturbation instance will be invoked once for each parameter in this instance, returning the perturbed value for that parameter. The result of this method is a new instance that is based on those perturbed values.
This instance is immutable and unaffected by this method call.
- Specified by:
withPerturbationin interfaceCurve- Specified by:
withPerturbationin interfaceParameterizedData- Parameters:
perturbation- the perturbation to apply- Returns:
- a parameterized data instance based on this with the specified perturbation applied
-
yValue
public double yValue(double x)
Description copied from interface:CurveComputes the y-value for the specified x-value.
-
yValueParameterSensitivity
public UnitParameterSensitivity yValueParameterSensitivity(double x)
Description copied from interface:CurveComputes the sensitivity of the y-value with respect to the curve parameters.This returns an array with one element for each parameter of the curve. The array contains the sensitivity of the y-value at the specified x-value to each parameter.
- Specified by:
yValueParameterSensitivityin interfaceCurve- Parameters:
x- the x-value at which the parameter sensitivity is computed- Returns:
- the sensitivity
-
firstDerivative
public double firstDerivative(double x)
Description copied from interface:CurveComputes the first derivative of the curve.The first derivative is
dy/dx.- Specified by:
firstDerivativein interfaceCurve- Parameters:
x- the x-value at which the derivative is taken- Returns:
- the first derivative
-
withMetadata
public ConstantCurve withMetadata(CurveMetadata metadata)
Description copied from interface:CurveReturns a new curve with the specified metadata.This allows the metadata of the curve to be changed while retaining all other information. If parameter metadata is present, the size of the list must match the number of parameters of this curve.
- Specified by:
withMetadatain interfaceCurve- Parameters:
metadata- the new metadata for the curve- Returns:
- the new curve
-
meta
public static ConstantCurve.Meta meta()
The meta-bean forConstantCurve.- Returns:
- the meta-bean, not null
-
metaBean
public ConstantCurve.Meta metaBean()
- Specified by:
metaBeanin interfaceorg.joda.beans.Bean
-
getMetadata
public CurveMetadata getMetadata()
Gets the curve metadata.The metadata will not normally have parameter metadata.
- Specified by:
getMetadatain interfaceCurve- Returns:
- the value of the property, not null
-
getYValue
public double getYValue()
Gets the single y-value.- Returns:
- the value of the property
-
-