Class InterpolatedNodalSurface
- java.lang.Object
-
- com.opengamma.strata.market.surface.InterpolatedNodalSurface
-
- All Implemented Interfaces:
ParameterizedData
,NodalSurface
,Surface
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class InterpolatedNodalSurface extends Object implements NodalSurface, org.joda.beans.ImmutableBean, Serializable
A surface based on interpolation between a number of nodal points.This class defines a surface in terms of a fixed number of nodes, referred to as parameters.
Each node has an x-value and a y-value. The interface is focused on finding the z-value for a given x-value and y-value. An interpolator is used to find z-values for x-values and y-values between two nodes.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InterpolatedNodalSurface.Builder
The bean-builder forInterpolatedNodalSurface
.static class
InterpolatedNodalSurface.Meta
The meta-bean forInterpolatedNodalSurface
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static InterpolatedNodalSurface.Builder
builder()
Returns a builder used to create an instance of the bean.CurrencyParameterSensitivity
createParameterSensitivity(Currency currency, DoubleArray sensitivities)
Creates a parameter sensitivity instance for this surface when the sensitivity values are known.UnitParameterSensitivity
createParameterSensitivity(DoubleArray sensitivities)
Creates a parameter sensitivity instance for this surface when the sensitivity values are known.boolean
equals(Object obj)
ValueDerivatives
firstPartialDerivatives(double x, double y)
Computes the partial derivatives of the surface.SurfaceInterpolator
getInterpolator()
Gets the underlying interpolator.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.DoubleArray
getXValues()
Gets the array of x-values, one for each point.DoubleArray
getYValues()
Gets the array of y-values, one for each point.DoubleArray
getZValues()
Gets the array of z-values, one for each point.int
hashCode()
static InterpolatedNodalSurface.Meta
meta()
The meta-bean forInterpolatedNodalSurface
.InterpolatedNodalSurface.Meta
metaBean()
static InterpolatedNodalSurface
of(SurfaceMetadata metadata, DoubleArray xValues, DoubleArray yValues, DoubleArray zValues, SurfaceInterpolator interpolator)
Creates an interpolated surface with metadata.static InterpolatedNodalSurface
ofUnsorted(SurfaceMetadata metadata, DoubleArray xValues, DoubleArray yValues, DoubleArray zValues, SurfaceInterpolator interpolator)
Creates an interpolated surface with metadata, where the values are not sorted.InterpolatedNodalSurface.Builder
toBuilder()
Returns a builder that allows this bean to be mutated.String
toString()
InterpolatedNodalSurface
withMetadata(SurfaceMetadata metadata)
Returns a new surface with the specified metadata.InterpolatedNodalSurface
withParameter(int parameterIndex, double newValue)
Returns a copy of the data with the value at the specified index altered.InterpolatedNodalSurface
withPerturbation(ParameterPerturbation perturbation)
Returns a perturbed copy of the data.InterpolatedNodalSurface
withZValues(DoubleArray zValues)
Returns a new surface with the specified values.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.NodalSurface
getParameterMetadata
-
Methods inherited from interface com.opengamma.strata.market.surface.Surface
findParameterIndex, getName, zValue, zValueParameterSensitivity
-
-
-
-
Method Detail
-
of
public static InterpolatedNodalSurface of(SurfaceMetadata metadata, DoubleArray xValues, DoubleArray yValues, DoubleArray zValues, SurfaceInterpolator interpolator)
Creates an interpolated surface with metadata.The value arrays must be sorted, by x-values then y-values. An exception is thrown if they are not sorted.
- Parameters:
metadata
- the surface metadataxValues
- the x-values, must be sorted from low to highyValues
- the y-values, must be sorted from low to high within xzValues
- the z-valuesinterpolator
- the interpolator- Returns:
- the surface
-
ofUnsorted
public static InterpolatedNodalSurface ofUnsorted(SurfaceMetadata metadata, DoubleArray xValues, DoubleArray yValues, DoubleArray zValues, SurfaceInterpolator interpolator)
Creates an interpolated surface with metadata, where the values are not sorted.The value arrays will be sorted, by x-values then y-values. Both the z-values and parameter metadata will be sorted along with the x and y values.
- Parameters:
metadata
- the surface metadataxValues
- the x-valuesyValues
- the y-valueszValues
- the z-valuesinterpolator
- the interpolator- 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 InterpolatedNodalSurface 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 interfaceNodalSurface
- 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 InterpolatedNodalSurface 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 interfaceNodalSurface
- 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 InterpolatedNodalSurface withMetadata(SurfaceMetadata metadata)
Description copied from interface:NodalSurface
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 interfaceNodalSurface
- Specified by:
withMetadata
in interfaceSurface
- Parameters:
metadata
- the new metadata for the surface- Returns:
- the new surface
-
withZValues
public InterpolatedNodalSurface withZValues(DoubleArray zValues)
Description copied from interface:NodalSurface
Returns a new surface with the specified values.This allows the z-values of the surface to be changed while retaining the same x-values and y-values.
- Specified by:
withZValues
in interfaceNodalSurface
- Parameters:
zValues
- the new y-values for the surface- Returns:
- the new surface
-
createParameterSensitivity
public UnitParameterSensitivity createParameterSensitivity(DoubleArray sensitivities)
Description copied from interface:Surface
Creates a parameter sensitivity instance for this surface when the sensitivity values are known.In most cases,
Surface.zValueParameterSensitivity(double, double)
should be used and manipulated. However, it can be useful to create aUnitParameterSensitivity
from pre-computed sensitivity values.- Specified by:
createParameterSensitivity
in interfaceSurface
- Parameters:
sensitivities
- the sensitivity values, which must match the parameter count of the surface- Returns:
- the sensitivity
-
createParameterSensitivity
public CurrencyParameterSensitivity createParameterSensitivity(Currency currency, DoubleArray sensitivities)
Description copied from interface:Surface
Creates a parameter sensitivity instance for this surface when the sensitivity values are known.In most cases,
Surface.zValueParameterSensitivity(double, double)
should be used and manipulated. However, it can be useful to create aCurrencyParameterSensitivity
from pre-computed sensitivity values.- Specified by:
createParameterSensitivity
in interfaceSurface
- Parameters:
currency
- the currencysensitivities
- the sensitivity values, which must match the parameter count of the surface- Returns:
- the sensitivity
-
meta
public static InterpolatedNodalSurface.Meta meta()
The meta-bean forInterpolatedNodalSurface
.- Returns:
- the meta-bean, not null
-
builder
public static InterpolatedNodalSurface.Builder builder()
Returns a builder used to create an instance of the bean.- Returns:
- the builder, not null
-
metaBean
public InterpolatedNodalSurface.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getMetadata
public SurfaceMetadata getMetadata()
Gets the surface metadata.The metadata includes an optional list of parameter metadata. If present, the size of the parameter metadata list will match the number of parameters of this surface.
- Specified by:
getMetadata
in interfaceSurface
- Returns:
- the value of the property, not null
-
getXValues
public DoubleArray getXValues()
Gets the array of x-values, one for each point.This array will contains at least two elements.
- Specified by:
getXValues
in interfaceNodalSurface
- Returns:
- the value of the property, not null
-
getYValues
public DoubleArray getYValues()
Gets the array of y-values, one for each point.This array will contains at least two elements and be of the same length as x-values.
- Specified by:
getYValues
in interfaceNodalSurface
- Returns:
- the value of the property, not null
-
getZValues
public DoubleArray getZValues()
Gets the array of z-values, one for each point.This array will contains at least two elements and be of the same length as x-values.
- Specified by:
getZValues
in interfaceNodalSurface
- Returns:
- the value of the property, not null
-
getInterpolator
public SurfaceInterpolator getInterpolator()
Gets the underlying interpolator.- Returns:
- the value of the property, not null
-
toBuilder
public InterpolatedNodalSurface.Builder toBuilder()
Returns a builder that allows this bean to be mutated.- Returns:
- the mutable builder, not null
-
-