T
- the type of the field elementspublic class FieldPolynomialFunction<T extends RealFieldElement<T>> extends Object implements RealFieldUnivariateFunction<T>
Horner's Method is used to evaluate the function.
Constructor and Description |
---|
FieldPolynomialFunction(T[] c)
Construct a polynomial with the given coefficients.
|
Modifier and Type | Method and Description |
---|---|
FieldPolynomialFunction<T> |
add(FieldPolynomialFunction<T> p)
Add a polynomial to the instance.
|
FieldPolynomialFunction<T> |
antiDerivative()
Returns an anti-derivative of this polynomial, with 0 constant term.
|
int |
degree()
Returns the degree of the polynomial.
|
protected static <T extends RealFieldElement<T>> |
differentiate(T[] coefficients)
Returns the coefficients of the derivative of the polynomial with the given coefficients.
|
protected static <T extends RealFieldElement<T>> |
evaluate(T[] coefficients,
T argument)
Uses Horner's Method to evaluate the polynomial with the given coefficients at
the argument.
|
T[] |
getCoefficients()
Returns a copy of the coefficients array.
|
Field<T> |
getField()
Get the
Field to which the instance belongs. |
T |
integrate(double lower,
double upper)
Returns the definite integral of this polymomial over the given interval.
|
T |
integrate(T lower,
T upper)
Returns the definite integral of this polymomial over the given interval.
|
FieldPolynomialFunction<T> |
multiply(FieldPolynomialFunction<T> p)
Multiply the instance by a polynomial.
|
FieldPolynomialFunction<T> |
negate()
Negate the instance.
|
FieldPolynomialFunction<T> |
polynomialDerivative()
Returns the derivative as a
FieldPolynomialFunction . |
FieldPolynomialFunction<T> |
subtract(FieldPolynomialFunction<T> p)
Subtract a polynomial from the instance.
|
T |
value(double x)
Compute the value of the function for the given argument.
|
T |
value(T x)
Compute the value of the function for the given argument.
|
public FieldPolynomialFunction(T[] c) throws MathIllegalArgumentException, NullArgumentException
The constructor makes a copy of the input array and assigns the copy to the coefficients property.
c
- Polynomial coefficients.NullArgumentException
- if c
is null
.MathIllegalArgumentException
- if c
is empty.public T value(double x)
The value returned is
coefficients[n] * x^n + ... + coefficients[1] * x + coefficients[0]
x
- Argument for which the function value should be computed.UnivariateFunction.value(double)
public T value(T x)
The value returned is
coefficients[n] * x^n + ... + coefficients[1] * x + coefficients[0]
value
in interface RealFieldUnivariateFunction<T extends RealFieldElement<T>>
x
- Argument for which the function value should be computed.UnivariateFunction.value(double)
public Field<T> getField()
Field
to which the instance belongs.Field
to which the instance belongspublic int degree()
public T[] getCoefficients()
Changes made to the returned copy will not affect the coefficients of the polynomial.
protected static <T extends RealFieldElement<T>> T evaluate(T[] coefficients, T argument) throws MathIllegalArgumentException, NullArgumentException
T
- the type of the field elementscoefficients
- Coefficients of the polynomial to evaluate.argument
- Input value.MathIllegalArgumentException
- if coefficients
is empty.NullArgumentException
- if coefficients
is null
.public FieldPolynomialFunction<T> add(FieldPolynomialFunction<T> p)
p
- Polynomial to add.p
.public FieldPolynomialFunction<T> subtract(FieldPolynomialFunction<T> p)
p
- Polynomial to subtract.p
.public FieldPolynomialFunction<T> negate()
public FieldPolynomialFunction<T> multiply(FieldPolynomialFunction<T> p)
p
- Polynomial to multiply by.p
protected static <T extends RealFieldElement<T>> T[] differentiate(T[] coefficients) throws MathIllegalArgumentException, NullArgumentException
T
- the type of the field elementscoefficients
- Coefficients of the polynomial to differentiate.null
if coefficients has length 1.MathIllegalArgumentException
- if coefficients
is empty.NullArgumentException
- if coefficients
is null
.public FieldPolynomialFunction<T> antiDerivative()
public T integrate(double lower, double upper)
[lower, upper] must describe a finite interval (neither can be infinite and lower must be less than or equal to upper).
lower
- lower bound for the integrationupper
- upper bound for the integrationMathIllegalArgumentException
- if the bounds do not describe a finite intervalpublic T integrate(T lower, T upper)
[lower, upper] must describe a finite interval (neither can be infinite and lower must be less than or equal to upper).
lower
- lower bound for the integrationupper
- upper bound for the integrationMathIllegalArgumentException
- if the bounds do not describe a finite intervalpublic FieldPolynomialFunction<T> polynomialDerivative()
FieldPolynomialFunction
.Copyright © 2016–2019 Hipparchus.org. All rights reserved.