Package org.moddingx.libx.util.math
Class DoublePolynomial
- All Implemented Interfaces:
DoubleFunction<Double>
,DoubleUnaryOperator
,Function<Double,
,Double> UnaryOperator<Double>
public final class DoublePolynomial
extends Polynomial<Double>
implements DoubleUnaryOperator, DoubleFunction<Double>
A polynomial with double coefficients.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<DoublePolynomial>
static final DoublePolynomial
The identity polynomial.static final DoublePolynomial
The polynomial that is always one.static final DoublePolynomial
The polynomial that is always zero. -
Constructor Summary
ConstructorDescriptionDoublePolynomial
(double... coefficients) Creates a new polynomial with the given coefficients. -
Method Summary
Modifier and TypeMethodDescriptionadd
(Polynomial<Double> other) Adds two polynomials together.apply
(double x) Computes the value of the polynomial at the given input.Computes the value of the polynomial at the given input.double
applyAsDouble
(double x) Computes the value of the polynomial at the given input.Gets the coefficients of this polynomial.Computes the derivative of this polynomial.boolean
int
hashCode()
Integrates this polynomial with constant part 0.integrate
(double constant) Integrates this polynomial with the given constant part.multiply
(Polynomial<Double> other) Multiplies two polynomials.negate()
Negates this polynomial.Methods inherited from class org.moddingx.libx.util.math.Polynomial
subtract, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.function.DoubleUnaryOperator
andThen, compose
-
Field Details
-
CODEC
-
ZERO
The polynomial that is always zero. -
ONE
The polynomial that is always one. -
IDENTITY
The identity polynomial.
-
-
Constructor Details
-
DoublePolynomial
public DoublePolynomial(double... coefficients) Creates a new polynomial with the given coefficients.new DoublePolynomial(2,0,1)
gives for example the polynomial2x²+1
.
-
-
Method Details
-
coefficients
Description copied from class:Polynomial
Gets the coefficients of this polynomial. For example, the coefficients[2, 0 1]
represent the polynomial2x²+1
.- Specified by:
coefficients
in classPolynomial<Double>
-
applyAsDouble
public double applyAsDouble(double x) Computes the value of the polynomial at the given input.- Specified by:
applyAsDouble
in interfaceDoubleUnaryOperator
-
apply
Computes the value of the polynomial at the given input.- Specified by:
apply
in interfaceDoubleFunction<Double>
-
apply
Computes the value of the polynomial at the given input. -
derivative
Description copied from class:Polynomial
Computes the derivative of this polynomial.- Specified by:
derivative
in classPolynomial<Double>
-
integrate
Integrates this polynomial with constant part 0. -
integrate
Integrates this polynomial with the given constant part. -
negate
Description copied from class:Polynomial
Negates this polynomial.- Specified by:
negate
in classPolynomial<Double>
-
add
Description copied from class:Polynomial
Adds two polynomials together.- Specified by:
add
in classPolynomial<Double>
-
multiply
Description copied from class:Polynomial
Multiplies two polynomials.- Specified by:
multiply
in classPolynomial<Double>
-
hashCode
public int hashCode() -
equals
-