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 classInterpolatedNodalSurface.BuilderThe bean-builder forInterpolatedNodalSurface.static classInterpolatedNodalSurface.MetaThe meta-bean forInterpolatedNodalSurface.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static InterpolatedNodalSurface.Builderbuilder()Returns a builder used to create an instance of the bean.CurrencyParameterSensitivitycreateParameterSensitivity(Currency currency, DoubleArray sensitivities)Creates a parameter sensitivity instance for this surface when the sensitivity values are known.UnitParameterSensitivitycreateParameterSensitivity(DoubleArray sensitivities)Creates a parameter sensitivity instance for this surface when the sensitivity values are known.booleanequals(Object obj)ValueDerivativesfirstPartialDerivatives(double x, double y)Computes the partial derivatives of the surface.SurfaceInterpolatorgetInterpolator()Gets the underlying interpolator.SurfaceMetadatagetMetadata()Gets the surface metadata.doublegetParameter(int parameterIndex)Gets the value of the parameter at the specified index.intgetParameterCount()Gets the number of parameters.DoubleArraygetXValues()Gets the array of x-values, one for each point.DoubleArraygetYValues()Gets the array of y-values, one for each point.DoubleArraygetZValues()Gets the array of z-values, one for each point.inthashCode()static InterpolatedNodalSurface.Metameta()The meta-bean forInterpolatedNodalSurface.InterpolatedNodalSurface.MetametaBean()static InterpolatedNodalSurfaceof(SurfaceMetadata metadata, DoubleArray xValues, DoubleArray yValues, DoubleArray zValues, SurfaceInterpolator interpolator)Creates an interpolated surface with metadata.static InterpolatedNodalSurfaceofUnsorted(SurfaceMetadata metadata, DoubleArray xValues, DoubleArray yValues, DoubleArray zValues, SurfaceInterpolator interpolator)Creates an interpolated surface with metadata, where the values are not sorted.InterpolatedNodalSurface.BuildertoBuilder()Returns a builder that allows this bean to be mutated.StringtoString()InterpolatedNodalSurfacewithMetadata(SurfaceMetadata metadata)Returns a new surface with the specified metadata.InterpolatedNodalSurfacewithParameter(int parameterIndex, double newValue)Returns a copy of the data with the value at the specified index altered.InterpolatedNodalSurfacewithPerturbation(ParameterPerturbation perturbation)Returns a perturbed copy of the data.InterpolatedNodalSurfacewithZValues(DoubleArray zValues)Returns a new surface with the specified values.doublezValue(double x, double y)Computes the z-value for the specified x-value and y-value.UnitParameterSensitivityzValueParameterSensitivity(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: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 InterpolatedNodalSurface 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 interfaceNodalSurface- Specified by:
withParameterin interfaceParameterizedData- Specified by:
withParameterin 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: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 interfaceNodalSurface- Specified by:
withPerturbationin interfaceParameterizedData- Specified by:
withPerturbationin 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:SurfaceComputes the z-value for the specified x-value and y-value.
-
zValueParameterSensitivity
public UnitParameterSensitivity zValueParameterSensitivity(double x, double y)
Description copied from interface:SurfaceComputes 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:
zValueParameterSensitivityin 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:SurfaceComputes 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:
firstPartialDerivativesin 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:NodalSurfaceReturns 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:
withMetadatain interfaceNodalSurface- Specified by:
withMetadatain interfaceSurface- Parameters:
metadata- the new metadata for the surface- Returns:
- the new surface
-
withZValues
public InterpolatedNodalSurface withZValues(DoubleArray zValues)
Description copied from interface:NodalSurfaceReturns 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:
withZValuesin interfaceNodalSurface- Parameters:
zValues- the new y-values for the surface- Returns:
- the new surface
-
createParameterSensitivity
public UnitParameterSensitivity createParameterSensitivity(DoubleArray sensitivities)
Description copied from interface:SurfaceCreates 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 aUnitParameterSensitivityfrom pre-computed sensitivity values.- Specified by:
createParameterSensitivityin 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:SurfaceCreates 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 aCurrencyParameterSensitivityfrom pre-computed sensitivity values.- Specified by:
createParameterSensitivityin 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:
metaBeanin 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:
getMetadatain 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:
getXValuesin 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:
getYValuesin 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:
getZValuesin 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
-
-