Class PiecewisePolynomialFunction1D
- java.lang.Object
-
- com.opengamma.strata.math.impl.function.PiecewisePolynomialFunction1D
-
- Direct Known Subclasses:
PiecewisePolynomialWithSensitivityFunction1D
public class PiecewisePolynomialFunction1D extends Object
Give a structPiecewisePolynomialResult
, Compute value, first derivative and integral of piecewise polynomial function.
-
-
Constructor Summary
Constructors Constructor Description PiecewisePolynomialFunction1D()
Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DoubleArray
differentiate(PiecewisePolynomialResult pp, double xKey)
Finds the first derivatives.DoubleMatrix
differentiate(PiecewisePolynomialResult pp, double[] xKeys)
Finds the first derivatives.DoubleArray
differentiateTwice(PiecewisePolynomialResult pp, double xKey)
Finds the second derivatives.DoubleMatrix
differentiateTwice(PiecewisePolynomialResult pp, double[] xKeys)
Finds the second derivatives.DoubleArray
evaluate(PiecewisePolynomialResult pp, double xKey)
Evaluates the function.DoubleMatrix
evaluate(PiecewisePolynomialResult pp, double[] xKeys)
Evaluates the function.DoubleMatrix[]
evaluate(PiecewisePolynomialResult pp, double[][] xKeys)
Evaluates the function.ValueDerivatives
evaluateAndDifferentiate(PiecewisePolynomialResult pp, double xKey)
Evaluates the function and its first derivative.protected double
getValue(double[] coefs, double x, double leftknot)
protected double
getValue(DoubleArray coefs, double x, double leftknot)
double
integrate(PiecewisePolynomialResult pp, double initialKey, double xKey)
Integration.DoubleArray
integrate(PiecewisePolynomialResult pp, double initialKey, double[] xKeys)
Integration.
-
-
-
Method Detail
-
evaluate
public DoubleArray evaluate(PiecewisePolynomialResult pp, double xKey)
Evaluates the function.- Parameters:
pp
- the PiecewisePolynomialResultxKey
- the key- Returns:
- the values of piecewise polynomial functions at xKey When _dim in PiecewisePolynomialResult is greater than 1, i.e., the struct contains multiple splines, an element in the return values corresponds to each spline
-
evaluate
public DoubleMatrix evaluate(PiecewisePolynomialResult pp, double[] xKeys)
Evaluates the function.- Parameters:
pp
- the PiecewisePolynomialResultxKeys
- the key- Returns:
- the values of piecewise polynomial functions at xKeys When _dim in PiecewisePolynomialResult is greater than 1, i.e., the struct contains multiple piecewise polynomials, a row vector of return value corresponds to each piecewise polynomial
-
evaluate
public DoubleMatrix[] evaluate(PiecewisePolynomialResult pp, double[][] xKeys)
Evaluates the function.- Parameters:
pp
- the PiecewisePolynomialResultxKeys
- the key- Returns:
- the values of piecewise polynomial functions at xKeys When _dim in PiecewisePolynomialResult is greater than 1, i.e., the struct contains multiple piecewise polynomials, one element of return vector of DoubleMatrix corresponds to each piecewise polynomial
-
differentiate
public DoubleArray differentiate(PiecewisePolynomialResult pp, double xKey)
Finds the first derivatives.- Parameters:
pp
- the PiecewisePolynomialResultxKey
- the key- Returns:
- the first derivatives of piecewise polynomial functions at xKey When _dim in PiecewisePolynomialResult is greater than 1, i.e., the struct contains multiple piecewise polynomials, an element in the return values corresponds to each piecewise polynomial
-
differentiate
public DoubleMatrix differentiate(PiecewisePolynomialResult pp, double[] xKeys)
Finds the first derivatives.- Parameters:
pp
- the PiecewisePolynomialResultxKeys
- the key- Returns:
- the first derivatives of piecewise polynomial functions at xKeys When _dim in PiecewisePolynomialResult is greater than 1, i.e., the struct contains multiple piecewise polynomials, a row vector of return value corresponds to each piecewise polynomial
-
differentiateTwice
public DoubleArray differentiateTwice(PiecewisePolynomialResult pp, double xKey)
Finds the second derivatives.- Parameters:
pp
- the PiecewisePolynomialResultxKey
- the key- Returns:
- the second derivatives of piecewise polynomial functions at xKey When _dim in PiecewisePolynomialResult is greater than 1, i.e., the struct contains multiple piecewise polynomials, an element in the return values corresponds to each piecewise polynomial
-
differentiateTwice
public DoubleMatrix differentiateTwice(PiecewisePolynomialResult pp, double[] xKeys)
Finds the second derivatives.- Parameters:
pp
- the PiecewisePolynomialResultxKeys
- the key- Returns:
- the second derivatives of piecewise polynomial functions at xKeys When _dim in PiecewisePolynomialResult is greater than 1, i.e., the struct contains multiple piecewise polynomials, a row vector of return value corresponds to each piecewise polynomial
-
integrate
public double integrate(PiecewisePolynomialResult pp, double initialKey, double xKey)
Integration.- Parameters:
pp
- the PiecewisePolynomialResultinitialKey
- the initial keyxKey
- the key- Returns:
- the integral of piecewise polynomial between initialKey and xKey
-
integrate
public DoubleArray integrate(PiecewisePolynomialResult pp, double initialKey, double[] xKeys)
Integration.- Parameters:
pp
- the PiecewisePolynomialResultinitialKey
- the initial keyxKeys
- the keys- Returns:
- the integral of piecewise polynomial between initialKey and xKeys
-
evaluateAndDifferentiate
public ValueDerivatives evaluateAndDifferentiate(PiecewisePolynomialResult pp, double xKey)
Evaluates the function and its first derivative.The dimension of
PiecewisePolynomialResult
must be 1.- Parameters:
pp
- the PiecewisePolynomialResultxKey
- the key- Returns:
- the value and derivative
-
getValue
protected double getValue(DoubleArray coefs, double x, double leftknot)
- Parameters:
coefs
- {a_n,a_{n-1},...} of f(x) = a_n x^{n} + a_{n-1} x^{n-1} + ....x
- the x-valueleftknot
- the knot specifying underlying interpolation function- Returns:
- the value of the underlying interpolation function at the value of x
-
getValue
protected double getValue(double[] coefs, double x, double leftknot)
- Parameters:
coefs
- {a_n,a_{n-1},...} of f(x) = a_n x^{n} + a_{n-1} x^{n-1} + ....x
- the x-valueleftknot
- the knot specifying underlying interpolation function- Returns:
- the value of the underlying interpolation function at the value of x
-
-