Class ConstantSurface
- java.lang.Object
-
- com.opengamma.strata.market.surface.ConstantSurface
-
- All Implemented Interfaces:
ParameterizedData
,Surface
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class ConstantSurface extends Object implements Surface, org.joda.beans.ImmutableBean, Serializable
A surface based on a single constant value.This class defines a surface in terms of a single parameter, the constant value. When queried,
zValue(double, double)
always returns the constant value. The sensitivity is 1 and the first derivative is 0.The surface has one parameter, the value of the constant.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConstantSurface.Meta
The meta-bean forConstantSurface
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
ValueDerivatives
firstPartialDerivatives(double x, double y)
Computes the partial derivatives of the surface.SurfaceMetadata
getMetadata()
Gets the surface metadata.double
getParameter(int parameterIndex)
Gets the value of the parameter at the specified index.int
getParameterCount()
Gets the number of parameters.double
getZValue()
Gets the single z-value.int
hashCode()
static ConstantSurface.Meta
meta()
The meta-bean forConstantSurface
.ConstantSurface.Meta
metaBean()
static ConstantSurface
of(SurfaceMetadata metadata, double zValue)
Creates a constant surface with a specific value.static ConstantSurface
of(SurfaceName name, double zValue)
Creates a constant surface with a specific value.static ConstantSurface
of(String name, double zValue)
Creates a constant surface with a specific value.String
toString()
ConstantSurface
withMetadata(SurfaceMetadata metadata)
Returns a new surface with the specified metadata.ConstantSurface
withParameter(int parameterIndex, double newValue)
Returns a copy of the data with the value at the specified index altered.ConstantSurface
withPerturbation(ParameterPerturbation perturbation)
Returns a perturbed copy of the data.double
zValue(double x, double y)
Computes the z-value for the specified x-value and y-value.UnitParameterSensitivity
zValueParameterSensitivity(double x, double y)
Computes the sensitivity of the z-value with respect to the surface parameters.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.market.surface.Surface
createParameterSensitivity, createParameterSensitivity, findParameterIndex, getName, getParameterMetadata, zValue, zValueParameterSensitivity
-
-
-
-
Method Detail
-
of
public static ConstantSurface of(String name, double zValue)
Creates a constant surface with a specific value.- Parameters:
name
- the surface namezValue
- the constant z-value- Returns:
- the surface
-
of
public static ConstantSurface of(SurfaceName name, double zValue)
Creates a constant surface with a specific value.- Parameters:
name
- the surface namezValue
- the constant z-value- Returns:
- the surface
-
of
public static ConstantSurface of(SurfaceMetadata metadata, double zValue)
Creates a constant surface with a specific value.- Parameters:
metadata
- the surface metadatazValue
- the constant z-value- Returns:
- the surface
-
getParameterCount
public int getParameterCount()
Description copied from interface:ParameterizedData
Gets 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:
getParameterCount
in interfaceParameterizedData
- Returns:
- the number of parameters
-
getParameter
public double getParameter(int parameterIndex)
Description copied from interface:ParameterizedData
Gets the value of the parameter at the specified index.- Specified by:
getParameter
in interfaceParameterizedData
- Parameters:
parameterIndex
- the zero-based index of the parameter to get- Returns:
- the value of the parameter
-
withParameter
public ConstantSurface withParameter(int parameterIndex, double newValue)
Description copied from interface:ParameterizedData
Returns 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:
withParameter
in interfaceParameterizedData
- Specified by:
withParameter
in interfaceSurface
- 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 ConstantSurface withPerturbation(ParameterPerturbation perturbation)
Description copied from interface:ParameterizedData
Returns 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:
withPerturbation
in interfaceParameterizedData
- Specified by:
withPerturbation
in interfaceSurface
- Parameters:
perturbation
- the perturbation to apply- Returns:
- a parameterized data instance based on this with the specified perturbation applied
-
zValue
public double zValue(double x, double y)
Description copied from interface:Surface
Computes the z-value for the specified x-value and y-value.
-
zValueParameterSensitivity
public UnitParameterSensitivity zValueParameterSensitivity(double x, double y)
Description copied from interface:Surface
Computes the sensitivity of the z-value with respect to the surface parameters.This returns an array with one element for each x-y parameter of the surface. The array contains one a sensitivity value for each parameter used to create the surface.
- Specified by:
zValueParameterSensitivity
in interfaceSurface
- Parameters:
x
- the x-value at which the parameter sensitivity is computedy
- the y-value at which the parameter sensitivity is computed- Returns:
- the sensitivity at the x/y/ point
-
firstPartialDerivatives
public ValueDerivatives firstPartialDerivatives(double x, double y)
Description copied from interface:Surface
Computes the partial derivatives of the surface.The first derivatives are
dz/dx and dz/dy
. The derivatives are in the following order:- [0] derivative with respect to x
- [1] derivative with respect to y
- Specified by:
firstPartialDerivatives
in interfaceSurface
- Parameters:
x
- the x-value at which the partial derivative is takeny
- the y-value at which the partial derivative is taken- Returns:
- the z-value and it's partial first derivatives
-
withMetadata
public ConstantSurface withMetadata(SurfaceMetadata metadata)
Description copied from interface:Surface
Returns a new surface with the specified metadata.This allows the metadata of the surface 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 surface.
- Specified by:
withMetadata
in interfaceSurface
- Parameters:
metadata
- the new metadata for the surface- Returns:
- the new surface
-
meta
public static ConstantSurface.Meta meta()
The meta-bean forConstantSurface
.- Returns:
- the meta-bean, not null
-
metaBean
public ConstantSurface.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getMetadata
public SurfaceMetadata getMetadata()
Gets the surface metadata.The metadata will have not have parameter metadata.
- Specified by:
getMetadata
in interfaceSurface
- Returns:
- the value of the property, not null
-
getZValue
public double getZValue()
Gets the single z-value.- Returns:
- the value of the property
-
-