Class RealPolynomialFunction1D
- java.lang.Object
- 
- com.opengamma.strata.math.impl.function.RealPolynomialFunction1D
 
- 
- All Implemented Interfaces:
- DoubleFunction1D,- DoubleUnaryOperator
 
 public class RealPolynomialFunction1D extends Object implements DoubleFunction1D Class representing a polynomial that has real coefficients and takes a real argument. The function is defined as: $$ \begin{align*} p(x) = a_0 + a_1 x + a_2 x^2 + \ldots + a_{n-1} x^{n-1} \end{align*} $$
- 
- 
Constructor SummaryConstructors Constructor Description RealPolynomialFunction1D(double... coefficients)Creates an instance.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description RealPolynomialFunction1Dadd(double a)Adds a constant to the polynomial (equivalent to adding the value to the constant term of the polynomial).DoubleFunction1Dadd(DoubleFunction1D f)Adds a function to the polynomial.doubleapplyAsDouble(double x)RealPolynomialFunction1Dderivative()Returns the derivative of this polynomial (also a polynomial), where $$ \begin{align*} P'(x) = a_1 + 2 a_2 x + 3 a_3 x^2 + 4 a_4 x^3 + \dots + n a_n x^{n-1} \end{align*} $$.RealPolynomialFunction1Ddivide(double a)Divides the polynomial by a constant value (equivalent to dividing each coefficient by this value).booleanequals(Object obj)double[]getCoefficients()Gets the coefficients of this polynomial.inthashCode()RealPolynomialFunction1Dmultiply(double a)Multiplies the polynomial by a constant value (equivalent to multiplying each coefficient by this value).DoubleFunction1Dmultiply(DoubleFunction1D f)Multiplies the polynomial by a function.RealPolynomialFunction1Dsubtract(double a)Subtracts a constant from the polynomial (equivalent to subtracting the value from the constant term of the polynomial).DoubleFunction1Dsubtract(DoubleFunction1D f)Subtracts a function from the polynomial.RealPolynomialFunction1DtoMonic()Converts the polynomial to its monic form.- 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface com.opengamma.strata.math.impl.function.DoubleFunction1Dderivative, divide
 - 
Methods inherited from interface java.util.function.DoubleUnaryOperatorandThen, compose
 
- 
 
- 
- 
- 
Constructor Detail- 
RealPolynomialFunction1Dpublic RealPolynomialFunction1D(double... coefficients) Creates an instance. The array of coefficients for a polynomial $p(x) = a_0 + a_1 x + a_2 x^2 + ... + a_{n-1} x^{n-1}$ is $\\{a_0, a_1, a_2, ..., a_{n-1}\\}$.- Parameters:
- coefficients- the array of coefficients, not null or empty
 
 
- 
 - 
Method Detail- 
applyAsDoublepublic double applyAsDouble(double x) - Specified by:
- applyAsDoublein interface- DoubleUnaryOperator
 
 - 
getCoefficientspublic double[] getCoefficients() Gets the coefficients of this polynomial.- Returns:
- the coefficients of this polynomial
 
 - 
addpublic DoubleFunction1D add(DoubleFunction1D f) Adds a function to the polynomial. If the function is not aRealPolynomialFunction1Dthen the addition takes place as inDoubleFunction1D, otherwise the result will also be a polynomial.- Specified by:
- addin interface- DoubleFunction1D
- Parameters:
- f- the function to add
- Returns:
- $P+f$
 
 - 
addpublic RealPolynomialFunction1D add(double a) Adds a constant to the polynomial (equivalent to adding the value to the constant term of the polynomial). The result is also a polynomial.- Specified by:
- addin interface- DoubleFunction1D
- Parameters:
- a- the value to add
- Returns:
- $P+a$
 
 - 
derivativepublic RealPolynomialFunction1D derivative() Returns the derivative of this polynomial (also a polynomial), where $$ \begin{align*} P'(x) = a_1 + 2 a_2 x + 3 a_3 x^2 + 4 a_4 x^3 + \dots + n a_n x^{n-1} \end{align*} $$.- Specified by:
- derivativein interface- DoubleFunction1D
- Returns:
- the derivative polynomial
 
 - 
dividepublic RealPolynomialFunction1D divide(double a) Divides the polynomial by a constant value (equivalent to dividing each coefficient by this value). The result is also a polynomial.- Specified by:
- dividein interface- DoubleFunction1D
- Parameters:
- a- the divisor
- Returns:
- the polynomial
 
 - 
multiplypublic DoubleFunction1D multiply(DoubleFunction1D f) Multiplies the polynomial by a function. If the function is not aRealPolynomialFunction1Dthen the multiplication takes place as inDoubleFunction1D, otherwise the result will also be a polynomial.- Specified by:
- multiplyin interface- DoubleFunction1D
- Parameters:
- f- the function by which to multiply
- Returns:
- $P \dot f$
 
 - 
multiplypublic RealPolynomialFunction1D multiply(double a) Multiplies the polynomial by a constant value (equivalent to multiplying each coefficient by this value). The result is also a polynomial.- Specified by:
- multiplyin interface- DoubleFunction1D
- Parameters:
- a- the multiplicator
- Returns:
- the polynomial
 
 - 
subtractpublic DoubleFunction1D subtract(DoubleFunction1D f) Subtracts a function from the polynomial.If the function is not a RealPolynomialFunction1Dthen the subtract takes place as inDoubleFunction1D, otherwise the result will also be a polynomial.- Specified by:
- subtractin interface- DoubleFunction1D
- Parameters:
- f- the function to subtract
- Returns:
- $P-f$
 
 - 
subtractpublic RealPolynomialFunction1D subtract(double a) Subtracts a constant from the polynomial (equivalent to subtracting the value from the constant term of the polynomial). The result is also a polynomial.- Specified by:
- subtractin interface- DoubleFunction1D
- Parameters:
- a- the value to add
- Returns:
- $P-a$
 
 - 
toMonicpublic RealPolynomialFunction1D toMonic() Converts the polynomial to its monic form. If $$ \begin{align*} P(x) = a_0 + a_1 x + a_2 x^2 + a_3 x^3 \dots + a_n x^n \end{align*} $$ then the monic form is $$ \begin{align*} P(x) = \lambda_0 + \lambda_1 x + \lambda_2 x^2 + \lambda_3 x^3 \dots + x^n \end{align*} $$ where $$ \begin{align*} \lambda_i = \frac{a_i}{a_n} \end{align*} $$- Returns:
- the polynomial in monic form
 
 
- 
 
-